Merge pull request #4203 from UdjinM6/pr4196

ci: Add `--enable-werror` to arm and c++17 builds (and fix all issues found via these builds)
This commit is contained in:
UdjinM6 2021-07-17 02:37:07 +03:00 committed by GitHub
commit 886024ba25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 119 additions and 109 deletions

View File

@ -40,7 +40,7 @@ if [ "$BUILD_TARGET" = "arm-linux" ]; then
export CHECK_DOC=1
# -Wno-psabi is to disable ABI warnings: "note: parameter passing for argument of type ... changed in GCC 7.1"
# This could be removed once the ABI change warning does not show up by default
export BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports CXXFLAGS=-Wno-psabi"
export BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports --enable-werror CXXFLAGS=-Wno-psabi"
export RUN_UNITTESTS=false
export RUN_INTEGRATIONTESTS=false
elif [ "$BUILD_TARGET" = "win32" ]; then
@ -67,7 +67,7 @@ elif [ "$BUILD_TARGET" = "linux64" ]; then
elif [ "$BUILD_TARGET" = "linux64_cxx17" ]; then
export HOST=x86_64-unknown-linux-gnu
export DEP_OPTS="NO_UPNP=1 DEBUG=1"
export BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports --enable-crash-hooks --enable-c++17 --with-sanitizers=undefined"
export BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports --enable-crash-hooks --enable-c++17 --enable-werror --with-sanitizers=undefined"
export CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG -DARENA_DEBUG"
export PYZMQ=true
export RUN_INTEGRATIONTESTS=false

View File

@ -20,7 +20,6 @@
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
static const int64_t DEFAULT_BENCH_EVALUATIONS = 5;
static const char* DEFAULT_BENCH_FILTER = ".*";
void InitBLSTests();

View File

