rpc: tracing logger memory encoding#20478
Merged
AskAlexSharov merged 4 commits intomainfrom Apr 12, 2026
Merged
Conversation
- Fix loop condition that silently dropped the last memory word when memory size was not a multiple of 32 bytes; pad partial word to 32 bytes with zeros - Add hexWithPrefix/formatMemoryWord helpers to emit 0x-prefixed hex strings - Fix storage keys/values missing 0x prefix in JsonStreamLogger - Use omitempty on StructLog error field to omit it when no error occurred - Add unit tests covering all three fixes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AskAlexSharov
approved these changes
Apr 12, 2026
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.
Summary of changes for compliance (ethereum/execution-apis PR 762)
see ethereum/execution-apis#762)
The changes fix the EVM tracer JSON output (structLog) to align with the Ethereum JSON-RPC specification.
Before: the loop used i+32 <= len(memData), silently dropping the last chunk when memory size was not an exact multiple of 32 bytes.
After: the loop iterates over all bytes; the last partial chunk is zero-padded to 32 bytes, as required by the spec (each memory word is always 32 bytes).
Before: storage keys/values and memory words were serialized as raw hex (e.g. "0000...0001").
After: all hex values are emitted with the 0x prefix (e.g. "0x0000...0001"), as required by the Ethereum JSON-RPC specification.
Before: the "error" field was serialized as "error": "" even when no error occurred.
After: with omitempty the field is omitted entirely when there is no error, making the output cleaner and consistent with the behavior expected by clients and Hive tests.
Impacted APIs
All three fixes are covered by unit tests in the new json_stream_test.go file.
Out of this PR is keyword to anable/disable and default value for them
Tracer Configuration Comparison
disable=false(ON)Enable=false(OFF)enable=false(OFF)disable=false(ON)Disable=false(ON)disable=false(ON)disable=false(ON)Disable=false(ON)disable=false(ON)disable=false(ON)Enable=false(OFF)enable=false(OFF)