Skip to content

feat: add stateful QuickNode bundle simulation - #14

Closed
congtanwkm wants to merge 1 commit into
mainfrom
codex/stateful-batch-simulation
Closed

congtanwkm wants to merge 1 commit into
mainfrom
codex/stateful-batch-simulation

Conversation

@congtanwkm

Copy link
Copy Markdown

Summary

Add ordered shared-state bundle simulation via QuickNode trace_callMany, including nested VM event decoding and rollback filtering. If VM logs cannot be decoded, replay the entire pinned bundle using debug_traceCallMany with callTracer logs and verify execution parity before accepting them. Preserve the existing main-branch simulation paths and add the version endpoint from the local feature base.

RPC uses BASE_BLOCKCHAIN_NODE_URL/{chainId}?provider=quicknode. Bundle v2 never falls back to independent calls or a fork node.

API

POST /api/v1/simulate_bundle_v2

Illustrative request (not a live execution claim):

POST /api/v1/simulate_bundle_v2
Content-Type: application/json
X-API-KEY: <configured-api-key>

The API key header is required only when API_KEY is configured.

[{"chainId":1,"blockNumber":25936975,"request_id":"call-1","from":"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","to":"0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb","data":"0x","value":"0","gasLimit":21000}]

Matching illustrative response — HTTP 200 for a successful empty-code call:

[{"request_id":"call-1","simulationId":1,"gasUsed":21000,"blockNumber":25936975,"success":true,"trace":[{"callType":"CALL","from":"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","to":"0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb","value":"0x0","functionSignature":"0x00000000"}],"logs":[],"exitReason":"Return","returnData":"0x","stateDiff":null,"error":null,"gasAccounting":"execution_plus_intrinsic"}]

Full approve → transferFrom → transferFrom request fixtures and log expectations are included for USDT and BSC97 recovery.

Accepts 1–20 calls on one chain and one block; omitted block is resolved once. Successful calls affect subsequent calls; each reverted call rolls back its own effects. Request IDs and repeated senders are preserved. Limits: 2MiB request, 32MiB RPC response, 30M gas/call (also default), 100M total and 45s deadline. Rejects stateOverrides and allowInsufficientFunds:true. Validation returns 400, oversized body 413, provider/invalid traces 502, missing configuration 503 and deadline 504. Errors use the existing { "code": 503, "message": "QUICKNODE_NOT_CONFIGURED" } envelope. Gas includes execution plus intrinsic gas, excluding refunds and gas-floor adjustments.

GET /api/v1/version

Request: no body or query; same conditional X-API-KEY header.
Response — HTTP 200:

{"version":2}

Validation

  • On origin/main: cargo test --offline --lib --test api passed (80 library + 5 API tests); 15 live-RPC tests ignored.
  • Includes USDT, nested/reverted/precompile traces and BSC97 whole-bundle replay/parity regression fixtures.
  • Scoped staged diff checks passed. No deployment files or unrelated base history included.

@congtanwkm congtanwkm self-assigned this Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

Failed to generate code suggestions for PR

@congtanwkm congtanwkm closed this Sep 9, 2026
@congtanwkm
congtanwkm deleted the codex/stateful-batch-simulation branch September 9, 2026 07:36
@congtanwkm

Copy link
Copy Markdown
Author

Superseded by #15 after renaming the source branch to feat/stateful-batch-simulation. Same commit and base; the replacement remains a draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant