diff --git a/ci/test/00_setup_env_native_tsan.sh b/ci/test/00_setup_env_native_tsan.sh index f138845f492d..efb398f112fe 100755 --- a/ci/test/00_setup_env_native_tsan.sh +++ b/ci/test/00_setup_env_native_tsan.sh @@ -33,5 +33,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 --without-zstd --with-sanitizers=thread CC=clang-19 CXX=clang++-19" -export CPPFLAGS="-DARENA_DEBUG" +export CPPFLAGS="-DARENA_DEBUG -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES" export PYZMQ=true diff --git a/configure.ac b/configure.ac index 814b70ffdeea..c27e59ad5376 100644 --- a/configure.ac +++ b/configure.ac @@ -525,6 +525,7 @@ AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough], [WARN_CXXFLAGS="$WARN_CXXFLAGS - AX_CHECK_COMPILE_FLAG([-Wunreachable-code], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunreachable-code"], [], [$CXXFLAG_WERROR]) AX_CHECK_COMPILE_FLAG([-Wdocumentation], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wdocumentation"], [], [$CXXFLAG_WERROR]) AX_CHECK_COMPILE_FLAG([-Wself-assign], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wself-assign"], [], [$CXXFLAG_WERROR]) +AX_CHECK_COMPILE_FLAG([-Wundef], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wundef"], [], [$CXXFLAG_WERROR]) dnl Some compilers (gcc) ignore unknown -Wno-* options, but warn about all dnl unknown options if any other warning is produced. Test the -Wfoo case, and @@ -1720,6 +1721,9 @@ if test "$with_libmultiprocess" = "yes" || test "$with_libmultiprocess" = "auto" PKG_CHECK_MODULES([LIBMULTIPROCESS], [libmultiprocess], [ libmultiprocess_found=yes; libmultiprocess_prefix=`$PKG_CONFIG --variable=prefix libmultiprocess`; + if test "$suppress_external_warnings" != "no" ; then + LIBMULTIPROCESS_CFLAGS=SUPPRESS_WARNINGS($LIBMULTIPROCESS_CFLAGS) + fi ], [true]) elif test "$with_libmultiprocess" != "no"; then AC_MSG_ERROR([--with-libmultiprocess=$with_libmultiprocess value is not yes, auto, or no]) diff --git a/src/Makefile.am b/src/Makefile.am index 7069ea92ed85..bcddb95fca27 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1530,7 +1530,7 @@ libbitcoin_ipc_a_SOURCES = \ ipc/process.cpp \ ipc/process.h \ ipc/protocol.h -libbitcoin_ipc_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) +libbitcoin_ipc_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS) libbitcoin_ipc_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) $(LIBMULTIPROCESS_CFLAGS) include $(MPGEN_PREFIX)/include/mpgen.mk diff --git a/src/crypto/sha256.cpp b/src/crypto/sha256.cpp index 9e6405a1f142..ce6449b65a40 100644 --- a/src/crypto/sha256.cpp +++ b/src/crypto/sha256.cpp @@ -9,8 +9,9 @@ #include #include -#include -#include +#include +#include +#include #if !defined(DISABLE_OPTIMIZED_SHA256) #include diff --git a/src/crypto/x11/sph_types.h b/src/crypto/x11/sph_types.h index 6f3b8db480c6..da17d960062e 100644 --- a/src/crypto/x11/sph_types.h +++ b/src/crypto/x11/sph_types.h @@ -101,7 +101,7 @@ typedef int_fast64_t sph_s64; * Define SPH_INLINE to be an "inline" qualifier, if available. We define * some small macro-like functions which benefit greatly from being inlined. */ -#if (defined __STDC__ && __STDC_VERSION__ >= 199901L) || defined __GNUC__ +#if (defined __STDC__ && defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) || defined __GNUC__ #define SPH_INLINE inline #elif defined _MSC_VER #define SPH_INLINE __inline @@ -214,14 +214,14 @@ typedef int_fast64_t sph_s64; /* * MIPS, little-endian. */ -#elif MIPSEL || _MIPSEL || __MIPSEL || __MIPSEL__ +#elif defined MIPSEL || defined _MIPSEL || defined __MIPSEL || defined __MIPSEL__ #define SPH_DETECT_LITTLE_ENDIAN 1 /* * MIPS, big-endian. */ -#elif MIPSEB || _MIPSEB || __MIPSEB || __MIPSEB__ +#elif defined MIPSEB || defined _MIPSEB || defined __MIPSEB || defined __MIPSEB__ #define SPH_DETECT_BIG_ENDIAN 1 @@ -316,6 +316,35 @@ typedef int_fast64_t sph_s64; #define SPH_PPC64_GCC SPH_DETECT_PPC64_GCC #endif +/* + * Give the remaining feature macros an explicit value of 0 so they can be + * tested with #if under -Wundef. + */ +#ifndef SPH_UNALIGNED +#define SPH_UNALIGNED 0 +#endif +#ifndef SPH_LITTLE_ENDIAN +#define SPH_LITTLE_ENDIAN 0 +#endif +#ifndef SPH_BIG_ENDIAN +#define SPH_BIG_ENDIAN 0 +#endif +#ifndef SPH_I386_GCC +#define SPH_I386_GCC 0 +#endif +#ifndef SPH_AMD64_GCC +#define SPH_AMD64_GCC 0 +#endif +#ifndef SPH_SPARCV9_GCC +#define SPH_SPARCV9_GCC 0 +#endif +#ifndef SPH_SPARCV9_GCC_64 +#define SPH_SPARCV9_GCC_64 0 +#endif +#ifndef SPH_NO_ASM +#define SPH_NO_ASM 0 +#endif + #if SPH_LITTLE_ENDIAN && !defined SPH_LITTLE_FAST #define SPH_LITTLE_FAST 1 #endif diff --git a/src/init.cpp b/src/init.cpp index dc2a1cb95296..62c256026349 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -165,7 +165,7 @@ #include -#if ENABLE_ZMQ +#ifdef ENABLE_ZMQ #include #include #include @@ -489,7 +489,7 @@ void PrepareShutdown(NodeContext& node) client->stop(); } -#if ENABLE_ZMQ +#ifdef ENABLE_ZMQ if (g_zmq_notification_interface) { UnregisterValidationInterface(g_zmq_notification_interface.get()); g_zmq_notification_interface.reset(); @@ -693,7 +693,7 @@ void SetupServerArgs(ArgsManager& argsman) argsman.AddArg("-maxsendbuffer=", strprintf("Maximum per-connection memory usage for the send buffer, *1000 bytes (default: %u)", DEFAULT_MAXSENDBUFFER), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); argsman.AddArg("-maxtimeadjustment", strprintf("Maximum allowed median peer time offset adjustment. Local perspective of time may be influenced by outbound peers forward or backward by this amount (default: %u seconds).", DEFAULT_MAX_TIME_ADJUSTMENT), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); argsman.AddArg("-maxuploadtarget=", strprintf("Tries to keep outbound traffic under the given target per 24h. Limit does not apply to peers with 'download' permission or blocks created within past week. 0 = no limit (default: %s). Optional suffix units [k|K|m|M|g|G|t|T] (default: M). Lowercase is 1000 base while uppercase is 1024 base", DEFAULT_MAX_UPLOAD_TARGET), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); -#if HAVE_SOCKADDR_UN +#ifdef HAVE_SOCKADDR_UN argsman.AddArg("-onion=", "Use separate SOCKS5 proxy to reach peers via Tor onion services, set -noonion to disable (default: -proxy). May be a local file path prefixed with 'unix:'.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); #else argsman.AddArg("-onion=", "Use separate SOCKS5 proxy to reach peers via Tor onion services, set -noonion to disable (default: -proxy)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); @@ -706,10 +706,8 @@ void SetupServerArgs(ArgsManager& argsman) argsman.AddArg("-peerbloomfilters", strprintf("Support filtering of blocks and transaction with bloom filters (default: %u)", DEFAULT_PEERBLOOMFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); argsman.AddArg("-txreconciliation", strprintf("Enable transaction reconciliations per BIP 330 (default: %d)", DEFAULT_TXRECONCILIATION_ENABLE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CONNECTION); argsman.AddArg("-peertimeout=", 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); - // TODO: remove the sentence "Nodes not using ... incoming connections." once the changes from - // https://github.com/bitcoin/bitcoin/pull/23542 have become widespread. - argsman.AddArg("-port=", strprintf("Listen for connections on . Nodes not using the default ports (default: %u, testnet: %u, devnet: %u, regtest: %u) are unlikely to get incoming connections. Not relevant for I2P (see doc/i2p.md).", defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort(), devnetChainParams->GetDefaultPort(), regtestChainParams->GetDefaultPort()), ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION); -#if HAVE_SOCKADDR_UN + argsman.AddArg("-port=", strprintf("Listen for connections on (default: %u, testnet: %u, devnet: %u, regtest: %u). Not relevant for I2P (see doc/i2p.md).", defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort(), devnetChainParams->GetDefaultPort(), regtestChainParams->GetDefaultPort()), ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION); +#ifdef HAVE_SOCKADDR_UN argsman.AddArg("-proxy=", "Connect through SOCKS5 proxy, set -noproxy to disable (default: disabled). May be a local file path prefixed with 'unix:' if the proxy supports it.", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_ELISION, OptionsCategory::CONNECTION); #else argsman.AddArg("-proxy=", "Connect through SOCKS5 proxy, set -noproxy to disable (default: disabled)", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_ELISION, OptionsCategory::CONNECTION); @@ -743,7 +741,7 @@ void SetupServerArgs(ArgsManager& argsman) g_wallet_init_interface.AddWalletOptions(argsman); -#if ENABLE_ZMQ +#ifdef ENABLE_ZMQ argsman.AddArg("-zmqpubhashblock=
", "Enable publish hash block in
", ArgsManager::ALLOW_ANY, OptionsCategory::ZMQ); argsman.AddArg("-zmqpubhashchainlock=
", "Enable publish hash block (locked via ChainLocks) in
", ArgsManager::ALLOW_ANY, OptionsCategory::ZMQ); argsman.AddArg("-zmqpubhashgovernanceobject=
", "Enable publish hash of governance objects (like proposals) in
", ArgsManager::ALLOW_ANY, OptionsCategory::ZMQ); @@ -870,7 +868,7 @@ void SetupServerArgs(ArgsManager& argsman) "is of this size or less (default: %u)", MAX_OP_RETURN_RELAY), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY); - argsman.AddArg("-permitbaremultisig", strprintf("Relay non-P2SH multisig (default: %u)", DEFAULT_PERMIT_BAREMULTISIG), ArgsManager::ALLOW_ANY, + argsman.AddArg("-permitbaremultisig", strprintf("Relay transactions creating non-P2SH multisig outputs (default: %u)", DEFAULT_PERMIT_BAREMULTISIG), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY); argsman.AddArg("-minrelaytxfee=", strprintf("Fees (in %s/kB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)", CURRENCY_UNIT, FormatMoney(DEFAULT_MIN_RELAY_TX_FEE)), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY); @@ -1620,7 +1618,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) } #endif // ENABLE_WALLET -#if ENABLE_ZMQ +#ifdef ENABLE_ZMQ RegisterZMQRPCCommands(tableRPC); #endif @@ -1815,7 +1813,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) std::string host_out; uint16_t port_out{0}; if (!SplitHostPort(socket_addr, port_out, host_out)) { -#if HAVE_SOCKADDR_UN +#ifdef HAVE_SOCKADDR_UN // Allow unix domain sockets for some options e.g. unix:/some/file/path if (!unix || socket_addr.find(ADDR_PREFIX_UNIX) != 0) { return InitError(InvalidPortErrMsg(arg, socket_addr)); @@ -1968,7 +1966,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) return InitError(ResolveErrMsg("externalip", strAddr)); } -#if ENABLE_ZMQ +#ifdef ENABLE_ZMQ g_zmq_notification_interface = CZMQNotificationInterface::Create( [&chainman = node.chainman](CBlock& block, const CBlockIndex& index) { assert(chainman); diff --git a/src/init.h b/src/init.h index b0c6feb26031..6c4113cea5d2 100644 --- a/src/init.h +++ b/src/init.h @@ -9,8 +9,6 @@ #include #include -#include -#include //! Default value for -daemon option static constexpr bool DEFAULT_DAEMON = false; diff --git a/src/netbase.cpp b/src/netbase.cpp index d885f2efdab8..bed9c49c75d4 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -24,7 +24,7 @@ #include #include -#if HAVE_SOCKADDR_UN +#ifdef HAVE_SOCKADDR_UN #include #endif @@ -228,7 +228,7 @@ CService LookupNumeric(const std::string& name, uint16_t portDefault, DNSLookupF bool IsUnixSocketPath(const std::string& name) { -#if HAVE_SOCKADDR_UN +#ifdef HAVE_SOCKADDR_UN if (name.find(ADDR_PREFIX_UNIX) != 0) return false; // Split off "unix:" prefix @@ -512,7 +512,7 @@ std::unique_ptr CreateSockOS(sa_family_t address_family) if (address_family == AF_UNSPEC) return nullptr; int protocol{IPPROTO_TCP}; -#if HAVE_SOCKADDR_UN +#ifdef HAVE_SOCKADDR_UN if (address_family == AF_UNIX) protocol = 0; #endif @@ -547,7 +547,7 @@ std::unique_ptr CreateSockOS(sa_family_t address_family) return nullptr; } -#if HAVE_SOCKADDR_UN +#ifdef HAVE_SOCKADDR_UN if (address_family == AF_UNIX) return sock; #endif @@ -655,7 +655,7 @@ std::unique_ptr Proxy::Connect() const if (!m_is_unix_socket) return ConnectDirectly(proxy, /*manual_connection=*/true); -#if HAVE_SOCKADDR_UN +#ifdef HAVE_SOCKADDR_UN auto sock = CreateSock(AF_UNIX); if (!sock) { LogPrintLevel(BCLog::NET, BCLog::Level::Error, "Cannot create a socket for connecting to %s\n", m_unix_socket_path); diff --git a/src/randomenv.cpp b/src/randomenv.cpp index 047ca914b38e..af74b380868c 100644 --- a/src/randomenv.cpp +++ b/src/randomenv.cpp @@ -43,15 +43,15 @@ #if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS #include #endif -#if HAVE_SYSCTL +#ifdef HAVE_SYSCTL #include -#if HAVE_VM_VM_PARAM_H +#ifdef HAVE_VM_VM_PARAM_H #include #endif -#if HAVE_SYS_RESOURCES_H +#ifdef HAVE_SYS_RESOURCES_H #include #endif -#if HAVE_SYS_VMMETER_H +#ifdef HAVE_SYS_VMMETER_H #include #endif #endif @@ -166,7 +166,7 @@ void AddPath(CSHA512& hasher, const char *path) } #endif -#if HAVE_SYSCTL +#ifdef HAVE_SYSCTL template void AddSysctl(CSHA512& hasher) { @@ -278,7 +278,7 @@ void RandAddDynamicEnv(CSHA512& hasher) AddFile(hasher, "/proc/self/status"); #endif -#if HAVE_SYSCTL +#ifdef HAVE_SYSCTL # ifdef CTL_KERN # if defined(KERN_PROC) && defined(KERN_PROC_ALL) AddSysctl(hasher); @@ -423,7 +423,7 @@ void RandAddStaticEnv(CSHA512& hasher) // For MacOS/BSDs, gather data through sysctl instead of /proc. Not all of these // will exist on every system. -#if HAVE_SYSCTL +#ifdef HAVE_SYSCTL # ifdef CTL_HW # ifdef HW_MACHINE AddSysctl(hasher); diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 8da6d0e80563..d8cfbbf36961 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -37,7 +37,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "setmocktime", 0, "timestamp" }, { "mockscheduler", 0, "delta_time" }, { "utxoupdatepsbt", 1, "descriptors" }, -#if ENABLE_MINER +#ifdef ENABLE_MINER { "generatetoaddress", 0, "nblocks" }, { "generatetoaddress", 2, "maxtries" }, { "generatetodescriptor", 0, "num_blocks" }, diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index d63c50dbf228..a7988416f98b 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -136,7 +136,7 @@ static RPCHelpMan getnetworkhashps() }; } -#if ENABLE_MINER +#ifdef ENABLE_MINER static bool GenerateBlock(ChainstateManager& chainman, CBlock& block, uint64_t& max_tries, std::shared_ptr& block_out, bool process_new_block) { block_out.reset(); diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp index 939d39ae9b89..4e822eedda8f 100644 --- a/src/test/rpc_tests.cpp +++ b/src/test/rpc_tests.cpp @@ -405,7 +405,7 @@ BOOST_AUTO_TEST_CASE(rpc_ban) BOOST_CHECK_EQUAL(adr.get_str(), "2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/128"); } -#if ENABLE_MINER +#ifdef ENABLE_MINER BOOST_AUTO_TEST_CASE(rpc_convert_values_generatetoaddress) { UniValue result; diff --git a/test/functional/mempool_accept.py b/test/functional/mempool_accept.py index 1fe8488f73ef..b93a018bf3bf 100755 --- a/test/functional/mempool_accept.py +++ b/test/functional/mempool_accept.py @@ -27,6 +27,8 @@ OP_HASH160, OP_RETURN, OP_TRUE, + SIGHASH_ALL, + sign_input, ) from test_framework.script_util import ( keys_to_multisig_script, @@ -388,5 +390,24 @@ def run_test(self): maxfeerate=0, ) + self.log.info('Spending a confirmed bare multisig is okay') + address = self.wallet.get_address() + tx = tx_from_hex(raw_tx_reference) + privkey, pubkey = generate_keypair() + tx.vout[0].scriptPubKey = keys_to_multisig_script([pubkey] * 3, k=1) # Some bare multisig script (1-of-3) + tx.rehash() + self.generateblock(node, address, [tx.serialize().hex()]) + tx_spend = CTransaction() + tx_spend.vin.append(CTxIn(COutPoint(tx.sha256, 0), b"")) + tx_spend.vout.append(CTxOut(tx.vout[0].nValue - int(fee*COIN), script_to_p2sh_script(CScript([OP_TRUE])))) + tx_spend.rehash() + sign_input(tx_spend, 0, tx.vout[0].scriptPubKey, privkey, sighash_type=SIGHASH_ALL) + tx_spend.vin[0].scriptSig = bytes(CScript([OP_0])) + tx_spend.vin[0].scriptSig + self.check_mempool_result( + result_expected=[{'txid': tx_spend.rehash(), 'allowed': True, 'vsize': tx_spend.get_vsize(), 'fees': { 'base': Decimal('0.00000700')}}], + rawtxs=[tx_spend.serialize().hex()], + maxfeerate=0, + ) + if __name__ == '__main__': MempoolAcceptanceTest().main()