Skip to content

[3.4] rpc: cherry-pick tracing logger memory encoding (#20478) #20749

Merged
lupin012 merged 6 commits into
release/3.4from
lupin012/tracing_memory_encoding
Apr 23, 2026
Merged

[3.4] rpc: cherry-pick tracing logger memory encoding (#20478) #20749
lupin012 merged 6 commits into
release/3.4from
lupin012/tracing_memory_encoding

Conversation

@lupin012
Copy link
Copy Markdown
Contributor

Summary of changes for compliance (ethereum/execution-apis PR 762)
see ethereum/execution-apis#762)

Impacted APIs

  • debug_traceTransaction
  • debug_traceBlockByNumber
  • debug_traceBlockByHash
  • debug_traceCall
  • debug_traceCallMany

lupin012 and others added 5 commits April 23, 2026 08:36
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).
---
  2. 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.
---
  3. 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

| 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) | ❌ |

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
…/3.4

Replace mdgas.MdGas with uint64 in GetRefund() mock — mdgas package
does not exist in release/3.4.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lupin012 lupin012 marked this pull request as ready for review April 23, 2026 09:21
…test.go

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lupin012 lupin012 merged commit 7192134 into release/3.4 Apr 23, 2026
21 checks passed
@lupin012 lupin012 deleted the lupin012/tracing_memory_encoding branch April 23, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants