Skip to content

[SharovBot] fix: add 0x prefix to structLogs storage keys/values in debug_traceCall#20647

Open
erigon-copilot[bot] wants to merge 2 commits intorelease/3.4from
agent-fix/structlog-storage-0x-prefix
Open

[SharovBot] fix: add 0x prefix to structLogs storage keys/values in debug_traceCall#20647
erigon-copilot[bot] wants to merge 2 commits intorelease/3.4from
agent-fix/structlog-storage-0x-prefix

Conversation

@erigon-copilot
Copy link
Copy Markdown
Contributor

[SharovBot]

Problem

mainnet-rpc-integ-tests-latest CI has been failing on every commit to release/3.4 branch (10/10 commits) due to a mismatch in debug_traceCall/test_43.json.

The diff shows:

storage: {
-  0x2fa8c5322c1048470ad77c09da3654fc909cba75d0344927ddd1da93527c2044: "0x0000000000000000000000000000000000000000000000000000000000000000"
+  2fa8c5322c1048470ad77c09da3654fc909cba75d0344927ddd1da93527c2044: "0000000000000000000000000000000000000000000000000000000000000000"
}

The reference implementation returns storage keys/values with 0x prefix, but Erigon was returning bare hex.

Root Cause

FormatLogs() in both rpc/ethapi/api.go and execution/tracing/tracers/logger/logger.go formats storage map keys and values using:

storage[fmt.Sprintf("%x", i)] = fmt.Sprintf("%x", storageValue)

%x format verb produces bare hex without the 0x prefix.

Fix

Use common.Hash.Hex() which calls hexutil.Encode() and produces properly 0x-prefixed output:

storage[i.Hex()] = storageValue.Hex()

Impact

Affects debug_traceCall, debug_traceTransaction, debug_traceBlock, debug_traceBlockByNumber, and any other endpoint that uses FormatLogs() for structLog output.

Testing

…ebug_traceCall

FormatLogs() was formatting storage map keys and values using
fmt.Sprintf("%x", ...) which produces bare hex without the 0x prefix.

The reference implementation returns storage keys/values with 0x prefix
(e.g. "0x2fa8c5322c..."), but Erigon was returning "2fa8c5322c...".

Fix: use common.Hash.Hex() which internally calls hexutil.Encode()
and properly produces 0x-prefixed hex strings for both keys and values.

This affects both rpc/ethapi/api.go (FormatLogs used by debug_traceCall,
debug_traceTransaction, etc.) and the duplicate copy in
execution/tracing/tracers/logger/logger.go.

Fixes mainnet-rpc-integ-tests-latest CI failure consistently seen across
all 10 recent release/3.4 commits (debug_traceCall/test_43.json).

Refs: https://github.com/erigontech/erigon/actions/runs/24602505567/job/71943405095

Co-authored-by: Giulio Rebuffo <[email protected]>
@erigon-copilot
Copy link
Copy Markdown
Contributor Author

[SharovBot]

⚠️ CI regression detected on this PR

The test-hive (rpc, compat, 23) job is failing with 56/204 tests on this PR's branch, while it passes cleanly (failed=0) on the release/3.4 base.

Failing job: https://github.com/erigontech/erigon/actions/runs/24602883581/job/71944385182

This suggests that the 0x prefix change in FormatLogs() is breaking the Hive RPC compat test suite expectations. The hive tests likely expect the old bare-hex format for structLog storage keys/values.

Before merging, the fix needs to either:

  1. Also update the Hive test fixture expectations to match the 0x-prefixed format, OR
  2. Investigate whether the reference implementation used in mainnet-rpc-integ-tests-latest and the Hive compat tests have different expectations (one wants 0x, the other wants bare hex)

The release/3.4 branch itself has mainnet-rpc-integ-tests-latest failing on all 10 recent commits due to debug_traceCall/test_43.json, which this PR correctly targets — but the current implementation introduces a new regression.

@yperbasis yperbasis added this to the 3.5.0 milestone Apr 20, 2026
@yperbasis yperbasis added the RPC label Apr 20, 2026
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