Skip to content

Commit

Permalink
fix: cycleHash should represent a cycle starting block of the signi…
Browse files Browse the repository at this point in the history
…ng quorum
  • Loading branch information
UdjinM6 committed Mar 4, 2025
1 parent 26ea618 commit 88bf3fa
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/llmq/instantsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,21 +671,26 @@ void CInstantSendManager::TrySignInstantSendLock(const CTransaction& tx)
islock.inputs.emplace_back(in.prevout);
}

{
const auto &llmq_params_opt = Params().GetLLMQ(llmqType);
assert(llmq_params_opt);
LOCK(cs_main);
const auto dkgInterval = llmq_params_opt->dkgInterval;
const auto quorumHeight = m_chainstate.m_chain.Height() - (m_chainstate.m_chain.Height() % dkgInterval);
islock.cycleHash = m_chainstate.m_chain[quorumHeight]->GetBlockHash();
}

auto id = islock.GetRequestId();

if (sigman.HasRecoveredSigForId(llmqType, id)) {
return;
}

const auto& llmq_params_opt = Params().GetLLMQ(llmqType);
assert(llmq_params_opt);
const auto quorum = SelectQuorumForSigning(llmq_params_opt.value(), m_chainstate.m_chain, qman, id);

if (!quorum) {
LogPrint(BCLog::INSTANTSEND, "CInstantSendManager::%s -- failed to select quorum. islock id=%s, txid=%s\n",
__func__, id.ToString(), tx.GetHash().ToString());
return;
}

const int cycle_height = quorum->m_quorum_base_block_index->nHeight -
quorum->m_quorum_base_block_index->nHeight % llmq_params_opt->dkgInterval;
islock.cycleHash = quorum->m_quorum_base_block_index->GetAncestor(cycle_height)->GetBlockHash();

{
LOCK(cs_creating);
auto e = creatingInstantSendLocks.emplace(id, std::move(islock));
Expand All @@ -695,7 +700,7 @@ void CInstantSendManager::TrySignInstantSendLock(const CTransaction& tx)
txToCreatingInstantSendLocks.emplace(tx.GetHash(), &e.first->second);
}

sigman.AsyncSignIfMember(llmqType, shareman, id, tx.GetHash());
sigman.AsyncSignIfMember(llmqType, shareman, id, tx.GetHash(), quorum->m_quorum_base_block_index->GetBlockHash());
}

void CInstantSendManager::HandleNewInstantSendLockRecoveredSig(const llmq::CRecoveredSig& recoveredSig)
Expand Down

0 comments on commit 88bf3fa

Please sign in to comment.