fix(core): b3b uses emission schedule, not per-block disk reads#716
Conversation
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark 'sentrix-trie benches'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.
| Benchmark suite | Current: d248350 | Previous: c6ae261 | Ratio |
|---|---|---|---|
insert_single |
183168 ns/iter (± 15493) |
83470 ns/iter (± 10721) |
2.19 |
This comment was automatically generated by workflow using github-action-benchmark.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR updates the workspace version to 2.2.17 and refactors the recomputation of total_minted in crates/sentrix-core/src/storage.rs to derive it from the canonical emission schedule (TOTAL_PREMINE + sum of per-height rewards using halvings_at and BLOCK_REWARD) instead of summing persisted block coinbases. B3b repair documentation is updated and tests are changed to delete block META entries and assert the recomputed total_minted is unchanged. Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Hotfix for the v2.2.16 boot-stall regression. The original B3b helper iterated `load_block(h)` from 1..=tip to sum coinbase amounts. At mainnet h~2.2M with six containers booting in parallel after a halt-all, MDBX I/O contention turned the "~30-60s sanity pass" estimate from the commit message into a multi-minute per-container stall — every node sat past `Blockchain state loaded` without proceeding to the BFT round loop. Public RPC stayed down, health checks failed, the v2.2.16 deploy rolled back at T+~24 min. C-04 at `block_executor.rs:336` enforces `coinbase.amount == reward` for every accepted block. The schedule sum (TOTAL_PREMINE + accumulated `BLOCK_REWARD >> halvings_at(h)` over 1..=tip) is therefore identical to the disk sum — but ~6 orders of magnitude cheaper. New cost at mainnet h~2.2M: ~2 ms in a tight CPU loop. The detection + repair contract is unchanged. Blob's `total_minted` is compared against the recomputed value; mismatch triggers warn + overwrite + atomic save-back through the existing B1 path. Regression test renamed to `test_recompute_total_minted_is_disk_independent` (was `_skips_missing_blocks`) — asserts the helper returns the same value whether or not blocks are persisted to MDBX. Guards against a future refactor accidentally reintroducing the O(N) disk-read cost. Also bumps workspace 2.2.16 -> 2.2.17.
d248350 to
597377d
Compare
Hotfix for the v2.2.16 boot-stall regression. The original B3b helper iterated
load_block(h)from 1..=tip to sum coinbase amounts. At mainnet h~2.2M with six containers booting in parallel after a halt-all, MDBX I/O contention turned the "~30-60s sanity pass" estimate from the commit message into a multi-minute per-container stall — every node sat pastBlockchain state loadedwithout proceeding to the BFT round loop. Public RPC stayed down, health checks failed, the v2.2.16 deploy rolled back at T+~24 min.C-04 at
block_executor.rs:336enforcescoinbase.amount == rewardfor every accepted block. The schedule sum (TOTAL_PREMINE + accumulatedBLOCK_REWARD >> halvings_at(h)over 1..=tip) is therefore identical to the disk sum — but6 orders of magnitude cheaper. New cost at mainnet h2.2M: ~2 ms in a tight CPU loop.The detection + repair contract is unchanged. Blob's
total_mintedis compared against the recomputed value; mismatch triggers warn + overwrite + atomic save-back through the existing B1 path.Regression test renamed to
test_recompute_total_minted_is_disk_independent(was_skips_missing_blocks) — asserts the helper returns the same value whether or not blocks are persisted to MDBX. Guards against a future refactor accidentally reintroducing the O(N) disk-read cost.Also bumps workspace 2.2.16 -> 2.2.17.
Summary
Risk tier
Check ONE:
sentrix-core,sentrix-trie,sentrix-staking,sentrix-bft),block_executor,apply_block_*,state_rootpathRequired by tier
🟢 Low — minimum bar
🟡 Medium — adds
#[test]in same PR🟠 High — adds
🔴 Critical — adds
Test plan
Rollback plan
Related
Summary by CodeRabbit
Chores
Bug Fixes