Skip to content

Commit

Permalink
fix: scan quorums instead just using verified sigs
Browse files Browse the repository at this point in the history
  • Loading branch information
knst committed Oct 4, 2023
1 parent 93c04c2 commit 0fdf236
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
17 changes: 7 additions & 10 deletions src/evo/mnhftx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,21 @@ CMNHFManager::Signals CMNHFManager::GetSignalsStage(const CBlockIndex* const pin
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) {
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-mnhf-nbit-out-of-bounds");
}

Consensus::LLMQType llmqType = Params().GetConsensus().llmqTypeMnhf;
const auto& llmq_params_opt = llmq::GetLLMQParams(llmqType);
if (!llmq_params_opt.has_value()) {
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-mnhf-quorum-type");
}
int signOffset{llmq_params_opt->dkgInterval};
const Consensus::LLMQType& llmqType = Params().GetConsensus().llmqTypeMnhf;
const auto quorum = llmq::quorumManager->GetQuorum(llmqType, quorumHash);

const uint256 requestId = ::SerializeHash(std::make_pair(MNEHF_REQUESTID_PREFIX, int64_t{versionBit}));

if (!llmq::CSigningManager::VerifyRecoveredSig(llmqType, *llmq::quorumManager, pQuorumIndex->nHeight + signOffset, requestId, msgHash, sig)) {
const uint256 signHash = llmq::utils::BuildSignHash(llmqType, quorum->qc->quorumHash, requestId, msgHash);
if (!sig.VerifyInsecure(quorum->qc->quorumPublicKey, signHash)) {
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-mnhf-invalid");
}

return true;
}

Expand Down Expand Up @@ -107,7 +104,7 @@ bool CheckMNHFTx(const CTransaction& tx, const CBlockIndex* pindexPrev, TxValida
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
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/evo/mnhftx.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class MNHFTx
{
public:
uint8_t versionBit{0};
uint256 quorumHash;
CBLSSignature sig;
uint256 quorumHash{0};
CBLSSignature sig{};

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)
{
Expand Down

0 comments on commit 0fdf236

Please sign in to comment.