Skip to content
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
2 changes: 1 addition & 1 deletion ci/dash/test_integrationtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ EXTRA_ARGS="--dashd-arg=-socketevents=$SOCKETEVENTS"

set +e
# shellcheck disable=SC2086
LD_LIBRARY_PATH="$DEPENDS_DIR/$HOST/lib" ./test/functional/test_runner.py --ci --attempts=3 --ansi --combinedlogslen=4000 --timeout-factor="${TEST_RUNNER_TIMEOUT_FACTOR}" ${TEST_RUNNER_EXTRA} --failfast --nocleanup --tmpdir="$(pwd)/testdatadirs" $PASS_ARGS $EXTRA_ARGS
LD_LIBRARY_PATH="$DEPENDS_DIR/$HOST/lib" ./test/functional/test_runner.py --ci --attempts=3 --ansi --combinedlogslen=99999999 --timeout-factor="${TEST_RUNNER_TIMEOUT_FACTOR}" ${TEST_RUNNER_EXTRA} --failfast --nocleanup --tmpdir="$(pwd)/testdatadirs" $PASS_ARGS $EXTRA_ARGS
RESULT=$?
set -e

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,7 @@ if test "$use_natpmp" != "no"; then
CPPFLAGS="$TEMP_CPPFLAGS"
fi

if test "$build_bitcoin_wallet$build_bitcoin_cli$build_bitcoin_tx$build_bitcoind$bitcoin_enable_qt$use_tests$use_bench$enable_fuzz_binary" = "nononononononono"; then
if test "$build_bitcoin_wallet$build_bitcoin_cli$build_bitcoin_tx$build_bitcoin_util$build_bitcoind$bitcoin_enable_qt$use_tests$use_bench$enable_fuzz_binary" = "nonononononononono"; then
use_boost=no
else
use_boost=yes
Expand Down
14 changes: 0 additions & 14 deletions contrib/debian/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ Copyright: 2010-2011, Jonas Smedegaard <[email protected]>
2011, Matt Corallo <[email protected]>
License: GPL-2+

Files: src/secp256k1/build-aux/m4/ax_jni_include_dir.m4
Copyright: 2008 Don Anderson <[email protected]>
License: GNU-All-permissive-License

Files: src/secp256k1/build-aux/m4/ax_prog_cc_for_build.m4
Copyright: 2008 Paolo Bonzini <[email protected]>
License: GNU-All-permissive-License


Files: src/qt/res/icons/proxy.png
src/qt/res/src/proxy.svg
Expand Down Expand Up @@ -56,12 +48,6 @@ License: Expat
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

License: GNU-All-permissive-License
Copying and distribution of this file, with or without modification, are
permitted in any medium without royalty provided the copyright notice
and this notice are preserved. This file is offered as-is, without any
warranty.

License: GPL-2+
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Expand Down
6 changes: 3 additions & 3 deletions doc/build-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Below are some notes on how to build Dash Core for Windows.
The options known to work for building Dash Core on Windows are:

