From bc3da48a11a1733d6102fe77907f782df17622a6 Mon Sep 17 00:00:00 2001 From: Peter Todd Date: Fri, 13 Nov 2015 17:19:33 -0500 Subject: [PATCH 1/3] Remove LOCK(cs_main) from decodescript Completely static RPC call that doesn't change or even look at mutable state anywhere. zcash: cherry picked b3ae384a8d1606948427b7bd2059d781a779b62a zcash: https://github.com/bitcoin/bitcoin/pull/7013 --- src/rpc/rawtransaction.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index bcfeb0ffb..2999febbe 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -779,7 +779,6 @@ UniValue decodescript(const UniValue& params, bool fHelp) + HelpExampleRpc("decodescript", "\"hexstring\"") ); - LOCK(cs_main); RPCTypeCheck(params, boost::assign::list_of(UniValue::VSTR)); UniValue r(UniValue::VOBJ); From 2713f9680d7a34257ae425b0d21d41947ab56fac Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 2 Dec 2015 13:42:47 +0100 Subject: [PATCH 2/3] rpc: remove cs_main lock from `createrawtransaction` This is a pure utility function that doesn't use main's data structures, so it does not require that lock. zcash: cs_main still needed while calling chainActive() zcash: cherry picked 6e765873605ee5e31652ce107848a157151791b4 zcash: https://github.com/bitcoin/bitcoin/pull/7156 --- src/rpc/rawtransaction.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 2999febbe..37f150580 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -573,7 +573,6 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp) + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\"address\\\":0.01}\"") ); - LOCK(cs_main); RPCTypeCheck(params, boost::assign::list_of(UniValue::VARR)(UniValue::VOBJ)(UniValue::VNUM)(UniValue::VNUM), true); if (params[0].isNull() || params[1].isNull()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, arguments 1 and 2 must be non-null"); @@ -581,7 +580,11 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp) UniValue inputs = params[0].get_array(); UniValue sendTo = params[1].get_obj(); - int nextBlockHeight = chainActive.Height() + 1; + int nextBlockHeight; + { + LOCK(cs_main); + nextBlockHeight = chainActive.Height() + 1; + } CMutableTransaction rawTx = CreateNewContextualCMutableTransaction( Params().GetConsensus(), nextBlockHeight); From 4359b3bdcfb5cd2c4426d716f0f6ffe8fa290394 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sat, 19 Dec 2015 14:26:56 +0100 Subject: [PATCH 3/3] [walletdb] Add missing LOCK() in Recover() for dummyWallet zcash: cherry picked fa33d9740c9b0d1071094ab6c1736f27a7090c95 zcash: https://github.com/bitcoin/bitcoin/pull/7229 --- src/wallet/walletdb.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index d642cd660..4b8f0ee92 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -1248,8 +1248,13 @@ bool CWalletDB::Recover(CDBEnv& dbenv, const std::string& filename, bool fOnlyKe CDataStream ssKey(row.first, SER_DISK, CLIENT_VERSION); CDataStream ssValue(row.second, SER_DISK, CLIENT_VERSION); string strType, strErr; - bool fReadOK = ReadKeyValue(&dummyWallet, ssKey, ssValue, + bool fReadOK; + { + // Required in LoadKeyMetadata(): + LOCK(dummyWallet.cs_wallet); + fReadOK = ReadKeyValue(&dummyWallet, ssKey, ssValue, wss, strType, strErr); + } if (!IsKeyType(strType)) continue; if (!fReadOK)