eth/tracers/logger: fix legacy structLog JSON encoding#34093
Merged
s1na merged 5 commits intoMar 31, 2026
Conversation
Fix several issues in the legacy structLog JSON format produced by the struct logger tracer: - Error field: change from string to *string so that error is truly omitted (rather than serialised as "") when there is no error. - Memory words: zero-pad each 32-byte chunk before hex-encoding so the output always matches the expected 64-character format instead of emitting a truncated hex string for partial words. - Storage/ReturnData: use hexutil.Encode / common.Hash.Hex() to produce consistent 0x-prefixed output rather than bare %x formatting. Add tests that cover the legacy JSON shape directly (TestStructLogLegacyJSONSpecFormatting), and two integration-level tracer tests verifying that refund counters and storage snapshots are captured correctly and that hard-failure vs revert return values are handled as specified.
reexec was a geth-specific, hash-scheme-only implementation detail that let callers cap how many ancestor blocks the node would re-execute to reconstruct missing historical state. It was never part of the execution API spec, and path-scheme nodes ignored it entirely. Remove Reexec from TraceConfig and StdTraceConfig so it is no longer accepted over JSON-RPC. Drop the parameter from the Backend interface (StateAtBlock, StateAtTransaction) and all the way down through EthAPIBackend and state_accessor. A local constant reexecLimit = 128 replaces the old defaultTraceReexec inside hashState, preserving the existing non-archive hash-scheme behaviour.
Contributor
Author
|
ci test failed but not because of my PR 😆 |
s1na
reviewed
Mar 27, 2026
Contributor
|
Generally looks good to me. I'd wait for merging until after the coming release. Given that it's breaking API output we should probably release it as part of a major version. |
Co-authored-by: Sina M <1591639+s1na@users.noreply.github.com>
fjl
reviewed
Mar 28, 2026
Use a plain string field with omitzero for the legacy structLog error field so the JSON shape stays unchanged without pointer indirection.
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.
Release notes
This is a breaking change for tracing APIs (debug_trace*), when using specifically the structlog (opcode) tracer. The following fields will have slightly different formatting in the response. The reason is for geth to conform to the newly established client-wide spec: ethereum/execution-apis#762.
memorywords will have the0xprefix. A word will be padded to 32-bytes.storage: keys and values will have the0xprefix.Summary
This PR fixes several correctness issues in the legacy
structLogJSON format produced byStructLogger(the default tracer behinddebug_traceTransaction), and removes the non-specreexecfield from the tracer config.Fix legacy structLog JSON encoding
stringto*stringso the"error"key is truly omitted when there is no error, rather than being serialised as""."0xaabb"instead of"0xaabb000000000000000000000000000000000000000000000000000000000000".fmt.Sprintf("%x", …)withhexutil.Encode/common.Hash.Hex()to produce consistent0x-prefixed output, matching the format expected by clients and conformance tests.Remove
reexecfrom tracer configreexecwas a geth-specific, hash-scheme-only knob that let callers cap how many ancestor blocks the node would re-execute when the requested state was not on disk. It was never part of the execution API spec and was silently ignored by path-scheme nodes.Reexec *uint64fromTraceConfigandStdTraceConfig— the field is no longer accepted over JSON-RPC.Backendinterface (StateAtBlock,StateAtTransaction) and propagated the removal down throughEthAPIBackend,state_accessor, andapi_debug.reexecLimit = 128constant instate_accessor.Tests
TestStructLogLegacyJSONSpecFormatting— unit tests directly exercising the legacy JSON shape for memory padding, storage encoding, and error omission.TestTraceTransactionRefundAndStorageSnapshots— integration test verifying thatSLOAD/SSTOREstorage snapshots and refund counters are correctly captured in a traced transaction.TestTraceTransactionFailureReturnValues— integration test verifying that a reverted transaction preserves its return data while a hard-failure (e.g.INVALID) clears it.Reference
execution-apis