Skip to content

fix(internal/ethapi): skip CALLCODE transfers and release reverted log indices #35248 #35841 - #2911

Merged
gzliudan merged 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:fix-simulate-tracer-upstream-parity
Nov 2, 2026
Merged

gzliudan merged 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:fix-simulate-tracer-upstream-parity

Conversation

@gzliudan

@gzliudan gzliudan commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The eth_simulateV1 log tracer reports ether transfers as synthetic logs and numbers every log it creates. Two upstream fixes are missing in this tree:

  1. CALLCODE frames are reported as transfers. onEnter skipped DELEGATECALL only, but CALLCODE moves no value either, so traceTransfers reported a transfer that never happened. Ported from go-ethereum internal/ethapi: skip transfer capture for callcode in log tracer ethereum/go-ethereum#35248.
  2. Dropped logs keep their index. A log dropped because its call or an inner call frame failed still consumed an index, so the returned logIndex did not match the numbering in receipts. Ported from go-ethereum internal/ethapi: number eth_simulateV1 logs like receipts ethereum/go-ethereum#35841.

Both fixes live in internal/ethapi/logtracer.go and are taken verbatim from upstream. execution-apis#881, which specifies this logIndex rule, is merged.

Changes

  • internal/ethapi/logtracer.go: onEnter skips CALLCODE next to DELEGATECALL; onExit/onEnd release the indices of the logs they drop.
  • internal/ethapi/api_test.go: TestSimulateV1LogIndex (end-to-end, index continuity across failed calls), TestTransferTracerSkipsCallCode and TestTransferTracerReleasesRevertedIndexes (tracer level).
  • The three tests carry the discrimination the fixes need: the reverter emits two logs, so a rollback of a single index cannot pass; the CALL and CALLCODE frames use different recipients, so the assertion can tell which frame produced the synthesized log; and the reverted frame in the tracer test holds a synthesized transfer plus a plain log, so the rollback covers transfer logs too.

Verification

  • make all clean; gofmt / goimports clean.
  • golangci-lint --new-from-rev=74abda0482 ./internal/ethapi/...: 0 issues.
  • go test ./internal/ethapi/ passes, including -race -count=2 on the new and updated tests.
  • Mutation checks, each confirmed to fail the named test:
    • removing the CALLCODE skip fails TestTransferTracerSkipsCallCode (2 logs instead of 1);
    • capturing CALLCODE instead of CALL fails TestTransferTracerSkipsCallCode (recipient topic is the CALLCODE one);
    • removing the inner-frame counter rollback fails TestTransferTracerReleasesRevertedIndexes (index 3 instead of 1) and TestSimulateV1LogIndex/reverted_inner_frame (0x2 instead of 0x1);
    • releasing a single index instead of the frame's real count fails TestTransferTracerReleasesRevertedIndexes (index 2 instead of 1) for the inner frame and TestSimulateV1LogIndex (0x1 instead of 0x0) for the top-level call;
    • removing the top-level rollback fails TestSimulateV1LogIndex (all three affected sub-tests);
    • writing synthesized transfers outside the current frame slot fails TestTransferTracerReleasesRevertedIndexes (3 logs instead of 2).

Related

Found while reviewing #2842 (EIP-7708). Its post-Amsterdam de-duplication turns the synthesis off (traceTransfers && !IsAmsterdam), so the CALLCODE phantom only affected the pre-Amsterdam synthesis path; both defects predate that work.

Ref: ethereum#35248
Ref: ethereum#35841

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d901a362-623b-45d8-b134-8443ad54b632

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@gzliudan
gzliudan force-pushed the fix-simulate-tracer-upstream-parity branch 2 times, most recently from 396c2d2 to 7a54d4c Compare October 28, 2026 23:11
@gzliudan
gzliudan force-pushed the fix-simulate-tracer-upstream-parity branch 2 times, most recently from c1c7a60 to dd1d93e Compare October 30, 2026 07:39
@gzliudan
gzliudan force-pushed the fix-simulate-tracer-upstream-parity branch from dd1d93e to eabf45c Compare October 30, 2026 10:29
…g indices ethereum#35248 ethereum#35841

The simulate log tracer synthesized a transfer log for every call frame with a
non-zero value, but CALLCODE moves no value: the frame was reported as a
transfer that never happened. The tracer also gave an index to every log,
including the ones it later dropped because their call or an inner call frame
failed, so the returned logIndex did not match the numbering in receipts.

Skip the synthesis for CALLCODE next to DELEGATECALL (geth ethereum#35248) and release
the indices of dropped logs (geth ethereum#35841). The dropped logs are always the most
recent ones, so the counter is rolled back for a reverted inner frame and for a
reverted top-level call.

TestSimulateV1LogIndex pins the index continuity across failed calls, with a
reverter that emits two logs so a rollback of a single index cannot pass. The
tracer tests pin the CALLCODE skip against a plain CALL to a different
recipient, and the reverted frame in the index test holds a synthesized transfer
plus a plain log, so both the rollback count and the transfer's slot are covered.

Ref: ethereum#35248
Ref: ethereum#35841
@gzliudan
gzliudan force-pushed the fix-simulate-tracer-upstream-parity branch from eabf45c to 314915e Compare November 1, 2026 09:06
@gzliudan
gzliudan merged commit 41d0555 into XinFinOrg:dev-upgrade Nov 2, 2026
23 checks passed
@gzliudan
gzliudan deleted the fix-simulate-tracer-upstream-parity branch November 2, 2026 19:00
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.

4 participants