Merge #6363: backport: trivial 2024 10 25 pr2

700b8c5ac5 Merge bitcoin/bitcoin#29658: Bugfix: GUI: Help messages already have a trailing newline, so don't add an extra one (merge-script)
a0cd305a7c Merge bitcoin/bitcoin#29948: test: add missing comparison of node1's mempool in MempoolPackagesTest (Ava Chow)
f1907ea997 Merge bitcoin/bitcoin#29984: net: Replace ifname check with IFF_LOOPBACK in Discover (merge-script)
daa6eeed5f Merge bitcoin/bitcoin#29960: depends: pass verbose through to cmake based makefiles (merge-script)
61a5832a6a Merge bitcoin/bitcoin#29907: test: Fix `test/streams_tests.cpp` compilation on SunOS / illumos (merge-script)
23f25a94fa Merge bitcoin/bitcoin#29872: test: Add missing Assert(mock_time_in >= 0s) to SetMockTime (merge-script)
a7daee71da Merge bitcoin/bitcoin#29689: lint: scripted-diff verification also requires GNU grep (Ava Chow)
3df1ca102b Merge bitcoin/bitcoin#29953: doc: Bash is needed in gen_id and is not installed on FreeBSD by default (merge-script)
b53b85409f Merge bitcoin/bitcoin#29850: net: Decrease nMaxIPs when learning from DNS seeds (Ava Chow)
c4a147cfea Merge bitcoin/bitcoin#28340: security: restrict abis in bitcoind.service (Ryan Ofsky)
acfdf9e438 Merge bitcoin/bitcoin#28373: doc: Add example of mixing private and public keys in descriptors (Ava Chow)
51bc8bdcd6 Merge bitcoin/bitcoin#29859: build: Fix false positive `CHECK_ATOMIC` test (merge-script)
bb4102c590 Merge bitcoin/bitcoin#29893: test: fix intermittent failure in p2p_compactblocks_hb.py (glozow)
4ecb76104e Merge bitcoin/bitcoin#29786: Drop Windows Socket dependency for `randomenv.cpp` (fanquake)
1a8e805aab Merge bitcoin/bitcoin#29498: test: Update --tmpdir doc string to say directory must not exist (fanquake)
81ca71c266 Merge bitcoin/bitcoin#29781: depends: add new LLVM debug macro (fanquake)
5ce92ca9ea Merge bitcoin/bitcoin#29527: depends: add -g to DEBUG=1 flags (fanquake)

Pull request description:

  ## Issue being fixed or feature implemented
  Trivial backports

  ## What was done?

  ## How Has This Been Tested?
  built locally

  ## Breaking Changes

  ## Checklist:
    _Go over all the following points, and put an `x` in all the boxes that apply._
  - [ ] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  UdjinM6:
    utACK 700b8c5ac5 but pls confirm Guix is happy now before merging
  kwvg:
    utACK 700b8c5ac5

Tree-SHA512: 9722979c4f0589cb02bfeaf39373713372a4aa1c8c5a55aa5b4d33388f73ef19231de3963b80ffaad25fbe0db90a133de5080baac691daed41b86a762b867b2d
This commit is contained in:
pasta 2024-10-26 19:18:46 -05:00
commit f211bb9289
No known key found for this signature in database
GPG Key ID: E2F3D7916E722D38
19 changed files with 89 additions and 42 deletions

View File

