Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: drop useless mutex cs_llmq_vbc to avoid deadlock #5749

Merged
merged 3 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/llmq/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ LLMQContext::~LLMQContext() {
llmq::chainLocksHandler.reset();
llmq::quorumManager.reset();
llmq::quorumBlockProcessor.reset();
UdjinM6 marked this conversation as resolved.
Show resolved Hide resolved
{
LOCK(llmq::cs_llmq_vbc);
llmq::llmq_versionbitscache.Clear();
UdjinM6 marked this conversation as resolved.
Show resolved Hide resolved
}
llmq::llmq_versionbitscache.Clear();
}

void LLMQContext::Interrupt() {
Expand Down
6 changes: 0 additions & 6 deletions src/llmq/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(co
namespace llmq
{

Mutex cs_llmq_vbc;
VersionBitsCache llmq_versionbitscache;

namespace utils
Expand Down Expand Up @@ -693,27 +692,23 @@ bool IsV19Active(gsl::not_null<const CBlockIndex*> pindex)

bool IsV20Active(gsl::not_null<const CBlockIndex*> pindex)
{
LOCK(cs_llmq_vbc);
return llmq_versionbitscache.State(pindex, Params().GetConsensus(), Consensus::DEPLOYMENT_V20) == ThresholdState::ACTIVE;
}

bool IsMNRewardReallocationActive(gsl::not_null<const CBlockIndex*> pindex)
{
if (!IsV20Active(pindex)) return false;

LOCK(cs_llmq_vbc);
return llmq_versionbitscache.State(pindex, Params().GetConsensus(), Consensus::DEPLOYMENT_MN_RR) == ThresholdState::ACTIVE;
}

ThresholdState GetV20State(gsl::not_null<const CBlockIndex*> pindex)
{
LOCK(cs_llmq_vbc);
return llmq_versionbitscache.State(pindex, Params().GetConsensus(), Consensus::DEPLOYMENT_V20);
}

int GetV20Since(gsl::not_null<const CBlockIndex*> pindex)
{
LOCK(cs_llmq_vbc);
return llmq_versionbitscache.StateSinceHeight(pindex, Params().GetConsensus(), Consensus::DEPLOYMENT_V20);
}

Expand Down Expand Up @@ -980,7 +975,6 @@ bool IsQuorumTypeEnabledInternal(Consensus::LLMQType llmqType, const CQuorumMana
return true;

case Consensus::LLMQType::LLMQ_TEST_V17: {
LOCK(cs_llmq_vbc);
return llmq_versionbitscache.State(pindex, consensusParams, Consensus::DEPLOYMENT_TESTDUMMY) == ThresholdState::ACTIVE;
}
case Consensus::LLMQType::LLMQ_100_67:
Expand Down
6 changes: 3 additions & 3 deletions src/llmq/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ namespace llmq
class CQuorumManager;
class CQuorumSnapshot;

// Use a separate cache instance instead of versionbitscache to avoid locking cs_main
// A separate cache instance instead of versionbitscache has been introduced to avoid locking cs_main
// and dealing with all kinds of deadlocks.
extern Mutex cs_llmq_vbc;
extern VersionBitsCache llmq_versionbitscache GUARDED_BY(cs_llmq_vbc);
// TODO: drop llmq_versionbitscache completely so far as VersionBitsCache do not uses anymore cs_main
UdjinM6 marked this conversation as resolved.
Show resolved Hide resolved
extern VersionBitsCache llmq_versionbitscache;

static const bool DEFAULT_ENABLE_QUORUM_DATA_RECOVERY = true;

Expand Down
Loading