Fix epoch stake seeding, add reward burn accounting, consolidate CLI #203
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Two commits addressing correctness in epoch stake seeding and reward distribution.
1. Fix startup epoch stake seeding (
9fb3668)At startup,
setupInitialVoteAcctsAndStakeAccts()was seedingEpochStakesPerVoteAcctandTotalEpochStakeusing rawdelegation.StakeLamportsfrom the AccountsDB scan. This is incorrect — epoch-effective stakes have warmup/cooldown applied viaDelegation.Stake(epoch, stakeHistory), and the manifest already stores these correctly.Changes:
global.EpochStakes(block.Epoch)from the epoch stakes cache (loaded bybuildInitialEpochStakesCache()from the manifest)SetVoteStakeTotals(),voteStakeTotalsfield,voteStakeTotalsMumutex inGlobalCtxFiles:
pkg/replay/block.go,pkg/global/global_ctx.go2. Add reward burn accounting (
aa8adfd)Mithril's reward distribution path previously panicked on per-record account-level failures during stake reward payout. Agave and Firedancer instead treat these as "burned" rewards — the sysvar advances by
distributed + burned, but capitalization only increases bydistributed. This is consensus-critical accounting.Changes:
DistributeStakingRewardsFromSpoolnow returns(distributedLamports, burnedLamports)ErrNoAccountfromGetAccount→ burn (AgaveAccountNotFound)fd_stake_get_state != 0)!fd_stake_state_v2_is_stake)ArithmeticOverflow)UnableToSetState)ErrNoAccountGetAccount errors (IO/storage corruption) still panic — these should not be silently burnedEpochRewards.Distribute(distributed + burned),Capitalization += distributedStoreAccountsto exclude burned recordsFiles:
pkg/rewards/rewards.go,pkg/replay/rewards.go🤖 Generated with Claude Code