@ -7,7 +7,7 @@ dnl warranty.
# Clang, when building for 32-bit, # Clang, when building for 32-bit,
# and linking against libstdc++, requires linking with # and linking against libstdc++, requires linking with
# -latomic if using the C++ atomic library. # -latomic if using the C++ atomic library.
# Can be tested with: clang++ test.cpp -m32 # Can be tested with: clang++ -std=c++20 test.cpp -m32
# #
# Sourced from http://bugs.debian.org/797228 # Sourced from http://bugs.debian.org/797228
@ -27,8 +27,11 @@ m4_define([_CHECK_ATOMIC_testbody], [[
auto t1 = t.load(); auto t1 = t.load();
t.compare_exchange_strong(t1, 3s); t.compare_exchange_strong(t1, 3s);
std::atomic<int64_t> a{}; std::atomic<double> d{};
d.store(3.14);
auto d1 = d.load();
std::atomic<int64_t> a{};
int64_t v = 5; int64_t v = 5;
int64_t r = a.fetch_add(v); int64_t r = a.fetch_add(v);
return static_cast<int>(r); return static_cast<int>(r);

View File

@ -78,5 +78,8 @@ PrivateDevices=true
# Deny the creation of writable and executable memory mappings. # Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute=true MemoryDenyWriteExecute=true
# Restrict ABIs to help ensure MemoryDenyWriteExecute is enforced
SystemCallArchitectures=native
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -87,6 +87,10 @@ For linux S390X cross compilation:
sudo apt-get install g++-s390x-linux-gnu binutils-s390x-linux-gnu sudo apt-get install g++-s390x-linux-gnu binutils-s390x-linux-gnu
### Install the required dependencies: FreeBSD
pkg install bash
### Install the required dependencies: OpenBSD ### Install the required dependencies: OpenBSD
pkg_add bash gtar pkg_add bash gtar

View File

@ -183,6 +183,7 @@ $(1)_cmake=env CC="$$($(1)_cc)" \
cmake -DCMAKE_INSTALL_PREFIX:PATH="$$($($(1)_type)_prefix)" \ cmake -DCMAKE_INSTALL_PREFIX:PATH="$$($($(1)_type)_prefix)" \
-DCMAKE_INSTALL_LIBDIR=lib/ \ -DCMAKE_INSTALL_LIBDIR=lib/ \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=$(V) \
$$($(1)_config_opts) $$($(1)_config_opts)
ifeq ($($(1)_type),build) ifeq ($($(1)_type),build)
$(1)_cmake += -DCMAKE_INSTALL_RPATH:PATH="$$($($(1)_type)_prefix)/lib" $(1)_cmake += -DCMAKE_INSTALL_RPATH:PATH="$$($($(1)_type)_prefix)/lib"

View File

@ -123,7 +123,7 @@ darwin_CXXFLAGS=$(darwin_CFLAGS)
darwin_release_CFLAGS=-O2 darwin_release_CFLAGS=-O2
darwin_release_CXXFLAGS=$(darwin_release_CFLAGS) darwin_release_CXXFLAGS=$(darwin_release_CFLAGS)
darwin_debug_CFLAGS=-O1 darwin_debug_CFLAGS=-O1 -g
darwin_debug_CXXFLAGS=$(darwin_debug_CFLAGS) darwin_debug_CXXFLAGS=$(darwin_debug_CFLAGS)
darwin_cmake_system=Darwin darwin_cmake_system=Darwin

View File

@ -10,10 +10,14 @@ linux_CXXFLAGS=$(linux_CFLAGS)
linux_release_CFLAGS=-O2 linux_release_CFLAGS=-O2
linux_release_CXXFLAGS=$(linux_release_CFLAGS) linux_release_CXXFLAGS=$(linux_release_CFLAGS)
linux_debug_CFLAGS=-O1 linux_debug_CFLAGS=-O1 -g
linux_debug_CXXFLAGS=$(linux_debug_CFLAGS) linux_debug_CXXFLAGS=$(linux_debug_CFLAGS)
linux_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_LIBCPP_ENABLE_DEBUG_MODE=1 # https://gcc.gnu.org/onlinedocs/libstdc++/manual/debug_mode.html
linux_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC
# https://libcxx.llvm.org/Hardening.html
linux_debug_CPPFLAGS+=-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG
ifeq (86,$(findstring 86,$(build_arch))) ifeq (86,$(findstring 86,$(build_arch)))
i686_linux_CC=gcc -m32 i686_linux_CC=gcc -m32

View File

@ -14,7 +14,7 @@ mingw32_CXXFLAGS=$(mingw32_CFLAGS)
mingw32_release_CFLAGS=-O2 mingw32_release_CFLAGS=-O2
mingw32_release_CXXFLAGS=$(mingw32_release_CFLAGS) mingw32_release_CXXFLAGS=$(mingw32_release_CFLAGS)
mingw32_debug_CFLAGS=-O1 mingw32_debug_CFLAGS=-O1 -g
mingw32_debug_CXXFLAGS=$(mingw32_debug_CFLAGS) mingw32_debug_CXXFLAGS=$(mingw32_debug_CFLAGS)
mingw32_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC mingw32_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC

View File

@ -8,7 +8,6 @@ define $(package)_set_vars
$(package)_config_opts=--disable-shared --disable-readline --disable-dynamic-extensions --enable-option-checking $(package)_config_opts=--disable-shared --disable-readline --disable-dynamic-extensions --enable-option-checking
$(package)_config_opts+= --disable-rtree --disable-fts4 --disable-fts5 $(package)_config_opts+= --disable-rtree --disable-fts4 --disable-fts5
# We avoid using `--enable-debug` because it overrides CFLAGS, a behavior we want to prevent. # We avoid using `--enable-debug` because it overrides CFLAGS, a behavior we want to prevent.
$(package)_cflags_debug += -g
$(package)_cppflags_debug += -DSQLITE_DEBUG $(package)_cppflags_debug += -DSQLITE_DEBUG
$(package)_cppflags+=-DSQLITE_DQS=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_OMIT_DEPRECATED $(package)_cppflags+=-DSQLITE_DQS=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_OMIT_DEPRECATED
$(package)_cppflags+=-DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_JSON -DSQLITE_LIKE_DOESNT_MATCH_BLOBS $(package)_cppflags+=-DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_JSON -DSQLITE_LIKE_DOESNT_MATCH_BLOBS

View File

@ -166,7 +166,18 @@ Often it is useful to communicate a description of scripts along with the
necessary private keys. For this reason, anywhere a public key or xpub is necessary private keys. For this reason, anywhere a public key or xpub is
supported, a private key in WIF format or xprv may be provided instead. supported, a private key in WIF format or xprv may be provided instead.
This is useful when private keys are necessary for hardened derivation This is useful when private keys are necessary for hardened derivation
steps, or for dumping wallet descriptors including private key material. steps, for signing transactions, or for dumping wallet descriptors
including private key material.
For example, after importing the following 2-of-3 multisig descriptor
into a wallet, one could use `signrawtransactionwithwallet`
to sign a transaction with the first key:
```
sh(multi(2,xprv.../84'/0'/0'/0/0,xpub1...,xpub2...))
```
Note how the first key is an xprv private key with a specific derivation path,
while the other two are public keys.
### Compatibility with old wallets ### Compatibility with old wallets

View File

@ -3062,7 +3062,11 @@ void CConnman::ThreadDNSAddressSeed()
if (!resolveSource.SetInternal(host)) { if (!resolveSource.SetInternal(host)) {
continue; continue;
} }
unsigned int nMaxIPs = 256; // Limits number of IPs learned from a DNS seed // Limit number of IPs learned from a single DNS seed. This limit exists to prevent the results from
// one DNS seed from dominating AddrMan. Note that the number of results from a UDP DNS query is
// bounded to 33 already, but it is possible for it to use TCP where a larger number of results can be
// returned.
unsigned int nMaxIPs = 32;
const auto addresses{LookupHost(host, nMaxIPs, true)}; const auto addresses{LookupHost(host, nMaxIPs, true)};
if (!addresses.empty()) { if (!addresses.empty()) {
for (const CNetAddr& ip : addresses) { for (const CNetAddr& ip : addresses) {
@ -4086,8 +4090,7 @@ void Discover()
{ {
if (ifa->ifa_addr == nullptr) continue; if (ifa->ifa_addr == nullptr) continue;
if ((ifa->ifa_flags & IFF_UP) == 0) continue; if ((ifa->ifa_flags & IFF_UP) == 0) continue;
if (strcmp(ifa->ifa_name, "lo") == 0) continue; if ((ifa->ifa_flags & IFF_LOOPBACK) != 0) continue;
if (strcmp(ifa->ifa_name, "lo0") == 0) continue;
if (ifa->ifa_addr->sa_family == AF_INET) if (ifa->ifa_addr->sa_family == AF_INET)
{ {
struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr); struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr);

View File

@ -170,8 +170,7 @@ struct CSerializedNetMsg {
/** /**
* Look up IP addresses from all interfaces on the machine and add them to the * Look up IP addresses from all interfaces on the machine and add them to the
* list of local addresses to self-advertise. * list of local addresses to self-advertise.
* The loopback interface is skipped and only the first address from each * The loopback interface is skipped.
* interface is used.
*/ */
void Discover(); void Discover();

View File

@ -158,7 +158,7 @@ HelpMessageDialog::~HelpMessageDialog()
void HelpMessageDialog::printToConsole() void HelpMessageDialog::printToConsole()
{ {
// On other operating systems, the expected action is to print the message to the console. // On other operating systems, the expected action is to print the message to the console.
tfm::format(std::cout, "%s\n", qPrintable(text)); tfm::format(std::cout, "%s", qPrintable(text));
} }
void HelpMessageDialog::showOrPrint() void HelpMessageDialog::showOrPrint()

View File

@ -12,6 +12,7 @@
#include <clientversion.h> #include <clientversion.h>
#include <compat/cpuid.h> #include <compat/cpuid.h>
#include <crypto/sha512.h> #include <crypto/sha512.h>
#include <span.h>
#include <support/cleanse.h> #include <support/cleanse.h>
#include <util/time.h> // for GetTime() #include <util/time.h> // for GetTime()
#ifdef WIN32 #ifdef WIN32
@ -358,10 +359,19 @@ void RandAddStaticEnv(CSHA512& hasher)
hasher << &hasher << &RandAddStaticEnv << &malloc << &errno << &environ; hasher << &hasher << &RandAddStaticEnv << &malloc << &errno << &environ;
// Hostname // Hostname
#ifdef WIN32
constexpr DWORD max_size = MAX_COMPUTERNAME_LENGTH + 1;
char hname[max_size];
DWORD size = max_size;
if (GetComputerNameA(hname, &size) != 0) {
hasher.Write(UCharCast(hname), size);
}
#else
char hname[256]; char hname[256];
if (gethostname(hname, 256) == 0) { if (gethostname(hname, 256) == 0) {
hasher.Write((const unsigned char*)hname, strnlen(hname, 256)); hasher.Write((const unsigned char*)hname, strnlen(hname, 256));
} }
#endif
#if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS #if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS
// Network interfaces // Network interfaces

View File

@ -85,8 +85,8 @@ BOOST_AUTO_TEST_CASE(streams_vector_reader)
BOOST_CHECK_EQUAL(reader.size(), 5U); BOOST_CHECK_EQUAL(reader.size(), 5U);
BOOST_CHECK(!reader.empty()); BOOST_CHECK(!reader.empty());
// Read a single byte as a signed char. // Read a single byte as a int8_t.
signed char b; int8_t b;
reader >> b; reader >> b;
BOOST_CHECK_EQUAL(b, -1); BOOST_CHECK_EQUAL(b, -1);
BOOST_CHECK_EQUAL(reader.size(), 4U); BOOST_CHECK_EQUAL(reader.size(), 4U);

View File

@ -21,7 +21,7 @@
void UninterruptibleSleep(const std::chrono::microseconds& n) { std::this_thread::sleep_for(n); } void UninterruptibleSleep(const std::chrono::microseconds& n) { std::this_thread::sleep_for(n); }
static std::atomic<int64_t> nMockTime(0); //!< For testing static std::atomic<std::chrono::seconds> g_mock_time{}; //!< For testing
bool ChronoSanityCheck() bool ChronoSanityCheck()
{ {
@ -69,7 +69,7 @@ bool ChronoSanityCheck()
template <typename T> template <typename T>
T GetTime() T GetTime()
{ {
const std::chrono::seconds mocktime{nMockTime.load(std::memory_order_relaxed)}; const auto mocktime{g_mock_time.load(std::memory_order_relaxed)};
const auto ret{ const auto ret{
mocktime.count() ? mocktime.count() ?
mocktime : mocktime :
@ -89,20 +89,16 @@ static T GetSystemTime()
return now; return now;
} }
void SetMockTime(int64_t nMockTimeIn) void SetMockTime(int64_t nMockTimeIn) { SetMockTime(std::chrono::seconds{nMockTimeIn}); }
{
Assert(nMockTimeIn >= 0);
nMockTime.store(nMockTimeIn, std::memory_order_relaxed);
}
void SetMockTime(std::chrono::seconds mock_time_in) void SetMockTime(std::chrono::seconds mock_time_in)
{ {
nMockTime.store(mock_time_in.count(), std::memory_order_relaxed); Assert(mock_time_in >= 0s);
g_mock_time.store(mock_time_in, std::memory_order_relaxed);
} }
std::chrono::seconds GetMockTime() std::chrono::seconds GetMockTime()
{ {
return std::chrono::seconds(nMockTime.load(std::memory_order_relaxed)); return g_mock_time.load(std::memory_order_relaxed);
} }
int64_t GetTimeMillis() int64_t GetTimeMillis()

View File

@ -201,13 +201,13 @@ class MempoolPackagesTest(BitcoinTestFramework):
assert set(mempool1).issubset(set(mempool0)) assert set(mempool1).issubset(set(mempool0))
for tx in chain[:MAX_ANCESTORS_CUSTOM]: for tx in chain[:MAX_ANCESTORS_CUSTOM]:
assert tx in mempool1 assert tx in mempool1
# TODO: more detailed check of node1's mempool (fees etc.) entry0 = self.nodes[0].getmempoolentry(tx)
# check transaction unbroadcast info (should be false if in both mempools) entry1 = self.nodes[1].getmempoolentry(tx)
mempool = self.nodes[0].getrawmempool(True) assert not entry0['unbroadcast']
for tx in mempool: assert not entry1['unbroadcast']
assert_equal(mempool[tx]['unbroadcast'], False) assert_equal(entry1['fees']['base'], entry0['fees']['base'])
assert_equal(entry1['vsize'], entry0['vsize'])
# TODO: test ancestor size limits assert_equal(entry1['depends'], entry0['depends'])
# Now test descendant chain limits # Now test descendant chain limits
txid = utxo[1]['txid'] txid = utxo[1]['txid']
@ -258,10 +258,14 @@ class MempoolPackagesTest(BitcoinTestFramework):
assert tx in mempool1 assert tx in mempool1
for tx in chain[MAX_DESCENDANTS_CUSTOM:]: for tx in chain[MAX_DESCENDANTS_CUSTOM:]:
assert tx not in mempool1 assert tx not in mempool1
# TODO: more detailed check of node1's mempool (fees etc.) for tx in mempool1:
entry0 = self.nodes[0].getmempoolentry(tx)
# TODO: test descendant size limits entry1 = self.nodes[1].getmempoolentry(tx)
assert not entry0['unbroadcast']
assert not entry1['unbroadcast']
assert_equal(entry1['fees']['base'], entry0['fees']['base'])
assert_equal(entry1['vsize'], entry0['vsize'])
assert_equal(entry1['depends'], entry0['depends'])
# Test reorg handling # Test reorg handling
# First, the basics: # First, the basics:
self.generate(self.nodes[0], 1) self.generate(self.nodes[0], 1)

View File

@ -33,10 +33,15 @@ class CompactBlocksConnectionTest(BitcoinTestFramework):
self.generate(self.nodes[0], 1) self.generate(self.nodes[0], 1)
self.sync_blocks() self.sync_blocks()
self.disconnect_nodes(peer, 0) self.disconnect_nodes(peer, 0)
status_to = [self.peer_info(1, i)['bip152_hb_to'] for i in range(2, 6)]
status_from = [self.peer_info(i, 1)['bip152_hb_from'] for i in range(2, 6)] def status_to():
assert_equal(status_to, status_from) return [self.peer_info(1, i)['bip152_hb_to'] for i in range(2, 6)]
return status_to
def status_from():
return [self.peer_info(i, 1)['bip152_hb_from'] for i in range(2, 6)]
self.wait_until(lambda: status_to() == status_from())
return status_to()
def run_test(self): def run_test(self):
self.log.info("Testing reserved high-bandwidth mode slot for outbound peer...") self.log.info("Testing reserved high-bandwidth mode slot for outbound peer...")

View File

@ -192,7 +192,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
help="Don't stop dashds after the test execution") help="Don't stop dashds after the test execution")
parser.add_argument("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/../../cache"), parser.add_argument("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/../../cache"),
help="Directory for caching pregenerated datadirs (default: %(default)s)") help="Directory for caching pregenerated datadirs (default: %(default)s)")
parser.add_argument("--tmpdir", dest="tmpdir", help="Root directory for datadirs") parser.add_argument("--tmpdir", dest="tmpdir", help="Root directory for datadirs (must not exist)")
parser.add_argument("-l", "--loglevel", dest="loglevel", default="INFO", parser.add_argument("-l", "--loglevel", dest="loglevel", default="INFO",
help="log events at this level and higher to the console. Can be set to DEBUG, INFO, WARNING, ERROR or CRITICAL. Passing --loglevel DEBUG will output all logs to console. Note that logs at all levels are always written to the test_framework.log file in the temporary test directory.") help="log events at this level and higher to the console. Can be set to DEBUG, INFO, WARNING, ERROR or CRITICAL. Passing --loglevel DEBUG will output all logs to console. Note that logs at all levels are always written to the test_framework.log file in the temporary test directory.")
parser.add_argument("--tracerpc", dest="trace_rpc", default=False, action="store_true", parser.add_argument("--tracerpc", dest="trace_rpc", default=False, action="store_true",

View File

@ -22,6 +22,11 @@ if ! sed --help 2>&1 | grep -q 'GNU'; then
exit 1; exit 1;
fi fi
if ! grep --help 2>&1 | grep -q 'GNU'; then
echo "Error: the installed grep package is not compatible. Please make sure you have GNU grep installed in your system.";
exit 1;
fi
RET=0 RET=0
PREV_BRANCH=$(git name-rev --name-only HEAD) PREV_BRANCH=$(git name-rev --name-only HEAD)
PREV_HEAD=$(git rev-parse HEAD) PREV_HEAD=$(git rev-parse HEAD)