Skip to content

Commit 2704003

Browse files
committed
fix: using proper quorums for asset unlock validation
1 parent 0253438 commit 2704003

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/evo/assetlocktx.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <chainparams.h>
1313
#include <consensus/params.h>
1414
#include <consensus/validation.h>
15+
#include <deploymentstatus.h>
1516
#include <logging.h>
1617
#include <tinyformat.h>
1718
#include <util/ranges_set.h>
@@ -113,13 +114,18 @@ bool CAssetUnlockPayload::VerifySig(const llmq::CQuorumManager& qman, const uint
113114
// and at the quorumHash must be active in either the current or previous quorum cycle
114115
// and the sig must validate against that specific quorumHash.
115116

117+
116118
Consensus::LLMQType llmqType = Params().GetConsensus().llmqTypePlatform;
117119

118-
// We check at most 2 quorums
119-
const auto quorums = qman.ScanQuorums(llmqType, pindexTip, 2);
120+
const auto& llmq_params_opt = Params().GetLLMQ(llmqType);
121+
assert(llmq_params_opt.has_value());
122+
123+
// after deployment WITHDRAWALS activated we check not to quorum, but all active quorums + 1 the latest inactive
124+
const int quorums_to_scan = DeploymentActiveAt(*pindexTip, Params().GetConsensus(), Consensus::DEPLOYMENT_WITHDRAWALS) ? (llmq_params_opt->signingActiveQuorumCount + 1) : 2;
125+
const auto quorums = qman.ScanQuorums(llmqType, pindexTip, quorums_to_scan);
120126

121127
if (bool isActive = std::any_of(quorums.begin(), quorums.end(), [&](const auto &q) { return q->qc->quorumHash == quorumHash; }); !isActive) {
122-
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-assetunlock-not-active-quorum");
128+
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-assetunlock-too-old-quorum");
123129
}
124130

125131
if (static_cast<uint32_t>(pindexTip->nHeight) < requestedHeight || pindexTip->nHeight >= getHeightToExpiry()) {

0 commit comments

Comments
 (0)