Skip to content

Commit

Permalink
Merge pull request #5541 from knst/bp-v21-p2
Browse files Browse the repository at this point in the history
  • Loading branch information
PastaPastaPasta authored Dec 4, 2023
2 parents b43af81 + f947086 commit 63b9071
Show file tree
Hide file tree
Showing 19 changed files with 332 additions and 293 deletions.
31 changes: 2 additions & 29 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -144,24 +144,12 @@ AC_ARG_WITH([miniupnpc],
[use_upnp=$withval],
[use_upnp=auto])

AC_ARG_ENABLE([upnp-default],
[AS_HELP_STRING([--enable-upnp-default],
[if UPNP is enabled, turn it on at startup (default is no)])],
[use_upnp_default=$enableval],
[use_upnp_default=no])

AC_ARG_WITH([natpmp],
[AS_HELP_STRING([--with-natpmp],
[enable NAT-PMP (default is yes if libnatpmp is found)])],
[use_natpmp=$withval],
[use_natpmp=auto])

AC_ARG_ENABLE([natpmp-default],
[AS_HELP_STRING([--enable-natpmp-default],
[if NAT-PMP is enabled, turn it on at startup (default is no)])],
[use_natpmp_default=$enableval],
[use_natpmp_default=no])

AC_ARG_ENABLE(tests,
AS_HELP_STRING([--disable-tests],[do not compile tests (default is to compile)]),
[use_tests=$enableval],
Expand Down Expand Up @@ -1609,16 +1597,8 @@ if test x$have_miniupnpc = xno; then
else
if test x$use_upnp != xno; then
AC_MSG_RESULT(yes)
AC_MSG_CHECKING([whether to build with UPnP enabled by default])
use_upnp=yes
upnp_setting=0
if test x$use_upnp_default != xno; then
use_upnp_default=yes
upnp_setting=1
fi
AC_MSG_RESULT($use_upnp_default)
AC_DEFINE_UNQUOTED([USE_UPNP],[$upnp_setting],[UPnP support not compiled if undefined, otherwise value (0 or 1) determines default state])
if test x$TARGET_OS = xwindows; then
AC_DEFINE([USE_UPNP], [1], [Define to 1 if UPnP support should be compiled in.]) if test x$TARGET_OS = xwindows; then
MINIUPNPC_CPPFLAGS="-DSTATICLIB -DMINIUPNP_STATICLIB"
fi
else
Expand All @@ -1637,15 +1617,8 @@ if test "x$have_natpmp" = xno; then
else
if test "x$use_natpmp" != xno; then
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([whether to build with NAT-PMP enabled by default])
use_natpmp=yes
natpmp_setting=0
if test "x$use_natpmp_default" != xno; then
use_natpmp_default=yes
natpmp_setting=1
fi
AC_MSG_RESULT($use_natpmp_default)
AC_DEFINE_UNQUOTED([USE_NATPMP], [$natpmp_setting], [NAT-PMP support not compiled if undefined, otherwise value (0 or 1) determines default state])
AC_DEFINE([USE_NATPMP], [1], [Define to 1 if UPnP support should be compiled in.])
if test x$TARGET_OS = xwindows; then
NATPMP_CPPFLAGS="-DSTATICLIB -DNATPMP_STATICLIB"
fi
Expand Down
16 changes: 4 additions & 12 deletions doc/build-unix.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ SQLite is required for the wallet:

To build Dash Core without wallet, see [*Disable-wallet mode*](#disable-wallet-mode)

Optional port mapping libraries (see: `--with-miniupnpc`, `--enable-upnp-default`, and `--with-natpmp`, `--enable-natpmp-default`):
Optional port mapping libraries (see: `--with-miniupnpc` and `--with-natpmp`):

sudo apt install libminiupnpc-dev libnatpmp-dev

Expand Down Expand Up @@ -154,7 +154,7 @@ SQLite is required for the wallet:

To build Dash Core without wallet, see [*Disable-wallet mode*](#disable-wallet-mode)

Optional port mapping libraries (see: `--with-miniupnpc`, `--enable-upnp-default`, and `--with-natpmp`, `--enable-natpmp-default`):
Optional port mapping libraries (see: `--with-miniupnpc` and `--with-natpmp`):

sudo dnf install miniupnpc-devel libnatpmp-devel

Expand Down Expand Up @@ -198,22 +198,14 @@ miniupnpc

[miniupnpc](https://miniupnp.tuxfamily.org) may be used for UPnP port mapping. It can be downloaded from [here](
https://miniupnp.tuxfamily.org/files/). UPnP support is compiled in and
turned off by default. See the configure options for upnp behavior desired:

--without-miniupnpc No UPnP support miniupnp not required
--disable-upnp-default (the default) UPnP support turned off by default at runtime
--enable-upnp-default UPnP support turned on by default at runtime
turned off by default.

libnatpmp
---------

[libnatpmp](https://miniupnp.tuxfamily.org/libnatpmp.html) may be used for NAT-PMP port mapping. It can be downloaded
from [here](https://miniupnp.tuxfamily.org/files/). NAT-PMP support is compiled in and
turned off by default. See the configure options for NAT-PMP behavior desired:

--without-natpmp No NAT-PMP support, libnatpmp not required
--disable-natpmp-default (the default) NAT-PMP support turned off by default at runtime
--enable-natpmp-default NAT-PMP support turned on by default at runtime
turned off by default.

Berkeley DB
-----------
Expand Down
7 changes: 7 additions & 0 deletions doc/release-notes-26896.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Build System
------------

The --enable-upnp-default and --enable-natpmp-default options
have been removed. If you want to use port mapping, you can
configure it using a .conf file, or by passing the relevant
options at runtime.
8 changes: 7 additions & 1 deletion src/bench/block_assemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@

static void AssembleBlock(benchmark::Bench& bench)
{
RegTestingSetup test_setup;
TestingSetup test_setup{
CBaseChainParams::REGTEST,
/* extra_args */ {
"-nodebuglogfile",
"-nodebug",
},
};
const CScript redeemScript = CScript() << OP_DROP << OP_TRUE;
const CScript SCRIPT_PUB =
CScript() << OP_HASH160 << ToByteVector(CScriptID(redeemScript))
Expand Down
8 changes: 7 additions & 1 deletion src/bench/duplicate_inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@

static void DuplicateInputs(benchmark::Bench& bench)
{
RegTestingSetup test_setup;
TestingSetup test_setup{
CBaseChainParams::REGTEST,
/* extra_args */ {
"-nodebuglogfile",
"-nodebug",
},
};

const CScript SCRIPT_PUB{CScript(OP_TRUE)};

Expand Down
12 changes: 9 additions & 3 deletions src/bench/mempool_eviction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@ static void AddTx(const CTransactionRef& tx, const CAmount& nFee, CTxMemPool& po
unsigned int sigOps = 1;
LockPoints lp;
pool.addUnchecked(CTxMemPoolEntry(
tx, nFee, nTime, nHeight,
spendsCoinbase, sigOps, lp));
tx, nFee, nTime, nHeight,
spendsCoinbase, sigOps, lp));
}

// Right now this is only testing eviction performance in an extremely small
// mempool. Code needs to be written to generate a much wider variety of
// unique transactions for a more meaningful performance measurement.
static void MempoolEviction(benchmark::Bench& bench)
{
RegTestingSetup test_setup;
TestingSetup test_setup{
CBaseChainParams::REGTEST,
/* extra_args */ {
"-nodebuglogfile",
"-nodebug",
},
};

CMutableTransaction tx1 = CMutableTransaction();
tx1.vin.resize(1);
Expand Down
10 changes: 8 additions & 2 deletions src/bench/wallet_balance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@

static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const bool add_watchonly, const bool add_mine, const uint32_t epoch_iters)
{
RegTestingSetup test_setup;
TestingSetup test_setup{
CBaseChainParams::REGTEST,
/* extra_args */ {
"-nodebuglogfile",
"-nodebug",
},
};
const auto& ADDRESS_WATCHONLY = ADDRESS_B58T_UNSPENDABLE;

CWallet wallet{test_setup.m_node.chain.get(), "", CreateMockWalletDatabase()};
Expand All @@ -24,7 +30,7 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b
bool first_run;
if (wallet.LoadWallet(first_run) != DBErrors::LOAD_OK) assert(false);
}
auto handler = test_setup.m_node.chain->handleNotifications({ &wallet, [](CWallet*) {} });
auto handler = test_setup.m_node.chain->handleNotifications({&wallet, [](CWallet*) {}});

const std::optional<std::string> address_mine{add_mine ? std::optional<std::string>{getnewaddress(wallet)} : std::nullopt};
if (add_watchonly) importaddress(wallet, ADDRESS_WATCHONLY);
Expand Down
8 changes: 0 additions & 8 deletions src/mapport.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,9 @@
#ifndef BITCOIN_MAPPORT_H
#define BITCOIN_MAPPORT_H

#ifdef USE_UPNP
static constexpr bool DEFAULT_UPNP = USE_UPNP;
#else
static constexpr bool DEFAULT_UPNP = false;
#endif // USE_UPNP

#ifdef USE_NATPMP
static constexpr bool DEFAULT_NATPMP = USE_NATPMP;
#else
static constexpr bool DEFAULT_NATPMP = false;
#endif // USE_NATPMP

enum MapPortProtoFlag : unsigned int {
NONE = 0x00,
Expand Down
5 changes: 3 additions & 2 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <net_permissions.h>
#include <netaddress.h>
#include <netbase.h>
#include <protocol.h>
#include <random.h>
#include <scheduler.h>
#include <ui_interface.h>
Expand Down Expand Up @@ -757,14 +758,14 @@ int CNode::GetSendVersion() const
int V1TransportDeserializer::readHeader(Span<const uint8_t> msg_bytes)
{
// copy data to temporary parsing buffer
unsigned int nRemaining = 24 - nHdrPos;
unsigned int nRemaining = CMessageHeader::HEADER_SIZE - nHdrPos;
unsigned int nCopy = std::min<unsigned int>(nRemaining, msg_bytes.size());

memcpy(&hdrbuf[nHdrPos], msg_bytes.data(), nCopy);
nHdrPos += nCopy;

// if header incomplete, exit
if (nHdrPos < 24)
if (nHdrPos < CMessageHeader::HEADER_SIZE)
return nCopy;

// deserialize to CMessageHeader
Expand Down
Loading

0 comments on commit 63b9071

Please sign in to comment.