mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
refactor: drop usage of chainstate globals in llmq logic
This commit is contained in:
parent
fa20718b4f
commit
303c6bb4db
@ -46,7 +46,7 @@ static bool CheckSpecialTxInner(CDeterministicMNManager& dmnman, const Chainstat
|
||||
case TRANSACTION_COINBASE:
|
||||
return CheckCbTx(tx, pindexPrev, state);
|
||||
case TRANSACTION_QUORUM_COMMITMENT:
|
||||
return llmq::CheckLLMQCommitment(dmnman, tx, pindexPrev, state);
|
||||
return llmq::CheckLLMQCommitment(dmnman, chainman, tx, pindexPrev, state);
|
||||
case TRANSACTION_MNHF_SIGNAL:
|
||||
if (!DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_V20)) {
|
||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "mnhf-before-v20");
|
||||
|
@ -257,7 +257,7 @@ bool CQuorumBlockProcessor::ProcessCommitment(int nHeight, const uint256& blockH
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-qc-dup");
|
||||
}
|
||||
|
||||
if (!IsMiningPhase(llmq_params, nHeight)) {
|
||||
if (!IsMiningPhase(llmq_params, m_chainstate.m_chain, nHeight)) {
|
||||
// should not happen as it's already handled in ProcessBlock
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-qc-height");
|
||||
}
|
||||
@ -385,12 +385,12 @@ bool CQuorumBlockProcessor::GetCommitmentsFromBlock(const CBlock& block, gsl::no
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CQuorumBlockProcessor::IsMiningPhase(const Consensus::LLMQParams& llmqParams, int nHeight)
|
||||
bool CQuorumBlockProcessor::IsMiningPhase(const Consensus::LLMQParams& llmqParams, const CChain& active_chain, int nHeight)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
|
||||
// Note: This function can be called for new blocks
|
||||
assert(nHeight <= ::ChainActive().Height() + 1);
|
||||
assert(nHeight <= active_chain.Height() + 1);
|
||||
|
||||
int quorumCycleStartHeight = nHeight - (nHeight % llmqParams.dkgInterval);
|
||||
int quorumCycleMiningStartHeight = quorumCycleStartHeight + llmqParams.dkgMiningWindowStart;
|
||||
@ -409,7 +409,7 @@ size_t CQuorumBlockProcessor::GetNumCommitmentsRequired(const Consensus::LLMQPar
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
|
||||
if (!IsMiningPhase(llmqParams, nHeight)) return 0;
|
||||
if (!IsMiningPhase(llmqParams, m_chainstate.m_chain, nHeight)) return 0;
|
||||
|
||||
// Note: This function can be called for new blocks
|
||||
assert(nHeight <= m_chainstate.m_chain.Height() + 1);
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
private:
|
||||
static bool GetCommitmentsFromBlock(const CBlock& block, gsl::not_null<const CBlockIndex*> pindex, std::multimap<Consensus::LLMQType, CFinalCommitment>& ret, BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
bool ProcessCommitment(int nHeight, const uint256& blockHash, const CFinalCommitment& qc, BlockValidationState& state, bool fJustCheck, bool fBLSChecks) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
static bool IsMiningPhase(const Consensus::LLMQParams& llmqParams, int nHeight) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
static bool IsMiningPhase(const Consensus::LLMQParams& llmqParams, const CChain& active_chain, int nHeight) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
size_t GetNumCommitmentsRequired(const Consensus::LLMQParams& llmqParams, int nHeight) const EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
static uint256 GetQuorumBlockHash(const Consensus::LLMQParams& llmqParams, const CChain& active_chain, int nHeight, int quorumIndex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
};
|
||||
|
@ -555,7 +555,7 @@ bool CChainLocksHandler::VerifyChainLock(const CChainLockSig& clsig) const
|
||||
{
|
||||
const auto llmqType = Params().GetConsensus().llmqTypeChainLocks;
|
||||
const uint256 nRequestId = ::SerializeHash(std::make_pair(llmq::CLSIG_REQUESTID_PREFIX, clsig.getHeight()));
|
||||
return llmq::VerifyRecoveredSig(llmqType, qman, clsig.getHeight(), nRequestId, clsig.getBlockHash(), clsig.getSig());
|
||||
return llmq::VerifyRecoveredSig(llmqType, m_chainstate.m_chain, qman, clsig.getHeight(), nRequestId, clsig.getBlockHash(), clsig.getSig());
|
||||
}
|
||||
|
||||
bool CChainLocksHandler::InternalHasChainLock(int nHeight, const uint256& blockHash) const
|
||||
|
@ -166,7 +166,7 @@ bool CFinalCommitment::VerifySizes(const Consensus::LLMQParams& params) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CheckLLMQCommitment(CDeterministicMNManager& dmnman, const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, TxValidationState& state)
|
||||
bool CheckLLMQCommitment(CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, TxValidationState& state)
|
||||
{
|
||||
const auto opt_qcTx = GetTxPayload<CFinalCommitmentTxPayload>(tx);
|
||||
if (!opt_qcTx) {
|
||||
@ -200,7 +200,7 @@ bool CheckLLMQCommitment(CDeterministicMNManager& dmnman, const CTransaction& tx
|
||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-qc-height");
|
||||
}
|
||||
|
||||
const CBlockIndex* pQuorumBaseBlockIndex = WITH_LOCK(cs_main, return g_chainman.m_blockman.LookupBlockIndex(qcTx.commitment.quorumHash));
|
||||
const CBlockIndex* pQuorumBaseBlockIndex = WITH_LOCK(cs_main, return chainman.m_blockman.LookupBlockIndex(qcTx.commitment.quorumHash));
|
||||
if (pQuorumBaseBlockIndex == nullptr) {
|
||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-qc-quorum-hash");
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
class CBlockIndex;
|
||||
class CDeterministicMNManager;
|
||||
class ChainstateManager;
|
||||
class TxValidationState;
|
||||
|
||||
namespace llmq
|
||||
@ -172,7 +173,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
bool CheckLLMQCommitment(CDeterministicMNManager& dmnman, const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, TxValidationState& state);
|
||||
bool CheckLLMQCommitment(CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, TxValidationState& state);
|
||||
|
||||
uint256 BuildCommitmentHash(Consensus::LLMQType llmqType, const uint256& blockHash, const std::vector<bool>& validMembers, const CBLSPublicKey& pubKey, const uint256& vvecHash);
|
||||
|
||||
|
@ -27,7 +27,7 @@ LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CDeterminis
|
||||
quorum_block_processor{std::make_unique<llmq::CQuorumBlockProcessor>(chainstate, dmnman, evo_db, peerman)},
|
||||
qdkgsman{std::make_unique<llmq::CDKGSessionManager>(*bls_worker, chainstate, connman, dmnman, *dkg_debugman, mn_metaman, *quorum_block_processor, mn_activeman, sporkman, peerman, unit_tests, wipe)},
|
||||
qman{std::make_unique<llmq::CQuorumManager>(*bls_worker, chainstate, connman, dmnman, *qdkgsman, evo_db, *quorum_block_processor, mn_activeman, mn_sync, sporkman)},
|
||||
sigman{std::make_unique<llmq::CSigningManager>(connman, mn_activeman, *qman, peerman, unit_tests, wipe)},
|
||||
sigman{std::make_unique<llmq::CSigningManager>(connman, mn_activeman, chainstate, *qman, peerman, unit_tests, wipe)},
|
||||
shareman{std::make_unique<llmq::CSigSharesManager>(connman, *sigman, mn_activeman, *qman, sporkman, peerman)},
|
||||
clhandler{[&]() -> llmq::CChainLocksHandler* const {
|
||||
assert(llmq::chainLocksHandler == nullptr);
|
||||
|
@ -86,7 +86,7 @@ void CEHFSignalsHandler::trySignEHFSignal(int bit, const CBlockIndex* const pind
|
||||
return;
|
||||
}
|
||||
|
||||
const auto quorum = llmq::SelectQuorumForSigning(llmq_params_opt.value(), qman, requestId);
|
||||
const auto quorum = llmq::SelectQuorumForSigning(llmq_params_opt.value(), chainstate.m_chain, qman, requestId);
|
||||
if (!quorum) {
|
||||
LogPrintf("CEHFSignalsHandler::trySignEHFSignal no quorum for id=%s\n", requestId.ToString());
|
||||
return;
|
||||
|
@ -920,7 +920,7 @@ std::unordered_set<uint256, StaticSaltedHasher> CInstantSendManager::ProcessPend
|
||||
nSignHeight = blockIndex->nHeight + dkgInterval - 1;
|
||||
}
|
||||
|
||||
auto quorum = llmq::SelectQuorumForSigning(llmq_params, qman, id, nSignHeight, signOffset);
|
||||
auto quorum = llmq::SelectQuorumForSigning(llmq_params, m_chainstate.m_chain, qman, id, nSignHeight, signOffset);
|
||||
if (!quorum) {
|
||||
// should not happen, but if one fails to select, all others will also fail to select
|
||||
return {};
|
||||
|
@ -1107,7 +1107,8 @@ void CQuorumManager::StartCleanupOldQuorumDataThread(const CBlockIndex* pIndex)
|
||||
});
|
||||
}
|
||||
|
||||
CQuorumCPtr SelectQuorumForSigning(const Consensus::LLMQParams& llmq_params, const CQuorumManager& quorum_manager, const uint256& selectionHash, int signHeight, int signOffset)
|
||||
CQuorumCPtr SelectQuorumForSigning(const Consensus::LLMQParams& llmq_params, const CChain& active_chain, const CQuorumManager& qman,
|
||||
const uint256& selectionHash, int signHeight, int signOffset)
|
||||
{
|
||||
size_t poolSize = llmq_params.signingActiveQuorumCount;
|
||||
|
||||
@ -1115,17 +1116,17 @@ CQuorumCPtr SelectQuorumForSigning(const Consensus::LLMQParams& llmq_params, con
|
||||
{
|
||||
LOCK(cs_main);
|
||||
if (signHeight == -1) {
|
||||
signHeight = ::ChainActive().Height();
|
||||
signHeight = active_chain.Height();
|
||||
}
|
||||
int startBlockHeight = signHeight - signOffset;
|
||||
if (startBlockHeight > ::ChainActive().Height() || startBlockHeight < 0) {
|
||||
if (startBlockHeight > active_chain.Height() || startBlockHeight < 0) {
|
||||
return {};
|
||||
}
|
||||
pindexStart = ::ChainActive()[startBlockHeight];
|
||||
pindexStart = active_chain[startBlockHeight];
|
||||
}
|
||||
|
||||
if (IsQuorumRotationEnabled(llmq_params, pindexStart)) {
|
||||
auto quorums = quorum_manager.ScanQuorums(llmq_params.type, pindexStart, poolSize);
|
||||
auto quorums = qman.ScanQuorums(llmq_params.type, pindexStart, poolSize);
|
||||
if (quorums.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -1149,7 +1150,7 @@ CQuorumCPtr SelectQuorumForSigning(const Consensus::LLMQParams& llmq_params, con
|
||||
}
|
||||
return *itQuorum;
|
||||
} else {
|
||||
auto quorums = quorum_manager.ScanQuorums(llmq_params.type, pindexStart, poolSize);
|
||||
auto quorums = qman.ScanQuorums(llmq_params.type, pindexStart, poolSize);
|
||||
if (quorums.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -1168,11 +1169,13 @@ CQuorumCPtr SelectQuorumForSigning(const Consensus::LLMQParams& llmq_params, con
|
||||
}
|
||||
}
|
||||
|
||||
bool VerifyRecoveredSig(Consensus::LLMQType llmqType, const CQuorumManager& quorum_manager, int signedAtHeight, const uint256& id, const uint256& msgHash, const CBLSSignature& sig, const int signOffset)
|
||||
bool VerifyRecoveredSig(Consensus::LLMQType llmqType, const CChain& active_chain, const CQuorumManager& qman,
|
||||
int signedAtHeight, const uint256& id, const uint256& msgHash, const CBLSSignature& sig,
|
||||
const int signOffset)
|
||||
{
|
||||
const auto& llmq_params_opt = Params().GetLLMQ(llmqType);
|
||||
assert(llmq_params_opt.has_value());
|
||||
auto quorum = SelectQuorumForSigning(llmq_params_opt.value(), quorum_manager, id, signedAtHeight, signOffset);
|
||||
auto quorum = SelectQuorumForSigning(llmq_params_opt.value(), active_chain, qman, id, signedAtHeight, signOffset);
|
||||
if (!quorum) {
|
||||
return false;
|
||||
}
|
||||
|
@ -294,11 +294,13 @@ private:
|
||||
// which are not 100% at the chain tip.
|
||||
static constexpr int SIGN_HEIGHT_OFFSET{8};
|
||||
|
||||
CQuorumCPtr SelectQuorumForSigning(const Consensus::LLMQParams& llmq_params, const CQuorumManager& quorum_manager, const uint256& selectionHash, int signHeight = -1 /*chain tip*/, int signOffset = SIGN_HEIGHT_OFFSET);
|
||||
CQuorumCPtr SelectQuorumForSigning(const Consensus::LLMQParams& llmq_params, const CChain& active_chain, const CQuorumManager& qman,
|
||||
const uint256& selectionHash, int signHeight = -1 /*chain tip*/, int signOffset = SIGN_HEIGHT_OFFSET);
|
||||
|
||||
// Verifies a recovered sig that was signed while the chain tip was at signedAtTip
|
||||
bool VerifyRecoveredSig(Consensus::LLMQType llmqType, const CQuorumManager& quorum_manager, int signedAtHeight, const uint256& id, const uint256& msgHash, const CBLSSignature& sig, int signOffset = SIGN_HEIGHT_OFFSET);
|
||||
|
||||
bool VerifyRecoveredSig(Consensus::LLMQType llmqType, const CChain& active_chain, const CQuorumManager& qman,
|
||||
int signedAtHeight, const uint256& id, const uint256& msgHash, const CBLSSignature& sig,
|
||||
int signOffset = SIGN_HEIGHT_OFFSET);
|
||||
} // namespace llmq
|
||||
|
||||
template<typename T> struct SaltedHasherImpl;
|
||||
|
@ -534,9 +534,9 @@ void CRecoveredSigsDb::CleanupOldVotes(int64_t maxAge)
|
||||
|
||||
//////////////////
|
||||
|
||||
CSigningManager::CSigningManager(CConnman& _connman, const CActiveMasternodeManager* const mn_activeman, const CQuorumManager& _qman,
|
||||
const std::unique_ptr<PeerManager>& peerman, bool fMemory, bool fWipe) :
|
||||
db(fMemory, fWipe), connman(_connman), m_mn_activeman(mn_activeman), qman(_qman), m_peerman(peerman)
|
||||
CSigningManager::CSigningManager(CConnman& _connman, const CActiveMasternodeManager* const mn_activeman, const CChainState& chainstate,
|
||||
const CQuorumManager& _qman, const std::unique_ptr<PeerManager>& peerman, bool fMemory, bool fWipe) :
|
||||
db(fMemory, fWipe), connman(_connman), m_mn_activeman(mn_activeman), m_chainstate(chainstate), qman(_qman), m_peerman(peerman)
|
||||
{
|
||||
}
|
||||
|
||||
@ -890,7 +890,7 @@ bool CSigningManager::AsyncSignIfMember(Consensus::LLMQType llmqType, CSigShares
|
||||
// TODO fix this by re-signing when the next block arrives, but only when that block results in a change of the quorum list and no recovered signature has been created in the mean time
|
||||
const auto &llmq_params_opt = Params().GetLLMQ(llmqType);
|
||||
assert(llmq_params_opt.has_value());
|
||||
return SelectQuorumForSigning(llmq_params_opt.value(), qman, id);
|
||||
return SelectQuorumForSigning(llmq_params_opt.value(), m_chainstate.m_chain, qman, id);
|
||||
} else {
|
||||
return qman.GetQuorum(llmqType, quorumHash);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <unordered_map>
|
||||
|
||||
class CActiveMasternodeManager;
|
||||
class CChainState;
|
||||
class CConnman;
|
||||
class CDataStream;
|
||||
class CDBBatch;
|
||||
@ -163,6 +164,7 @@ private:
|
||||
CRecoveredSigsDb db;
|
||||
CConnman& connman;
|
||||
const CActiveMasternodeManager* const m_mn_activeman;
|
||||
const CChainState& m_chainstate;
|
||||
const CQuorumManager& qman;
|
||||
const std::unique_ptr<PeerManager>& m_peerman;
|
||||
|
||||
@ -179,8 +181,8 @@ private:
|
||||
std::vector<CRecoveredSigsListener*> recoveredSigsListeners GUARDED_BY(cs_listeners);
|
||||
|
||||
public:
|
||||
CSigningManager(CConnman& _connman, const CActiveMasternodeManager* const mn_activeman, const CQuorumManager& _qman,
|
||||
const std::unique_ptr<PeerManager>& peerman, bool fMemory, bool fWipe);
|
||||
CSigningManager(CConnman& _connman, const CActiveMasternodeManager* const mn_activeman, const CChainState& chainstate,
|
||||
const CQuorumManager& _qman, const std::unique_ptr<PeerManager>& peerman, bool fMemory, bool fWipe);
|
||||
|
||||
bool AlreadyHave(const CInv& inv) const;
|
||||
bool GetRecoveredSigForGetData(const uint256& hash, CRecoveredSig& ret) const;
|
||||
|
@ -86,14 +86,14 @@ UniValue CQuorumRotationInfo::ToJson() const
|
||||
}
|
||||
|
||||
bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotationInfo& response,
|
||||
CDeterministicMNManager& dmnman, const CQuorumManager& qman,
|
||||
CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const CQuorumManager& qman,
|
||||
const CQuorumBlockProcessor& quorum_block_processor, std::string& errorRet)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
|
||||
std::vector<const CBlockIndex*> baseBlockIndexes;
|
||||
if (request.baseBlockHashes.size() == 0) {
|
||||
const CBlockIndex* blockIndex = ::ChainActive().Genesis();
|
||||
const CBlockIndex* blockIndex = chainman.ActiveChain().Genesis();
|
||||
if (!blockIndex) {
|
||||
errorRet = strprintf("genesis block not found");
|
||||
return false;
|
||||
@ -101,12 +101,12 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
||||
baseBlockIndexes.push_back(blockIndex);
|
||||
} else {
|
||||
for (const auto& blockHash : request.baseBlockHashes) {
|
||||
const CBlockIndex* blockIndex = g_chainman.m_blockman.LookupBlockIndex(blockHash);
|
||||
const CBlockIndex* blockIndex = chainman.m_blockman.LookupBlockIndex(blockHash);
|
||||
if (!blockIndex) {
|
||||
errorRet = strprintf("block %s not found", blockHash.ToString());
|
||||
return false;
|
||||
}
|
||||
if (!::ChainActive().Contains(blockIndex)) {
|
||||
if (!chainman.ActiveChain().Contains(blockIndex)) {
|
||||
errorRet = strprintf("block %s is not in the active chain", blockHash.ToString());
|
||||
return false;
|
||||
}
|
||||
@ -117,7 +117,7 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
||||
});
|
||||
}
|
||||
|
||||
const CBlockIndex* tipBlockIndex = ::ChainActive().Tip();
|
||||
const CBlockIndex* tipBlockIndex = chainman.ActiveChain().Tip();
|
||||
if (!tipBlockIndex) {
|
||||
errorRet = strprintf("tip block not found");
|
||||
return false;
|
||||
@ -127,7 +127,7 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
||||
return false;
|
||||
}
|
||||
|
||||
const CBlockIndex* blockIndex = g_chainman.m_blockman.LookupBlockIndex(request.blockRequestHash);
|
||||
const CBlockIndex* blockIndex = chainman.m_blockman.LookupBlockIndex(request.blockRequestHash);
|
||||
if (!blockIndex) {
|
||||
errorRet = strprintf("block not found");
|
||||
return false;
|
||||
|
@ -208,7 +208,7 @@ public:
|
||||
};
|
||||
|
||||
bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotationInfo& response,
|
||||
CDeterministicMNManager& dmnman, const CQuorumManager& qman,
|
||||
CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const CQuorumManager& qman,
|
||||
const CQuorumBlockProcessor& quorumBlockProcessor, std::string& errorRet);
|
||||
uint256 GetLastBaseBlockHash(Span<const CBlockIndex*> baseBlockIndexes, const CBlockIndex* blockIndex);
|
||||
|
||||
|
@ -4842,7 +4842,7 @@ void PeerManagerImpl::ProcessMessage(
|
||||
|
||||
llmq::CQuorumRotationInfo quorumRotationInfoRet;
|
||||
std::string strError;
|
||||
if (BuildQuorumRotationInfo(cmd, quorumRotationInfoRet, *m_dmnman, *m_llmq_ctx->qman, *m_llmq_ctx->quorum_block_processor, strError)) {
|
||||
if (BuildQuorumRotationInfo(cmd, quorumRotationInfoRet, *m_dmnman, m_chainman, *m_llmq_ctx->qman, *m_llmq_ctx->quorum_block_processor, strError)) {
|
||||
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::QUORUMROTATIONINFO, quorumRotationInfoRet));
|
||||
} else {
|
||||
strError = strprintf("getquorumrotationinfo failed for size(baseBlockHashes)=%d, blockRequestHash=%s. error=%s", cmd.baseBlockHashes.size(), cmd.blockRequestHash.ToString(), strError);
|
||||
|
@ -444,6 +444,7 @@ static RPCHelpMan quorum_sign()
|
||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||
{
|
||||
const NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||
const ChainstateManager& chainman = EnsureChainman(node);
|
||||
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||
|
||||
const Consensus::LLMQType llmqType{static_cast<Consensus::LLMQType>(ParseInt32V(request.params[0], "llmqType"))};
|
||||
@ -469,7 +470,7 @@ static RPCHelpMan quorum_sign()
|
||||
llmq::CQuorumCPtr pQuorum;
|
||||
|
||||
if (quorumHash.IsNull()) {
|
||||
pQuorum = llmq::SelectQuorumForSigning(llmq_params_opt.value(), *llmq_ctx.qman, id);
|
||||
pQuorum = llmq::SelectQuorumForSigning(llmq_params_opt.value(), chainman.ActiveChain(), *llmq_ctx.qman, id);
|
||||
} else {
|
||||
pQuorum = llmq_ctx.qman->GetQuorum(llmqType, quorumHash);
|
||||
}
|
||||
@ -520,6 +521,7 @@ static RPCHelpMan quorum_verify()
|
||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||
{
|
||||
const NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||
const ChainstateManager& chainman = EnsureChainman(node);
|
||||
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||
|
||||
const Consensus::LLMQType llmqType{static_cast<Consensus::LLMQType>(ParseInt32V(request.params[0], "llmqType"))};
|
||||
@ -545,8 +547,8 @@ static RPCHelpMan quorum_verify()
|
||||
}
|
||||
// First check against the current active set, if it fails check against the last active set
|
||||
int signOffset{llmq_params_opt->dkgInterval};
|
||||
return llmq::VerifyRecoveredSig(llmqType, *llmq_ctx.qman, signHeight, id, msgHash, sig, 0) ||
|
||||
llmq::VerifyRecoveredSig(llmqType, *llmq_ctx.qman, signHeight, id, msgHash, sig, signOffset);
|
||||
return llmq::VerifyRecoveredSig(llmqType, chainman.ActiveChain(), *llmq_ctx.qman, signHeight, id, msgHash, sig, 0) ||
|
||||
llmq::VerifyRecoveredSig(llmqType, chainman.ActiveChain(), *llmq_ctx.qman, signHeight, id, msgHash, sig, signOffset);
|
||||
}
|
||||
|
||||
uint256 quorumHash(ParseHashV(request.params[4], "quorumHash"));
|
||||
@ -669,6 +671,7 @@ static RPCHelpMan quorum_selectquorum()
|
||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||
{
|
||||
const NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||
const ChainstateManager& chainman = EnsureChainman(node);
|
||||
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||
|
||||
const Consensus::LLMQType llmqType{static_cast<Consensus::LLMQType>(ParseInt32V(request.params[0], "llmqType"))};
|
||||
@ -681,7 +684,7 @@ static RPCHelpMan quorum_selectquorum()
|
||||
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
|
||||
const auto quorum = llmq::SelectQuorumForSigning(llmq_params_opt.value(), *llmq_ctx.qman, id);
|
||||
const auto quorum = llmq::SelectQuorumForSigning(llmq_params_opt.value(), chainman.ActiveChain(), *llmq_ctx.qman, id);
|
||||
if (!quorum) {
|
||||
throw JSONRPCError(RPC_MISC_ERROR, "no quorums active");
|
||||
}
|
||||
@ -796,6 +799,7 @@ static RPCHelpMan quorum_rotationinfo()
|
||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||
{
|
||||
const NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||
const ChainstateManager& chainman = EnsureChainman(node);
|
||||
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||
CHECK_NONFATAL(node.dmnman);
|
||||
|
||||
@ -814,7 +818,7 @@ static RPCHelpMan quorum_rotationinfo()
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
if (!BuildQuorumRotationInfo(cmd, quorumRotationInfoRet, *node.dmnman, *llmq_ctx.qman, *llmq_ctx.quorum_block_processor, strError)) {
|
||||
if (!BuildQuorumRotationInfo(cmd, quorumRotationInfoRet, *node.dmnman, chainman, *llmq_ctx.qman, *llmq_ctx.quorum_block_processor, strError)) {
|
||||
throw JSONRPCError(RPC_INVALID_REQUEST, strError);
|
||||
}
|
||||
|
||||
@ -1030,8 +1034,8 @@ static RPCHelpMan verifyislock()
|
||||
const auto llmq_params_opt = Params().GetLLMQ(llmqType);
|
||||
CHECK_NONFATAL(llmq_params_opt.has_value());
|
||||
const int signOffset{llmq_params_opt->dkgInterval};
|
||||
return llmq::VerifyRecoveredSig(llmqType, *llmq_ctx.qman, signHeight, id, txid, sig, 0) ||
|
||||
llmq::VerifyRecoveredSig(llmqType, *llmq_ctx.qman, signHeight, id, txid, sig, signOffset);
|
||||
return llmq::VerifyRecoveredSig(llmqType, chainman.ActiveChain(), *llmq_ctx.qman, signHeight, id, txid, sig, 0) ||
|
||||
llmq::VerifyRecoveredSig(llmqType, chainman.ActiveChain(), *llmq_ctx.qman, signHeight, id, txid, sig, signOffset);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user