Skip to content

Commit bbf24f1

Browse files
Merge branch 'develop' of https://github.com/dashpay/dash into develop
2 parents a3f28de + 8a05f0c commit bbf24f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+911
-272
lines changed

ci/test/00_setup_env_native_tsan.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ export TEST_RUNNER_EXTRA="--extended --exclude feature_pruning,feature_dbcrash,w
1313
export TEST_RUNNER_EXTRA="${TEST_RUNNER_EXTRA} --timeout-factor=4" # Increase timeout because sanitizers slow down
1414
export GOAL="install"
1515
export BITCOIN_CONFIG="--enable-zmq --with-gui=no --with-sanitizers=thread CC=clang-16 CXX=clang++-16 CXXFLAGS='-g' --with-boost-process"
16-
export CPPFLAGS="-DDEBUG_LOCKORDER -DARENA_DEBUG"
16+
export CPPFLAGS="-DARENA_DEBUG -DDEBUG_LOCKORDER -DDEBUG_LOCKCONTENTION"
1717
export PYZMQ=true

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ if test "x$enable_debug" = xyes; then
389389

390390
AX_CHECK_PREPROC_FLAG([-DDEBUG_CORE],[[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DDEBUG_CORE"]],,[[$CXXFLAG_WERROR]])
391391
AX_CHECK_PREPROC_FLAG([-DDEBUG_LOCKORDER],[[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DDEBUG_LOCKORDER"]],,[[$CXXFLAG_WERROR]])
392+
AX_CHECK_PREPROC_FLAG([-DDEBUG_LOCKCONTENTION], [DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DDEBUG_LOCKCONTENTION"], [], [$CXXFLAG_WERROR])
392393
AX_CHECK_PREPROC_FLAG([-DABORT_ON_FAILED_ASSUME],[[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DABORT_ON_FAILED_ASSUME"]],,[[$CXXFLAG_WERROR]])
393394
AX_CHECK_COMPILE_FLAG([-ftrapv],[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -ftrapv"],,[[$CXXFLAG_WERROR]])
394395
else

doc/developer-notes.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Developer Notes
1717
- [`debug.log`](#debuglog)
1818
- [Testnet and Regtest modes](#testnet-and-regtest-modes)
1919
- [DEBUG_LOCKORDER](#debug_lockorder)
20+
- [DEBUG_LOCKCONTENTION](#debug_lockcontention)
2021
- [Valgrind suppressions file](#valgrind-suppressions-file)
2122
- [Compiling for test coverage](#compiling-for-test-coverage)
2223
- [Performance profiling with perf](#performance-profiling-with-perf)
@@ -389,8 +390,10 @@ Run configure with the `--enable-gprof` option, then make.
389390
If the code is behaving strangely, take a look in the `debug.log` file in the data directory;
390391
error and debugging messages are written there.
391392

392-
The `-debug=...` command-line option controls debugging; running with just `-debug` or `-debug=1` will turn
393-
on all categories (and give you a very large `debug.log` file).
393+
Debug logging can be enabled on startup with the `-debug` and `-loglevel`
394+
configuration options and toggled while dashd is running with the `logging`
395+
RPC. For instance, launching dashd with `-debug` or `-debug=1` will turn on
396+
all log categories and `-loglevel=trace` will turn on all log severity levels.
394397

395398
The Qt code routes `qDebug()` output to `debug.log` under category "qt": run with `-debug=qt`
396399
to see it.
@@ -412,6 +415,21 @@ configure option adds `-DDEBUG_LOCKORDER` to the compiler flags. This inserts
412415
run-time checks to keep track of which locks are held and adds warnings to the
413416
`debug.log` file if inconsistencies are detected.
414417

418+
### DEBUG_LOCKCONTENTION
419+
420+
Defining `DEBUG_LOCKCONTENTION` adds a "lock" logging category to the logging
421+
RPC that, when enabled, logs the location and duration of each lock contention
422+
to the `debug.log` file.
423+
424+
The `--enable-debug` configure option adds `-DDEBUG_LOCKCONTENTION` to the
425+
compiler flags. You may also enable it manually for a non-debug build by running
426+
configure with `-DDEBUG_LOCKCONTENTION` added to your CPPFLAGS,
427+
i.e. `CPPFLAGS="-DDEBUG_LOCKCONTENTION"`, then build and run dashd.
428+
429+
You can then use the `-debug=lock` configuration option at dashd startup or
430+
`dash-cli logging '["lock"]'` at runtime to turn on lock contention logging.
431+
It can be toggled off again with `dash-cli logging [] '["lock"]'`.
432+
415433
### Assertions and Checks
416434

417435
The util file `src/util/check.h` offers helpers to protect against coding and
@@ -846,11 +864,6 @@ int GetInt(Tabs tab)
846864
Strings and formatting
847865
------------------------
848866
849-
- Be careful of `LogPrint` versus `LogPrintf`. `LogPrint` takes a `category` argument, `LogPrintf` does not.
850-
851-
- *Rationale*: Confusion of these can result in runtime exceptions due to
852-
formatting mismatch, and it is easy to get wrong because of subtly similar naming.
853-
854867
- Use `std::string`, avoid C string manipulation functions.
855868
856869
- *Rationale*: C++ string handling is marginally safer, less scope for

doc/release-process.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ Follow the relevant Guix README.md sections:
9797
- [Building](/contrib/guix/README.md#building)
9898
- [Attesting to build outputs](/contrib/guix/README.md#attesting-to-build-outputs)
9999

100+
_Note: we ship releases for only some supported HOSTs so consider providing limited `HOSTS` variable or run `./contrib/containers/guix/scripts/guix-start` instead of `./contrib/guix/guix-build` when building binaries for quicker builds that exclude the supported but not shipped HOSTs_
101+
100102
### Verify other builders' signatures to your own. (Optional)
101103

102104
Add other builders keys to your gpg keyring, and/or refresh keys: See `../dash/contrib/builder-keys/README.md`.

src/batchedlogger.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44

55
#include <batchedlogger.h>
66

7-
CBatchedLogger::CBatchedLogger(BCLog::LogFlags _category, const std::string& logging_function, const std::string& source_file, int source_line) :
8-
accept(LogAcceptCategory(_category)),
9-
m_logging_function(logging_function),
10-
m_source_file(source_file),
11-
m_source_line(source_line)
7+
CBatchedLogger::CBatchedLogger(BCLog::LogFlags category, BCLog::Level level, const std::string& logging_function,
8+
const std::string& source_file, int source_line) :
9+
m_accept{LogAcceptCategory(category, level)},
10+
m_category{category},
11+
m_level{level},
12+
m_logging_function{logging_function},
13+
m_source_file{source_file},
14+
m_source_line{source_line}
1215
{
1316
}
1417

@@ -19,9 +22,9 @@ CBatchedLogger::~CBatchedLogger()
1922

2023
void CBatchedLogger::Flush()
2124
{
22-
if (!accept || msg.empty()) {
25+
if (!m_accept || m_msg.empty()) {
2326
return;
2427
}
25-
LogInstance().LogPrintStr(msg, m_logging_function, m_source_file, m_source_line);
26-
msg.clear();
28+
LogInstance().LogPrintStr(m_msg, m_logging_function, m_source_file, m_source_line, m_category, m_level);
29+
m_msg.clear();
2730
}

src/batchedlogger.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,26 @@
1010
class CBatchedLogger
1111
{
1212
private:
13-
bool accept;
14-
std::string m_logging_function;;
13+
bool m_accept;
14+
BCLog::LogFlags m_category;
15+
BCLog::Level m_level;
16+
std::string m_logging_function;
1517
std::string m_source_file;
1618
const int m_source_line;
17-
std::string msg;
19+
std::string m_msg;
20+
1821
public:
19-
CBatchedLogger(BCLog::LogFlags _category, const std::string& logging_function, const std::string& m_source_file, int m_source_line);
22+
CBatchedLogger(BCLog::LogFlags category, BCLog::Level level, const std::string& logging_function,
23+
const std::string& m_source_file, int m_source_line);
2024
virtual ~CBatchedLogger();
2125

2226
template<typename... Args>
2327
void Batch(const std::string& fmt, const Args&... args)
2428
{
25-
if (!accept) {
29+
if (!m_accept) {
2630
return;
2731
}
28-
msg += " " + strprintf(fmt, args...) + "\n";
32+
m_msg += " " + strprintf(fmt, args...) + "\n";
2933
}
3034

3135
void Flush();

src/coinjoin/client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CDataS
132132
WITH_LOCK(cs_vecqueue, vecCoinJoinQueue.push_back(dsq));
133133
}
134134
} // cs_ProcessDSQueue
135-
dsq.Relay(connman, *peerman);
135+
peerman->RelayDSQ(dsq);
136136
return {};
137137
}
138138

src/coinjoin/client.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class CMasternodeSync;
2828
class CNode;
2929
class CoinJoinWalletManager;
3030
class CTxMemPool;
31+
class PeerManager;
3132

3233
class UniValue;
3334

src/coinjoin/coinjoin.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <masternode/node.h>
1515
#include <masternode/sync.h>
1616
#include <messagesigner.h>
17-
#include <net_processing.h>
1817
#include <netmessagemaker.h>
1918
#include <txmempool.h>
2019
#include <util/moneystr.h>
@@ -71,19 +70,6 @@ bool CCoinJoinQueue::CheckSignature(const CBLSPublicKey& blsPubKey) const
7170
return true;
7271
}
7372

74-
bool CCoinJoinQueue::Relay(CConnman& connman, PeerManager& peerman)
75-
{
76-
CInv inv(MSG_DSQ, GetHash());
77-
peerman.RelayInv(inv, DSQ_INV_VERSION);
78-
connman.ForEachNode([&connman, this](CNode* pnode) {
79-
CNetMsgMaker msgMaker(pnode->GetCommonVersion());
80-
if (pnode->fSendDSQueue && pnode->nVersion < DSQ_INV_VERSION) {
81-
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::DSQUEUE, (*this)));
82-
}
83-
});
84-
return true;
85-
}
86-
8773
bool CCoinJoinQueue::IsTimeOutOfBounds(int64_t current_time) const
8874
{
8975
return current_time - nTime > COINJOIN_QUEUE_TIMEOUT ||

src/coinjoin/coinjoin.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@
2424

2525
class CActiveMasternodeManager;
2626
class CChainState;
27-
class CConnman;
2827
class CBLSPublicKey;
2928
class CBlockIndex;
3029
class ChainstateManager;
3130
class CMasternodeSync;
3231
class CTxMemPool;
3332
class TxValidationState;
34-
class PeerManager;
3533

3634
namespace llmq {
3735
class CChainLocksHandler;
@@ -221,8 +219,6 @@ class CCoinJoinQueue
221219
/// Check if we have a valid Masternode address
222220
[[nodiscard]] bool CheckSignature(const CBLSPublicKey& blsPubKey) const;
223221

224-
bool Relay(CConnman& connman, PeerManager& peerman);
225-
226222
/// Check if a queue is too old or too far into the future
227223
[[nodiscard]] bool IsTimeOutOfBounds(int64_t current_time = GetAdjustedTime()) const;
228224

src/coinjoin/server.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ PeerMsgRet CCoinJoinServer::ProcessDSQUEUE(const CNode& peer, CDataStream& vRecv
186186
TRY_LOCK(cs_vecqueue, lockRecv);
187187
if (!lockRecv) return {};
188188
vecCoinJoinQueue.push_back(dsq);
189-
dsq.Relay(connman, *m_peerman);
189+
m_peerman->RelayDSQ(dsq);
190190
}
191191
return {};
192192
}
@@ -519,7 +519,7 @@ void CCoinJoinServer::CheckForCompleteQueue()
519519
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::CheckForCompleteQueue -- queue is ready, signing and relaying (%s) " /* Continued */
520520
"with %d participants\n", dsq.ToString(), vecSessionCollaterals.size());
521521
dsq.Sign(*m_mn_activeman);
522-
dsq.Relay(connman, *m_peerman);
522+
m_peerman->RelayDSQ(dsq);
523523
}
524524
}
525525

@@ -732,7 +732,7 @@ bool CCoinJoinServer::CreateNewSession(const CCoinJoinAccept& dsa, PoolMessage&
732732
GetAdjustedTime(), false);
733733
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::CreateNewSession -- signing and relaying new queue: %s\n", dsq.ToString());
734734
dsq.Sign(*m_mn_activeman);
735-
dsq.Relay(connman, *m_peerman);
735+
m_peerman->RelayDSQ(dsq);
736736
LOCK(cs_vecqueue);
737737
vecCoinJoinQueue.push_back(dsq);
738738
}

src/coinjoin/server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
class CActiveMasternodeManager;
1313
class CCoinJoinServer;
14+
class CConnman;
1415
class CDataStream;
1516
class CDeterministicMNManager;
1617
class CDSTXManager;

src/dbwrapper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CBitcoinLevelDBLogger : public leveldb::Logger {
2020
// This code is adapted from posix_logger.h, which is why it is using vsprintf.
2121
// Please do not do this in normal code
2222
void Logv(const char * format, va_list ap) override {
23-
if (!LogAcceptCategory(BCLog::LEVELDB)) {
23+
if (!LogAcceptCategory(BCLog::LEVELDB, BCLog::Level::Debug)) {
2424
return;
2525
}
2626
char buffer[500];
@@ -64,7 +64,7 @@ class CBitcoinLevelDBLogger : public leveldb::Logger {
6464

6565
assert(p <= limit);
6666
base[std::min(bufsize - 1, (int)(p - base))] = '\0';
67-
LogPrintf("leveldb: %s", base); /* Continued */
67+
LogPrintLevel(BCLog::LEVELDB, BCLog::Level::Debug, "%s", base); /* Continued */
6868
if (base != buffer) {
6969
delete[] base;
7070
}
@@ -187,7 +187,7 @@ CDBWrapper::~CDBWrapper()
187187

188188
bool CDBWrapper::WriteBatch(CDBBatch& batch, bool fSync)
189189
{
190-
const bool log_memory = LogAcceptCategory(BCLog::LEVELDB);
190+
const bool log_memory = LogAcceptCategory(BCLog::LEVELDB, BCLog::Level::Debug);
191191
double mem_before = 0;
192192
if (log_memory) {
193193
mem_before = DynamicMemoryUsage() / 1024.0 / 1024;

src/evo/creditpool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <serialize.h>
1111
#include <sync.h>
1212
#include <threadsafety.h>
13+
#include <tinyformat.h>
1314
#include <unordered_lru_cache.h>
1415
#include <util/ranges_set.h>
1516

src/httpserver.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,22 @@ static void HTTPWorkQueueRun(WorkQueue<HTTPClosure>* queue, int worker_num)
375375
/** libevent event log callback */
376376
static void libevent_log_cb(int severity, const char *msg)
377377
{
378-
if (severity >= EVENT_LOG_WARN) // Log warn messages and higher without debug category
379-
LogPrintf("libevent: %s\n", msg);
380-
// The below code causes log spam on Travis and the output of these logs has never been of any use so far
381-
//else
382-
// LogPrint(BCLog::LIBEVENT, "libevent: %s\n", msg);
378+
BCLog::Level level;
379+
switch (severity) {
380+
case EVENT_LOG_DEBUG:
381+
level = BCLog::Level::Debug;
382+
break;
383+
case EVENT_LOG_MSG:
384+
level = BCLog::Level::Info;
385+
break;
386+
case EVENT_LOG_WARN:
387+
level = BCLog::Level::Warning;
388+
break;
389+
default: // EVENT_LOG_ERR and others are mapped to error
390+
level = BCLog::Level::Error;
391+
break;
392+
}
393+
LogPrintLevel(BCLog::LIBEVENT, level, "%s\n", msg);
383394
}
384395

385396
bool InitHTTPServer()

src/init.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ void SetupServerArgs(ArgsManager& argsman)
583583
argsman.AddArg("-peertimeout=<n>", strprintf("Specify a p2p connection timeout delay in seconds. After connecting to a peer, wait this amount of time before considering disconnection based on inactivity (minimum: 1, default: %d)", DEFAULT_PEER_CONNECT_TIMEOUT), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
584584
argsman.AddArg("-permitbaremultisig", strprintf("Relay non-P2SH multisig (default: %u)", DEFAULT_PERMIT_BAREMULTISIG), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
585585
argsman.AddArg("-port=<port>", strprintf("Listen for connections on <port>. Nodes not using the default ports (default: %u, testnet: %u, regtest: %u) are unlikely to get incoming connections. Not relevant for I2P (see doc/i2p.md).", defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort(), regtestChainParams->GetDefaultPort()), ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION);
586-
argsman.AddArg("-proxy=<ip:port>", "Connect through SOCKS5 proxy, set -noproxy to disable (default: disabled)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
586+
argsman.AddArg("-proxy=<ip:port>", "Connect through SOCKS5 proxy, set -noproxy to disable (default: disabled)", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_ELISION, OptionsCategory::CONNECTION);
587587
argsman.AddArg("-proxyrandomize", strprintf("Randomize credentials for every proxy connection. This enables Tor stream isolation (default: %u)", DEFAULT_PROXYRANDOMIZE), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
588588
argsman.AddArg("-seednode=<ip>", "Connect to a node to retrieve peer addresses, and disconnect. This option can be specified multiple times to connect to multiple nodes.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
589589
argsman.AddArg("-socketevents=<mode>", "Socket events mode, which must be one of 'select', 'poll', 'epoll' or 'kqueue', depending on your system (default: Linux - 'epoll', FreeBSD/Apple - 'kqueue', Windows - 'select')", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
@@ -1212,6 +1212,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)
12121212

12131213
// ********************************************************* Step 3: parameter-to-internal-flags
12141214
init::SetLoggingCategories(args);
1215+
init::SetLoggingLevel(args);
12151216

12161217
fCheckBlockIndex = args.GetBoolArg("-checkblockindex", chainparams.DefaultConsistencyChecks());
12171218
fCheckpointsEnabled = args.GetBoolArg("-checkpoints", DEFAULT_CHECKPOINTS_ENABLED);
@@ -1337,10 +1338,6 @@ bool AppInitParameterInteraction(const ArgsManager& args)
13371338

13381339
nMaxTipAge = args.GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);
13391340

1340-
if (args.IsArgSet("-proxy") && args.GetArg("-proxy", "").empty()) {
1341-
return InitError(_("No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>."));
1342-
}
1343-
13441341
if (args.GetBoolArg("-reindex-chainstate", false)) {
13451342
// indexes that must be deactivated to prevent index corruption, see #24630
13461343
if (args.GetBoolArg("-coinstatsindex", DEFAULT_COINSTATSINDEX)) {

0 commit comments

Comments
 (0)