Skip to content

Commit 11ac6c3

Browse files
committed
fix: governance should not lock mempool mutex even call GetTransaction
GetTransaction is indeed called deep inside but the nullptr is pass as a pointer to mempool. There is no used global mempool and GetTransaction do not use any other mempool if argument with pointer to mempol is empty.
1 parent 70607a7 commit 11ac6c3

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/governance/governance.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ void CGovernanceManager::ProcessMessage(CNode& peer, std::string_view msg_type,
143143
return;
144144
}
145145

146-
LOCK2(cs_main, ::mempool.cs); // Lock mempool because of GetTransaction deep inside
147-
LOCK(cs);
146+
LOCK2(cs_main, cs);
148147

149148
if (mapObjects.count(nHash) || mapPostponedObjects.count(nHash) || mapErasedGovernanceObjects.count(nHash)) {
150149
// TODO - print error code? what if it's GOVOBJ_ERROR_IMMATURE?
@@ -263,8 +262,7 @@ void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, CConnman
263262

264263
govobj.UpdateSentinelVariables(); //this sets local vars in object
265264

266-
LOCK2(cs_main, ::mempool.cs); // Lock mempool because of GetTransaction deep inside
267-
LOCK(cs);
265+
LOCK2(cs_main, cs);
268266
std::string strError;
269267

270268
// MAKE SURE THIS OBJECT IS OK
@@ -321,8 +319,7 @@ void CGovernanceManager::UpdateCachesAndClean()
321319

322320
std::vector<uint256> vecDirtyHashes = mmetaman.GetAndClearDirtyGovernanceObjectHashes();
323321

324-
LOCK2(cs_main, ::mempool.cs); // Lock mempool because of GetTransaction deep inside
325-
LOCK(cs);
322+
LOCK2(cs_main, cs);
326323

327324
for (const uint256& nHash : vecDirtyHashes) {
328325
auto it = mapObjects.find(nHash);
@@ -831,8 +828,7 @@ void CGovernanceManager::CheckPostponedObjects(CConnman& connman)
831828
{
832829
if (!::masternodeSync->IsSynced()) return;
833830

834-
LOCK2(cs_main, ::mempool.cs); // Lock mempool because of GetTransaction deep inside
835-
LOCK(cs);
831+
LOCK2(cs_main, cs);
836832

837833
// Check postponed proposals
838834
for (auto it = mapPostponedObjects.begin(); it != mapPostponedObjects.end();) {

src/governance/object.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,6 @@ CAmount CGovernanceObject::GetMinCollateralFee(bool fork_active) const
531531
bool CGovernanceObject::IsCollateralValid(std::string& strError, bool& fMissingConfirmations) const
532532
{
533533
AssertLockHeld(cs_main);
534-
AssertLockHeld(::mempool.cs); // because of GetTransaction
535534

536535
strError = "";
537536
fMissingConfirmations = false;

0 commit comments

Comments
 (0)