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

(WIP) Fix CI warnings #435

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions src/chainparamsseeds.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ static const uint8_t chainparams_seed_main[] = {
};

static const uint8_t chainparams_seed_test[] = {
0x01,0x04,0x00,0x00,0x00,0x00,0x20,0x8e,
};
#endif // BITCOIN_CHAINPARAMSSEEDS_H
1 change: 1 addition & 0 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ BlockAssembler::TxAllowedForNamecoin (const CTransaction& tx) const
if (nameOutFound && nameOpOut.getNameOp () == OP_NAME_FIRSTUPDATE)
{
bool nameNewFound = false;
LOCK (cs_main);
const auto& coinsTip = ::ChainstateActive ().CoinsTip ();
for (const auto& txIn : tx.vin)
{
Expand Down
7 changes: 5 additions & 2 deletions src/names/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <names/common.h>
#include <primitives/transaction.h>
#include <serialize.h>
#include <sync.h>

#include <set>

Expand All @@ -19,6 +20,8 @@ class ChainstateManager;
class CTxMemPool;
class TxValidationState;

extern RecursiveMutex cs_main;

/* Some constants defining name limits. */
constexpr unsigned MAX_VALUE_LENGTH = 1023;
constexpr unsigned MAX_NAME_LENGTH = 255;
Expand Down Expand Up @@ -105,7 +108,7 @@ void ApplyNameTransaction (const CTransaction& tx, unsigned nHeight,
/**
* Expire all names at the given height. This removes their coins
* from the UTXO set.
* @param height The new block height.
* @param nHeight The new block height.
* @param view The coins view to update.
* @param undo The block undo object to record undo information.
* @param names List all expired names here.
Expand All @@ -132,6 +135,6 @@ bool UnexpireNames (unsigned nHeight, CBlockUndo& undo,
* this throws an assertion failure.
* @param disconnect Whether we are disconnecting blocks.
*/
void CheckNameDB (ChainstateManager& chainman, bool disconnect);
void CheckNameDB (ChainstateManager& chainman, bool disconnect) EXCLUSIVE_LOCKS_REQUIRED (cs_main);

#endif // H_BITCOIN_NAMES_MAIN
18 changes: 9 additions & 9 deletions src/names/mempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace
* there is any. The txid must be for an entry in the mempool.
*/
COutPoint
getNameOutput (const CTxMemPool& pool, const uint256& txid)
getNameOutput (const CTxMemPool& pool, const uint256& txid) EXCLUSIVE_LOCKS_REQUIRED (pool.cs)
{
AssertLockHeld (pool.cs);

Expand All @@ -57,7 +57,7 @@ getNameOutput (const CTxMemPool& pool, const uint256& txid)
} // anonymous namespace

COutPoint
CNameMemPool::lastNameOutput (const valtype& name) const
CNameMemPool::lastNameOutput (const valtype& name) const EXCLUSIVE_LOCKS_REQUIRED (pool.cs)
{
const auto itUpd = updates.find (name);
if (itUpd != updates.end ())
Expand Down Expand Up @@ -102,7 +102,7 @@ CNameMemPool::lastNameOutput (const valtype& name) const
}

void
CNameMemPool::addUnchecked (const CTxMemPoolEntry& entry)
CNameMemPool::addUnchecked (const CTxMemPoolEntry& entry) EXCLUSIVE_LOCKS_REQUIRED (pool.cs)
{
AssertLockHeld (pool.cs);

Expand Down Expand Up @@ -137,7 +137,7 @@ CNameMemPool::addUnchecked (const CTxMemPoolEntry& entry)
}

void
CNameMemPool::remove (const CTxMemPoolEntry& entry)
CNameMemPool::remove (const CTxMemPoolEntry& entry) EXCLUSIVE_LOCKS_REQUIRED (pool.cs)
{
AssertLockHeld (pool.cs);

Expand All @@ -162,7 +162,7 @@ CNameMemPool::remove (const CTxMemPoolEntry& entry)
}

void
CNameMemPool::removeConflicts (const CTransaction& tx)
CNameMemPool::removeConflicts (const CTransaction& tx) EXCLUSIVE_LOCKS_REQUIRED (pool.cs)
{
AssertLockHeld (pool.cs);

Expand All @@ -188,7 +188,7 @@ CNameMemPool::removeConflicts (const CTransaction& tx)
}

void
CNameMemPool::removeUnexpireConflicts (const std::set<valtype>& unexpired)
CNameMemPool::removeUnexpireConflicts (const std::set<valtype>& unexpired) EXCLUSIVE_LOCKS_REQUIRED (pool.cs)
{
AssertLockHeld (pool.cs);

Expand All @@ -209,7 +209,7 @@ CNameMemPool::removeUnexpireConflicts (const std::set<valtype>& unexpired)
}

void
CNameMemPool::removeExpireConflicts (const std::set<valtype>& expired)
CNameMemPool::removeExpireConflicts (const std::set<valtype>& expired) EXCLUSIVE_LOCKS_REQUIRED (pool.cs)
{
AssertLockHeld (pool.cs);

Expand Down Expand Up @@ -238,7 +238,7 @@ CNameMemPool::removeExpireConflicts (const std::set<valtype>& expired)
}

void
CNameMemPool::check (ChainstateManager& chainman, CChainState& active_chainstate) const
CNameMemPool::check (ChainstateManager& chainman, CChainState& active_chainstate) const EXCLUSIVE_LOCKS_REQUIRED (pool.cs, cs_main)
{
AssertLockHeld (pool.cs);

Expand Down Expand Up @@ -309,7 +309,7 @@ CNameMemPool::check (ChainstateManager& chainman, CChainState& active_chainstate
}

bool
CNameMemPool::checkTx (const CTransaction& tx) const
CNameMemPool::checkTx (const CTransaction& tx) const EXCLUSIVE_LOCKS_REQUIRED (pool.cs)
{
AssertLockHeld (pool.cs);

Expand Down
1 change: 1 addition & 0 deletions src/names/mempool.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <names/common.h>
#include <primitives/transaction.h>
#include <uint256.h>
#include <sync.h>

#include <map>
#include <memory>
Expand Down
1 change: 1 addition & 0 deletions src/rest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,7 @@ static bool rest_name(const std::any& context, HTTPRequest* req, const std::stri
return RESTERR(req, HTTP_BAD_REQUEST,
"Invalid encoded name: " + encodedName);

LOCK (cs_main);
CNameData data;
if (!::ChainstateActive ().CoinsTip ().GetName(plainName, data))
return RESTERR(req, HTTP_NOT_FOUND,
Expand Down
8 changes: 5 additions & 3 deletions src/rpc/names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ addExpirationInfo (const ChainstateManager& chainman,
*/
void
addOwnershipInfo (const CScript& addr, const CWallet* pwallet,
UniValue& data)
UniValue& data) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
{
if (pwallet == nullptr)
return;
Expand Down Expand Up @@ -311,9 +311,11 @@ class MaybeWalletForRequest
*/
void
addOwnershipInfo (const CScript& addr, const MaybeWalletForRequest& wallet,
UniValue& data)
UniValue& data) EXCLUSIVE_LOCKS_REQUIRED(wallet.getLock())
{
#ifdef ENABLE_WALLET
LOCK (wallet.getWallet()->cs_wallet); // This is unneccessary, but the type analyzer can't conclude wallet.getLock() == wallet.getWallet()->cs_wallet
//LOCK (wallet.getLock()); // This is unneccessary, but the type analyzer can't conclude wallet.getLock() == wallet.getWallet()->cs_wallet
addOwnershipInfo (addr, wallet.getWallet (), data);
#endif
}
Expand All @@ -325,7 +327,7 @@ addOwnershipInfo (const CScript& addr, const MaybeWalletForRequest& wallet,
UniValue
getNameInfo (const ChainstateManager& chainman, const UniValue& options,
const valtype& name, const CNameData& data,
const MaybeWalletForRequest& wallet)
const MaybeWalletForRequest& wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.getLock())
{
UniValue res = getNameInfo (chainman, options, name, data);
addOwnershipInfo (data.getAddress (), wallet, res);
Expand Down
2 changes: 1 addition & 1 deletion src/txdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class CCoinsViewDB final : public CCoinsView
CNameIterator* IterateNames() const override;
bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock, const CNameCache &names) override;
CCoinsViewCursor *Cursor() const override;
bool ValidateNameDB(ChainstateManager& chainman, const std::function<void()>& interruption_point) const override;
bool ValidateNameDB(ChainstateManager& chainman, const std::function<void()>& interruption_point) const override EXCLUSIVE_LOCKS_REQUIRED(cs_main);

//! Attempt to update from an older database format. Returns whether an error occurred.
bool Upgrade();
Expand Down
6 changes: 3 additions & 3 deletions src/wallet/rpcnames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ namespace
* @return True on success, false otherwise
*/
bool
getNameSalt(CWallet* const pwallet, const valtype& name, const CScript& output, valtype& rand)
getNameSalt(CWallet* const pwallet, const valtype& name, const CScript& output, valtype& rand) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
{
AssertLockHeld(pwallet->cs_wallet);

Expand Down Expand Up @@ -467,7 +467,7 @@ namespace
* @return True if the output could be found.
*/
bool
getNamePrevout (const uint256& txid, CTxOut& txOut, CTxIn& txIn)
getNamePrevout (const uint256& txid, CTxOut& txOut, CTxIn& txIn) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
{
AssertLockHeld (cs_main);

Expand Down Expand Up @@ -871,7 +871,7 @@ sendtoname ()
the user could have gotten from another RPC command prior to now. */
pwallet->BlockUntilSyncedToCurrentChain();

LOCK(pwallet->cs_wallet);
LOCK2 (pwallet->cs_wallet, cs_main);

/* sendtoname does not support an options argument (e.g. to override the
configured name/value encodings). That would just add to the already
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/rpcwallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
#include <vector>

class CCoinControl;
class CRecipient;
class CRPCCommand;
class CWallet;
class CWalletTx;
class JSONRPCRequest;
class LegacyScriptPubKeyMan;
class UniValue;
class CTransaction;
struct CRecipient;
struct PartiallySignedTransaction;
struct WalletContext;

Expand Down
7 changes: 4 additions & 3 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const std::map<uint64_t,std::string> WALLET_FLAG_CAVEATS{

static const size_t OUTPUT_GROUP_MAX_ENTRIES = 10;

RecursiveMutex cs_wallet;
RecursiveMutex cs_wallets;
static std::vector<std::shared_ptr<CWallet>> vpwallets GUARDED_BY(cs_wallets);
static std::list<LoadWalletFn> g_load_wallet_fns GUARDED_BY(cs_wallets);
Expand Down Expand Up @@ -1977,7 +1978,7 @@ CAmount CWalletTx::GetCachableAmount(AmountType type, const isminefilter& filter
return amount.m_value[filter];
}

CAmount CWalletTx::GetDebit(const isminefilter& filter) const
CAmount CWalletTx::GetDebit(const isminefilter& filter) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
{
if (tx->vin.empty())
return 0;
Expand Down Expand Up @@ -2742,7 +2743,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
bool
CWallet::FindValueInNameInput (const CTxIn& nameInput,
CAmount& value, const CWalletTx*& walletTx,
bilingual_str& error) const
bilingual_str& error) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
{
walletTx = GetWalletTx (nameInput.prevout.hash);
if (!walletTx)
Expand Down Expand Up @@ -2903,6 +2904,7 @@ bool CWallet::CreateTransactionInternal(
additionally to the selected coins. */
CAmount nInputValue = 0;
const CWalletTx* withInputTx = nullptr;
LOCK(cs_wallet);
if (withInput)
{
if (!FindValueInNameInput (*withInput, nInputValue, withInputTx, error))
Expand All @@ -2919,7 +2921,6 @@ bool CWallet::CreateTransactionInternal(
int nBytes;
{
std::set<CInputCoin> setCoins;
LOCK(cs_wallet);
txNew.nLockTime = GetLocktimeForNewTransaction(chain(), GetLastBlockHash(), GetLastBlockHeight());
{
std::vector<COutput> vAvailableCoins;
Expand Down