fix: scan quorums instead just using verified sigs

This commit is contained in:
Konstantin Akimov 2023-09-24 22:57:04 +07:00 committed by PastaPastaPasta
parent 4b046bb608
commit f7705cdf72
2 changed files with 10 additions and 13 deletions

View File

@ -53,24 +53,21 @@ CMNHFManager::Signals CMNHFManager::GetSignalsStage(const CBlockIndex* const pin
return signals; return signals;
} }
bool MNHFTx::Verify(const CBlockIndex* const pQuorumIndex, const uint256& msgHash, TxValidationState& state) const bool MNHFTx::Verify(const uint256& quorumHash, const uint256& msgHash, TxValidationState& state) const
{ {
if (versionBit >= VERSIONBITS_NUM_BITS) { if (versionBit >= VERSIONBITS_NUM_BITS) {
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-mnhf-nbit-out-of-bounds"); return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-mnhf-nbit-out-of-bounds");
} }
Consensus::LLMQType llmqType = Params().GetConsensus().llmqTypeMnhf; const Consensus::LLMQType& llmqType = Params().GetConsensus().llmqTypeMnhf;
const auto& llmq_params_opt = llmq::GetLLMQParams(llmqType); const auto quorum = llmq::quorumManager->GetQuorum(llmqType, quorumHash);
if (!llmq_params_opt.has_value()) {
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-mnhf-quorum-type");
}
int signOffset{llmq_params_opt->dkgInterval};
const uint256 requestId = ::SerializeHash(std::make_pair(MNEHF_REQUESTID_PREFIX, int64_t{versionBit})); const uint256 requestId = ::SerializeHash(std::make_pair(MNEHF_REQUESTID_PREFIX, int64_t{versionBit}));
const uint256 signHash = llmq::utils::BuildSignHash(llmqType, quorum->qc->quorumHash, requestId, msgHash);
if (!llmq::CSigningManager::VerifyRecoveredSig(llmqType, *llmq::quorumManager, pQuorumIndex->nHeight + signOffset, requestId, msgHash, sig)) { if (!sig.VerifyInsecure(quorum->qc->quorumPublicKey, signHash)) {
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-mnhf-invalid"); return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-mnhf-invalid");
} }
return true; return true;
} }
@ -107,7 +104,7 @@ bool CheckMNHFTx(const CTransaction& tx, const CBlockIndex* pindexPrev, TxValida
uint256 msgHash = tx_copy.GetHash(); uint256 msgHash = tx_copy.GetHash();
if (!mnhfTx.signal.Verify(pindexQuorum, msgHash, state)) { if (!mnhfTx.signal.Verify(mnhfTx.signal.quorumHash, msgHash, state)) {
// set up inside Verify // set up inside Verify
return false; return false;
} }

View File

@ -28,11 +28,11 @@ class MNHFTx
{ {
public: public:
uint8_t versionBit{0}; uint8_t versionBit{0};
uint256 quorumHash; uint256 quorumHash{0};
CBLSSignature sig; CBLSSignature sig{};
MNHFTx() = default; MNHFTx() = default;
bool Verify(const CBlockIndex* const pQuorumIndex, const uint256& msgHash, TxValidationState& state) const; bool Verify(const uint256& quorumHash, const uint256& msgHash, TxValidationState& state) const;
SERIALIZE_METHODS(MNHFTx, obj) SERIALIZE_METHODS(MNHFTx, obj)
{ {