Implement callTracer withLog with receipt-aligned log index - #11342
Open
MysticRyuujin wants to merge 4 commits into
Open
MysticRyuujin wants to merge 4 commits into
MysticRyuujin wants to merge 4 commits into
Conversation
Signed-off-by: Chase Wright <chase.wright@ethereum.org>
MysticRyuujin
marked this pull request as ready for review
September 27, 2026 13:46
…to root Signed-off-by: Chase Wright <chase.wright@ethereum.org>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
callTracerignored thewithLogtracer option. Every frame came back without alogsarray. This change implements it.With
withLog, each frame that emitted logs carries alogsarray of{address, topics, data, position, index}. Frames that emitted no logs omit the key. Reverted frames and their descendants carry no logs. WithoutwithLogthe output is unchanged.The field semantics follow the execution-apis spec change in ethereum/execution-apis#855. It defines
indexas: "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."positionis the number of subcalls the frame had created when the log was emitted, so it is 0 underonlyTopCall.Mechanism.
CallTracerrecords new entries offrame.getLogs()after each opcode and at frame exit, so LOG opcodes and EIP-7708 transfer logs are both seen. At re-entry of a parent frame it skips the child logs the EVM merged in.buildResultmatches the recorded logs by identity againstTransactionProcessingResult.getLogs(), which holds only the logs that took effect, and assignsindexfrom that order plus an offset. Logs that did not take effect are dropped. EIP-7708 closure logs, whichMainnetTransactionProcessoradds to the initial frame after the root frame exits, go to the root frame, as in go-ethereum. The offset is the receipt log index offset fordebug_traceTransaction, read only whenwithLogis set, the running count of preceding transaction logs indebug_traceBlock*, and 0 fordebug_traceCall.Hive
rpc-compatwith the spec branch fixtures, before:calltracer-with-log-indexandcalltracer-only-top-call-with-logfail (nologskey). After: both pass withindex0x3and0x2, and the existingcalltracer-contract-call,calltracer-only-top-call,calltracer-simple-transfer,calltracer-revert-reasonandcalltracer-createfixtures stay green (9 of 9 including client launch).Tests:
CallTracerTestunit cases, andwithLogspec fixtures indebug-geth/specs/call-tracer/with-logfor blocks 0xf, 0x13, 0x19 and 0x22, includingonlyTopCallanddebug_traceTransaction. Everyindexin them equals thelogIndexfrometh_getBlockReceipts.The other besu callTracer differences listed in ethereum/execution-apis#855 are out of scope. #11077 already fixed the root
gasUsed, the DELEGATECALLfromaddress andonlyTopCall. The block hash parameter ofdebug_traceCallis a separate change.