feat(consensus): migrate liveness + total_minted to state trie post-fork (SIP-6, PR 3/N)#757
Conversation
…ork (SIP-6, PR 3/N)
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Warning Review limit reached
More reviews will be available in 22 minutes and 7 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR extends the state trie persistence layer to store validator liveness and total_minted state alongside existing pending_rewards. It defines new domain-separated trie keys and fixed-layout value codecs in the address module, then updates the block trie operation to collect liveness stats and total_minted from blockchain state, encode them according to the new codecs, and write them to the trie under their respective keys. The changes gate new collection/write phases on a trie-height predicate. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary
PR 3/N in the SIP-6 series. Extends PR #756's apply-path trie write with two more off-trie consensus state pieces — per-validator liveness + jail state, and the global `Blockchain.total_minted` counter. Pre-fork (`STATE_IN_TRIE_HEIGHT == u64::MAX`) is bit-identical.
What this PR adds to the trie post-fork
What changes
Self-review notes
Tests
Activation hazard (same as PR #756)
The first post-fork block writes EVERY validator's current liveness + total_minted. If those values have already drifted across validators (the bug this PR closes), state_root will diverge at the activation block. Mitigation = operator-set canonical override env vars at activation time (modelled on `STATE_ROOT_V2_TREASURY_BALANCE`). Out of scope here.
Next PRs
Summary by CodeRabbit