Skip to content

rpc: tracing logger memory encoding#20478

Merged
AskAlexSharov merged 4 commits intomainfrom
lupin012/tracing-logger-memory-encoding
Apr 12, 2026
Merged

rpc: tracing logger memory encoding#20478
AskAlexSharov merged 4 commits intomainfrom
lupin012/tracing-logger-memory-encoding

Conversation

@lupin012
Copy link
Copy Markdown
Contributor

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.


  1. Last memory word truncation
    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).

  1. Missing 0x prefix on storage and memory
    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.

  1. error field always present even without errors
    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

  • debug_traceTransaction
  • debug_traceBlockByNumber
  • debug_traceBlockByHash
  • debug_traceCall
  • debug_traceCallMany

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

Field Erigon Geth Spec #762 Aligned
Memory disable=false (ON) Enable=false (OFF) enable=false (OFF)
Stack disable=false (ON) Disable=false (ON) disable=false (ON)
Storage disable=false (ON) Disable=false (ON) disable=false (ON)
Return disable=false (ON) Enable=false (OFF) enable=false (OFF)

lupin012 and others added 4 commits April 10, 2026 13:52
- 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>
@lupin012 lupin012 marked this pull request as ready for review April 12, 2026 10:47
@lupin012 lupin012 added the RPC label Apr 12, 2026
@AskAlexSharov AskAlexSharov added this pull request to the merge queue Apr 12, 2026
Merged via the queue into main with commit 36ba6ed Apr 12, 2026
37 of 57 checks passed
@AskAlexSharov AskAlexSharov deleted the lupin012/tracing-logger-memory-encoding branch April 12, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants