Skip to content

Commit 98600eb

Browse files
Merge #6940: fix: reuse best clsig to avoid potential race condition
c0faae0 fix: reuse best clsig to avoid potential race condition (Kittywhiskers Van Gogh) 98dc874 trivial: use `GetBestChainLockHeight()` (Kittywhiskers Van Gogh) Pull request description: ## Additional Information Fix for potential race condition identified by CodeRabbit in [dash#6933](#6933) ([comment](#6933 (comment))) ## Breaking Changes None expected. ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)** - [x] I have added or updated relevant unit/integration/functional/e2e tests **(note: N/A)** - [x] I have made corresponding changes to the documentation **(note: N/A)** - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK c0faae0 Tree-SHA512: 74762c5d715405a32af4a58553c05dc2fd98cdb7f038a519cf244a7c84a6a536ff341d8e8f534dbb6a0df952730314f85c52738c4d5b2e72fa74a4f02a6b2237
2 parents e8c71ce + c0faae0 commit 98600eb

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/evo/chainhelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ bool CChainstateHelper::HasChainLock(int nHeight, const uint256& blockHash) cons
3838
return clhandler.HasChainLock(nHeight, blockHash);
3939
}
4040

41-
int32_t CChainstateHelper::GetBestChainLockHeight() const { return clhandler.GetBestChainLock().getHeight(); }
41+
int32_t CChainstateHelper::GetBestChainLockHeight() const { return clhandler.GetBestChainLockHeight(); }
4242

4343
/** Passthrough functions to CInstantSendManager */
4444
std::optional<std::pair</*islock_hash=*/uint256, /*txid=*/uint256>> CChainstateHelper::ConflictingISLockIfAny(

src/node/miner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static bool CalcCbTxBestChainlock(const llmq::CChainLocksHandler& chainlock_hand
173173

174174
// Inserting our best CL
175175
bestCLHeightDiff = pindexPrev->nHeight - best_clsig.getHeight();
176-
bestCLSignature = chainlock_handler.GetBestChainLock().getSig();
176+
bestCLSignature = best_clsig.getSig();
177177

178178
return true;
179179
}

src/rpc/rawtransaction.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,9 @@ static RPCHelpMan getassetunlockstatuses()
667667
}
668668
else {
669669
const auto pBlockIndexBestCL = [&]() -> const CBlockIndex* {
670-
if (!llmq_ctx.clhandler->GetBestChainLock().IsNull()) {
671-
return pTipBlockIndex->GetAncestor(llmq_ctx.clhandler->GetBestChainLock().getHeight());
670+
const auto best_clsig = llmq_ctx.clhandler->GetBestChainLock();
671+
if (!best_clsig.IsNull()) {
672+
return pTipBlockIndex->GetAncestor(best_clsig.getHeight());
672673
}
673674
// If no CL info is available, try to use CbTx CL information
674675
if (const auto cbtx_best_cl = GetNonNullCoinbaseChainlock(pTipBlockIndex)) {

0 commit comments

Comments
 (0)