* On Linux, using the [Mingw-w64](https://www.mingw-w64.org/) cross compiler tool chain.
* On Windows, using [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/windows/wsl/about) and Mingw-w64.
* On Windows, using [Windows Subsystem for Linux (WSL)](https://learn.microsoft.com/en-us/windows/wsl/about) and Mingw-w64.

Other options which may work, but which have not been extensively tested are (please contribute instructions):

Expand All @@ -18,7 +18,7 @@ package meets the minimum required `g++` version specified in [dependencies.md](
Installing Windows Subsystem for Linux
---------------------------------------

Follow the upstream installation instructions, available [here](https://docs.microsoft.com/windows/wsl/install-win10).
Follow the upstream installation instructions, available [here](https://learn.microsoft.com/en-us/windows/wsl/install).

Cross-compilation
-------------------
Expand All @@ -34,7 +34,7 @@ Note that for WSL the Dash Core source path MUST be somewhere in the default mou
example /usr/src/dash, AND not under /mnt/d/. If this is not the case the dependency autoconf scripts will fail.
This means you cannot use a directory that is located directly on the host Windows file system to perform the build.

Additional WSL Note: WSL support for [launching Win32 applications](https://docs.microsoft.com/en-us/archive/blogs/wsl/windows-and-ubuntu-interoperability#launching-win32-applications-from-within-wsl)
Additional WSL Note: WSL support for [launching Win32 applications](https://learn.microsoft.com/en-us/archive/blogs/wsl/windows-and-ubuntu-interoperability#launching-win32-applications-from-within-wsl)
results in `Autoconf` configure scripts being able to execute Windows Portable Executable files. This can cause
unexpected behaviour during the build, such as Win32 error dialogs for missing libraries. The recommended approach
is to temporarily disable WSL support for Win32 applications.
Expand Down
4 changes: 2 additions & 2 deletions doc/fuzzing.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ $ sudo apt-get install libtool libtool-bin wget automake autoconf bison gdb
```

At this point, you must install the .NET core. The process differs, depending on your Linux distribution.
See [this link](https://docs.microsoft.com/en-us/dotnet/core/install/linux) for details.
On ubuntu 20.04, the following should work:
See [this link](https://learn.microsoft.com/en-us/dotnet/core/install/linux) for details.
On Ubuntu 20.04, the following should work:

```sh
$ wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
Expand Down
6 changes: 3 additions & 3 deletions doc/managing-wallets.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ In the RPC, the destination parameter must include the name of the file. Otherwi
$ dash-cli -rpcwallet="wallet-01" backupwallet /home/node01/Backups/backup-01.dat
```

In the GUI, the wallet is selected in the `Wallet` drop-down list in the upper right corner. If this list is not present, the wallet can be loaded in `File` ->`Open wallet` if necessary. Then, the backup can be done in `File` -> `Backup Wallet...`.
In the GUI, the wallet is selected in the `Wallet` drop-down list in the upper right corner. If this list is not present, the wallet can be loaded in `File` ->`Open Wallet` if necessary. Then, the backup can be done in `File` -> `Backup Wallet`.

This backup file can be stored on one or multiple offline devices, which must be reliable enough to work in an emergency and be malware free. Backup files can be regularly tested to avoid problems in the future.

Expand All @@ -110,7 +110,7 @@ Non-HD wallets must be backed up every 1000 keys used since the previous backup,

### 1.6 Restoring the Wallet From a Backup

To restore a wallet, the `restorewallet` RPC must be used.
To restore a wallet, the `restorewallet` RPC or the `Restore Wallet` GUI menu item (`File` -> `Restore Wallet…`) must be used.

```
$ dash-cli restorewallet "restored-wallet" /home/node01/Backups/backup-01.dat
Expand All @@ -122,4 +122,4 @@ After that, `getwalletinfo` can be used to check if the wallet has been fully re
$ dash-cli -rpcwallet="restored-wallet" getwalletinfo
```

The restored wallet can also be loaded in the GUI via `File` ->`Open wallet`.
The restored wallet can also be loaded in the GUI via `File` ->`Open wallet`.
2 changes: 2 additions & 0 deletions src/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ modernize-use-default-member-init,
modernize-use-nullptr,
performance-for-range-copy,
performance-move-const-arg,
performance-no-automatic-move,
performance-unnecessary-copy-initialization,
readability-const-return-type,
readability-redundant-declaration,
Expand All @@ -19,6 +20,7 @@ misc-unused-using-decls,
modernize-use-default-member-init,
modernize-use-nullptr,
performance-move-const-arg,
performance-no-automatic-move,
performance-unnecessary-copy-initialization,
readability-redundant-declaration,
readability-redundant-string-init,
Expand Down
6 changes: 3 additions & 3 deletions src/addrman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,7 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::SelectTriedCollision()
{
LOCK(cs);
Check();
const auto ret = SelectTriedCollision_();
auto ret = SelectTriedCollision_();
Check();
return ret;
}
Expand All @@ -1204,7 +1204,7 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::Select(bool new_only, std::optiona
{
LOCK(cs);
Check();
const auto addrRet = Select_(new_only, network);
auto addrRet = Select_(new_only, network);
Check();
return addrRet;
}
Expand All @@ -1213,7 +1213,7 @@ std::vector<CAddress> AddrManImpl::GetAddr(size_t max_addresses, size_t max_pct,
{
LOCK(cs);
Check();
const auto addresses = GetAddr_(max_addresses, max_pct, network);
auto addresses = GetAddr_(max_addresses, max_pct, network);
Check();
return addresses;
}
Expand Down
2 changes: 1 addition & 1 deletion src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ static UniValue CallRPC(BaseRequestHandler* rh, const std::string& strMethod, co
UniValue valReply(UniValue::VSTR);
if (!valReply.read(response.body))
throw std::runtime_error("couldn't parse reply from server");
const UniValue reply = rh->ProcessReply(valReply);
UniValue reply = rh->ProcessReply(valReply);
if (reply.empty())
throw std::runtime_error("expected reply to have result, error and id properties");

Expand Down
12 changes: 7 additions & 5 deletions src/bitcoin-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,12 @@ static int AppInitUtil(ArgsManager& args, int argc, char* argv[])
return CONTINUE_EXECUTION;
}

static void grind_task(uint32_t nBits, CBlockHeader& header_orig, uint32_t offset, uint32_t step, std::atomic<bool>& found)
static void grind_task(uint32_t nBits, CBlockHeader header, uint32_t offset, uint32_t step, std::atomic<bool>& found, uint32_t& proposed_nonce)
{
arith_uint256 target;
bool neg, over;
target.SetCompact(nBits, &neg, &over);
if (target == 0 || neg || over) return;
CBlockHeader header = header_orig; // working copy
header.nNonce = offset;

uint32_t finish = std::numeric_limits<uint32_t>::max() - step;
Expand All @@ -94,7 +93,7 @@ static void grind_task(uint32_t nBits, CBlockHeader& header_orig, uint32_t offse
do {
if (UintToArith256(header.GetHash()) <= target) {
if (!found.exchange(true)) {
header_orig.nNonce = header.nNonce;
proposed_nonce = header.nNonce;
}
return;
}
Expand All @@ -118,16 +117,19 @@ static int Grind(const std::vector<std::string>& args, std::string& strPrint)

uint32_t nBits = header.nBits;
std::atomic<bool> found{false};
uint32_t proposed_nonce{};

std::vector<std::thread> threads;
int n_tasks = std::max(1u, std::thread::hardware_concurrency());
for (int i = 0; i < n_tasks; ++i) {
threads.emplace_back( grind_task, nBits, std::ref(header), i, n_tasks, std::ref(found) );
threads.emplace_back(grind_task, nBits, header, i, n_tasks, std::ref(found), std::ref(proposed_nonce));
}
for (auto& t : threads) {
t.join();
}
if (!found) {
if (found) {
header.nNonce = proposed_nonce;
} else {
strPrint = "Could not satisfy difficulty target";
return EXIT_FAILURE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/instantsend/instantsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ std::variant<uint256, CTransactionRef, std::monostate> CInstantSendManager::Proc
}

uint256 hashBlock{};
const auto tx = GetTransaction(nullptr, &mempool, islock->txid, Params().GetConsensus(), hashBlock);
auto tx = GetTransaction(nullptr, &mempool, islock->txid, Params().GetConsensus(), hashBlock);
const bool found_transaction{tx != nullptr};
// we ignore failure here as we must be able to propagate the lock even if we don't have the TX locally
std::optional<int> minedHeight = GetBlockHeight(hashBlock);
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ class Chain
{
public:
virtual ~Notifications() {}
virtual void transactionAddedToMempool(const CTransactionRef& tx, int64_t nAcceptTime, uint64_t mempool_sequence) {}
virtual void transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) {}
virtual void transactionAddedToMempool(const CTransactionRef& tx, int64_t nAcceptTime) {}
virtual void transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason) {}
virtual void blockConnected(const CBlock& block, int height) {}
virtual void blockDisconnected(const CBlock& block, int height) {}
virtual void updatedBlockTip() {}
Expand Down
37 changes: 18 additions & 19 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,9 +773,9 @@ class PeerManagerImpl final : public PeerManager
bool MaybeSendGetHeaders(CNode& pfrom, const std::string& msg_type, const CBlockLocator& locator, Peer& peer)
EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex);
/** Potentially fetch blocks from this peer upon receipt of a new headers tip */
void HeadersDirectFetchBlocks(CNode& pfrom, const Peer& peer, const CBlockIndex* pindexLast);
void HeadersDirectFetchBlocks(CNode& pfrom, const Peer& peer, const CBlockIndex& last_header);
/** Update peer state based on received headers message */
void UpdatePeerStateForReceivedHeaders(CNode& pfrom, const CBlockIndex *pindexLast, bool received_new_header, bool may_have_more_headers);
void UpdatePeerStateForReceivedHeaders(CNode& pfrom, const CBlockIndex& last_header, bool received_new_header, bool may_have_more_headers);

void SendBlockTransactions(CNode& pfrom, const CBlock& block, const BlockTransactionsRequest& req)
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
Expand Down Expand Up @@ -3136,22 +3136,21 @@ bool PeerManagerImpl::MaybeSendGetHeaders(CNode& pfrom, const std::string& msg_t
}

/*
* Given a new headers tip ending in pindexLast, potentially request blocks towards that tip.
* Given a new headers tip ending in last_header, potentially request blocks towards that tip.
* We require that the given tip have at least as much work as our tip, and for
* our current tip to be "close to synced" (see CanDirectFetch()).
*/
void PeerManagerImpl::HeadersDirectFetchBlocks(CNode& pfrom, const Peer& peer, const CBlockIndex* pindexLast)
void PeerManagerImpl::HeadersDirectFetchBlocks(CNode& pfrom, const Peer& peer, const CBlockIndex& last_header)
{
const CNetMsgMaker msgMaker(pfrom.GetCommonVersion());

LOCK(cs_main);
CNodeState *nodestate = State(pfrom.GetId());

if (CanDirectFetch() && pindexLast->IsValid(BLOCK_VALID_TREE) && m_chainman.ActiveChain().Tip()->nChainWork <= pindexLast->nChainWork) {

if (CanDirectFetch() && last_header.IsValid(BLOCK_VALID_TREE) && m_chainman.ActiveChain().Tip()->nChainWork <= last_header.nChainWork) {
std::vector<const CBlockIndex*> vToFetch;
const CBlockIndex *pindexWalk = pindexLast;
// Calculate all the blocks we'd need to switch to pindexLast, up to a limit.
const CBlockIndex* pindexWalk{&last_header};
// Calculate all the blocks we'd need to switch to last_header, up to a limit.
while (pindexWalk && !m_chainman.ActiveChain().Contains(pindexWalk) && vToFetch.size() <= MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
if (!(pindexWalk->nStatus & BLOCK_HAVE_DATA) &&
!IsBlockRequested(pindexWalk->GetBlockHash())) {
Expand All @@ -3166,8 +3165,8 @@ void PeerManagerImpl::HeadersDirectFetchBlocks(CNode& pfrom, const Peer& peer, c
// direct fetch and rely on parallel download instead.
if (!m_chainman.ActiveChain().Contains(pindexWalk)) {
LogPrint(BCLog::NET, "Large reorg, won't direct fetch to %s (%d)\n",
pindexLast->GetBlockHash().ToString(),
pindexLast->nHeight);
last_header.GetBlockHash().ToString(),
last_header.nHeight);
} else {
std::vector<CInv> vGetData;
// Download as much as possible, from earliest to latest.
Expand All @@ -3183,14 +3182,15 @@ void PeerManagerImpl::HeadersDirectFetchBlocks(CNode& pfrom, const Peer& peer, c
}
if (vGetData.size() > 1) {
LogPrint(BCLog::NET, "Downloading blocks toward %s (%d) via headers direct fetch\n",
pindexLast->GetBlockHash().ToString(), pindexLast->nHeight);
last_header.GetBlockHash().ToString(),
last_header.nHeight);
}
if (vGetData.size() > 0) {
if (!m_ignore_incoming_txs &&
nodestate->m_provides_cmpctblocks &&
vGetData.size() == 1 &&
mapBlocksInFlight.size() == 1 &&
pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN)) {
last_header.pprev->IsValid(BLOCK_VALID_CHAIN)) {
// In any case, we want to download using a compact block, not a regular one
vGetData[0] = CInv(MSG_CMPCT_BLOCK, vGetData[0].hash);
}
Expand All @@ -3201,12 +3201,12 @@ void PeerManagerImpl::HeadersDirectFetchBlocks(CNode& pfrom, const Peer& peer, c
}

/**
* Given receipt of headers from a peer ending in pindexLast, along with
* Given receipt of headers from a peer ending in last_header, along with
* whether that header was new and whether the headers message was full,
* update the state we keep for the peer.
*/
void PeerManagerImpl::UpdatePeerStateForReceivedHeaders(CNode& pfrom,
const CBlockIndex *pindexLast, bool received_new_header, bool may_have_more_headers)
const CBlockIndex& last_header, bool received_new_header, bool may_have_more_headers)
{
LOCK(cs_main);
CNodeState *nodestate = State(pfrom.GetId());
Expand All @@ -3215,14 +3215,13 @@ void PeerManagerImpl::UpdatePeerStateForReceivedHeaders(CNode& pfrom,
}
nodestate->nUnconnectingHeaders = 0;

assert(pindexLast);
UpdateBlockAvailability(pfrom.GetId(), pindexLast->GetBlockHash());
UpdateBlockAvailability(pfrom.GetId(), last_header.GetBlockHash());

// From here, pindexBestKnownBlock should be guaranteed to be non-null,
// because it is set in UpdateBlockAvailability. Some nullptr checks
// are still present, however, as belt-and-suspenders.

if (received_new_header && pindexLast->nChainWork > m_chainman.ActiveChain().Tip()->nChainWork) {
if (received_new_header && last_header.nChainWork > m_chainman.ActiveChain().Tip()->nChainWork) {
nodestate->m_last_block_announcement = GetTime();
}

Expand Down Expand Up @@ -3319,10 +3318,10 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
}
}

UpdatePeerStateForReceivedHeaders(pfrom, pindexLast, received_new_header, nCount == GetHeadersLimit(pfrom, uses_compressed));
UpdatePeerStateForReceivedHeaders(pfrom, *pindexLast, received_new_header, nCount == GetHeadersLimit(pfrom, uses_compressed));

// Consider immediately downloading blocks.
HeadersDirectFetchBlocks(pfrom, peer, pindexLast);
HeadersDirectFetchBlocks(pfrom, peer, *pindexLast);

return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/node/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -909,11 +909,11 @@ class NotificationsProxy : public CValidationInterface
virtual ~NotificationsProxy() = default;
void TransactionAddedToMempool(const CTransactionRef& tx, int64_t nAcceptTime, uint64_t mempool_sequence) override
{
m_notifications->transactionAddedToMempool(tx, nAcceptTime, mempool_sequence);
m_notifications->transactionAddedToMempool(tx, nAcceptTime);
}
void TransactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override
{
m_notifications->transactionRemovedFromMempool(tx, reason, mempool_sequence);
m_notifications->transactionRemovedFromMempool(tx, reason);
}
void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* index) override
{
Expand Down Expand Up @@ -1303,7 +1303,7 @@ class ChainImpl : public Chain
if (!m_node.mempool) return;
LOCK2(::cs_main, m_node.mempool->cs);
for (const CTxMemPoolEntry& entry : m_node.mempool->mapTx) {
notifications.transactionAddedToMempool(entry.GetSharedTx(), /* nAcceptTime = */ 0, /* mempool_sequence = */ 0);
notifications.transactionAddedToMempool(entry.GetSharedTx(), /*nAcceptTime=*/0);
}
}
bool hasAssumedValidChain() override
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ UniValue RPCHelpMan::HandleRequest(const JSONRPCRequest& request) const
if (request.mode == JSONRPCRequest::GET_HELP || !IsValidNumArgs(request.params.size())) {
throw std::runtime_error(ToString());
}
const UniValue ret = m_fun(*this, request);
UniValue ret = m_fun(*this, request);
if (gArgs.GetBoolArg("-rpcdoccheck", DEFAULT_RPC_DOC_CHECK)) {
CHECK_NONFATAL(std::any_of(m_results.m_results.begin(), m_results.m_results.end(), [&ret](const RPCResult& res) { return res.MatchesType(ret); }));
}
Expand Down
Loading
Loading