Repository navigation
feat: PoSe-vote members that persistently do not sign quorum commitments #8086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| Proof of Service | ||
| ---------------- | ||
|
|
||
| DKG members now also vote a member bad if it persistently does not sign final commitments. This applies to a | ||
| masternode that was a valid member of at least 6 commitments mined for quorums of the last 4032 blocks (about a | ||
| week) and signed at most a quarter of them. Like the other bad votes, it requires `SPORK_23_QUORUM_POSE`. | ||
|
|
||
| A commitment in which the masternode was voted bad adds nothing to its signing history. Once over the threshold, | ||
| it therefore keeps being voted bad in the quorums it is selected for until it is PoSe-banned. Reviving it with a | ||
| `ProUpServTx`, after fixing the cause, clears the history (#8086). |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| #include <llmq/blockprocessor.h> | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| #include <evo/deterministicmns.h> | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <evo/evodb.h> | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <evo/specialtx.h> | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <llmq/commitment.h> | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -28,6 +29,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| #include <algorithm> | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <map> | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <ranges> | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <set> | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <utility> | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -844,6 +846,100 @@ std::vector<const CBlockIndex*> CQuorumBlockProcessor::GetMinedCommitmentsIndexe | |||||||||||||||||||||||||||||||||||||||||||||
| return ret; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| std::shared_ptr<const CQuorumBlockProcessor::ValidMemberSigners> CQuorumBlockProcessor::GetValidMemberSigners( | ||||||||||||||||||||||||||||||||||||||||||||||
| const CFinalCommitment& qc, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex) const | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| const uint256 qc_hash{::SerializeHash(qc)}; | ||||||||||||||||||||||||||||||||||||||||||||||
| if (auto it = m_valid_member_signers_cache.find(qc_hash); it != m_valid_member_signers_cache.end()) { | ||||||||||||||||||||||||||||||||||||||||||||||
| return it->second.second; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const auto members = utils::GetAllQuorumMembers(qc.llmqType, {m_dmnman, m_qsnapman, m_chainman, pQuorumBaseBlockIndex}); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (members.size() > qc.validMembers.size() || members.size() > qc.signers.size()) { | ||||||||||||||||||||||||||||||||||||||||||||||
| return nullptr; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| auto signers = std::make_shared<ValidMemberSigners>(); | ||||||||||||||||||||||||||||||||||||||||||||||
| for (size_t i = 0; i < members.size(); ++i) { | ||||||||||||||||||||||||||||||||||||||||||||||
| if (qc.validMembers[i]) { | ||||||||||||||||||||||||||||||||||||||||||||||
| signers->emplace_back(members[i]->proTxHash, qc.signers[i]); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| m_valid_member_signers_cache.try_emplace(qc_hash, pQuorumBaseBlockIndex->nHeight, signers); | ||||||||||||||||||||||||||||||||||||||||||||||
| return signers; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| std::shared_ptr<const SigningRecords> CQuorumBlockProcessor::GetSigningRecords(gsl::not_null<const CBlockIndex*> pindex, | ||||||||||||||||||||||||||||||||||||||||||||||
| int window) const | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| // Held throughout, so that DKG sessions starting at the same block gather the records only once | ||||||||||||||||||||||||||||||||||||||||||||||
| LOCK(m_signing_records_mutex); | ||||||||||||||||||||||||||||||||||||||||||||||
| const uint256 cache_key{::SerializeHash(std::make_pair(pindex->GetBlockHash(), window))}; | ||||||||||||||||||||||||||||||||||||||||||||||
| if (std::shared_ptr<const SigningRecords> cached; m_signing_records_cache.get(cache_key, cached)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| return cached; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const int min_height{pindex->nHeight - window}; | ||||||||||||||||||||||||||||||||||||||||||||||
| std::vector<std::pair<Consensus::LLMQType, std::vector<const CBlockIndex*>>> quorums_by_type; | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| // While pindex is on the active chain, the mined commitments until pindex are those of its chain | ||||||||||||||||||||||||||||||||||||||||||||||
| LOCK(::cs_main); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (!m_chainman.ActiveChain().Contains(pindex)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| return nullptr; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| for (const auto& params : Params().GetConsensus().llmqs) { | ||||||||||||||||||||||||||||||||||||||||||||||
| if (params.is_single_member()) { | ||||||||||||||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| const bool rotation{IsQuorumRotationEnabled(params, pindex)}; | ||||||||||||||||||||||||||||||||||||||||||||||
| const size_t max_count{static_cast<size_t>(window / params.dkgInterval + 1) * | ||||||||||||||||||||||||||||||||||||||||||||||
| static_cast<size_t>(rotation ? params.signingActiveQuorumCount : 1)}; | ||||||||||||||||||||||||||||||||||||||||||||||
| quorums_by_type.emplace_back(params.type, | ||||||||||||||||||||||||||||||||||||||||||||||
| rotation ? GetMinedCommitmentsIndexedUntilBlock(params.type, pindex, max_count) | ||||||||||||||||||||||||||||||||||||||||||||||
| : GetMinedCommitmentsUntilBlock(params.type, pindex, max_count)); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+893
to
+898
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion: Collect commitments from both indexes across the DIP0024 transition The source: |
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| auto ret = std::make_shared<SigningRecords>(); | ||||||||||||||||||||||||||||||||||||||||||||||
| std::vector<uint256> mined_block_hashes; | ||||||||||||||||||||||||||||||||||||||||||||||
| for (const auto& [type, quorums] : quorums_by_type) { | ||||||||||||||||||||||||||||||||||||||||||||||
| // Oldest first, so that the member lists of the active quorums stay in the shared caches | ||||||||||||||||||||||||||||||||||||||||||||||
| for (const auto* pQuorumBaseBlockIndex : quorums | std::views::reverse) { | ||||||||||||||||||||||||||||||||||||||||||||||
| if (pQuorumBaseBlockIndex->nHeight <= min_height) { | ||||||||||||||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| const auto [qc, mined_block_hash] = GetMinedCommitment(type, pQuorumBaseBlockIndex->GetBlockHash()); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (qc.IsNull()) { | ||||||||||||||||||||||||||||||||||||||||||||||
| return nullptr; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| const auto signers = GetValidMemberSigners(qc, pQuorumBaseBlockIndex); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (!signers) { | ||||||||||||||||||||||||||||||||||||||||||||||
| return nullptr; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| mined_block_hashes.emplace_back(mined_block_hash); | ||||||||||||||||||||||||||||||||||||||||||||||
| for (const auto& [proTxHash, signed_commitment] : *signers) { | ||||||||||||||||||||||||||||||||||||||||||||||
| (*ret)[proTxHash].push_back({pQuorumBaseBlockIndex->nHeight, signed_commitment}); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+881
to
+920
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🟡 Suggestion: Add focused unit coverage for signing-history and voting boundaries The new functional scenarios cover eventual banning, isolated omission, revival, and the spork gate, but no unit tests exercise GetSigningRecords or CountSignedCommitments. The functional test also does not deliberately cross the 4032-block history boundary or distinguish a commitment based inside the window but mined after the gathering block. These selection rules determine whether an honest member receives a bad vote. Extend the existing LLMQ unit suites with records exactly at and immediately inside the lower boundary, commitments mined at and after the gathering block, registration/revival cutoffs, and cold-versus-cached queries, including indexed rotated-quorum enumeration. Pin the eligibility and ratio decisions as well: five versus six eligible commitments and signing exactly one quarter versus just above it. Keep test-only access in the test code rather than adding a public production helper solely for testing. source:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in b98097e:
The count and the threshold check are now free functions in 🤖 Posted autonomously by Claude on behalf of pasta.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved (re-reviewed at
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update at acd03e2: the unit tests are trimmed to the window, mining-height and rotation selection, the unavailable-view cases, the registration/revival cutoffs and the threshold table. I removed the session-level test for the 🤖 Posted autonomously by Claude on behalf of pasta.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved (re-reviewed at |
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| // The commitments were read without cs_main, so a reorg may have replaced some of them since | ||||||||||||||||||||||||||||||||||||||||||||||
| LOCK(::cs_main); | ||||||||||||||||||||||||||||||||||||||||||||||
| for (const auto& hash : mined_block_hashes) { | ||||||||||||||||||||||||||||||||||||||||||||||
| const auto* mined_block = m_chainman.m_blockman.LookupBlockIndex(hash); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (mined_block == nullptr || pindex->GetAncestor(mined_block->nHeight) != mined_block) { | ||||||||||||||||||||||||||||||||||||||||||||||
| return nullptr; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+925
to
+933
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion: Recheck gathering-block membership before caching signing records The initial lookup verifies that
Suggested change
source: |
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // Sessions of types with a longer DKG interval gather at an older block | ||||||||||||||||||||||||||||||||||||||||||||||
| std::erase_if(m_valid_member_signers_cache, | ||||||||||||||||||||||||||||||||||||||||||||||
| [&](const auto& entry) { return entry.second.first <= min_height - window; }); | ||||||||||||||||||||||||||||||||||||||||||||||
| m_signing_records_cache.insert(cache_key, ret); | ||||||||||||||||||||||||||||||||||||||||||||||
| return ret; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // The returned quorums are in reversed order, so the most recent one is at index 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| std::map<Consensus::LLMQType, std::vector<const CBlockIndex*>> CQuorumBlockProcessor::GetMinedAndActiveCommitmentsUntilBlock(gsl::not_null<const CBlockIndex*> pindex) const | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.