mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
llmq: Move GetAllQuorumMembers into CFinalCommitment::Verify (#4032)
Instead of calling `CLLMQUtils::GetAllQuorumMembers` before each `CFinalCommitment::Verify` call to get the quorum members, just get them inside `CFinalCommitment::Verify`.
This commit is contained in:
parent
d66d52a256
commit
ab819ce489
@ -103,9 +103,7 @@ void CQuorumBlockProcessor::ProcessMessage(CNode* pfrom, const std::string& strC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto members = CLLMQUtils::GetAllQuorumMembers(type, pquorumIndex);
|
if (!qc.Verify(pquorumIndex, true)) {
|
||||||
|
|
||||||
if (!qc.Verify(members, true)) {
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
LogPrint(BCLog::LLMQ, "CQuorumBlockProcessor::%s -- commitment for quorum %s:%d is not valid, peer=%d\n", __func__,
|
LogPrint(BCLog::LLMQ, "CQuorumBlockProcessor::%s -- commitment for quorum %s:%d is not valid, peer=%d\n", __func__,
|
||||||
qc.quorumHash.ToString(), qc.llmqType, pfrom->GetId());
|
qc.quorumHash.ToString(), qc.llmqType, pfrom->GetId());
|
||||||
@ -219,9 +217,8 @@ bool CQuorumBlockProcessor::ProcessCommitment(int nHeight, const uint256& blockH
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto quorumIndex = LookupBlockIndex(qc.quorumHash);
|
auto quorumIndex = LookupBlockIndex(qc.quorumHash);
|
||||||
auto members = CLLMQUtils::GetAllQuorumMembers(params.type, quorumIndex);
|
|
||||||
|
|
||||||
if (!qc.Verify(members, true)) {
|
if (!qc.Verify(quorumIndex, true)) {
|
||||||
return state.DoS(100, false, REJECT_INVALID, "bad-qc-invalid");
|
return state.DoS(100, false, REJECT_INVALID, "bad-qc-invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ CFinalCommitment::CFinalCommitment(const Consensus::LLMQParams& params, const ui
|
|||||||
LogPrintStr(strprintf("CFinalCommitment::%s -- %s", __func__, tinyformat::format(__VA_ARGS__))); \
|
LogPrintStr(strprintf("CFinalCommitment::%s -- %s", __func__, tinyformat::format(__VA_ARGS__))); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
bool CFinalCommitment::Verify(const std::vector<CDeterministicMNCPtr>& members, bool checkSigs) const
|
bool CFinalCommitment::Verify(const CBlockIndex* pQuorumIndex, bool checkSigs) const
|
||||||
{
|
{
|
||||||
if (nVersion == 0 || nVersion > CURRENT_VERSION) {
|
if (nVersion == 0 || nVersion > CURRENT_VERSION) {
|
||||||
return false;
|
return false;
|
||||||
@ -65,6 +65,7 @@ bool CFinalCommitment::Verify(const std::vector<CDeterministicMNCPtr>& members,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto members = CLLMQUtils::GetAllQuorumMembers(llmqType, pQuorumIndex);
|
||||||
for (size_t i = members.size(); i < params.size; i++) {
|
for (size_t i = members.size(); i < params.size; i++) {
|
||||||
if (validMembers[i]) {
|
if (validMembers[i]) {
|
||||||
LogPrintfFinalCommitment("invalid validMembers bitset. bit %d should not be set\n", i);
|
LogPrintfFinalCommitment("invalid validMembers bitset. bit %d should not be set\n", i);
|
||||||
@ -159,7 +160,6 @@ bool CheckLLMQCommitment(const CTransaction& tx, const CBlockIndex* pindexPrev,
|
|||||||
if (!Params().GetConsensus().llmqs.count((Consensus::LLMQType)qcTx.commitment.llmqType)) {
|
if (!Params().GetConsensus().llmqs.count((Consensus::LLMQType)qcTx.commitment.llmqType)) {
|
||||||
return state.DoS(100, false, REJECT_INVALID, "bad-qc-type");
|
return state.DoS(100, false, REJECT_INVALID, "bad-qc-type");
|
||||||
}
|
}
|
||||||
const auto& params = Params().GetConsensus().llmqs.at((Consensus::LLMQType)qcTx.commitment.llmqType);
|
|
||||||
|
|
||||||
if (qcTx.commitment.IsNull()) {
|
if (qcTx.commitment.IsNull()) {
|
||||||
if (!qcTx.commitment.VerifyNull()) {
|
if (!qcTx.commitment.VerifyNull()) {
|
||||||
@ -168,8 +168,7 @@ bool CheckLLMQCommitment(const CTransaction& tx, const CBlockIndex* pindexPrev,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto members = CLLMQUtils::GetAllQuorumMembers(params.type, pindexQuorum);
|
if (!qcTx.commitment.Verify(pindexQuorum, false)) {
|
||||||
if (!qcTx.commitment.Verify(members, false)) {
|
|
||||||
return state.DoS(100, false, REJECT_INVALID, "bad-qc-invalid");
|
return state.DoS(100, false, REJECT_INVALID, "bad-qc-invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public:
|
|||||||
return (int)std::count(validMembers.begin(), validMembers.end(), true);
|
return (int)std::count(validMembers.begin(), validMembers.end(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Verify(const std::vector<CDeterministicMNCPtr>& members, bool checkSigs) const;
|
bool Verify(const CBlockIndex* pQuorumIndex, bool checkSigs) const;
|
||||||
bool VerifyNull() const;
|
bool VerifyNull() const;
|
||||||
bool VerifySizes(const Consensus::LLMQParams& params) const;
|
bool VerifySizes(const Consensus::LLMQParams& params) const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user