fix(l1): fix callTracer log index under onlyTopCall and in debug_traceCall - #7294
Draft
MysticRyuujin wants to merge 1 commit into
Draft
MysticRyuujin wants to merge 1 commit into
MysticRyuujin wants to merge 1 commit into
Conversation
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.
This makes the callTracer
withLogoutput follow the log index rules that ethereum/execution-apis#855 adds tocall-tracer.yaml.The spec defines
CallLog.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." Forpositionit says: "When onlyTopCall is set, no subcall frames are collected and position is 0 for every log."Two things in ethrex do not match this.
Under
onlyTopCallthe tracer never pushed nested frames, so thecallframes.len() > 1guard inlog()never fired. Every nested log landed on the root frame, including logs of nested calls that reverted, and the root log got a transaction-local index. The tracer now always builds the full frame tree. After it prunes reverted logs and assigns indices on the top frame, it drops the root'scallsand sets every remainingpositionto 0 whenonlyTopCallis set. The root frame's gas, output and error fields do not change. Becausetrace_block_callscounted the logs of the returned trace to seed the next transaction, and that count would now miss the hidden nested logs,run_call_tracereturns the tracer's next log index instead andcount_call_logsis gone.debug_traceCallwithouttxIndexseeded the index from the receipts of the whole block. It now starts at 0. WithtxIndexit still counts the logs of the replayed transactions, which is what geth'sStateAtTransactionstate does. Reviewers may want to decide whethertxIndexshould also start at 0; the spec sentence quoted above does not distinguish the two.The spec fixture
calltracer-only-top-call-with-logtraces the calltree transaction with{"onlyTopCall":true,"withLog":true}and expects exactly one root log with"index":"0x2"(two nested logs precede it and are not reported),"position":"0x0"and nocallskey. The existingcalltracer-with-log-indexfixture expects"index":"0x3"for a transaction that follows one with three logs.Hive cannot verify this against ethrex today. ethrex rejects the execution-apis test chain before London because the base fee header check runs on pre-London blocks (#6954), so the rpc-compat simulator never reaches these tests. Unit tests cover the change instead:
trace_call_calls_only_top_call_keeps_block_absolute_log_index,trace_call_calls_only_top_call_ignores_reverted_nested_logandtrace_call_log_index_starts_at_zero_on_top_of_the_block. All three fail on main and pass with this change.