Skip to content

rpc: seed callTracer log index with the block's preceding logs - #27356

Open
MysticRyuujin wants to merge 2 commits into
paradigmxyz:mainfrom
MysticRyuujin:calltracer-log-index
Open

MysticRyuujin wants to merge 2 commits into
paradigmxyz:mainfrom
MysticRyuujin:calltracer-log-index

Conversation

@MysticRyuujin

Copy link
Copy Markdown
Contributor

This change makes the callTracer logs[].index follow ethereum/execution-apis#855: "The log's index within the block: the number of logs that took effect in the block before this one, counting the logs of all preceding transactions. It MUST equal the logIndex of the same log in the transaction receipt. Logs of reverted frames never take effect and do not consume an index, and onlyTopCall does not change the numbering. For debug_traceCall, where no receipt exists, numbering starts at zero for the traced call."

The counter lives in revm-inspectors and restarts at 0 for every traced transaction. The companion change paradigmxyz/revm-inspectors#512 adds DebugInspector::set_next_log_index, restores the counter when a frame reverts, and sets position to 0 under onlyTopCall. This PR depends on that unreleased change and does not build until a release with it is picked up.

debug_traceTransaction reads the block's receipts from the RPC cache and seeds the tracer with the log count of the preceding transactions, through the same helper eth_getTransactionReceipt uses for logIndex. It reads the receipts because inspect_transaction_in_block may attach a BAL instead of replaying the preceding transactions. debug_traceBlock* and traceChain accumulate the log count across the block and seed the tracer again after each fuse. debug_traceCall and debug_traceCallMany keep starting at 0.

When the block's receipts are pruned, the seed falls back to 0 and the numbering is transaction-local, as before. Reviewers may want to decide if that fallback is acceptable; a receipt to match does not exist in that case, and deriving the count through replay does not work on the BAL path.

Hive rpc-compat with the fixtures of the spec PR, built from this branch with the patched revm-inspectors: debug_traceTransaction/calltracer-with-log-index passes (root log index 0x3, was 0x0) and debug_traceTransaction/calltracer-only-top-call-with-log passes (position 0x0, was 0x8). The five other callTracer debug_traceTransaction fixtures stay green. debug_traceCall/calltracer-only-top-call fails before and after because the response carries the EIP-8037 gas fields; that is unrelated to this change.

debug_traceTransaction seeds the tracer with the log count of the preceding receipts, and debug_traceBlock* and traceChain accumulate it across the block. Follows ethereum/execution-apis#855; needs revm-inspectors set_next_log_index.
@MysticRyuujin
MysticRyuujin marked this pull request as ready for review September 27, 2026 13:45

This branch has not been deployed

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

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant