Skip to content

Commit

Permalink
fix: using proper quorums for asset unlock validation
Browse files Browse the repository at this point in the history
  • Loading branch information
knst committed Oct 7, 2024
1 parent 0253438 commit 2704003
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/evo/assetlocktx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <chainparams.h>
#include <consensus/params.h>
#include <consensus/validation.h>
#include <deploymentstatus.h>
#include <logging.h>
#include <tinyformat.h>
#include <util/ranges_set.h>
Expand Down Expand Up @@ -113,13 +114,18 @@ bool CAssetUnlockPayload::VerifySig(const llmq::CQuorumManager& qman, const uint
// and at the quorumHash must be active in either the current or previous quorum cycle
// and the sig must validate against that specific quorumHash.


Consensus::LLMQType llmqType = Params().GetConsensus().llmqTypePlatform;

// We check at most 2 quorums
const auto quorums = qman.ScanQuorums(llmqType, pindexTip, 2);
const auto& llmq_params_opt = Params().GetLLMQ(llmqType);
assert(llmq_params_opt.has_value());

// after deployment WITHDRAWALS activated we check not to quorum, but all active quorums + 1 the latest inactive
const int quorums_to_scan = DeploymentActiveAt(*pindexTip, Params().GetConsensus(), Consensus::DEPLOYMENT_WITHDRAWALS) ? (llmq_params_opt->signingActiveQuorumCount + 1) : 2;
const auto quorums = qman.ScanQuorums(llmqType, pindexTip, quorums_to_scan);

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

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

0 comments on commit 2704003

Please sign in to comment.