Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/dashpay/dash into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
PastaPastaPasta committed Nov 28, 2024
2 parents a3f28de + 8a05f0c commit bbf24f1
Show file tree
Hide file tree
Showing 61 changed files with 911 additions and 272 deletions.
2 changes: 1 addition & 1 deletion ci/test/00_setup_env_native_tsan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export TEST_RUNNER_EXTRA="--extended --exclude feature_pruning,feature_dbcrash,w
export TEST_RUNNER_EXTRA="${TEST_RUNNER_EXTRA} --timeout-factor=4" # Increase timeout because sanitizers slow down
export GOAL="install"
export BITCOIN_CONFIG="--enable-zmq --with-gui=no --with-sanitizers=thread CC=clang-16 CXX=clang++-16 CXXFLAGS='-g' --with-boost-process"
export CPPFLAGS="-DDEBUG_LOCKORDER -DARENA_DEBUG"
export CPPFLAGS="-DARENA_DEBUG -DDEBUG_LOCKORDER -DDEBUG_LOCKCONTENTION"
export PYZMQ=true
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ if test "x$enable_debug" = xyes; then

AX_CHECK_PREPROC_FLAG([-DDEBUG_CORE],[[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DDEBUG_CORE"]],,[[$CXXFLAG_WERROR]])
AX_CHECK_PREPROC_FLAG([-DDEBUG_LOCKORDER],[[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DDEBUG_LOCKORDER"]],,[[$CXXFLAG_WERROR]])
AX_CHECK_PREPROC_FLAG([-DDEBUG_LOCKCONTENTION], [DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DDEBUG_LOCKCONTENTION"], [], [$CXXFLAG_WERROR])
AX_CHECK_PREPROC_FLAG([-DABORT_ON_FAILED_ASSUME],[[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DABORT_ON_FAILED_ASSUME"]],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-ftrapv],[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -ftrapv"],,[[$CXXFLAG_WERROR]])
else
Expand Down
27 changes: 20 additions & 7 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Developer Notes
- [`debug.log`](#debuglog)
- [Testnet and Regtest modes](#testnet-and-regtest-modes)
- [DEBUG_LOCKORDER](#debug_lockorder)
- [DEBUG_LOCKCONTENTION](#debug_lockcontention)
- [Valgrind suppressions file](#valgrind-suppressions-file)
- [Compiling for test coverage](#compiling-for-test-coverage)
- [Performance profiling with perf](#performance-profiling-with-perf)
Expand Down Expand Up @@ -389,8 +390,10 @@ Run configure with the `--enable-gprof` option, then make.
If the code is behaving strangely, take a look in the `debug.log` file in the data directory;
error and debugging messages are written there.

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

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

### DEBUG_LOCKCONTENTION

Defining `DEBUG_LOCKCONTENTION` adds a "lock" logging category to the logging
RPC that, when enabled, logs the location and duration of each lock contention
to the `debug.log` file.

The `--enable-debug` configure option adds `-DDEBUG_LOCKCONTENTION` to the
compiler flags. You may also enable it manually for a non-debug build by running
configure with `-DDEBUG_LOCKCONTENTION` added to your CPPFLAGS,
i.e. `CPPFLAGS="-DDEBUG_LOCKCONTENTION"`, then build and run dashd.

You can then use the `-debug=lock` configuration option at dashd startup or
`dash-cli logging '["lock"]'` at runtime to turn on lock contention logging.
It can be toggled off again with `dash-cli logging [] '["lock"]'`.

### Assertions and Checks

The util file `src/util/check.h` offers helpers to protect against coding and
Expand Down Expand Up @@ -846,11 +864,6 @@ int GetInt(Tabs tab)
Strings and formatting
------------------------
- Be careful of `LogPrint` versus `LogPrintf`. `LogPrint` takes a `category` argument, `LogPrintf` does not.
- *Rationale*: Confusion of these can result in runtime exceptions due to
formatting mismatch, and it is easy to get wrong because of subtly similar naming.
- Use `std::string`, avoid C string manipulation functions.
- *Rationale*: C++ string handling is marginally safer, less scope for
Expand Down
2 changes: 2 additions & 0 deletions doc/release-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ Follow the relevant Guix README.md sections:
- [Building](/contrib/guix/README.md#building)
- [Attesting to build outputs](/contrib/guix/README.md#attesting-to-build-outputs)

_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_

### Verify other builders' signatures to your own. (Optional)

Add other builders keys to your gpg keyring, and/or refresh keys: See `../dash/contrib/builder-keys/README.md`.
Expand Down
19 changes: 11 additions & 8 deletions src/batchedlogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

#include <batchedlogger.h>

CBatchedLogger::CBatchedLogger(BCLog::LogFlags _category, const std::string& logging_function, const std::string& source_file, int source_line) :
accept(LogAcceptCategory(_category)),
m_logging_function(logging_function),
m_source_file(source_file),
m_source_line(source_line)
CBatchedLogger::CBatchedLogger(BCLog::LogFlags category, BCLog::Level level, const std::string& logging_function,
const std::string& source_file, int source_line) :
m_accept{LogAcceptCategory(category, level)},
m_category{category},
m_level{level},
m_logging_function{logging_function},
m_source_file{source_file},
m_source_line{source_line}
{
}

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

void CBatchedLogger::Flush()
{
if (!accept || msg.empty()) {
if (!m_accept || m_msg.empty()) {
return;
}
LogInstance().LogPrintStr(msg, m_logging_function, m_source_file, m_source_line);
msg.clear();
LogInstance().LogPrintStr(m_msg, m_logging_function, m_source_file, m_source_line, m_category, m_level);
m_msg.clear();
}
16 changes: 10 additions & 6 deletions src/batchedlogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,26 @@
class CBatchedLogger
{
private:
bool accept;
std::string m_logging_function;;
bool m_accept;
BCLog::LogFlags m_category;
BCLog::Level m_level;
std::string m_logging_function;
std::string m_source_file;
const int m_source_line;
std::string msg;
std::string m_msg;

public:
CBatchedLogger(BCLog::LogFlags _category, const std::string& logging_function, const std::string& m_source_file, int m_source_line);
CBatchedLogger(BCLog::LogFlags category, BCLog::Level level, const std::string& logging_function,
const std::string& m_source_file, int m_source_line);
virtual ~CBatchedLogger();

template<typename... Args>
void Batch(const std::string& fmt, const Args&... args)
{
if (!accept) {
if (!m_accept) {
return;
}
msg += " " + strprintf(fmt, args...) + "\n";
m_msg += " " + strprintf(fmt, args...) + "\n";
}

void Flush();
Expand Down
2 changes: 1 addition & 1 deletion src/coinjoin/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CDataS
WITH_LOCK(cs_vecqueue, vecCoinJoinQueue.push_back(dsq));
}
} // cs_ProcessDSQueue
dsq.Relay(connman, *peerman);
peerman->RelayDSQ(dsq);
return {};
}

Expand Down
1 change: 1 addition & 0 deletions src/coinjoin/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class CMasternodeSync;
class CNode;
class CoinJoinWalletManager;
class CTxMemPool;
class PeerManager;

class UniValue;

Expand Down
14 changes: 0 additions & 14 deletions src/coinjoin/coinjoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <masternode/node.h>
#include <masternode/sync.h>
#include <messagesigner.h>
#include <net_processing.h>
#include <netmessagemaker.h>
#include <txmempool.h>
#include <util/moneystr.h>
Expand Down Expand Up @@ -71,19 +70,6 @@ bool CCoinJoinQueue::CheckSignature(const CBLSPublicKey& blsPubKey) const
return true;
}

bool CCoinJoinQueue::Relay(CConnman& connman, PeerManager& peerman)
{
CInv inv(MSG_DSQ, GetHash());
peerman.RelayInv(inv, DSQ_INV_VERSION);
connman.ForEachNode([&connman, this](CNode* pnode) {
CNetMsgMaker msgMaker(pnode->GetCommonVersion());
if (pnode->fSendDSQueue && pnode->nVersion < DSQ_INV_VERSION) {
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::DSQUEUE, (*this)));
}
});
return true;
}

bool CCoinJoinQueue::IsTimeOutOfBounds(int64_t current_time) const
{
return current_time - nTime > COINJOIN_QUEUE_TIMEOUT ||
Expand Down
4 changes: 0 additions & 4 deletions src/coinjoin/coinjoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@

class CActiveMasternodeManager;
class CChainState;
class CConnman;
class CBLSPublicKey;
class CBlockIndex;
class ChainstateManager;
class CMasternodeSync;
class CTxMemPool;
class TxValidationState;
class PeerManager;

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

bool Relay(CConnman& connman, PeerManager& peerman);

/// Check if a queue is too old or too far into the future
[[nodiscard]] bool IsTimeOutOfBounds(int64_t current_time = GetAdjustedTime()) const;

Expand Down
6 changes: 3 additions & 3 deletions src/coinjoin/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ PeerMsgRet CCoinJoinServer::ProcessDSQUEUE(const CNode& peer, CDataStream& vRecv
TRY_LOCK(cs_vecqueue, lockRecv);
if (!lockRecv) return {};
vecCoinJoinQueue.push_back(dsq);
dsq.Relay(connman, *m_peerman);
m_peerman->RelayDSQ(dsq);
}
return {};
}
Expand Down Expand Up @@ -519,7 +519,7 @@ void CCoinJoinServer::CheckForCompleteQueue()
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::CheckForCompleteQueue -- queue is ready, signing and relaying (%s) " /* Continued */
"with %d participants\n", dsq.ToString(), vecSessionCollaterals.size());
dsq.Sign(*m_mn_activeman);
dsq.Relay(connman, *m_peerman);
m_peerman->RelayDSQ(dsq);
}
}

Expand Down Expand Up @@ -732,7 +732,7 @@ bool CCoinJoinServer::CreateNewSession(const CCoinJoinAccept& dsa, PoolMessage&
GetAdjustedTime(), false);
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::CreateNewSession -- signing and relaying new queue: %s\n", dsq.ToString());
dsq.Sign(*m_mn_activeman);
dsq.Relay(connman, *m_peerman);
m_peerman->RelayDSQ(dsq);
LOCK(cs_vecqueue);
vecCoinJoinQueue.push_back(dsq);
}
Expand Down
1 change: 1 addition & 0 deletions src/coinjoin/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

class CActiveMasternodeManager;
class CCoinJoinServer;
class CConnman;
class CDataStream;
class CDeterministicMNManager;
class CDSTXManager;
Expand Down
6 changes: 3 additions & 3 deletions src/dbwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CBitcoinLevelDBLogger : public leveldb::Logger {
// This code is adapted from posix_logger.h, which is why it is using vsprintf.
// Please do not do this in normal code
void Logv(const char * format, va_list ap) override {
if (!LogAcceptCategory(BCLog::LEVELDB)) {
if (!LogAcceptCategory(BCLog::LEVELDB, BCLog::Level::Debug)) {
return;
}
char buffer[500];
Expand Down Expand Up @@ -64,7 +64,7 @@ class CBitcoinLevelDBLogger : public leveldb::Logger {

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

bool CDBWrapper::WriteBatch(CDBBatch& batch, bool fSync)
{
const bool log_memory = LogAcceptCategory(BCLog::LEVELDB);
const bool log_memory = LogAcceptCategory(BCLog::LEVELDB, BCLog::Level::Debug);
double mem_before = 0;
if (log_memory) {
mem_before = DynamicMemoryUsage() / 1024.0 / 1024;
Expand Down
1 change: 1 addition & 0 deletions src/evo/creditpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <serialize.h>
#include <sync.h>
#include <threadsafety.h>
#include <tinyformat.h>
#include <unordered_lru_cache.h>
#include <util/ranges_set.h>

Expand Down
21 changes: 16 additions & 5 deletions src/httpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,22 @@ static void HTTPWorkQueueRun(WorkQueue<HTTPClosure>* queue, int worker_num)
/** libevent event log callback */
static void libevent_log_cb(int severity, const char *msg)
{
if (severity >= EVENT_LOG_WARN) // Log warn messages and higher without debug category
LogPrintf("libevent: %s\n", msg);
// The below code causes log spam on Travis and the output of these logs has never been of any use so far
//else
// LogPrint(BCLog::LIBEVENT, "libevent: %s\n", msg);
BCLog::Level level;
switch (severity) {
case EVENT_LOG_DEBUG:
level = BCLog::Level::Debug;
break;
case EVENT_LOG_MSG:
level = BCLog::Level::Info;
break;
case EVENT_LOG_WARN:
level = BCLog::Level::Warning;
break;
default: // EVENT_LOG_ERR and others are mapped to error
level = BCLog::Level::Error;
break;
}
LogPrintLevel(BCLog::LIBEVENT, level, "%s\n", msg);
}

bool InitHTTPServer()
Expand Down
7 changes: 2 additions & 5 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ void SetupServerArgs(ArgsManager& argsman)
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);
argsman.AddArg("-permitbaremultisig", strprintf("Relay non-P2SH multisig (default: %u)", DEFAULT_PERMIT_BAREMULTISIG), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
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);
argsman.AddArg("-proxy=<ip:port>", "Connect through SOCKS5 proxy, set -noproxy to disable (default: disabled)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
argsman.AddArg("-proxy=<ip:port>", "Connect through SOCKS5 proxy, set -noproxy to disable (default: disabled)", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_ELISION, OptionsCategory::CONNECTION);
argsman.AddArg("-proxyrandomize", strprintf("Randomize credentials for every proxy connection. This enables Tor stream isolation (default: %u)", DEFAULT_PROXYRANDOMIZE), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
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);
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);
Expand Down Expand Up @@ -1212,6 +1212,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)

// ********************************************************* Step 3: parameter-to-internal-flags
init::SetLoggingCategories(args);
init::SetLoggingLevel(args);

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

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

if (args.IsArgSet("-proxy") && args.GetArg("-proxy", "").empty()) {
return InitError(_("No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>."));
}

if (args.GetBoolArg("-reindex-chainstate", false)) {
// indexes that must be deactivated to prevent index corruption, see #24630
if (args.GetBoolArg("-coinstatsindex", DEFAULT_COINSTATSINDEX)) {
Expand Down
Loading

0 comments on commit bbf24f1

Please sign in to comment.