Repository navigation
perf(dash)!: share masternode and quorum maps between masternode lists - #1066
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: dashpay/rust-dashcore/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (10)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughMasternode lists now store shared maps and entries using ChangesShared List State
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Refactor Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable issue remains from the inspected changes; the PR is mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to Shared list state affects quorum verification across blocks and changes a public API. The reviewed paths retain key validation controls, but the breadth of the state change and incomplete downstream coverage warrant a design review. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 56.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 9 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 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 |
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
74a91f2 to
b099486
Compare
Every `apply_diff` cloned the base list's masternode and quorum maps whole, so the engine held a full copy of the list per block it applied. On mainnet the list changes in about 290 of every 4608 blocks, so nearly all of those copies were identical. `MasternodeList::masternodes` and `quorums` become `Arc<MasternodeMap>` and `Arc<QuorumMap>`, with every entry behind its own `Arc`: - a diff that touches no masternode shares the base list's masternode map, and one that touches no quorum (nor carries ChainLock signatures) shares its quorum map; - a diff that does change a map copies it on write, and the copy still shares every entry it kept; - a quorum status change goes through `set_quorum_status_in_lists`, which writes it once per distinct map, so lists that shared a map before the change keep sharing the updated one instead of splitting into copies. The status update loops in `apply_diff`, `verify_non_rotating_masternode_list_quorums` and the rotated cycle paths go through that helper; what they compute is unchanged. Measured on the mainnet list at 2_227_096 (3147 masternodes) with one empty diff per block for a 288-block cycle, release build, RSS growth for 288 lists: dev 311.6 MiB (~1.08 MiB per block, unbounded), this branch 1.3 MiB. BREAKING CHANGE: `MasternodeList::masternodes` is `Arc<BTreeMap<ProTxHash, Arc<QualifiedMasternodeListEntry>>>` and `quorums` is `Arc<BTreeMap<LLMQType, BTreeMap<QuorumHash, Arc<QualifiedQuorumEntry>>>>`. Reads through `.values()`/`.get()` deref as before; writers go through `Arc::make_mut`. `serde` gains its `rc` feature. Verified: fmt, clippy --workspace --all-features --all-targets -D warnings, dashcore 618 (2 new: an empty diff shares both maps; a status change keeps three lists on one map), dash-spv 570 + dashd_masternode 10 + dashd_sync 32, dash-spv-ffi 49 + dashd_sync 7. Co-Authored-By: Claude Opus 5.5 <[email protected]>
b099486 to
0b2cf4c
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev #1066 +/- ##
==========================================
- Coverage 77.53% 77.39% -0.14%
==========================================
Files 317 317
Lines 80681 80742 +61
==========================================
- Hits 62552 62493 -59
- Misses 18129 18249 +120
|
|
Bots are done — your move: post |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Bots are done — your move: post |
Every
apply_diffcloned the base list's masternode and quorum maps whole, so the engine held a full copy of the list per block it applied. On mainnet the list changes in about 290 of every 4608 blocks, so nearly all of those copies were identical.MasternodeList::masternodesandquorumsbecomeArc<MasternodeMap>andArc<QuorumMap>, with every entry behind its ownArc:set_quorum_status_in_lists, which writes it once per distinct map, so lists that shared a map before the change keep sharing the updated one instead of splitting into copies.The status update loops in
apply_diff,verify_non_rotating_masternode_list_quorumsand the rotated cycle paths go through that helper; what they compute is unchanged.Measured on the mainnet list at 2_227_096 (3147 masternodes) with one empty diff per block for a 288-block cycle, release build, RSS growth for 288 lists: dev 311.6 MiB (~1.08 MiB per block, unbounded), this branch 1.3 MiB.
BREAKING CHANGE:
MasternodeList::masternodesisArc<BTreeMap<ProTxHash, Arc<QualifiedMasternodeListEntry>>>andquorumsisArc<BTreeMap<LLMQType, BTreeMap<QuorumHash, Arc<QualifiedQuorumEntry>>>>. Reads through.values()/.get()deref as before; writers go throughArc::make_mut.serdegains itsrcfeature.Verified: fmt, clippy --workspace --all-features --all-targets -D warnings, dashcore 618 (2 new: an empty diff shares both maps; a status change keeps three lists on one map), dash-spv 570 + dashd_masternode 10 + dashd_sync 32, dash-spv-ffi 49 + dashd_sync 7.
PR Hygiene ·
0b2cf4c/self-revieweddash/Cargo.toml,dash/src/sml/masternode_list/apply_diff.rs,dash/src/sml/masternode_list/builder.rsand 7 more) — QuantumExplorer or xdustinfaceWhen every box is checked the
PR Hygienecheck passes and this can merge.Summary by CodeRabbit
Bug Fixes
Improvements