@ -86,8 +86,6 @@ public:
ReceiveVvecs();
size_t memberIdx = 0;
bench.minEpochIterations(epoch_iters).run([&] {
auto& m = members[memberIdx];
ReceiveShares(memberIdx);
std::set<size_t> invalidIndexes;

View File

@ -11,7 +11,6 @@
#include <random.h>
static const int MIN_CORES = 2;
static const size_t BATCHES = 101;
static const size_t BATCH_SIZE = 30;
static const int PREVECTOR_SIZE = 28;

View File

@ -74,6 +74,7 @@ public:
// by swapping the members of two classes,
// the two classes are effectively swapped
LOCK2(first.cs, second.cs);
swap(first.nVersion, second.nVersion);
swap(first.id, second.id);
swap(first.fCrypted, second.fCrypted);

View File

@ -2061,7 +2061,6 @@ bool AppInitMain()
LogPrintf("* Using %.1fMiB for in-memory UTXO set (plus up to %.1fMiB of unused mempool space)\n", nCoinCacheUsage * (1.0 / 1024 / 1024), nMempoolSizeMax * (1.0 / 1024 / 1024));
bool fLoaded = false;
int64_t nStart = GetTimeMillis();
while (!fLoaded && !ShutdownRequested()) {
bool fReset = fReindex;

View File

@ -555,23 +555,24 @@ void CChainLocksHandler::EnforceBestChainLock()
activateNeeded = chainActive.Tip()->GetAncestor(currentBestChainLockBlockIndex->nHeight) != currentBestChainLockBlockIndex;
}
if (activateNeeded && !ActivateBestChain(state, params)) {
LogPrintf("CChainLocksHandler::%s -- ActivateBestChain failed: %s\n", __func__, FormatStateMessage(state));
}
const CBlockIndex* pindexNotify = nullptr;
{
if (activateNeeded) {
if(!ActivateBestChain(state, params)) {
LogPrintf("CChainLocksHandler::%s -- ActivateBestChain failed: %s\n", __func__, FormatStateMessage(state));
return;
}
LOCK(cs_main);
if (lastNotifyChainLockBlockIndex != currentBestChainLockBlockIndex &&
chainActive.Tip()->GetAncestor(currentBestChainLockBlockIndex->nHeight) == currentBestChainLockBlockIndex) {
lastNotifyChainLockBlockIndex = currentBestChainLockBlockIndex;
pindexNotify = currentBestChainLockBlockIndex;
if (chainActive.Tip()->GetAncestor(currentBestChainLockBlockIndex->nHeight) != currentBestChainLockBlockIndex) {
return;
}
}
if (pindexNotify) {
GetMainSignals().NotifyChainLock(pindexNotify, clsig);
{
LOCK(cs);
if (lastNotifyChainLockBlockIndex == currentBestChainLockBlockIndex) return;
lastNotifyChainLockBlockIndex = currentBestChainLockBlockIndex;
}
GetMainSignals().NotifyChainLock(currentBestChainLockBlockIndex, clsig);
}
void CChainLocksHandler::HandleNewRecoveredSig(const llmq::CRecoveredSig& recoveredSig)

View File

@ -657,6 +657,8 @@ void CDKGSession::VerifyAndJustify(CDKGPendingMessages& pendingMessages)
std::set<uint256> justifyFor;
LOCK(invCs);
for (const auto& m : members) {
if (m->bad) {
continue;
@ -1212,21 +1214,25 @@ std::vector<CFinalCommitment> CDKGSession::FinalizeCommitments()
typedef std::vector<bool> Key;
std::map<Key, std::vector<CDKGPrematureCommitment>> commitmentsMap;
for (const auto& p : prematureCommitments) {
auto& qc = p.second;
if (!validCommitments.count(p.first)) {
continue;
{
LOCK(invCs);
for (const auto& p : prematureCommitments) {
auto& qc = p.second;
if (!validCommitments.count(p.first)) {
continue;
}
// should have been verified before
assert(qc.CountValidMembers() >= params.minSize);
auto it = commitmentsMap.find(qc.validMembers);
if (it == commitmentsMap.end()) {
it = commitmentsMap.emplace(qc.validMembers, std::vector<CDKGPrematureCommitment>()).first;
}
it->second.emplace_back(qc);
}
// should have been verified before
assert(qc.CountValidMembers() >= params.minSize);
auto it = commitmentsMap.find(qc.validMembers);
if (it == commitmentsMap.end()) {
it = commitmentsMap.emplace(qc.validMembers, std::vector<CDKGPrematureCommitment>()).first;
}
it->second.emplace_back(qc);
}
std::vector<CFinalCommitment> finalCommitments;

View File

@ -386,7 +386,7 @@ std::set<NodeId> BatchVerifyMessageSigs(CDKGSession& session, const std::vector<
}
// are all messages from the same node?
NodeId firstNodeId;
NodeId firstNodeId{-1};
first = true;
bool nodeIdsAllSame = true;
for (auto it = messages.begin(); it != messages.end(); ++it) {

View File

@ -117,10 +117,11 @@ private:
std::shared_ptr<CDKGSession> curSession;
std::thread phaseHandlerThread;
CDKGPendingMessages pendingContributions GUARDED_BY(cs);
CDKGPendingMessages pendingComplaints GUARDED_BY(cs);
CDKGPendingMessages pendingJustifications GUARDED_BY(cs);
CDKGPendingMessages pendingPrematureCommitments GUARDED_BY(cs);
// Do not guard these, they protect their internals themselves
CDKGPendingMessages pendingContributions;
CDKGPendingMessages pendingComplaints;
CDKGPendingMessages pendingJustifications;
CDKGPendingMessages pendingPrematureCommitments;
public:
CDKGSessionHandler(const Consensus::LLMQParams& _params, CBLSWorker& blsWorker, CDKGSessionManager& _dkgManager);

View File

@ -1418,7 +1418,7 @@ void CInstantSendManager::AskNodesForLockedTx(const uint256& txid)
{
std::vector<CNode*> nodesToAskFor;
g_connman->ForEachNode([&](CNode* pnode) {
LOCK(pnode->cs_filter);
LOCK(pnode->cs_inventory);
if (pnode->filterInventoryKnown.contains(txid)) {
pnode->AddRef();
nodesToAskFor.emplace_back(pnode);

View File

@ -594,6 +594,7 @@ void CSigSharesManager::CollectPendingSigSharesToVerify(
}
auto& sigShare = *ns.pendingIncomingSigShares.GetFirst();
AssertLockHeld(cs);
bool alreadyHave = this->sigShares.Has(sigShare.GetKey());
if (!alreadyHave) {
uniqueSignHashes.emplace(nodeId, sigShare.GetSignHash());
@ -1062,6 +1063,7 @@ void CSigSharesManager::CollectSigSharesToAnnounce(std::unordered_map<NodeId, st
std::unordered_map<std::pair<Consensus::LLMQType, uint256>, std::unordered_set<NodeId>, StaticSaltedHasher> quorumNodesMap;
sigSharesQueuedToAnnounce.ForEach([&](const SigShareKey& sigShareKey, bool) {
AssertLockHeld(cs);
auto& signHash = sigShareKey.first;
auto quorumMember = sigShareKey.second;
const CSigShare* sigShare = sigShares.Get(sigShareKey);
@ -1421,6 +1423,7 @@ void CSigSharesManager::Cleanup()
}
// remove global requested state to force a re-request from another node
it->second.requestedSigShares.ForEach([&](const SigShareKey& k, bool) {
AssertLockHeld(cs);
sigSharesRequested.Erase(k);
});
nodeStates.erase(nodeId);
@ -1455,6 +1458,7 @@ void CSigSharesManager::RemoveBannedNodeStates()
if (IsBanned(it->first)) {
// re-request sigshares from other nodes
it->second.requestedSigShares.ForEach([&](const SigShareKey& k, int64_t) {
AssertLockHeld(cs);
sigSharesRequested.Erase(k);
});
it = nodeStates.erase(it);
@ -1484,6 +1488,7 @@ void CSigSharesManager::BanNode(NodeId nodeId)
// Whatever we requested from him, let's request it from someone else now
nodeState.requestedSigShares.ForEach([&](const SigShareKey& k, int64_t) {
AssertLockHeld(cs);
sigSharesRequested.Erase(k);
});
nodeState.requestedSigShares.Clear();

View File

@ -23,20 +23,24 @@ CMasternodeSync::CMasternodeSync()
void CMasternodeSync::Reset(bool fForce, bool fNotifyReset)
{
// Avoid resetting the sync process if we just "recently" received a new block
if (fForce || (GetTime() - nTimeLastUpdateBlockTip > MASTERNODE_SYNC_RESET_SECONDS)) {
{
LOCK(cs);
nCurrentAsset = MASTERNODE_SYNC_BLOCKCHAIN;
nTriedPeerCount = 0;
nTimeAssetSyncStarted = GetTime();
nTimeLastBumped = GetTime();
nTimeLastUpdateBlockTip = 0;
fReachedBestHeader = false;
}
if (fNotifyReset) {
uiInterface.NotifyAdditionalDataSyncProgressChanged(-1);
if (!fForce) {
LOCK(cs);
if (GetTime() - nTimeLastUpdateBlockTip < MASTERNODE_SYNC_RESET_SECONDS) {
return;
}
}
{
LOCK(cs);
nCurrentAsset = MASTERNODE_SYNC_BLOCKCHAIN;
nTriedPeerCount = 0;
nTimeAssetSyncStarted = GetTime();
nTimeLastBumped = GetTime();
nTimeLastUpdateBlockTip = 0;
fReachedBestHeader = false;
}
if (fNotifyReset) {
uiInterface.NotifyAdditionalDataSyncProgressChanged(-1);
}
}
void CMasternodeSync::BumpAssetLastTime(const std::string& strFuncName)
@ -88,6 +92,7 @@ void CMasternodeSync::SwitchToNextAsset(CConnman& connman)
std::string CMasternodeSync::GetSyncStatus() const
{
LOCK(cs);
switch (nCurrentAsset) {
case MASTERNODE_SYNC_BLOCKCHAIN: return _("Synchronizing blockchain...");
case MASTERNODE_SYNC_GOVERNANCE: return _("Synchronizing governance objects...");
@ -143,6 +148,7 @@ void CMasternodeSync::ProcessTick(CConnman& connman)
return;
}
LOCK(cs);
// Calculate "progress" for LOG reporting / GUI notification
double nSyncProgress = double(nTriedPeerCount + (nCurrentAsset - 1) * 8) / (8*4);
LogPrint(BCLog::MNSYNC, "CMasternodeSync::ProcessTick -- nTick %d nCurrentAsset %d nTriedPeerCount %d nSyncProgress %f\n", nTick, nCurrentAsset, nTriedPeerCount, nSyncProgress);
@ -371,6 +377,7 @@ void CMasternodeSync::UpdatedBlockTip(const CBlockIndex *pindexNew, bool fInitia
// Note: since we sync headers first, it should be ok to use this
bool fReachedBestHeaderNew = pindexNew->GetBlockHash() == pindexTip->GetBlockHash();
LOCK(cs);
if (fReachedBestHeader && !fReachedBestHeaderNew) {
// Switching from true to false means that we previously stuck syncing headers for some reason,
// probably initial timeout was not enough,
@ -378,10 +385,7 @@ void CMasternodeSync::UpdatedBlockTip(const CBlockIndex *pindexNew, bool fInitia
Reset(true);
}
{
LOCK(cs);
fReachedBestHeader = fReachedBestHeaderNew;
}
fReachedBestHeader = fReachedBestHeaderNew;
LogPrint(BCLog::MNSYNC, "CMasternodeSync::UpdatedBlockTip -- pindexNew->nHeight: %d pindexTip->nHeight: %d fInitialDownload=%d fReachedBestHeader=%d\n",
pindexNew->nHeight, pindexTip->nHeight, fInitialDownload, fReachedBestHeader);
}

View File

@ -1278,15 +1278,15 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
m_msgproc->InitializeNode(pnode);
if (fLogIPs) {
LogPrint(BCLog::NET_NETCONN, "connection from %s accepted, sock=%d, peer=%d\n", addr.ToString(), pnode->hSocket, pnode->GetId());
LogPrint(BCLog::NET_NETCONN, "connection from %s accepted, sock=%d, peer=%d\n", addr.ToString(), hSocket, pnode->GetId());
} else {
LogPrint(BCLog::NET_NETCONN, "connection accepted, sock=%d, peer=%d\n", pnode->hSocket, pnode->GetId());
LogPrint(BCLog::NET_NETCONN, "connection accepted, sock=%d, peer=%d\n", hSocket, pnode->GetId());
}
{
LOCK(cs_vNodes);
vNodes.push_back(pnode);
mapSocketToNode.emplace(pnode->hSocket, pnode);
mapSocketToNode.emplace(hSocket, pnode);
RegisterEvents(pnode);
WakeSelect();
}
@ -1443,8 +1443,9 @@ void CConnman::CalculateNumConnectionsChangedStats()
}
mapRecvBytesMsgStats[NET_MESSAGE_COMMAND_OTHER] = 0;
mapSentBytesMsgStats[NET_MESSAGE_COMMAND_OTHER] = 0;
LOCK(cs_vNodes);
for (const CNode* pnode : vNodes) {
auto vNodesCopy = CopyNodeVector(CConnman::FullyConnectedOnly);
for (auto pnode : vNodesCopy) {
LOCK(pnode->cs_vRecv);
for (const mapMsgCmdSize::value_type &i : pnode->mapRecvBytesPerMsgCmd)
mapRecvBytesMsgStats[i.first] += i.second;
for (const mapMsgCmdSize::value_type &i : pnode->mapSendBytesPerMsgCmd)
@ -1466,6 +1467,7 @@ void CConnman::CalculateNumConnectionsChangedStats()
if(pnode->nPingUsecTime > 0)
statsClient.timing("peers.ping_us", pnode->nPingUsecTime, 1.0f);
}
ReleaseNodeVector(vNodesCopy);
for (const std::string &msg : getAllNetMessageTypes()) {
statsClient.gauge("bandwidth.message." + msg + ".totalBytesReceived", mapRecvBytesMsgStats[msg], 1.0f);
statsClient.gauge("bandwidth.message." + msg + ".totalBytesSent", mapSentBytesMsgStats[msg], 1.0f);
@ -2787,7 +2789,12 @@ void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
LogPrint(BCLog::NET_NETCONN, "CConnman::%s -- ConnectNode failed for %s\n", __func__, getIpStr());
return;
}
LogPrint(BCLog::NET_NETCONN, "CConnman::%s -- succesfully connected to %s, sock=%d, peer=%d\n", __func__, getIpStr(), pnode->hSocket, pnode->GetId());
{
LOCK(pnode->cs_hSocket);
LogPrint(BCLog::NET_NETCONN, "CConnman::%s -- succesfully connected to %s, sock=%d, peer=%d\n", __func__, getIpStr(), pnode->hSocket, pnode->GetId());
}
if (grantOutbound)
grantOutbound->MoveTo(pnode->grantOutbound);
if (fOneShot)
@ -2802,7 +2809,7 @@ void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
pnode->m_masternode_probe_connection = true;
{
LOCK(cs_vNodes);
LOCK2(cs_vNodes, pnode->cs_hSocket);
mapSocketToNode.emplace(pnode->hSocket, pnode);
}
@ -3374,7 +3381,10 @@ void CConnman::Stop()
}
vNodes.clear();
mapSocketToNode.clear();
mapReceivableNodes.clear();
{
LOCK(cs_vNodes);
mapReceivableNodes.clear();
}
{
LOCK(cs_mapNodesWithDataToSend);
mapNodesWithDataToSend.clear();

View File

@ -1077,7 +1077,6 @@ void Misbehaving(NodeId pnode, int howmuch, const std::string& message) EXCLUSIV
}
}
// Requires cs_main.
bool IsBanned(NodeId pnode)
{
CNodeState *state = State(pnode);
@ -4235,13 +4234,13 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
//
std::vector<CInv> vInv;
{
LOCK2(mempool.cs, pto->cs_inventory);
size_t reserve = std::min<size_t>(pto->setInventoryTxToSend.size(), INVENTORY_BROADCAST_MAX_PER_1MB_BLOCK * MaxBlockSize() / 1000000);
reserve = std::max<size_t>(reserve, pto->vInventoryBlockToSend.size());
reserve = std::min<size_t>(reserve, MAX_INV_SZ);
vInv.reserve(reserve);
LOCK2(mempool.cs, pto->cs_inventory);
// Add blocks
for (const uint256& hash : pto->vInventoryBlockToSend) {
vInv.push_back(CInv(MSG_BLOCK, hash));

View File

@ -87,15 +87,15 @@ struct CNodeStateStats {
/** Get statistics from node state */
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats);
bool IsBanned(NodeId nodeid);
bool IsBanned(NodeId nodeid) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
// Upstream moved this into net_processing.cpp (13417), however since we use Misbehaving in a number of dash specific
// files such as mnauth.cpp and governance.cpp it makes sense to keep it in the header
/** Increase a node's misbehavior score. */
void Misbehaving(NodeId nodeid, int howmuch, const std::string& message="") EXCLUSIVE_LOCKS_REQUIRED(cs_main);
void EraseObjectRequest(NodeId nodeId, const CInv& inv);
void RequestObject(NodeId nodeId, const CInv& inv, std::chrono::microseconds current_time, bool fForce=false);
size_t GetRequestedObjectCount(NodeId nodeId);
void EraseObjectRequest(NodeId nodeId, const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
void RequestObject(NodeId nodeId, const CInv& inv, std::chrono::microseconds current_time, bool fForce=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
size_t GetRequestedObjectCount(NodeId nodeId) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
#endif // BITCOIN_NET_PROCESSING_H

View File

@ -925,7 +925,7 @@ bool CBlockPolicyEstimator::Read(CAutoFile& filein)
try {
LOCK(cs_feeEstimator);
int nVersionRequired, nVersionThatWrote;
unsigned int nFileBestSeenHeight, nFileHistoricalFirst, nFileHistoricalBest;
unsigned int nFileBestSeenHeight;
filein >> nVersionRequired >> nVersionThatWrote;
if (nVersionRequired > CLIENT_VERSION)
return error("CBlockPolicyEstimator::Read(): up-version (%d) fee estimate file", nVersionRequired);

View File

@ -482,7 +482,6 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel *
unsigned int nBytes = 0;
unsigned int nBytesInputs = 0;
unsigned int nQuantity = 0;
int nQuantityUncompressed = 0;
bool fUnselectedSpent{false};
bool fUnselectedNonMixed{false};

View File

@ -42,9 +42,8 @@ void NetworkStyle::rotateColor(QColor& col, const int iconColorHueShift, const i
col.setHsl(h,s,l,a);
}
void NetworkStyle::rotateColors(QImage& img, const int iconColorHueShift, const int iconColorSaturationReduction) {
int h,s,l,a;
void NetworkStyle::rotateColors(QImage& img, const int iconColorHueShift, const int iconColorSaturationReduction)
{
// traverse though lines
for(int y=0;y<img.height();y++)
{

View File

@ -166,7 +166,7 @@ void WalletFrame::gotoSendCoinsPage(QString addr)
void WalletFrame::gotoCoinJoinCoinsPage(QString addr)
{
QMap<QString, WalletView*>::const_iterator i;
for (auto i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) {
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) {
i.value()->gotoCoinJoinCoinsPage(addr);
}
}

View File

@ -981,8 +981,6 @@ static UniValue protx_list(const JSONRPCRequest& request)
g_txindex->BlockUntilSyncedToCurrentChain();
}
LOCK(cs_main);
if (type == "wallet") {
if (!pwallet) {
throw std::runtime_error("\"protx list wallet\" not supported when wallet is disabled");

View File

@ -63,7 +63,6 @@ struct mt_pooled_secure_allocator : public std::allocator<T> {
private:
size_t get_bucket()
{
auto tid = std::this_thread::get_id();
size_t x = std::hash<std::thread::id>{}(std::this_thread::get_id());
return x % pools.size();
}

View File

@ -517,7 +517,6 @@ BOOST_FIXTURE_TEST_CASE(dip3_test_mempool_reorg, TestChainDIP3Setup)
BOOST_FIXTURE_TEST_CASE(dip3_test_mempool_dual_proregtx, TestChainDIP3Setup)
{
int nHeight = chainActive.Height();
auto utxos = BuildSimpleUtxoMap(m_coinbase_txns);
// Create a MN

View File

@ -531,6 +531,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
SetMockTime(0);
mempool.clear();
LOCK(::mempool.cs);
TestPackageSelection(chainparams, scriptPubKey, txFirst);
fCheckpointsEnabled = true;

View File

@ -31,7 +31,7 @@ const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
void CConnmanTest::AddNode(CNode& node)
{
LOCK(g_connman->cs_vNodes);
LOCK2(g_connman->cs_vNodes, node.cs_hSocket);
g_connman->vNodes.push_back(&node);
g_connman->mapSocketToNode.emplace(node.hSocket, &node);
}

View File

@ -860,6 +860,7 @@ void CTxMemPool::removeProTxSpentCollateralConflicts(const CTransaction &tx)
// Remove TXs that refer to a MN for which the collateral was spent
auto removeSpentCollateralConflict = [&](const uint256& proTxHash) {
// Can't use equal_range here as every call to removeRecursive might invalidate iterators
AssertLockHeld(cs);
while (true) {
auto it = mapProTxRefs.find(proTxHash);
if (it == mapProTxRefs.end()) {
@ -1248,6 +1249,7 @@ bool CTxMemPool::existsProviderTxConflict(const CTransaction &tx) const {
LOCK(cs);
auto hasKeyChangeInMempool = [&](const uint256& proTxHash) {
AssertLockHeld(cs);
for (auto its = mapProTxRefs.equal_range(proTxHash); its.first != its.second; ++its.first) {
auto txit = mapTx.find(its.first->second);
if (txit == mapTx.end()) {

View File

@ -581,12 +581,12 @@ public:
void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN);
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
void removeConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs);
void removeProTxPubKeyConflicts(const CTransaction &tx, const CKeyID &keyId);
void removeProTxPubKeyConflicts(const CTransaction &tx, const CBLSPublicKey &pubKey);
void removeProTxCollateralConflicts(const CTransaction &tx, const COutPoint &collateralOutpoint);
void removeProTxSpentCollateralConflicts(const CTransaction &tx);
void removeProTxKeyChangedConflicts(const CTransaction &tx, const uint256& proTxHash, const uint256& newKeyHash);
void removeProTxConflicts(const CTransaction &tx);
void removeProTxPubKeyConflicts(const CTransaction &tx, const CKeyID &keyId) EXCLUSIVE_LOCKS_REQUIRED(cs);
void removeProTxPubKeyConflicts(const CTransaction &tx, const CBLSPublicKey &pubKey) EXCLUSIVE_LOCKS_REQUIRED(cs);
void removeProTxCollateralConflicts(const CTransaction &tx, const COutPoint &collateralOutpoint) EXCLUSIVE_LOCKS_REQUIRED(cs);
void removeProTxSpentCollateralConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs);
void removeProTxKeyChangedConflicts(const CTransaction &tx, const uint256& proTxHash, const uint256& newKeyHash) EXCLUSIVE_LOCKS_REQUIRED(cs);
void removeProTxConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs);
void removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight);
void clear();

View File

@ -238,7 +238,7 @@ public:
}
/** Convert regular argument into the network-specific setting */
static inline std::string NetworkArg(const ArgsManager& am, const std::string& arg)
static inline std::string NetworkArg(const ArgsManager& am, const std::string& arg) EXCLUSIVE_LOCKS_REQUIRED(am.cs_args)
{
assert(arg.length() > 1 && arg[0] == '-');
return "-" + am.m_network + "." + arg.substr(1);

View File

@ -197,7 +197,7 @@ public:
bool ReplayBlocks(const CChainParams& params, CCoinsView* view);
bool LoadGenesisBlock(const CChainParams& chainparams);
bool AddGenesisBlock(const CChainParams& chainparams, const CBlock& block, CValidationState& state);
bool AddGenesisBlock(const CChainParams& chainparams, const CBlock& block, CValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
void PruneBlockIndexCandidates();
@ -693,8 +693,6 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
auto itConflicting = pool.mapNextTx.find(txin.prevout);
if (itConflicting != pool.mapNextTx.end())
{
const CTransaction *ptxConflicting = itConflicting->second;
// Transaction conflicts with mempool and RBF doesn't exist in Dash
return state.Invalid(false, REJECT_DUPLICATE, "txn-mempool-conflict");
}
@ -824,7 +822,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
// Check against previous transactions
// This is done last to help prevent CPU exhaustion denial-of-service attacks.
PrecomputedTransactionData txdata(tx);
if (!CheckInputs(tx, state, view, true, STANDARD_SCRIPT_VERIFY_FLAGS, true, false, txdata))
if (!CheckInputs(tx, state, view, true, scriptVerifyFlags, true, false, txdata))
return false; // state filled in by CheckInputs
// Check again against the current block tip's script verification
@ -1235,7 +1233,6 @@ bool IsInitialBlockDownload()
return false;
if (fImporting || fReindex)
return true;
const CChainParams& chainParams = Params();
if (chainActive.Tip() == nullptr)
return true;
if (chainActive.Tip()->nChainWork < nMinimumChainWork)
@ -1366,7 +1363,7 @@ void static InvalidChainFound(CBlockIndex* pindexNew) EXCLUSIVE_LOCKS_REQUIRED(c
CheckForkWarningConditions();
}
void static ConflictingChainFound(CBlockIndex* pindexNew)
void static ConflictingChainFound(CBlockIndex* pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
{
statsClient.inc("warnings.ConflictingChainFound", 1.0f);
@ -2353,7 +2350,6 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
} else {
// The node which relayed this should switch to correct chain.
// TODO: relay instantsend data/proof.
LOCK(cs_main);
return state.DoS(10, error("ConnectBlock(DASH): transaction %s conflicts with transaction lock %s", tx->GetHash().ToString(), conflictLock->txid.ToString()),
REJECT_INVALID, "conflict-tx-lock");
}

View File

@ -306,7 +306,7 @@ uint64_t CalculateCurrentUsage();
/**
* Mark one block file as pruned.
*/
void PruneOneBlockFile(const int fileNumber);
void PruneOneBlockFile(const int fileNumber) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
/**
* Actually unlink the specified files

View File

@ -4367,7 +4367,6 @@ UniValue importwallet(const JSONRPCRequest& request);
UniValue importprunedfunds(const JSONRPCRequest& request);
UniValue removeprunedfunds(const JSONRPCRequest& request);
UniValue importmulti(const JSONRPCRequest& request);
UniValue rescanblockchain(const JSONRPCRequest& request);
UniValue dumphdinfo(const JSONRPCRequest& request);
UniValue importelectrumwallet(const JSONRPCRequest& request);

View File

@ -2321,6 +2321,7 @@ std::set<uint256> CWalletTx::GetConflicts() const
std::set<uint256> result;
if (pwallet != nullptr)
{
AssertLockHeld(pwallet->cs_wallet);
uint256 myHash = GetHash();
result = pwallet->GetConflicts(myHash);
result.erase(myHash);
@ -3588,7 +3589,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
assert(txNew.nLockTime < LOCKTIME_THRESHOLD);
FeeCalculation feeCalc;
CFeeRate discard_rate = coin_control.m_discard_feerate ? *coin_control.m_discard_feerate : GetDiscardRate(*this, ::feeEstimator);
unsigned int nBytes;
unsigned int nBytes{0};
{
std::vector<CInputCoin> vecCoins;
LOCK2(cs_main, mempool.cs);
@ -4053,13 +4054,10 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
fFirstRunRet = mapKeys.empty() && mapHdPubKeys.empty() && mapCryptedKeys.empty() && mapWatchKeys.empty() && setWatchOnly.empty() && mapScripts.empty() && !IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
}
{
LOCK2(cs_main, cs_wallet);
for (auto& pair : mapWallet) {
for(unsigned int i = 0; i < pair.second.tx->vout.size(); ++i) {
if (IsMine(pair.second.tx->vout[i]) && !IsSpent(pair.first, i)) {
setWalletUTXO.insert(COutPoint(pair.first, i));
}
for (auto& pair : mapWallet) {
for(unsigned int i = 0; i < pair.second.tx->vout.size(); ++i) {
if (IsMine(pair.second.tx->vout[i]) && !IsSpent(pair.first, i)) {
setWalletUTXO.insert(COutPoint(pair.first, i));
}
}
}
@ -5534,8 +5532,6 @@ void CMerkleTx::SetMerkleBranch(const CBlockIndex* pindex, int posInBlock)
int CMerkleTx::GetDepthInMainChain() const
{
int nResult;
if (hashUnset())
return 0;

View File

@ -487,8 +487,8 @@ public:
CAmount GetImmatureWatchOnlyCredit(const bool fUseCache=true) const EXCLUSIVE_LOCKS_REQUIRED(cs_main);
CAmount GetChange() const;
CAmount GetAnonymizedCredit(const CCoinControl* coinControl = nullptr) const;
CAmount GetDenominatedCredit(bool unconfirmed, bool fUseCache=true) const;
CAmount GetAnonymizedCredit(const CCoinControl* coinControl = nullptr) const EXCLUSIVE_LOCKS_REQUIRED(cs_main);
CAmount GetDenominatedCredit(bool unconfirmed, bool fUseCache=true) const EXCLUSIVE_LOCKS_REQUIRED(cs_main);
// Get the marginal bytes if spending the specified output from this transaction
int GetSpendSize(unsigned int out, bool use_max_sig = false) const