Skip to content

fix(eth/tracers): fix supply tracer uncle accounting #31882 - #2905

Open
gzliudan wants to merge 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:fix-supply-tracer-uncle-accounting
Open

gzliudan wants to merge 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:fix-supply-tracer-uncle-accounting

Conversation

@gzliudan

Copy link
Copy Markdown
Collaborator

Summary

The supply live tracer (--vmtrace supply) dropped uncle rewards from issuance.reward. OnBalanceChange put BalanceIncreaseRewardMineUncle in its own empty case body, and Go's switch does not fall through, so the block below never ran for uncle rewards:

case tracing.BalanceIncreaseRewardMineUncle:
case tracing.BalanceIncreaseRewardMineBlock:
	s.delta.Issuance.Reward.Add(s.delta.Issuance.Reward, diff)

Fix

Merge the two reward reasons into one case, as upstream go-ethereum ethereum#31882 does:

case tracing.BalanceIncreaseRewardMineBlock, tracing.BalanceIncreaseRewardMineUncle:
	s.delta.Issuance.Reward.Add(s.delta.Issuance.Reward, diff)

Impact

Production XDPoS chains never emit uncle rewards: VerifyUncles rejects any block carrying uncles and Finalize sets an empty uncle hash. The ethash engine is still in the tree and is used by AllEthashProtocolChanges and friends, so ethash-based dev and test chains were the ones under-reporting issuance.reward.

Tests

TestSupplyRewardAccounting in eth/tracers/live drives OnBalanceChange at the hook boundary:

  • block-reward: a block reward is added to issuance.reward.
  • uncle-reward: an uncle reward is added (fails before the fix).
  • accumulates: block and uncle rewards add up.
  • other-reasons: a non-reward balance change is ignored.

Reverting the merged case makes uncle-reward and accumulates fail.

Found while reviewing

This surfaced while reviewing #2833 (the EIP-8246 selfdestruct burn gate), which touches the same function but does not change this line. Kept separate to keep #2833 focused.

Ref: ethereum#31882

@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: e1044152-a483-460f-80c4-55b735f8aadf

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

Comment @coderabbitai help to get the list of available commands.

The supply tracer's OnBalanceChange put BalanceIncreaseRewardMineUncle in its
own empty case body. Go's switch does not fall through, so uncle rewards were
silently dropped from issuance.reward. Merge the two reward reasons into one
case, as upstream go-ethereum ethereum#31882 does.

Production XDPoS chains never emit uncle rewards (VerifyUncles rejects them),
so this only affects ethash-based test and dev chains.

Tests: eth/tracers/live covers block reward, uncle reward and their
accumulation at the hook boundary; removing the merged case makes the uncle
cases fail.

Ref: ethereum#31882
@gzliudan
gzliudan force-pushed the fix-supply-tracer-uncle-accounting branch from 696cd15 to 50654f9 Compare October 28, 2026 08:26

This branch has not been deployed

No deployments
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.

3 participants