From c06a2e27029165a6f16d7cf70e27ed898f07a6bb Mon Sep 17 00:00:00 2001 From: Pablo Greco Date: Mon, 2 Oct 2023 11:12:59 -0700 Subject: [PATCH] test --- src/dynafed.cpp | 3 +++ src/pegins.cpp | 1 + src/validation.cpp | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/dynafed.cpp b/src/dynafed.cpp index 29a2029483..e4564c84b1 100644 --- a/src/dynafed.cpp +++ b/src/dynafed.cpp @@ -11,6 +11,7 @@ bool NextBlockIsParameterTransition(const CBlockIndex* pindexPrev, const Consens winning_entry.SetNull(); return false; } + LOCK(cs_main); std::map vote_tally; assert(next_height >= consensus.dynamic_epoch_length); for (int32_t height = next_height - 1; height >= (int32_t)(next_height - consensus.dynamic_epoch_length); --height) { @@ -62,6 +63,7 @@ DynaFedParamEntry ComputeNextBlockFullCurrentParameters(const CBlockIndex* pinde // may be pre-dynafed params const CBlockIndex* p_epoch_start = pindexPrev->GetAncestor(epoch_start_height); assert(p_epoch_start); + LOCK(cs_main); ForceUntrimHeader(p_epoch_start); if (p_epoch_start->dynafed_params().IsNull()) { // We need to construct the "full" current parameters of pre-dynafed @@ -96,6 +98,7 @@ DynaFedParamEntry ComputeNextBlockCurrentParameters(const CBlockIndex* pindexPre { assert(pindexPrev); + LOCK(cs_main); ForceUntrimHeader(pindexPrev); DynaFedParamEntry entry = ComputeNextBlockFullCurrentParameters(pindexPrev, consensus); diff --git a/src/pegins.cpp b/src/pegins.cpp index da47025d43..9146d2da50 100644 --- a/src/pegins.cpp +++ b/src/pegins.cpp @@ -475,6 +475,7 @@ std::vector> GetValidFedpegScripts(const CBlockIndex fedpegscripts.push_back(std::make_pair(next_param.m_fedpeg_program, next_param.m_fedpegscript)); } + LOCK(cs_main); // Next we walk backwards up to M epoch starts for (int32_t i = 0; i < (int32_t) params.total_valid_epochs; i++) { // We are within total_valid_epochs of the genesis diff --git a/src/validation.cpp b/src/validation.cpp index 749c0f98a5..00d54f588b 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2467,6 +2467,7 @@ void ForceUntrimHeader(const CBlockIndex *pindex_) if (!pindex_->trimmed()) { return; } + LOCK(cs_main); AssertLockHeld(cs_main); CBlockIndex* pindex = const_cast(pindex_); pindex->untrim(); @@ -2510,6 +2511,7 @@ void CChainState::UpdateTip(const CBlockIndex* pindexNew) this->CoinsTip().DynamicMemoryUsage() * (1.0 / (1<<20)), this->CoinsTip().GetCacheSize(), !warning_messages.empty() ? strprintf(" warning='%s'", warning_messages.original) : ""); + LOCK(cs_main); ForceUntrimHeader(pindexNew); // Do some logging if dynafed parameters changed. if (pindexNew->pprev && !pindexNew->dynafed_params().IsNull()) {