From 4f4a72da8eb06a3fdea72981f606adee307e5aab Mon Sep 17 00:00:00 2001 From: Duke Date: Fri, 13 Sep 2024 09:28:59 -0400 Subject: [PATCH] Go back to taking both main+wallet lock in DecrementWitnesses By taking a wallet lock first and then main later we run into a potential deadlock : 2024-09-13 11:14:37 POTENTIAL DEADLOCK DETECTED 2024-09-13 11:14:37 Previous lock order was: 2024-09-13 11:14:37 (1) cs_wallet wallet/wallet.cpp:985 2024-09-13 11:14:37 (2) cs_main wallet/wallet.cpp:890 2024-09-13 11:14:37 Current lock order is: 2024-09-13 11:14:37 (2) cs_main wallet/wallet.cpp:2845 2024-09-13 11:14:37 (1) cs_wallet wallet/wallet.cpp:2845 --- src/wallet/wallet.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 26faed52a..01af7b78e 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -887,7 +887,6 @@ bool CWallet::IsSaplingSpent(const uint256& nullifier) const { } unsigned int CWallet::GetSaplingSpendDepth(const uint256& nullifier) const { - LOCK(cs_main); pair range; range = mapTxSaplingNullifiers.equal_range(nullifier); @@ -979,10 +978,9 @@ void CWallet::ClearNoteWitnessCache() void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) { - extern int32_t HUSH_REWIND; - LOCK(cs_wallet); + LOCK2(cs_main, cs_wallet); for (std::pair& wtxItem : mapWallet) { //Sapling