Repository navigation
fix: erase the superseded mineable commitment when a better one replaces it - #8048
PastaPastaPasta wants to merge 1 commit into
Conversation
When AddMineableCommitment received a commitment with more signers than the one already pooled for that quorum, it pointed the quorum's entry at the new hash first and then erased by that same reference. The erase therefore targeted the new hash, which was not in the map yet, and the superseded commitment stayed in minableCommitments. This has been the case since commitments were first pooled in dashpay#2477. The replacement runs when a DKG member's own finalization yields a commitment with more signers than one it already pooled. Nothing pointed at the old entry afterwards, so it was never chosen for a block template, but HasMineableCommitment and GetMineableCommitmentByHash still found it: the node kept answering AlreadyHave for it and serving it on GETDATA, and held it for the life of the process unless that exact commitment was later mined. Erase the old entry before repointing the quorum's entry at the new one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7cc7e8d to
2d7a4f5
Compare
|
✅ Final review complete — no blockers (commit 2d7a4f5) · triage: low |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
At head 2d7a4f5, erasing the superseded commitment before updating the quorum's stored hash correctly fixes the replacement leak without changing commitment selection or block validation. The regression test exercises the affected hash lookups and rejection of worse or tied submissions; no in-scope defects were found. Current GitHub checks show successful builds, tests, sanitizers, and lint with no pending or failed checks; no builds or tests were run locally, and the supplied base-drift evidence reports no conflicts or intervening changes to the touched files.
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: dash-core-commit-history); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — The diff makes a small, contained map-update ordering fix in AddMineableCommitment and adds a focused regression test without changing consensus or commitment selection logic. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 98% left, weekly 58% left; passed overgemini-3.8-flash-high(antigravity quota lookup failed) - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— dash-core-commit-history (completed, effort medium); agentphase2-reviewer
Out-of-scope follow-up suggestions (2)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Inverted better-commitment pre-check in ProcessMessage prevents normal P2P upgrades — At src/llmq/blockprocessor.cpp:181-193, the pre-check returns when the pooled commitment has fewer or equal signers than the incoming commitment. It therefore rejects a better incoming commitment while allowing a worse one through signature verification. This condition also exists in the parent commit and is independent of the replacement cleanup: correcting AddMineableCommitment does not require changing which peer commitments are accepted.
- Follow-up: Track a separate fix for the comparison, with regression coverage showing that a valid better incoming commitment replaces the pooled one and an inferior commitment is rejected before expensive verification.
- Mining a different commitment leaves the pooled best commitment orphaned — At src/llmq/blockprocessor.cpp:449-452, ProcessCommitment removes the quorum's lookup entry but erases only the mined commitment's hash. If the node pooled a different commitment for that quorum, its hash entry remains available through HasMineableCommitment and GetMineableCommitmentByHash without a corresponding quorum entry. The parent commit contains the same cleanup logic; this separate block-processing lifecycle defect is neither introduced nor worsened by the replacement fix.
- Follow-up: Track a separate cleanup fix and unit test for mining a commitment whose hash differs from the locally pooled best commitment.
|
This pull request has conflicts, please rebase. |
|
Closing as superseded by #8085 (merged in 9c981d9). It moved Two follow-ups from this PR's description are still open on develop:
🤖 Posted autonomously by Claude on behalf of pasta. |
… rejected 3936953 fix: keep final commitments mineable when their block is rejected (pasta) Pull request description: ## Issue being fixed or feature implemented `CQuorumBlockProcessor::ProcessCommitment()` removed a block's final commitments from the mineable pool while the block was still being validated. `ConnectBlock()` processes quorum commitments early, before inputs, scripts, the coinbase amount/payee checks and several special-transaction checks. A block carrying the commitment of a finished DKG that then failed one of those later checks was never connected, yet every node that validated it (compact blocks are relayed before validation) had dropped the commitment from its pool. Nothing re-adds it, so that quorum was not mined in that DKG cycle. ## What was done? - `ProcessCommitment()` no longer touches the mineable pool, apart from dropping its caches. - New `CQuorumBlockProcessor::RemoveMineableCommitmentsForBlock()` removes the same entries as before, called once `ConnectBlock()` has accepted the block (next to where the BLS scheme switch is committed) and in `RollforwardBlock()`. - Check-only validation (`fJustCheck` / `TestBlockValidity`) returns before that point and never touches the pool. `UndoBlock()` still re-adds the commitments of a disconnected block, so reorgs behave as before. Re-adding on the failure path instead was rejected: a block can fail partway through its commitments, which could re-pool a commitment that was never verified. This doesn't overlap with #8048, which changes `AddMineableCommitment` only. ## How Has This Been Tested? `feature_llmq_dkgerrors.py`: after the existing `invalidateblock` check, the test submits the same commitment-carrying block with the coinbase paying 1 duff too much, expects `bad-cb-amount`, and asserts the commitment is still listed as mineable in `quorum dkgstatus`. It fails on `develop` and passed three times with this change. A five-node reproduction also fails on `develop`; with the fix every node keeps the commitment and the quorum is mined within its window. `llmq_*`, `evo_*` and `validation_chainstatemanager_tests` unit tests pass, as do `feature_llmq_rotation.py`, `feature_llmq_is_cl_conflicts.py`, `feature_llmq_evo.py`, `feature_llmq_signing.py`, `feature_llmq_simplepose.py`, `feature_llmq_singlenode.py`, `feature_llmq_dkg_intake.py`, `feature_dip4_coinbasemerkleroots.py`, `feature_quorum_proof_chain.py`, `rpc_quorum.py`, `feature_new_quorum_type_activation.py` and `feature_abortnode.py`. ## Breaking Changes None. ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have made corresponding changes to the documentation - [ ] I have assigned this pull request to a milestone _(if you have permission to set one)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Top commit has no ACKs. Tree-SHA512: a306a6fbf6613ca25dfce8665815c94833ebeb012642f492db882ea7154ac1a987bfe5c0afbebcc7d09762fcf8373e664ea3bb2a82e0c5921d87723426e2f4b6
…lock is rejected 3936953 fix: keep final commitments mineable when their block is rejected (pasta) Pull request description: ## Issue being fixed or feature implemented `CQuorumBlockProcessor::ProcessCommitment()` removed a block's final commitments from the mineable pool while the block was still being validated. `ConnectBlock()` processes quorum commitments early, before inputs, scripts, the coinbase amount/payee checks and several special-transaction checks. A block carrying the commitment of a finished DKG that then failed one of those later checks was never connected, yet every node that validated it (compact blocks are relayed before validation) had dropped the commitment from its pool. Nothing re-adds it, so that quorum was not mined in that DKG cycle. ## What was done? - `ProcessCommitment()` no longer touches the mineable pool, apart from dropping its caches. - New `CQuorumBlockProcessor::RemoveMineableCommitmentsForBlock()` removes the same entries as before, called once `ConnectBlock()` has accepted the block (next to where the BLS scheme switch is committed) and in `RollforwardBlock()`. - Check-only validation (`fJustCheck` / `TestBlockValidity`) returns before that point and never touches the pool. `UndoBlock()` still re-adds the commitments of a disconnected block, so reorgs behave as before. Re-adding on the failure path instead was rejected: a block can fail partway through its commitments, which could re-pool a commitment that was never verified. This doesn't overlap with dashpay#8048, which changes `AddMineableCommitment` only. ## How Has This Been Tested? `feature_llmq_dkgerrors.py`: after the existing `invalidateblock` check, the test submits the same commitment-carrying block with the coinbase paying 1 duff too much, expects `bad-cb-amount`, and asserts the commitment is still listed as mineable in `quorum dkgstatus`. It fails on `develop` and passed three times with this change. A five-node reproduction also fails on `develop`; with the fix every node keeps the commitment and the quorum is mined within its window. `llmq_*`, `evo_*` and `validation_chainstatemanager_tests` unit tests pass, as do `feature_llmq_rotation.py`, `feature_llmq_is_cl_conflicts.py`, `feature_llmq_evo.py`, `feature_llmq_signing.py`, `feature_llmq_simplepose.py`, `feature_llmq_singlenode.py`, `feature_llmq_dkg_intake.py`, `feature_dip4_coinbasemerkleroots.py`, `feature_quorum_proof_chain.py`, `rpc_quorum.py`, `feature_new_quorum_type_activation.py` and `feature_abortnode.py`. ## Breaking Changes None. ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have made corresponding changes to the documentation - [ ] I have assigned this pull request to a milestone _(if you have permission to set one)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Top commit has no ACKs. Tree-SHA512: a306a6fbf6613ca25dfce8665815c94833ebeb012642f492db882ea7154ac1a987bfe5c0afbebcc7d09762fcf8373e664ea3bb2a82e0c5921d87723426e2f4b6 v24.0.x adaptations: Chainstate has no m_special_tx member here, so ConnectBlock() and RollforwardBlock() call the processor through m_chain_helper->special_tx like the neighbouring special-tx calls. CQuorumBlockProcessor keeps the v24.0.x GetCommitmentsFromBlock(), and RemoveMineableCommitmentsForBlock()'s lock annotation drops !m_commitment_payload_mutex, which only exists with dashpay#7936. (cherry picked from commit ce9ef66)
…lock is rejected 3936953 fix: keep final commitments mineable when their block is rejected (pasta) Pull request description: ## Issue being fixed or feature implemented `CQuorumBlockProcessor::ProcessCommitment()` removed a block's final commitments from the mineable pool while the block was still being validated. `ConnectBlock()` processes quorum commitments early, before inputs, scripts, the coinbase amount/payee checks and several special-transaction checks. A block carrying the commitment of a finished DKG that then failed one of those later checks was never connected, yet every node that validated it (compact blocks are relayed before validation) had dropped the commitment from its pool. Nothing re-adds it, so that quorum was not mined in that DKG cycle. ## What was done? - `ProcessCommitment()` no longer touches the mineable pool, apart from dropping its caches. - New `CQuorumBlockProcessor::RemoveMineableCommitmentsForBlock()` removes the same entries as before, called once `ConnectBlock()` has accepted the block (next to where the BLS scheme switch is committed) and in `RollforwardBlock()`. - Check-only validation (`fJustCheck` / `TestBlockValidity`) returns before that point and never touches the pool. `UndoBlock()` still re-adds the commitments of a disconnected block, so reorgs behave as before. Re-adding on the failure path instead was rejected: a block can fail partway through its commitments, which could re-pool a commitment that was never verified. This doesn't overlap with dashpay#8048, which changes `AddMineableCommitment` only. ## How Has This Been Tested? `feature_llmq_dkgerrors.py`: after the existing `invalidateblock` check, the test submits the same commitment-carrying block with the coinbase paying 1 duff too much, expects `bad-cb-amount`, and asserts the commitment is still listed as mineable in `quorum dkgstatus`. It fails on `develop` and passed three times with this change. A five-node reproduction also fails on `develop`; with the fix every node keeps the commitment and the quorum is mined within its window. `llmq_*`, `evo_*` and `validation_chainstatemanager_tests` unit tests pass, as do `feature_llmq_rotation.py`, `feature_llmq_is_cl_conflicts.py`, `feature_llmq_evo.py`, `feature_llmq_signing.py`, `feature_llmq_simplepose.py`, `feature_llmq_singlenode.py`, `feature_llmq_dkg_intake.py`, `feature_dip4_coinbasemerkleroots.py`, `feature_quorum_proof_chain.py`, `rpc_quorum.py`, `feature_new_quorum_type_activation.py` and `feature_abortnode.py`. ## Breaking Changes None. ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have made corresponding changes to the documentation - [ ] I have assigned this pull request to a milestone _(if you have permission to set one)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Top commit has no ACKs. Tree-SHA512: a306a6fbf6613ca25dfce8665815c94833ebeb012642f492db882ea7154ac1a987bfe5c0afbebcc7d09762fcf8373e664ea3bb2a82e0c5921d87723426e2f4b6 v24.0.x adaptations: Chainstate has no m_special_tx member here, so ConnectBlock() and RollforwardBlock() call the processor through m_chain_helper->special_tx like the neighbouring special-tx calls. CQuorumBlockProcessor keeps the v24.0.x GetCommitmentsFromBlock(), and RemoveMineableCommitmentsForBlock()'s lock annotation drops !m_commitment_payload_mutex, which only exists with dashpay#7936. (cherry picked from commit ce9ef66)
Issue being fixed or feature implemented
When a better final commitment (more signers) replaces the one a node has pooled for a quorum, the old commitment is never erased.
AddMineableCommitmentrepoints the quorum's entry at the new hash first, and then erases through that same reference, so the erase targets the new hash, which is not in the map yet. It has been like this since commitments were first pooled in #2477.Nothing points at the old entry afterwards, so it is never chosen for a block template. But
HasMineableCommitmentandGetMineableCommitmentByHashstill find it, so the node keeps answeringAlreadyHavefor it and keeps serving it onGETDATA. It also holds the commitment for the life of the process, unless that exact commitment is later mined. The replacement runs when a DKG member's own finalization produces a commitment with more signers than one it already pooled.What was done?
AddMineableCommitmentnow erases the old entry before repointing the quorum's entry at the new one. The reference is renamed frominsertedQuorumHashtoknownCommitmentHash, since it holds a commitment hash, not a quorum hash.Why this can't change mining or validity:
GetMineableCommitments, which feeds block templates andquorum dkgstatus, only reads commitments throughminableCommitmentsByQuorum, and that map's contents are unchanged.llmqTypeandquorumHash.The only P2P difference is that a superseded hash is no longer "already have". A peer that announces it is handled the same way as any worse commitment the node never stored.
Related issues found while checking this, left for separate PRs:
ProcessCommitmenterases the mined commitment's hash and the quorum's entry. If the mined commitment differs from the pool's best for that quorum, the pool's best is orphaned the same way.ProcessMessageis inverted. It drops an incoming commitment with at least as many signers as the pooled one, and sends a worse one on to full verification. So a pooled commitment is never upgraded over P2P. Fixing it changes which commitment gets mined, so it needs its own review.UndoBlockre-pools a commitment even when the mined record is kept for another chainstate. Background validation never disconnects a shared block, so this can't happen today; it belongs with the AssumeUTXO work.How Has This Been Tested?
The new unit test
llmq_blockprocessor_tests/superseded_mineable_commitment_is_droppedcovers this. A better commitment replaces a worse one, after which the worse one is no longer found byHasMineableCommitmentorGetMineableCommitmentByHash. Re-adding the worse one, or one with an equal signer count, neither displaces the kept commitment nor gets stored.With the
blockprocessor.cppchange reverted, the test fails on exactly the three checks for the superseded hash. With the change, it passes. Thellmq_*,evo_cbtx_tests,evo_db_tests,evo_snapshot_tests,evo_simplifiedmns_tests,validation_chainstatemanager_testsandblock_reward_reallocation_testssuites also pass, 153 cases in all, on a Linux x86_64--enable-debugbuild.Breaking Changes
None.
Checklist:
🤖 Generated with Claude Code