From 5555d5dcb55969f6b5eefcf8733b628b2f36f8c7 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Thu, 30 Jul 2026 16:33:48 +0200 Subject: [PATCH] scripted-diff: Use inline constexpr over static constexpr Both are fine and this refactor shouldn't change any behavior. However, inline constexpr will ensure each symbol has a single address across all TU, making the release binary smaller. Review note: In theory the script may also cover functions, but they were handled in the prior commit, to remove the redundant inline for them. -BEGIN VERIFY SCRIPT- sed --regexp-extended -i 's/^(static constexpr|constexpr static)\>/inline constexpr/g' $( \ git grep --extended-regexp -l '^(static constexpr|constexpr static)' -- \ '*.h' \ ':(exclude)src/crc32c' \ ':(exclude)src/ipc/libmultiprocess' \ ':(exclude)src/minisketch' \ ) -END VERIFY SCRIPT- --- src/addrman.h | 22 ++--- src/addrman_impl.h | 12 +-- src/banman.h | 4 +- src/bech32.h | 4 +- src/bip324.h | 2 +- src/chain.h | 8 +- src/common/bloom.h | 4 +- src/consensus/amount.h | 4 +- src/consensus/consensus.h | 4 +- src/consensus/validation.h | 4 +- src/i2p.h | 2 +- src/index/blockfilterindex.h | 2 +- src/index/coinstatsindex.h | 2 +- src/index/db_key.h | 4 +- src/index/txindex.h | 2 +- src/index/txospenderindex.h | 2 +- src/init.h | 4 +- src/kernel/blockmanager_opts.h | 2 +- src/kernel/caches.h | 12 +-- src/kernel/chainstatemanager_opts.h | 4 +- src/kernel/mempool_options.h | 10 +-- src/key.h | 2 +- src/logging.h | 2 +- src/mapport.h | 2 +- src/net.h | 20 ++--- src/net_processing.h | 6 +- src/netaddress.h | 16 ++-- src/node/blockstorage.h | 4 +- src/node/caches.h | 2 +- src/node/chainstatemanager_args.h | 2 +- src/node/kernel_notifications.h | 2 +- src/node/mempool_persist_args.h | 2 +- src/node/txdownloadman.h | 12 +-- src/node/txorphanage.h | 4 +- src/node/txreconciliation.h | 2 +- src/node/utxo_snapshot.h | 2 +- src/outputtype.h | 2 +- src/policy/fees/block_policy_estimator.h | 8 +- src/policy/packages.h | 4 +- src/policy/policy.h | 64 +++++++-------- src/policy/rbf.h | 2 +- src/policy/truc_policy.h | 14 ++-- src/primitives/transaction.h | 4 +- src/protocol.h | 4 +- src/psbt.h | 100 +++++++++++------------ src/qt/guiconstants.h | 8 +- src/qt/modaloverlay.h | 2 +- src/qt/optionsmodel.h | 2 +- src/qt/qrimagewidget.h | 6 +- src/rpc/blockchain.h | 2 +- src/rpc/util.h | 2 +- src/script/interpreter.h | 24 +++--- src/script/miniscript.h | 2 +- src/script/script.h | 8 +- src/script/sigcache.h | 6 +- src/serialize.h | 2 +- src/test/util/setup_common.h | 2 +- src/test/util/versionbits.h | 2 +- src/txgraph.h | 2 +- src/txmempool.h | 4 +- src/util/rbf.h | 2 +- src/util/sock.h | 2 +- src/validation.h | 6 +- src/wallet/coincontrol.h | 2 +- src/wallet/coinselection.h | 4 +- src/wallet/scriptpubkeyman.h | 2 +- src/wallet/wallet.h | 6 +- 67 files changed, 247 insertions(+), 247 deletions(-) diff --git a/src/addrman.h b/src/addrman.h index 9449c938ca1..70697f76e64 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -23,25 +23,25 @@ class NetGroupManager; /** Over how many buckets entries with tried addresses from a single group (/16 for IPv4) are spread */ -static constexpr uint32_t ADDRMAN_TRIED_BUCKETS_PER_GROUP{8}; +inline constexpr uint32_t ADDRMAN_TRIED_BUCKETS_PER_GROUP{8}; /** Over how many buckets entries with new addresses originating from a single group are spread */ -static constexpr uint32_t ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP{64}; +inline constexpr uint32_t ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP{64}; /** Maximum number of times an address can occur in the new table */ -static constexpr int32_t ADDRMAN_NEW_BUCKETS_PER_ADDRESS{8}; +inline constexpr int32_t ADDRMAN_NEW_BUCKETS_PER_ADDRESS{8}; /** How old addresses can maximally be */ -static constexpr auto ADDRMAN_HORIZON{30 * 24h}; +inline constexpr auto ADDRMAN_HORIZON{30 * 24h}; /** After how many failed attempts we give up on a new node */ -static constexpr int32_t ADDRMAN_RETRIES{3}; +inline constexpr int32_t ADDRMAN_RETRIES{3}; /** How many successive failures are allowed ... */ -static constexpr int32_t ADDRMAN_MAX_FAILURES{10}; +inline constexpr int32_t ADDRMAN_MAX_FAILURES{10}; /** ... in at least this duration */ -static constexpr auto ADDRMAN_MIN_FAIL{7 * 24h}; +inline constexpr auto ADDRMAN_MIN_FAIL{7 * 24h}; /** How recent a successful connection should be before we allow an address to be evicted from tried */ -static constexpr auto ADDRMAN_REPLACEMENT{4h}; +inline constexpr auto ADDRMAN_REPLACEMENT{4h}; /** The maximum number of tried addr collisions to store */ -static constexpr size_t ADDRMAN_SET_TRIED_COLLISION_SIZE{10}; +inline constexpr size_t ADDRMAN_SET_TRIED_COLLISION_SIZE{10}; /** The maximum time we'll spend trying to resolve a tried table collision */ -static constexpr auto ADDRMAN_TEST_WINDOW{40min}; +inline constexpr auto ADDRMAN_TEST_WINDOW{40min}; class InvalidAddrManVersionError : public std::ios_base::failure { @@ -53,7 +53,7 @@ class AddrManImpl; class AddrInfo; /** Default for -checkaddrman */ -static constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS{0}; +inline constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS{0}; /** Location information for an address in AddrMan */ struct AddressPosition { diff --git a/src/addrman_impl.h b/src/addrman_impl.h index 88ee92e1b04..e6e2cab8dce 100644 --- a/src/addrman_impl.h +++ b/src/addrman_impl.h @@ -23,14 +23,14 @@ #include /** Total number of buckets for tried addresses */ -static constexpr int32_t ADDRMAN_TRIED_BUCKET_COUNT_LOG2{8}; -static constexpr int ADDRMAN_TRIED_BUCKET_COUNT{1 << ADDRMAN_TRIED_BUCKET_COUNT_LOG2}; +inline constexpr int32_t ADDRMAN_TRIED_BUCKET_COUNT_LOG2{8}; +inline constexpr int ADDRMAN_TRIED_BUCKET_COUNT{1 << ADDRMAN_TRIED_BUCKET_COUNT_LOG2}; /** Total number of buckets for new addresses */ -static constexpr int32_t ADDRMAN_NEW_BUCKET_COUNT_LOG2{10}; -static constexpr int ADDRMAN_NEW_BUCKET_COUNT{1 << ADDRMAN_NEW_BUCKET_COUNT_LOG2}; +inline constexpr int32_t ADDRMAN_NEW_BUCKET_COUNT_LOG2{10}; +inline constexpr int ADDRMAN_NEW_BUCKET_COUNT{1 << ADDRMAN_NEW_BUCKET_COUNT_LOG2}; /** Maximum allowed number of entries in buckets for new and tried addresses */ -static constexpr int32_t ADDRMAN_BUCKET_SIZE_LOG2{6}; -static constexpr int ADDRMAN_BUCKET_SIZE{1 << ADDRMAN_BUCKET_SIZE_LOG2}; +inline constexpr int32_t ADDRMAN_BUCKET_SIZE_LOG2{6}; +inline constexpr int ADDRMAN_BUCKET_SIZE{1 << ADDRMAN_BUCKET_SIZE_LOG2}; /** * User-defined type for the internally used nIds diff --git a/src/banman.h b/src/banman.h index 93149e63c5a..815e2438ae2 100644 --- a/src/banman.h +++ b/src/banman.h @@ -16,10 +16,10 @@ #include // NOTE: When adjusting this, update rpcnet:setban's help ("24h") -static constexpr unsigned int DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24; // Default 24-hour ban +inline constexpr unsigned int DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24; // Default 24-hour ban /// How often to dump banned addresses/subnets to disk. -static constexpr std::chrono::minutes DUMP_BANS_INTERVAL{15}; +inline constexpr std::chrono::minutes DUMP_BANS_INTERVAL{15}; class CClientUIInterface; class CNetAddr; diff --git a/src/bech32.h b/src/bech32.h index 9a43a58f396..f16aa8559b5 100644 --- a/src/bech32.h +++ b/src/bech32.h @@ -23,8 +23,8 @@ namespace bech32 { -static constexpr size_t CHECKSUM_SIZE = 6; -static constexpr char SEPARATOR = '1'; +inline constexpr size_t CHECKSUM_SIZE = 6; +inline constexpr char SEPARATOR = '1'; enum class Encoding { INVALID, //!< Failed decoding diff --git a/src/bip324.h b/src/bip324.h index 821cc3f759f..276f71e4a89 100644 --- a/src/bip324.h +++ b/src/bip324.h @@ -15,7 +15,7 @@ #include #include -static constexpr unsigned BIP324_SHORTIDS_IMPLEMENTED{38}; +inline constexpr unsigned BIP324_SHORTIDS_IMPLEMENTED{38}; /** The BIP324 packet cipher, encapsulating its key derivation, stream cipher, and AEAD. */ class BIP324Cipher diff --git a/src/chain.h b/src/chain.h index 7701e9262a4..1ca218458b9 100644 --- a/src/chain.h +++ b/src/chain.h @@ -26,7 +26,7 @@ * Maximum amount of time that a block timestamp is allowed to exceed the * current time before the block will be accepted. */ -static constexpr int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60; +inline constexpr int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60; /** * Timestamp window used as a grace period by code that compares external @@ -34,10 +34,10 @@ static constexpr int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60; * to block timestamps. This should be set at least as high as * MAX_FUTURE_BLOCK_TIME. */ -static constexpr int64_t TIMESTAMP_WINDOW = MAX_FUTURE_BLOCK_TIME; +inline constexpr int64_t TIMESTAMP_WINDOW = MAX_FUTURE_BLOCK_TIME; //! Init values for CBlockIndex nSequenceId when loaded from disk -static constexpr int32_t SEQ_ID_BEST_CHAIN_FROM_DISK = 0; -static constexpr int32_t SEQ_ID_INIT_FROM_DISK = 1; +inline constexpr int32_t SEQ_ID_BEST_CHAIN_FROM_DISK = 0; +inline constexpr int32_t SEQ_ID_INIT_FROM_DISK = 1; enum BlockStatus : uint32_t { //! Unused. diff --git a/src/common/bloom.h b/src/common/bloom.h index c9ed89f85e3..49d45552e45 100644 --- a/src/common/bloom.h +++ b/src/common/bloom.h @@ -15,8 +15,8 @@ class COutPoint; class CTransaction; //! 20,000 items with fp rate < 0.1% or 10,000 items and <0.0001% -static constexpr unsigned int MAX_BLOOM_FILTER_SIZE = 36000; // bytes -static constexpr unsigned int MAX_HASH_FUNCS = 50; +inline constexpr unsigned int MAX_BLOOM_FILTER_SIZE = 36000; // bytes +inline constexpr unsigned int MAX_HASH_FUNCS = 50; /** * First two bits of nFlags control how much IsRelevantAndUpdate actually updates diff --git a/src/consensus/amount.h b/src/consensus/amount.h index 2a65a83123e..684c28569fc 100644 --- a/src/consensus/amount.h +++ b/src/consensus/amount.h @@ -12,7 +12,7 @@ typedef int64_t CAmount; /** The amount of satoshis in one BTC. */ -static constexpr CAmount COIN = 100000000; +inline constexpr CAmount COIN = 100000000; /** No amount larger than this (in satoshi) is valid. * @@ -23,7 +23,7 @@ static constexpr CAmount COIN = 100000000; * critical; in unusual circumstances like a(nother) overflow bug that allowed * for the creation of coins out of thin air modification could lead to a fork. * */ -static constexpr CAmount MAX_MONEY = 21000000 * COIN; +inline constexpr CAmount MAX_MONEY = 21000000 * COIN; inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); } #endif // BITCOIN_CONSENSUS_AMOUNT_H diff --git a/src/consensus/consensus.h b/src/consensus/consensus.h index 71b5fe2468d..5d22d58284d 100644 --- a/src/consensus/consensus.h +++ b/src/consensus/consensus.h @@ -25,13 +25,13 @@ static const size_t MIN_SERIALIZABLE_TRANSACTION_WEIGHT = WITNESS_SCALE_FACTOR * /** Flags for nSequence and nLockTime locks */ /** Interpret sequence numbers as relative lock-time constraints. */ -static constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE = (1 << 0); +inline constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE = (1 << 0); /** * Maximum number of seconds that the timestamp of the first * block of a difficulty adjustment period is allowed to * be earlier than the last block of the previous period (BIP94). */ -static constexpr int64_t MAX_TIMEWARP = 600; +inline constexpr int64_t MAX_TIMEWARP = 600; #endif // BITCOIN_CONSENSUS_CONSENSUS_H diff --git a/src/consensus/validation.h b/src/consensus/validation.h index 37a40e767e2..b23033fce25 100644 --- a/src/consensus/validation.h +++ b/src/consensus/validation.h @@ -12,10 +12,10 @@ #include /** Index marker for when no witness commitment is present in a coinbase transaction. */ -static constexpr int NO_WITNESS_COMMITMENT{-1}; +inline constexpr int NO_WITNESS_COMMITMENT{-1}; /** Minimum size of a witness commitment structure. Defined in BIP 141. **/ -static constexpr size_t MINIMUM_WITNESS_COMMITMENT{38}; +inline constexpr size_t MINIMUM_WITNESS_COMMITMENT{38}; /** A "reason" why a transaction was invalid, suitable for determining whether the * provider of the transaction should be banned/ignored/disconnected/etc. diff --git a/src/i2p.h b/src/i2p.h index 38556d8744a..9cba32c9830 100644 --- a/src/i2p.h +++ b/src/i2p.h @@ -48,7 +48,7 @@ namespace sam { * The longest known message is ~1400 bytes, so this is high enough not to be triggered during * normal operation, yet low enough to avoid a malicious proxy from filling our memory. */ -static constexpr size_t MAX_MSG_SIZE{65536}; +inline constexpr size_t MAX_MSG_SIZE{65536}; /** * I2P SAM session. diff --git a/src/index/blockfilterindex.h b/src/index/blockfilterindex.h index 0bb4a74e125..77b87ff4765 100644 --- a/src/index/blockfilterindex.h +++ b/src/index/blockfilterindex.h @@ -28,7 +28,7 @@ enum class BlockFilterType : uint8_t; static const char* const DEFAULT_BLOCKFILTERINDEX = "0"; /** Interval between compact filter checkpoints. See BIP 157. */ -static constexpr int CFCHECKPT_INTERVAL = 1000; +inline constexpr int CFCHECKPT_INTERVAL = 1000; /** * BlockFilterIndex is used to store and retrieve block filters, hashes, and headers for a range of diff --git a/src/index/coinstatsindex.h b/src/index/coinstatsindex.h index 0e26fba56d9..fe61cbc7a68 100644 --- a/src/index/coinstatsindex.h +++ b/src/index/coinstatsindex.h @@ -22,7 +22,7 @@ namespace kernel { struct CCoinsStats; } -static constexpr bool DEFAULT_COINSTATSINDEX{false}; +inline constexpr bool DEFAULT_COINSTATSINDEX{false}; /** * CoinStatsIndex maintains statistics on the UTXO set. diff --git a/src/index/db_key.h b/src/index/db_key.h index 7c31f8afb8a..ffea70db2da 100644 --- a/src/index/db_key.h +++ b/src/index/db_key.h @@ -26,8 +26,8 @@ namespace index_util { * Keys for the hash index have the type [DB_BLOCK_HASH, uint256]. */ -static constexpr uint8_t DB_BLOCK_HASH{'s'}; -static constexpr uint8_t DB_BLOCK_HEIGHT{'t'}; +inline constexpr uint8_t DB_BLOCK_HASH{'s'}; +inline constexpr uint8_t DB_BLOCK_HEIGHT{'t'}; struct DBHeightKey { int height; diff --git a/src/index/txindex.h b/src/index/txindex.h index 0358e0ae49f..f35b9495767 100644 --- a/src/index/txindex.h +++ b/src/index/txindex.h @@ -16,7 +16,7 @@ namespace interfaces { class Chain; } -static constexpr bool DEFAULT_TXINDEX{false}; +inline constexpr bool DEFAULT_TXINDEX{false}; /** * TxIndex is used to look up transactions included in the blockchain by hash. diff --git a/src/index/txospenderindex.h b/src/index/txospenderindex.h index 35ca30d8b31..9a2103ca718 100644 --- a/src/index/txospenderindex.h +++ b/src/index/txospenderindex.h @@ -21,7 +21,7 @@ struct CDiskTxPos; -static constexpr bool DEFAULT_TXOSPENDERINDEX{false}; +inline constexpr bool DEFAULT_TXOSPENDERINDEX{false}; struct TxoSpender { CTransactionRef tx; diff --git a/src/init.h b/src/init.h index f3a55da35ee..ef0588a9c89 100644 --- a/src/init.h +++ b/src/init.h @@ -9,9 +9,9 @@ #include //! Default value for -daemon option -static constexpr bool DEFAULT_DAEMON = false; +inline constexpr bool DEFAULT_DAEMON = false; //! Default value for -daemonwait option -static constexpr bool DEFAULT_DAEMONWAIT = false; +inline constexpr bool DEFAULT_DAEMONWAIT = false; class ArgsManager; namespace interfaces { diff --git a/src/kernel/blockmanager_opts.h b/src/kernel/blockmanager_opts.h index 3d8af68b808..396a3ff1d93 100644 --- a/src/kernel/blockmanager_opts.h +++ b/src/kernel/blockmanager_opts.h @@ -15,7 +15,7 @@ class CChainParams; namespace kernel { -static constexpr bool DEFAULT_XOR_BLOCKSDIR{true}; +inline constexpr bool DEFAULT_XOR_BLOCKSDIR{true}; /** * An options struct for `BlockManager`, more ergonomically referred to as diff --git a/src/kernel/caches.h b/src/kernel/caches.h index 6bc10c92355..c355ed0a4bd 100644 --- a/src/kernel/caches.h +++ b/src/kernel/caches.h @@ -12,18 +12,18 @@ #include //! Minimum total database cache (bytes) -static constexpr uint64_t MIN_DBCACHE_BYTES{4_MiB}; +inline constexpr uint64_t MIN_DBCACHE_BYTES{4_MiB}; //! Maximum total database cache on current architecture (bytes) -static constexpr uint64_t MAX_DBCACHE_BYTES{sizeof(void*) == 4 ? 1_GiB : std::numeric_limits::max()}; +inline constexpr uint64_t MAX_DBCACHE_BYTES{sizeof(void*) == 4 ? 1_GiB : std::numeric_limits::max()}; //! Suggested default amount of cache reserved for the kernel (bytes) -static constexpr uint64_t DEFAULT_KERNEL_CACHE{450_MiB}; +inline constexpr uint64_t DEFAULT_KERNEL_CACHE{450_MiB}; //! Default LevelDB write batch size -static constexpr uint64_t DEFAULT_DB_CACHE_BATCH{32_MiB}; +inline constexpr uint64_t DEFAULT_DB_CACHE_BATCH{32_MiB}; //! Max memory allocated to block tree DB specific cache (bytes) -static constexpr uint64_t MAX_BLOCK_DB_CACHE{2_MiB}; +inline constexpr uint64_t MAX_BLOCK_DB_CACHE{2_MiB}; //! Max memory allocated to coin DB specific cache (bytes) -static constexpr uint64_t MAX_COINS_DB_CACHE{8_MiB}; +inline constexpr uint64_t MAX_COINS_DB_CACHE{8_MiB}; namespace kernel { struct CacheSizes { diff --git a/src/kernel/chainstatemanager_opts.h b/src/kernel/chainstatemanager_opts.h index 554d032eddc..806331caed9 100644 --- a/src/kernel/chainstatemanager_opts.h +++ b/src/kernel/chainstatemanager_opts.h @@ -21,8 +21,8 @@ class CChainParams; class ValidationSignals; -static constexpr auto DEFAULT_MAX_TIP_AGE{24h}; -static constexpr int32_t DEFAULT_PREVOUTFETCH_THREADS{8}; +inline constexpr auto DEFAULT_MAX_TIP_AGE{24h}; +inline constexpr int32_t DEFAULT_PREVOUTFETCH_THREADS{8}; namespace kernel { diff --git a/src/kernel/mempool_options.h b/src/kernel/mempool_options.h index 392c837fbbf..80b5316eee6 100644 --- a/src/kernel/mempool_options.h +++ b/src/kernel/mempool_options.h @@ -16,15 +16,15 @@ class ValidationSignals; /** Default for -maxmempool, maximum megabytes of mempool memory usage */ -static constexpr unsigned int DEFAULT_MAX_MEMPOOL_SIZE_MB{300}; +inline constexpr unsigned int DEFAULT_MAX_MEMPOOL_SIZE_MB{300}; /** Default for -maxmempool when blocksonly is set */ -static constexpr unsigned int DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB{5}; +inline constexpr unsigned int DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB{5}; /** Default for -mempoolexpiry, expiration time for mempool transactions in hours */ -static constexpr unsigned int DEFAULT_MEMPOOL_EXPIRY_HOURS{336}; +inline constexpr unsigned int DEFAULT_MEMPOOL_EXPIRY_HOURS{336}; /** Whether to fall back to legacy V1 serialization when writing mempool.dat */ -static constexpr bool DEFAULT_PERSIST_V1_DAT{false}; +inline constexpr bool DEFAULT_PERSIST_V1_DAT{false}; /** Default for -acceptnonstdtxn */ -static constexpr bool DEFAULT_ACCEPT_NON_STD_TXN{false}; +inline constexpr bool DEFAULT_ACCEPT_NON_STD_TXN{false}; namespace kernel { /** diff --git a/src/key.h b/src/key.h index 56f416ea8d0..87b130a8732 100644 --- a/src/key.h +++ b/src/key.h @@ -25,7 +25,7 @@ typedef struct secp256k1_context_struct secp256k1_context; typedef std::vector > CPrivKey; /** Size of ECDH shared secrets. */ -constexpr static size_t ECDH_SECRET_SIZE = CSHA256::OUTPUT_SIZE; +inline constexpr size_t ECDH_SECRET_SIZE = CSHA256::OUTPUT_SIZE; // Used to represent ECDH shared secret (ECDH_SECRET_SIZE bytes) using ECDHSecret = std::array; diff --git a/src/logging.h b/src/logging.h index 4bdcd0f241d..688f2b607f0 100644 --- a/src/logging.h +++ b/src/logging.h @@ -32,7 +32,7 @@ static const bool DEFAULT_LOGIPS = false; static const bool DEFAULT_LOGTIMESTAMPS = true; static const bool DEFAULT_LOGTHREADNAMES = false; static const bool DEFAULT_LOGSOURCELOCATIONS = false; -static constexpr bool DEFAULT_LOGLEVELALWAYS = false; +inline constexpr bool DEFAULT_LOGLEVELALWAYS = false; extern const char * const DEFAULT_DEBUGLOGFILE; extern bool fLogIPs; diff --git a/src/mapport.h b/src/mapport.h index 2133907badb..a33f9c609df 100644 --- a/src/mapport.h +++ b/src/mapport.h @@ -5,7 +5,7 @@ #ifndef BITCOIN_MAPPORT_H #define BITCOIN_MAPPORT_H -static constexpr bool DEFAULT_NATPMP = true; +inline constexpr bool DEFAULT_NATPMP = true; void StartMapPort(bool enable); void InterruptMapPort(); diff --git a/src/net.h b/src/net.h index 04c26a11e5e..9911d91fb92 100644 --- a/src/net.h +++ b/src/net.h @@ -56,11 +56,11 @@ class CScheduler; struct bilingual_str; /** Time after which to disconnect, after waiting for a ping response (or inactivity). */ -static constexpr std::chrono::minutes TIMEOUT_INTERVAL{20}; +inline constexpr std::chrono::minutes TIMEOUT_INTERVAL{20}; /** Run the feeler connection loop once every 2 minutes. **/ -static constexpr auto FEELER_INTERVAL = 2min; +inline constexpr auto FEELER_INTERVAL = 2min; /** Run the extra block-relay-only connection loop once every 5 minutes. **/ -static constexpr auto EXTRA_BLOCK_RELAY_ONLY_PEER_INTERVAL = 5min; +inline constexpr auto EXTRA_BLOCK_RELAY_ONLY_PEER_INTERVAL = 5min; /** Maximum length of incoming protocol messages (no message over 4 MB is currently acceptable). */ static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1000 * 1000; /** Maximum length of the user agent string in `version` message */ @@ -74,7 +74,7 @@ static const int MAX_BLOCK_RELAY_ONLY_CONNECTIONS = 2; /** Maximum number of feeler connections */ static const int MAX_FEELER_CONNECTIONS = 1; /** Maximum number of private broadcast connections */ -static constexpr size_t MAX_PRIVATE_BROADCAST_CONNECTIONS{64}; +inline constexpr size_t MAX_PRIVATE_BROADCAST_CONNECTIONS{64}; /** -listen default */ static const bool DEFAULT_LISTEN = true; /** The maximum number of peer connections to maintain. */ @@ -88,19 +88,19 @@ static const bool DEFAULT_BLOCKSONLY = false; /** -peertimeout default */ static const int64_t DEFAULT_PEER_CONNECT_TIMEOUT = 60; /** Default for -privatebroadcast. */ -static constexpr bool DEFAULT_PRIVATE_BROADCAST{false}; +inline constexpr bool DEFAULT_PRIVATE_BROADCAST{false}; /** Number of file descriptors required for message capture **/ static const int NUM_FDS_MESSAGE_CAPTURE = 1; /** Interval for ASMap Health Check **/ -static constexpr std::chrono::hours ASMAP_HEALTH_CHECK_INTERVAL{24}; +inline constexpr std::chrono::hours ASMAP_HEALTH_CHECK_INTERVAL{24}; -static constexpr bool DEFAULT_FORCEDNSSEED{false}; -static constexpr bool DEFAULT_DNSSEED{true}; -static constexpr bool DEFAULT_FIXEDSEEDS{true}; +inline constexpr bool DEFAULT_FORCEDNSSEED{false}; +inline constexpr bool DEFAULT_DNSSEED{true}; +inline constexpr bool DEFAULT_FIXEDSEEDS{true}; static const size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000; static const size_t DEFAULT_MAXSENDBUFFER = 1 * 1000; -static constexpr bool DEFAULT_V2_TRANSPORT{true}; +inline constexpr bool DEFAULT_V2_TRANSPORT{true}; typedef int64_t NodeId; diff --git a/src/net_processing.h b/src/net_processing.h index a381a6d80bc..50c329e2891 100644 --- a/src/net_processing.h +++ b/src/net_processing.h @@ -38,12 +38,12 @@ class Warnings; } // namespace node /** Whether transaction reconciliation protocol should be enabled by default. */ -static constexpr bool DEFAULT_TXRECONCILIATION_ENABLE{false}; +inline constexpr bool DEFAULT_TXRECONCILIATION_ENABLE{false}; /** Default number of non-mempool transactions to keep around for block reconstruction. Includes orphan, replaced, and rejected transactions. */ static const uint32_t DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN{100}; /** Default maximum per-second rate for sending transaction inventory to peers. */ -static constexpr unsigned int DEFAULT_TX_SEND_RATE{14}; +inline constexpr unsigned int DEFAULT_TX_SEND_RATE{14}; static const bool DEFAULT_PEERBLOOMFILTERS = false; static const bool DEFAULT_PEERBLOCKFILTERS = false; /** Maximum number of outstanding CMPCTBLOCK requests for the same block. */ @@ -52,7 +52,7 @@ static const unsigned int MAX_CMPCTBLOCKS_INFLIGHT_PER_BLOCK = 3; * less than this number, we reached its tip. Changing this value is a protocol upgrade. */ static const unsigned int MAX_HEADERS_RESULTS = 2000; /** The compactblocks version we support. See BIP 152. */ -static constexpr uint64_t CMPCTBLOCKS_VERSION{2}; +inline constexpr uint64_t CMPCTBLOCKS_VERSION{2}; struct CNodeStateStats { int nSyncHeight = -1; diff --git a/src/netaddress.h b/src/netaddress.h index 2191da54b76..60028fd7aca 100644 --- a/src/netaddress.h +++ b/src/netaddress.h @@ -80,29 +80,29 @@ static const std::array INTERNAL_IN_IPV6_PREFIX{ /// All CJDNS addresses start with 0xFC. See /// https://github.com/cjdelisle/cjdns/blob/master/doc/Whitepaper.md#pulling-it-all-together -static constexpr uint8_t CJDNS_PREFIX{0xFC}; +inline constexpr uint8_t CJDNS_PREFIX{0xFC}; /// Size of IPv4 address (in bytes). -static constexpr size_t ADDR_IPV4_SIZE = 4; +inline constexpr size_t ADDR_IPV4_SIZE = 4; /// Size of IPv6 address (in bytes). -static constexpr size_t ADDR_IPV6_SIZE = 16; +inline constexpr size_t ADDR_IPV6_SIZE = 16; /// Size of TORv3 address (in bytes). This is the length of just the address /// as used in BIP155, without the checksum and the version byte. -static constexpr size_t ADDR_TORV3_SIZE = 32; +inline constexpr size_t ADDR_TORV3_SIZE = 32; /// Size of I2P address (in bytes). -static constexpr size_t ADDR_I2P_SIZE = 32; +inline constexpr size_t ADDR_I2P_SIZE = 32; /// Size of CJDNS address (in bytes). -static constexpr size_t ADDR_CJDNS_SIZE = 16; +inline constexpr size_t ADDR_CJDNS_SIZE = 16; /// Size of "internal" (NET_INTERNAL) address (in bytes). -static constexpr size_t ADDR_INTERNAL_SIZE = 10; +inline constexpr size_t ADDR_INTERNAL_SIZE = 10; /// SAM 3.1 and earlier do not support specifying ports and force the port to 0. -static constexpr uint16_t I2P_SAM31_PORT{0}; +inline constexpr uint16_t I2P_SAM31_PORT{0}; std::string OnionToString(std::span addr); diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h index 0ab595ac851..9178fb21824 100644 --- a/src/node/blockstorage.h +++ b/src/node/blockstorage.h @@ -126,10 +126,10 @@ static const unsigned int UNDOFILE_CHUNK_SIZE{1_MiB}; static const unsigned int MAX_BLOCKFILE_SIZE{128_MiB}; /** Size of header written by WriteBlock before a serialized CBlock (8 bytes) */ -static constexpr uint32_t STORAGE_HEADER_BYTES{std::tuple_size_v + sizeof(unsigned int)}; +inline constexpr uint32_t STORAGE_HEADER_BYTES{std::tuple_size_v + sizeof(unsigned int)}; /** Total overhead when writing undo data: header (8 bytes) plus checksum (32 bytes) */ -static constexpr uint32_t UNDO_DATA_DISK_OVERHEAD{STORAGE_HEADER_BYTES + uint256::size()}; +inline constexpr uint32_t UNDO_DATA_DISK_OVERHEAD{STORAGE_HEADER_BYTES + uint256::size()}; // Because validation code takes pointers to the map's CBlockIndex objects, if // we ever switch to another associative container, we need to either use a diff --git a/src/node/caches.h b/src/node/caches.h index 14056a2516f..4e8b49b37dc 100644 --- a/src/node/caches.h +++ b/src/node/caches.h @@ -15,7 +15,7 @@ class ArgsManager; //! Reserved non-dbcache memory usage. -static constexpr uint64_t DBCACHE_WARNING_RESERVED_RAM{2_GiB}; +inline constexpr uint64_t DBCACHE_WARNING_RESERVED_RAM{2_GiB}; namespace node { uint64_t GetDefaultDBCache(); diff --git a/src/node/chainstatemanager_args.h b/src/node/chainstatemanager_args.h index cbcbb6b47ca..9f62244ffd6 100644 --- a/src/node/chainstatemanager_args.h +++ b/src/node/chainstatemanager_args.h @@ -11,7 +11,7 @@ class ArgsManager; /** -par default (number of script-checking threads, 0 = auto) */ -static constexpr int DEFAULT_SCRIPTCHECK_THREADS{0}; +inline constexpr int DEFAULT_SCRIPTCHECK_THREADS{0}; namespace node { [[nodiscard]] util::Result ApplyArgsManOptions(const ArgsManager& args, ChainstateManager::Options& opts); diff --git a/src/node/kernel_notifications.h b/src/node/kernel_notifications.h index b152e7a476a..2f1089405dc 100644 --- a/src/node/kernel_notifications.h +++ b/src/node/kernel_notifications.h @@ -26,7 +26,7 @@ enum class Warning; namespace node { class Warnings; -static constexpr int DEFAULT_STOPATHEIGHT{0}; +inline constexpr int DEFAULT_STOPATHEIGHT{0}; //! State tracked by the KernelNotifications interface meant to be used by //! mining code, index code, RPCs, and other code sitting above the validation diff --git a/src/node/mempool_persist_args.h b/src/node/mempool_persist_args.h index 7973ec5821a..28ff297986d 100644 --- a/src/node/mempool_persist_args.h +++ b/src/node/mempool_persist_args.h @@ -15,7 +15,7 @@ namespace node { * Default for -persistmempool, indicating whether the node should attempt to * automatically load the mempool on start and save to disk on shutdown */ -static constexpr bool DEFAULT_PERSIST_MEMPOOL{true}; +inline constexpr bool DEFAULT_PERSIST_MEMPOOL{true}; bool ShouldPersistMempool(const ArgsManager& argsman); fs::path MempoolPath(const ArgsManager& argsman); diff --git a/src/node/txdownloadman.h b/src/node/txdownloadman.h index bef1d162d22..e362110212e 100644 --- a/src/node/txdownloadman.h +++ b/src/node/txdownloadman.h @@ -22,20 +22,20 @@ class TxDownloadManagerImpl; /** Maximum number of in-flight transaction requests from a peer. It is not a hard limit, but the threshold at which * point the OVERLOADED_PEER_TX_DELAY kicks in. */ -static constexpr int32_t MAX_PEER_TX_REQUEST_IN_FLIGHT = 100; +inline constexpr int32_t MAX_PEER_TX_REQUEST_IN_FLIGHT = 100; /** Maximum number of transactions to consider for requesting, per peer. It provides a reasonable DoS limit to * per-peer memory usage spent on announcements, while covering peers continuously sending INVs at the maximum * rate (by our own policy, see DEFAULT_TX_SEND_RATE) for several minutes, while not receiving * the actual transaction (from any peer) in response to requests for them. */ -static constexpr int32_t MAX_PEER_TX_ANNOUNCEMENTS = 5000; +inline constexpr int32_t MAX_PEER_TX_ANNOUNCEMENTS = 5000; /** How long to delay requesting transactions via txids, if we have wtxid-relaying peers */ -static constexpr auto TXID_RELAY_DELAY{2s}; +inline constexpr auto TXID_RELAY_DELAY{2s}; /** How long to delay requesting transactions from non-preferred peers */ -static constexpr auto NONPREF_PEER_TX_DELAY{2s}; +inline constexpr auto NONPREF_PEER_TX_DELAY{2s}; /** How long to delay requesting transactions from overloaded peers (see MAX_PEER_TX_REQUEST_IN_FLIGHT). */ -static constexpr auto OVERLOADED_PEER_TX_DELAY{2s}; +inline constexpr auto OVERLOADED_PEER_TX_DELAY{2s}; /** How long to wait before downloading a transaction from an additional peer */ -static constexpr auto GETDATA_TX_INTERVAL{60s}; +inline constexpr auto GETDATA_TX_INTERVAL{60s}; struct TxDownloadOptions { /** Read-only reference to mempool. */ const CTxMemPool& m_mempool; diff --git a/src/node/txorphanage.h b/src/node/txorphanage.h index 81c57da33e8..4411f15d0a4 100644 --- a/src/node/txorphanage.h +++ b/src/node/txorphanage.h @@ -17,10 +17,10 @@ namespace node { /** Default value for TxOrphanage::m_reserved_usage_per_peer. Helps limit the total amount of memory used by the orphanage. */ -static constexpr int64_t DEFAULT_RESERVED_ORPHAN_WEIGHT_PER_PEER{404'000}; +inline constexpr int64_t DEFAULT_RESERVED_ORPHAN_WEIGHT_PER_PEER{404'000}; /** Default value for TxOrphanage::m_max_global_latency_score. Helps limit the maximum latency for operations like * EraseForBlock and LimitOrphans. */ -static constexpr unsigned int DEFAULT_MAX_ORPHANAGE_LATENCY_SCORE{3000}; +inline constexpr unsigned int DEFAULT_MAX_ORPHANAGE_LATENCY_SCORE{3000}; /** A class to track orphan transactions (failed on TX_MISSING_INPUTS) * Since we cannot distinguish orphans from bad transactions with non-existent inputs, we heavily limit the amount of diff --git a/src/node/txreconciliation.h b/src/node/txreconciliation.h index 68deeabaf64..c9db24802ff 100644 --- a/src/node/txreconciliation.h +++ b/src/node/txreconciliation.h @@ -12,7 +12,7 @@ #include /** Supported transaction reconciliation protocol version */ -static constexpr uint32_t TXRECONCILIATION_VERSION{1}; +inline constexpr uint32_t TXRECONCILIATION_VERSION{1}; enum class ReconciliationRegisterResult { NOT_FOUND, diff --git a/src/node/utxo_snapshot.h b/src/node/utxo_snapshot.h index 482edd3e6fc..8807c27edf5 100644 --- a/src/node/utxo_snapshot.h +++ b/src/node/utxo_snapshot.h @@ -25,7 +25,7 @@ #include // UTXO set snapshot magic bytes -static constexpr std::array SNAPSHOT_MAGIC_BYTES = {'u', 't', 'x', 'o', 0xff}; +inline constexpr std::array SNAPSHOT_MAGIC_BYTES = {'u', 't', 'x', 'o', 0xff}; class Chainstate; diff --git a/src/outputtype.h b/src/outputtype.h index 4dde381b356..2b4c4d9baea 100644 --- a/src/outputtype.h +++ b/src/outputtype.h @@ -23,7 +23,7 @@ enum class OutputType { UNKNOWN, }; -static constexpr auto OUTPUT_TYPES = std::array{ +inline constexpr auto OUTPUT_TYPES = std::array{ OutputType::LEGACY, OutputType::P2SH_SEGWIT, OutputType::BECH32, diff --git a/src/policy/fees/block_policy_estimator.h b/src/policy/fees/block_policy_estimator.h index d513f15a858..a87970cd4dc 100644 --- a/src/policy/fees/block_policy_estimator.h +++ b/src/policy/fees/block_policy_estimator.h @@ -23,16 +23,16 @@ // How often to flush fee estimates to fee_estimates.dat. -static constexpr std::chrono::hours FEE_FLUSH_INTERVAL{1}; +inline constexpr std::chrono::hours FEE_FLUSH_INTERVAL{1}; /** fee_estimates.dat that are more than 60 hours (2.5 days) old will not be read, * as fee estimates are based on historical data and may be inaccurate if * network activity has changed. */ -static constexpr std::chrono::hours MAX_FILE_AGE{60}; +inline constexpr std::chrono::hours MAX_FILE_AGE{60}; // Whether we allow importing a fee_estimates file older than MAX_FILE_AGE. -static constexpr bool DEFAULT_ACCEPT_STALE_FEE_ESTIMATES{false}; +inline constexpr bool DEFAULT_ACCEPT_STALE_FEE_ESTIMATES{false}; class AutoFile; class TxConfirmStats; @@ -47,7 +47,7 @@ enum class FeeEstimateHorizon { LONG_HALFLIFE, }; -static constexpr auto ALL_FEE_ESTIMATE_HORIZONS = std::array{ +inline constexpr auto ALL_FEE_ESTIMATE_HORIZONS = std::array{ FeeEstimateHorizon::SHORT_HALFLIFE, FeeEstimateHorizon::MED_HALFLIFE, FeeEstimateHorizon::LONG_HALFLIFE, diff --git a/src/policy/packages.h b/src/policy/packages.h index 1a7e101ef46..e5704fb3796 100644 --- a/src/policy/packages.h +++ b/src/policy/packages.h @@ -16,12 +16,12 @@ #include /** Default maximum number of transactions in a package. */ -static constexpr uint32_t MAX_PACKAGE_COUNT{25}; +inline constexpr uint32_t MAX_PACKAGE_COUNT{25}; /** Default maximum total weight of transactions in a package in weight to allow for context-less checks. This must allow a superset of sigops weighted vsize limited transactions to not disallow transactions we would have otherwise accepted individually. */ -static constexpr uint32_t MAX_PACKAGE_WEIGHT = 404'000; +inline constexpr uint32_t MAX_PACKAGE_WEIGHT = 404'000; static_assert(MAX_PACKAGE_WEIGHT >= MAX_STANDARD_TX_WEIGHT); // Packages are part of a single cluster, so ensure that the package limits are diff --git a/src/policy/policy.h b/src/policy/policy.h index 13bcf4cef75..87d20486bbf 100644 --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -22,60 +22,60 @@ class CFeeRate; class CScript; /** Default for -blockmaxweight, which controls the range of block weights the mining code will create **/ -static constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT{MAX_BLOCK_WEIGHT}; +inline constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT{MAX_BLOCK_WEIGHT}; /** Default for -blockreservedweight **/ -static constexpr unsigned int DEFAULT_BLOCK_RESERVED_WEIGHT{8000}; +inline constexpr unsigned int DEFAULT_BLOCK_RESERVED_WEIGHT{8000}; /** Default sigops cost to reserve for coinbase transaction outputs when creating block templates. */ -static constexpr unsigned int DEFAULT_COINBASE_OUTPUT_MAX_ADDITIONAL_SIGOPS{400}; +inline constexpr unsigned int DEFAULT_COINBASE_OUTPUT_MAX_ADDITIONAL_SIGOPS{400}; /** This accounts for the block header, var_int encoding of the transaction count and a minimally viable * coinbase transaction. It adds an additional safety margin, because even with a thorough understanding * of block serialization, it's easy to make a costly mistake when trying to squeeze every last byte. * Setting a lower value is prevented at startup. */ -static constexpr unsigned int MINIMUM_BLOCK_RESERVED_WEIGHT{2000}; +inline constexpr unsigned int MINIMUM_BLOCK_RESERVED_WEIGHT{2000}; /** Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by mining code **/ -static constexpr unsigned int DEFAULT_BLOCK_MIN_TX_FEE{1}; +inline constexpr unsigned int DEFAULT_BLOCK_MIN_TX_FEE{1}; /** The maximum weight for transactions we're willing to relay/mine */ -static constexpr int32_t MAX_STANDARD_TX_WEIGHT{400000}; +inline constexpr int32_t MAX_STANDARD_TX_WEIGHT{400000}; /** The minimum non-witness size for transactions we're willing to relay/mine: one larger than 64 */ -static constexpr unsigned int MIN_STANDARD_TX_NONWITNESS_SIZE{65}; +inline constexpr unsigned int MIN_STANDARD_TX_NONWITNESS_SIZE{65}; /** Maximum number of signature check operations in an IsStandard() P2SH script */ -static constexpr unsigned int MAX_P2SH_SIGOPS{15}; +inline constexpr unsigned int MAX_P2SH_SIGOPS{15}; /** The maximum number of sigops we're willing to relay/mine in a single tx */ -static constexpr unsigned int MAX_STANDARD_TX_SIGOPS_COST{MAX_BLOCK_SIGOPS_COST/5}; +inline constexpr unsigned int MAX_STANDARD_TX_SIGOPS_COST{MAX_BLOCK_SIGOPS_COST/5}; /** The maximum number of potentially executed legacy signature operations in a single standard tx */ -static constexpr unsigned int MAX_TX_LEGACY_SIGOPS{2'500}; +inline constexpr unsigned int MAX_TX_LEGACY_SIGOPS{2'500}; /** Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or replacement **/ -static constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE{100}; +inline constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE{100}; /** Default for -bytespersigop */ -static constexpr unsigned int DEFAULT_BYTES_PER_SIGOP{20}; +inline constexpr unsigned int DEFAULT_BYTES_PER_SIGOP{20}; /** Default for -permitbaremultisig */ -static constexpr bool DEFAULT_PERMIT_BAREMULTISIG{true}; +inline constexpr bool DEFAULT_PERMIT_BAREMULTISIG{true}; /** The maximum number of witness stack items in a standard P2WSH script */ -static constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS{100}; +inline constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS{100}; /** The maximum size in bytes of each witness stack item in a standard P2WSH script */ -static constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEM_SIZE{80}; +inline constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEM_SIZE{80}; /** The maximum size in bytes of each witness stack item in a standard BIP 342 script (Taproot, leaf version 0xc0) */ -static constexpr unsigned int MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE{80}; +inline constexpr unsigned int MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE{80}; /** The maximum size in bytes of a standard witnessScript */ -static constexpr unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE{3600}; +inline constexpr unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE{3600}; /** The maximum size of a standard ScriptSig */ -static constexpr unsigned int MAX_STANDARD_SCRIPTSIG_SIZE{1650}; +inline constexpr unsigned int MAX_STANDARD_SCRIPTSIG_SIZE{1650}; /** Min feerate for defining dust. * Changing the dust limit changes which transactions are * standard and should be done with care and ideally rarely. It makes sense to * only increase the dust limit after prior releases were already not creating * outputs below the new threshold */ -static constexpr unsigned int DUST_RELAY_TX_FEE{3000}; +inline constexpr unsigned int DUST_RELAY_TX_FEE{3000}; /** Default for -minrelaytxfee, minimum relay fee for transactions */ -static constexpr unsigned int DEFAULT_MIN_RELAY_TX_FEE{100}; +inline constexpr unsigned int DEFAULT_MIN_RELAY_TX_FEE{100}; /** Maximum number of transactions per cluster (default) */ -static constexpr unsigned int DEFAULT_CLUSTER_LIMIT{64}; +inline constexpr unsigned int DEFAULT_CLUSTER_LIMIT{64}; /** Maximum size of cluster in virtual kilobytes */ -static constexpr unsigned int DEFAULT_CLUSTER_SIZE_LIMIT_KVB{101}; +inline constexpr unsigned int DEFAULT_CLUSTER_SIZE_LIMIT_KVB{101}; /** Default for -limitancestorcount, max number of in-mempool ancestors */ -static constexpr unsigned int DEFAULT_ANCESTOR_LIMIT{25}; +inline constexpr unsigned int DEFAULT_ANCESTOR_LIMIT{25}; /** Default for -limitdescendantcount, max number of in-mempool descendants */ -static constexpr unsigned int DEFAULT_DESCENDANT_LIMIT{25}; +inline constexpr unsigned int DEFAULT_DESCENDANT_LIMIT{25}; /** Default for -datacarrier */ static const bool DEFAULT_ACCEPT_DATACARRIER = true; /** @@ -87,12 +87,12 @@ static const unsigned int MAX_OP_RETURN_RELAY = MAX_STANDARD_TX_WEIGHT / WITNESS * ancestor and is no larger than this. Not really any reason to make this * configurable as it doesn't materially change DoS parameters. */ -static constexpr unsigned int EXTRA_DESCENDANT_TX_SIZE_LIMIT{10000}; +inline constexpr unsigned int EXTRA_DESCENDANT_TX_SIZE_LIMIT{10000}; /** * Maximum number of ephemeral dust outputs allowed. */ -static constexpr unsigned int MAX_DUST_OUTPUTS_PER_TX{1}; +inline constexpr unsigned int MAX_DUST_OUTPUTS_PER_TX{1}; /** * Mandatory script verification flags that all new transactions must comply with for @@ -101,7 +101,7 @@ static constexpr unsigned int MAX_DUST_OUTPUTS_PER_TX{1}; * Note that this does not affect consensus validity; see GetBlockScriptFlags() * for that. */ -static constexpr script_verify_flags MANDATORY_SCRIPT_VERIFY_FLAGS{SCRIPT_VERIFY_P2SH | +inline constexpr script_verify_flags MANDATORY_SCRIPT_VERIFY_FLAGS{SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_NULLDUMMY | SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY | @@ -115,7 +115,7 @@ static constexpr script_verify_flags MANDATORY_SCRIPT_VERIFY_FLAGS{SCRIPT_VERIFY * the additional (non-mandatory) rules here, to improve forwards and * backwards compatibility. */ -static constexpr script_verify_flags STANDARD_SCRIPT_VERIFY_FLAGS{MANDATORY_SCRIPT_VERIFY_FLAGS | +inline constexpr script_verify_flags STANDARD_SCRIPT_VERIFY_FLAGS{MANDATORY_SCRIPT_VERIFY_FLAGS | SCRIPT_VERIFY_STRICTENC | SCRIPT_VERIFY_MINIMALDATA | SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS | @@ -131,10 +131,10 @@ static constexpr script_verify_flags STANDARD_SCRIPT_VERIFY_FLAGS{MANDATORY_SCRI SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_PUBKEYTYPE}; /** For convenience, standard but not mandatory verify flags. */ -static constexpr script_verify_flags STANDARD_NOT_MANDATORY_VERIFY_FLAGS{STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS}; +inline constexpr script_verify_flags STANDARD_NOT_MANDATORY_VERIFY_FLAGS{STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS}; /** Used as the flags parameter to sequence and nLocktime checks in non-consensus code. */ -static constexpr unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS{LOCKTIME_VERIFY_SEQUENCE}; +inline constexpr unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS{LOCKTIME_VERIFY_SEQUENCE}; CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFee); @@ -148,8 +148,8 @@ std::vector GetDust(const CTransaction& tx, CFeeRate dust_relay_rate); // Changing the default transaction version requires a two step process: first // adapting relay policy by bumping TX_MAX_STANDARD_VERSION, and then later // allowing the new transaction version in the wallet/RPC. -static constexpr decltype(CTransaction::version) TX_MIN_STANDARD_VERSION{1}; -static constexpr decltype(CTransaction::version) TX_MAX_STANDARD_VERSION{3}; +inline constexpr decltype(CTransaction::version) TX_MIN_STANDARD_VERSION{1}; +inline constexpr decltype(CTransaction::version) TX_MAX_STANDARD_VERSION{3}; /** * Check for standard transaction types diff --git a/src/policy/rbf.h b/src/policy/rbf.h index 0ba646ca8d1..81769602bc0 100644 --- a/src/policy/rbf.h +++ b/src/policy/rbf.h @@ -23,7 +23,7 @@ class uint256; /** Maximum number of unique clusters that can be affected by an RBF (Rule #5); * see GetEntriesForConflicts() */ -static constexpr uint32_t MAX_REPLACEMENT_CANDIDATES{100}; +inline constexpr uint32_t MAX_REPLACEMENT_CANDIDATES{100}; /** The rbf state of unconfirmed transactions */ enum class RBFTransactionState { diff --git a/src/policy/truc_policy.h b/src/policy/truc_policy.h index b6fe6e1242b..137f54b88de 100644 --- a/src/policy/truc_policy.h +++ b/src/policy/truc_policy.h @@ -17,21 +17,21 @@ // This module enforces rules for BIP 431 TRUC transactions which help make // RBF abilities more robust. A transaction with version=3 is treated as TRUC. -static constexpr decltype(CTransaction::version) TRUC_VERSION{3}; +inline constexpr decltype(CTransaction::version) TRUC_VERSION{3}; // TRUC only allows 1 parent and 1 child when unconfirmed. This translates to a descendant set size // of 2 and ancestor set size of 2. /** Maximum number of transactions including an unconfirmed tx and its descendants. */ -static constexpr unsigned int TRUC_DESCENDANT_LIMIT{2}; +inline constexpr unsigned int TRUC_DESCENDANT_LIMIT{2}; /** Maximum number of transactions including a TRUC tx and all its mempool ancestors. */ -static constexpr unsigned int TRUC_ANCESTOR_LIMIT{2}; +inline constexpr unsigned int TRUC_ANCESTOR_LIMIT{2}; /** Maximum sigop-adjusted virtual size of all v3 transactions. */ -static constexpr int64_t TRUC_MAX_VSIZE{10000}; -static constexpr int64_t TRUC_MAX_WEIGHT{TRUC_MAX_VSIZE * WITNESS_SCALE_FACTOR}; +inline constexpr int64_t TRUC_MAX_VSIZE{10000}; +inline constexpr int64_t TRUC_MAX_WEIGHT{TRUC_MAX_VSIZE * WITNESS_SCALE_FACTOR}; /** Maximum sigop-adjusted virtual size of a tx which spends from an unconfirmed TRUC transaction. */ -static constexpr int64_t TRUC_CHILD_MAX_VSIZE{1000}; -static constexpr int64_t TRUC_CHILD_MAX_WEIGHT{TRUC_CHILD_MAX_VSIZE * WITNESS_SCALE_FACTOR}; +inline constexpr int64_t TRUC_CHILD_MAX_VSIZE{1000}; +inline constexpr int64_t TRUC_CHILD_MAX_WEIGHT{TRUC_CHILD_MAX_VSIZE * WITNESS_SCALE_FACTOR}; // These limits are within the default cluster limits. static_assert(TRUC_MAX_VSIZE + TRUC_CHILD_MAX_VSIZE <= DEFAULT_CLUSTER_SIZE_LIMIT_KVB * 1000); diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 17fea5b46b5..9fc8923fba7 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -177,8 +177,8 @@ struct TransactionSerParams { const bool allow_witness; SER_PARAMS_OPFUNC }; -static constexpr TransactionSerParams TX_WITH_WITNESS{.allow_witness = true}; -static constexpr TransactionSerParams TX_NO_WITNESS{.allow_witness = false}; +inline constexpr TransactionSerParams TX_WITH_WITNESS{.allow_witness = true}; +inline constexpr TransactionSerParams TX_NO_WITNESS{.allow_witness = false}; /** * Basic transaction serialization format: diff --git a/src/protocol.h b/src/protocol.h index a15a3aa60af..a53f15e455a 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -310,8 +310,8 @@ inline const std::array ALL_NET_MESSAGE_TYPES{std::to_array({ NetMsgType::FEATURE, })}; -static constexpr size_t MAX_FEATUREID_LENGTH{80}; -static constexpr size_t MAX_FEATUREDATA_LENGTH{512}; +inline constexpr size_t MAX_FEATUREID_LENGTH{80}; +inline constexpr size_t MAX_FEATUREDATA_LENGTH{512}; namespace NetMsgFeature { //inline constexpr std::string_view FOO{"BIP-FOO"}; diff --git a/src/psbt.h b/src/psbt.h index b0177a3e555..233a4fb673d 100644 --- a/src/psbt.h +++ b/src/psbt.h @@ -29,71 +29,71 @@ enum class TransactionError; using common::PSBTError; // Magic bytes -static constexpr uint8_t PSBT_MAGIC_BYTES[5] = {'p', 's', 'b', 't', 0xff}; +inline constexpr uint8_t PSBT_MAGIC_BYTES[5] = {'p', 's', 'b', 't', 0xff}; // Global types -static constexpr uint8_t PSBT_GLOBAL_UNSIGNED_TX = 0x00; -static constexpr uint8_t PSBT_GLOBAL_XPUB = 0x01; -static constexpr uint8_t PSBT_GLOBAL_TX_VERSION = 0x02; -static constexpr uint8_t PSBT_GLOBAL_FALLBACK_LOCKTIME = 0x03; -static constexpr uint8_t PSBT_GLOBAL_INPUT_COUNT = 0x04; -static constexpr uint8_t PSBT_GLOBAL_OUTPUT_COUNT = 0x05; -static constexpr uint8_t PSBT_GLOBAL_TX_MODIFIABLE = 0x06; -static constexpr uint8_t PSBT_GLOBAL_VERSION = 0xFB; -static constexpr uint8_t PSBT_GLOBAL_PROPRIETARY = 0xFC; +inline constexpr uint8_t PSBT_GLOBAL_UNSIGNED_TX = 0x00; +inline constexpr uint8_t PSBT_GLOBAL_XPUB = 0x01; +inline constexpr uint8_t PSBT_GLOBAL_TX_VERSION = 0x02; +inline constexpr uint8_t PSBT_GLOBAL_FALLBACK_LOCKTIME = 0x03; +inline constexpr uint8_t PSBT_GLOBAL_INPUT_COUNT = 0x04; +inline constexpr uint8_t PSBT_GLOBAL_OUTPUT_COUNT = 0x05; +inline constexpr uint8_t PSBT_GLOBAL_TX_MODIFIABLE = 0x06; +inline constexpr uint8_t PSBT_GLOBAL_VERSION = 0xFB; +inline constexpr uint8_t PSBT_GLOBAL_PROPRIETARY = 0xFC; // Input types -static constexpr uint8_t PSBT_IN_NON_WITNESS_UTXO = 0x00; -static constexpr uint8_t PSBT_IN_WITNESS_UTXO = 0x01; -static constexpr uint8_t PSBT_IN_PARTIAL_SIG = 0x02; -static constexpr uint8_t PSBT_IN_SIGHASH = 0x03; -static constexpr uint8_t PSBT_IN_REDEEMSCRIPT = 0x04; -static constexpr uint8_t PSBT_IN_WITNESSSCRIPT = 0x05; -static constexpr uint8_t PSBT_IN_BIP32_DERIVATION = 0x06; -static constexpr uint8_t PSBT_IN_SCRIPTSIG = 0x07; -static constexpr uint8_t PSBT_IN_SCRIPTWITNESS = 0x08; -static constexpr uint8_t PSBT_IN_RIPEMD160 = 0x0A; -static constexpr uint8_t PSBT_IN_SHA256 = 0x0B; -static constexpr uint8_t PSBT_IN_HASH160 = 0x0C; -static constexpr uint8_t PSBT_IN_HASH256 = 0x0D; -static constexpr uint8_t PSBT_IN_PREVIOUS_TXID = 0x0e; -static constexpr uint8_t PSBT_IN_OUTPUT_INDEX = 0x0f; -static constexpr uint8_t PSBT_IN_SEQUENCE = 0x10; -static constexpr uint8_t PSBT_IN_REQUIRED_TIME_LOCKTIME = 0x11; -static constexpr uint8_t PSBT_IN_REQUIRED_HEIGHT_LOCKTIME = 0x12; -static constexpr uint8_t PSBT_IN_TAP_KEY_SIG = 0x13; -static constexpr uint8_t PSBT_IN_TAP_SCRIPT_SIG = 0x14; -static constexpr uint8_t PSBT_IN_TAP_LEAF_SCRIPT = 0x15; -static constexpr uint8_t PSBT_IN_TAP_BIP32_DERIVATION = 0x16; -static constexpr uint8_t PSBT_IN_TAP_INTERNAL_KEY = 0x17; -static constexpr uint8_t PSBT_IN_TAP_MERKLE_ROOT = 0x18; -static constexpr uint8_t PSBT_IN_MUSIG2_PARTICIPANT_PUBKEYS = 0x1a; -static constexpr uint8_t PSBT_IN_MUSIG2_PUB_NONCE = 0x1b; -static constexpr uint8_t PSBT_IN_MUSIG2_PARTIAL_SIG = 0x1c; -static constexpr uint8_t PSBT_IN_PROPRIETARY = 0xFC; +inline constexpr uint8_t PSBT_IN_NON_WITNESS_UTXO = 0x00; +inline constexpr uint8_t PSBT_IN_WITNESS_UTXO = 0x01; +inline constexpr uint8_t PSBT_IN_PARTIAL_SIG = 0x02; +inline constexpr uint8_t PSBT_IN_SIGHASH = 0x03; +inline constexpr uint8_t PSBT_IN_REDEEMSCRIPT = 0x04; +inline constexpr uint8_t PSBT_IN_WITNESSSCRIPT = 0x05; +inline constexpr uint8_t PSBT_IN_BIP32_DERIVATION = 0x06; +inline constexpr uint8_t PSBT_IN_SCRIPTSIG = 0x07; +inline constexpr uint8_t PSBT_IN_SCRIPTWITNESS = 0x08; +inline constexpr uint8_t PSBT_IN_RIPEMD160 = 0x0A; +inline constexpr uint8_t PSBT_IN_SHA256 = 0x0B; +inline constexpr uint8_t PSBT_IN_HASH160 = 0x0C; +inline constexpr uint8_t PSBT_IN_HASH256 = 0x0D; +inline constexpr uint8_t PSBT_IN_PREVIOUS_TXID = 0x0e; +inline constexpr uint8_t PSBT_IN_OUTPUT_INDEX = 0x0f; +inline constexpr uint8_t PSBT_IN_SEQUENCE = 0x10; +inline constexpr uint8_t PSBT_IN_REQUIRED_TIME_LOCKTIME = 0x11; +inline constexpr uint8_t PSBT_IN_REQUIRED_HEIGHT_LOCKTIME = 0x12; +inline constexpr uint8_t PSBT_IN_TAP_KEY_SIG = 0x13; +inline constexpr uint8_t PSBT_IN_TAP_SCRIPT_SIG = 0x14; +inline constexpr uint8_t PSBT_IN_TAP_LEAF_SCRIPT = 0x15; +inline constexpr uint8_t PSBT_IN_TAP_BIP32_DERIVATION = 0x16; +inline constexpr uint8_t PSBT_IN_TAP_INTERNAL_KEY = 0x17; +inline constexpr uint8_t PSBT_IN_TAP_MERKLE_ROOT = 0x18; +inline constexpr uint8_t PSBT_IN_MUSIG2_PARTICIPANT_PUBKEYS = 0x1a; +inline constexpr uint8_t PSBT_IN_MUSIG2_PUB_NONCE = 0x1b; +inline constexpr uint8_t PSBT_IN_MUSIG2_PARTIAL_SIG = 0x1c; +inline constexpr uint8_t PSBT_IN_PROPRIETARY = 0xFC; // Output types -static constexpr uint8_t PSBT_OUT_REDEEMSCRIPT = 0x00; -static constexpr uint8_t PSBT_OUT_WITNESSSCRIPT = 0x01; -static constexpr uint8_t PSBT_OUT_BIP32_DERIVATION = 0x02; -static constexpr uint8_t PSBT_OUT_AMOUNT = 0x03; -static constexpr uint8_t PSBT_OUT_SCRIPT = 0x04; -static constexpr uint8_t PSBT_OUT_TAP_INTERNAL_KEY = 0x05; -static constexpr uint8_t PSBT_OUT_TAP_TREE = 0x06; -static constexpr uint8_t PSBT_OUT_TAP_BIP32_DERIVATION = 0x07; -static constexpr uint8_t PSBT_OUT_MUSIG2_PARTICIPANT_PUBKEYS = 0x08; -static constexpr uint8_t PSBT_OUT_PROPRIETARY = 0xFC; +inline constexpr uint8_t PSBT_OUT_REDEEMSCRIPT = 0x00; +inline constexpr uint8_t PSBT_OUT_WITNESSSCRIPT = 0x01; +inline constexpr uint8_t PSBT_OUT_BIP32_DERIVATION = 0x02; +inline constexpr uint8_t PSBT_OUT_AMOUNT = 0x03; +inline constexpr uint8_t PSBT_OUT_SCRIPT = 0x04; +inline constexpr uint8_t PSBT_OUT_TAP_INTERNAL_KEY = 0x05; +inline constexpr uint8_t PSBT_OUT_TAP_TREE = 0x06; +inline constexpr uint8_t PSBT_OUT_TAP_BIP32_DERIVATION = 0x07; +inline constexpr uint8_t PSBT_OUT_MUSIG2_PARTICIPANT_PUBKEYS = 0x08; +inline constexpr uint8_t PSBT_OUT_PROPRIETARY = 0xFC; // The separator is 0x00. Reading this in means that the unserializer can interpret it // as a 0 length key which indicates that this is the separator. The separator has no value. -static constexpr uint8_t PSBT_SEPARATOR = 0x00; +inline constexpr uint8_t PSBT_SEPARATOR = 0x00; // BIP 174 does not specify a maximum file size, but we set a limit anyway // to prevent reading a stream indefinitely and running out of memory. const std::streamsize MAX_FILE_SIZE_PSBT = 100000000; // 100 MB // PSBT version number -static constexpr uint32_t PSBT_HIGHEST_VERSION = 2; +inline constexpr uint32_t PSBT_HIGHEST_VERSION = 2; /** A structure for PSBT proprietary types */ struct PSBTProprietary diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h index a3b8cb9d9ce..79d5b577e3b 100644 --- a/src/qt/guiconstants.h +++ b/src/qt/guiconstants.h @@ -11,10 +11,10 @@ using namespace std::chrono_literals; /* A delay between model updates */ -static constexpr auto MODEL_UPDATE_DELAY{250ms}; +inline constexpr auto MODEL_UPDATE_DELAY{250ms}; /* A delay between shutdown pollings */ -static constexpr auto SHUTDOWN_POLLING_DELAY{200ms}; +inline constexpr auto SHUTDOWN_POLLING_DELAY{200ms}; /* AskPassphraseDialog -- Maximum passphrase length */ static const int MAX_PASSPHRASE_SIZE = 1024; @@ -55,9 +55,9 @@ static const int TOOLTIP_WRAP_THRESHOLD = 80; #define QAPP_APP_NAME_REGTEST "Bitcoin-Qt-regtest" /* One gigabyte (GB) in bytes */ -static constexpr uint64_t GB_BYTES{1000000000}; +inline constexpr uint64_t GB_BYTES{1000000000}; // Default prune target displayed in GUI. -static constexpr int DEFAULT_PRUNE_TARGET_GB{2}; +inline constexpr int DEFAULT_PRUNE_TARGET_GB{2}; #endif // BITCOIN_QT_GUICONSTANTS_H diff --git a/src/qt/modaloverlay.h b/src/qt/modaloverlay.h index 7c4b7a4b85c..f434aaadc1e 100644 --- a/src/qt/modaloverlay.h +++ b/src/qt/modaloverlay.h @@ -10,7 +10,7 @@ #include //! The required delta of headers to the estimated number of available headers until we show the IBD progress -static constexpr int HEADER_HEIGHT_DELTA_SYNC = 24; +inline constexpr int HEADER_HEIGHT_DELTA_SYNC = 24; namespace Ui { class ModalOverlay; diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index feef00a3cf4..9d10694718b 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -22,7 +22,7 @@ class Node; } extern const char *DEFAULT_GUI_PROXY_HOST; -static constexpr uint16_t DEFAULT_GUI_PROXY_PORT = 9050; +inline constexpr uint16_t DEFAULT_GUI_PROXY_PORT = 9050; /** * Convert configured prune target MiB to displayed GB. Round up to avoid underestimating max disk usage. diff --git a/src/qt/qrimagewidget.h b/src/qt/qrimagewidget.h index 844a6e031ab..b65b2b7a0dc 100644 --- a/src/qt/qrimagewidget.h +++ b/src/qt/qrimagewidget.h @@ -12,9 +12,9 @@ static const int MAX_URI_LENGTH = 255; /* Size of exported QR Code image */ -static constexpr int QR_IMAGE_SIZE = 300; -static constexpr int QR_IMAGE_TEXT_MARGIN = 10; -static constexpr int QR_IMAGE_MARGIN = 2 * QR_IMAGE_TEXT_MARGIN; +inline constexpr int QR_IMAGE_SIZE = 300; +inline constexpr int QR_IMAGE_TEXT_MARGIN = 10; +inline constexpr int QR_IMAGE_MARGIN = 2 * QR_IMAGE_TEXT_MARGIN; QT_BEGIN_NAMESPACE class QMenu; diff --git a/src/rpc/blockchain.h b/src/rpc/blockchain.h index 45f62c628b0..1b7c34d945d 100644 --- a/src/rpc/blockchain.h +++ b/src/rpc/blockchain.h @@ -27,7 +27,7 @@ class BlockManager; struct NodeContext; } // namespace node -static constexpr int NUM_GETBLOCKSTATS_PERCENTILES = 5; +inline constexpr int NUM_GETBLOCKSTATS_PERCENTILES = 5; /** * Get the difficulty of the net wrt to the given block index. diff --git a/src/rpc/util.h b/src/rpc/util.h index 143abbba5f3..3122bb7dbc5 100644 --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -43,7 +43,7 @@ namespace node { enum class TransactionError; } // namespace node -static constexpr bool DEFAULT_RPC_DOC_CHECK{ +inline constexpr bool DEFAULT_RPC_DOC_CHECK{ #ifdef RPC_DOC_CHECK true #else diff --git a/src/script/interpreter.h b/src/script/interpreter.h index ff63a73f0fc..47d9bfb09c9 100644 --- a/src/script/interpreter.h +++ b/src/script/interpreter.h @@ -45,7 +45,7 @@ enum * flags (A | B) is a subset of the acceptable scripts under flag (A). */ -static constexpr script_verify_flags SCRIPT_VERIFY_NONE{0}; +inline constexpr script_verify_flags SCRIPT_VERIFY_NONE{0}; enum class script_verify_flag_name : uint8_t { // Evaluate P2SH subscripts (BIP16). @@ -152,12 +152,12 @@ enum class script_verify_flag_name : uint8_t { }; using enum script_verify_flag_name; -static constexpr int MAX_SCRIPT_VERIFY_FLAGS_BITS = static_cast(SCRIPT_VERIFY_END_MARKER); +inline constexpr int MAX_SCRIPT_VERIFY_FLAGS_BITS = static_cast(SCRIPT_VERIFY_END_MARKER); // assert there is still a spare bit static_assert(0 < MAX_SCRIPT_VERIFY_FLAGS_BITS && MAX_SCRIPT_VERIFY_FLAGS_BITS <= 63); -static constexpr script_verify_flags::value_type MAX_SCRIPT_VERIFY_FLAGS = ((script_verify_flags::value_type{1} << MAX_SCRIPT_VERIFY_FLAGS_BITS) - 1); +inline constexpr script_verify_flags::value_type MAX_SCRIPT_VERIFY_FLAGS = ((script_verify_flags::value_type{1} << MAX_SCRIPT_VERIFY_FLAGS_BITS) - 1); bool CheckSignatureEncoding(const std::vector &vchSig, script_verify_flags flags, ScriptError* serror); @@ -235,16 +235,16 @@ struct ScriptExecutionData }; /** Signature hash sizes */ -static constexpr size_t WITNESS_V0_SCRIPTHASH_SIZE = 32; -static constexpr size_t WITNESS_V0_KEYHASH_SIZE = 20; -static constexpr size_t WITNESS_V1_TAPROOT_SIZE = 32; +inline constexpr size_t WITNESS_V0_SCRIPTHASH_SIZE = 32; +inline constexpr size_t WITNESS_V0_KEYHASH_SIZE = 20; +inline constexpr size_t WITNESS_V1_TAPROOT_SIZE = 32; -static constexpr uint8_t TAPROOT_LEAF_MASK = 0xfe; -static constexpr uint8_t TAPROOT_LEAF_TAPSCRIPT = 0xc0; -static constexpr size_t TAPROOT_CONTROL_BASE_SIZE = 33; -static constexpr size_t TAPROOT_CONTROL_NODE_SIZE = 32; -static constexpr size_t TAPROOT_CONTROL_MAX_NODE_COUNT = 128; -static constexpr size_t TAPROOT_CONTROL_MAX_SIZE = TAPROOT_CONTROL_BASE_SIZE + TAPROOT_CONTROL_NODE_SIZE * TAPROOT_CONTROL_MAX_NODE_COUNT; +inline constexpr uint8_t TAPROOT_LEAF_MASK = 0xfe; +inline constexpr uint8_t TAPROOT_LEAF_TAPSCRIPT = 0xc0; +inline constexpr size_t TAPROOT_CONTROL_BASE_SIZE = 33; +inline constexpr size_t TAPROOT_CONTROL_NODE_SIZE = 32; +inline constexpr size_t TAPROOT_CONTROL_MAX_NODE_COUNT = 128; +inline constexpr size_t TAPROOT_CONTROL_MAX_SIZE = TAPROOT_CONTROL_BASE_SIZE + TAPROOT_CONTROL_NODE_SIZE * TAPROOT_CONTROL_MAX_NODE_COUNT; extern const HashWriter HASHER_TAPSIGHASH; //!< Hasher with tag "TapSighash" pre-fed to it. extern const HashWriter HASHER_TAPLEAF; //!< Hasher with tag "TapLeaf" pre-fed to it. diff --git a/src/script/miniscript.h b/src/script/miniscript.h index 4e8beb19e6b..f0867acf3ee 100644 --- a/src/script/miniscript.h +++ b/src/script/miniscript.h @@ -268,7 +268,7 @@ constexpr bool IsTapscript(MiniscriptContext ms_ctx) namespace internal { //! The maximum size of a witness item for a Miniscript under Tapscript context. (A BIP340 signature with a sighash type byte.) -static constexpr uint32_t MAX_TAPMINISCRIPT_STACK_ELEM_SIZE{65}; +inline constexpr uint32_t MAX_TAPMINISCRIPT_STACK_ELEM_SIZE{65}; //! version + nLockTime constexpr uint32_t TX_OVERHEAD{4 + 4}; diff --git a/src/script/script.h b/src/script/script.h index e23ad440490..5590ecce215 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -35,7 +35,7 @@ static const int MAX_OPS_PER_SCRIPT = 201; static const int MAX_PUBKEYS_PER_MULTISIG = 20; /** The limit of keys in OP_CHECKSIGADD-based scripts. It is due to the stack limit in BIP342. */ -static constexpr unsigned int MAX_PUBKEYS_PER_MULTI_A = 999; +inline constexpr unsigned int MAX_PUBKEYS_PER_MULTI_A = 999; // Maximum script length in bytes static const int MAX_SCRIPT_SIZE = 10000; @@ -56,13 +56,13 @@ static const uint32_t LOCKTIME_MAX = 0xFFFFFFFFU; // Tag for input annex. If there are at least two witness elements for a transaction input, // and the first byte of the last element is 0x50, this last element is called annex, and // has meanings independent of the script -static constexpr unsigned int ANNEX_TAG = 0x50; +inline constexpr unsigned int ANNEX_TAG = 0x50; // Validation weight per passing signature (Tapscript only, see BIP 342). -static constexpr int64_t VALIDATION_WEIGHT_PER_SIGOP_PASSED{50}; +inline constexpr int64_t VALIDATION_WEIGHT_PER_SIGOP_PASSED{50}; // How much weight budget is added to the witness size (Tapscript only, see BIP 342). -static constexpr int64_t VALIDATION_WEIGHT_OFFSET{50}; +inline constexpr int64_t VALIDATION_WEIGHT_OFFSET{50}; template std::vector ToByteVector(const T& in) diff --git a/src/script/sigcache.h b/src/script/sigcache.h index 092bbf3e8e1..d11c6ad316d 100644 --- a/src/script/sigcache.h +++ b/src/script/sigcache.h @@ -28,9 +28,9 @@ class XOnlyPubKey; // DoS prevention: limit cache size to 32MiB (over 1000000 entries on 64-bit // systems). Due to how we count cache size, actual memory usage is slightly // more (~32.25 MiB) -static constexpr size_t DEFAULT_VALIDATION_CACHE_BYTES{32_MiB}; -static constexpr size_t DEFAULT_SIGNATURE_CACHE_BYTES{DEFAULT_VALIDATION_CACHE_BYTES / 2}; -static constexpr size_t DEFAULT_SCRIPT_EXECUTION_CACHE_BYTES{DEFAULT_VALIDATION_CACHE_BYTES / 2}; +inline constexpr size_t DEFAULT_VALIDATION_CACHE_BYTES{32_MiB}; +inline constexpr size_t DEFAULT_SIGNATURE_CACHE_BYTES{DEFAULT_VALIDATION_CACHE_BYTES / 2}; +inline constexpr size_t DEFAULT_SCRIPT_EXECUTION_CACHE_BYTES{DEFAULT_VALIDATION_CACHE_BYTES / 2}; static_assert(DEFAULT_VALIDATION_CACHE_BYTES == DEFAULT_SIGNATURE_CACHE_BYTES + DEFAULT_SCRIPT_EXECUTION_CACHE_BYTES); /** diff --git a/src/serialize.h b/src/serialize.h index 5d38a510076..5d8b4109b11 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -32,7 +32,7 @@ * The maximum size of a serialized object in bytes or number of elements * (for eg vectors) when the size is encoded as CompactSize. */ -static constexpr uint64_t MAX_SIZE = 0x02000000; +inline constexpr uint64_t MAX_SIZE = 0x02000000; /** Maximum amount of memory (in bytes) to allocate at once when deserializing vectors. */ static const unsigned int MAX_VECTOR_ALLOCATE = 5000000; diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h index 7818224e554..a1ac01f2075 100644 --- a/src/test/util/setup_common.h +++ b/src/test/util/setup_common.h @@ -38,7 +38,7 @@ extern const std::function()> G_TEST_COMMAND_LINE_ARGUM /** Retrieve the unit test name. */ extern const std::function G_TEST_GET_FULL_NAME; -static constexpr CAmount CENT{1000000}; +inline constexpr CAmount CENT{1000000}; /** Register common test args. Shared across binaries that rely on the test framework. */ void SetupCommonTestArgs(ArgsManager& argsman); diff --git a/src/test/util/versionbits.h b/src/test/util/versionbits.h index 478b7882fab..c1f7e458435 100644 --- a/src/test/util/versionbits.h +++ b/src/test/util/versionbits.h @@ -8,6 +8,6 @@ #include /** Total possible bits available for versionbits per original BIP 9 specification */ -static constexpr int VERSIONBITS_MAX_NUM_BITS{29}; +inline constexpr int VERSIONBITS_MAX_NUM_BITS{29}; #endif // BITCOIN_TEST_UTIL_VERSIONBITS_H diff --git a/src/txgraph.h b/src/txgraph.h index f76915c8d18..174ff560d16 100644 --- a/src/txgraph.h +++ b/src/txgraph.h @@ -15,7 +15,7 @@ #ifndef BITCOIN_TXGRAPH_H #define BITCOIN_TXGRAPH_H -static constexpr unsigned MAX_CLUSTER_COUNT_LIMIT{64}; +inline constexpr unsigned MAX_CLUSTER_COUNT_LIMIT{64}; /** Data structure to encapsulate fees, sizes, and dependencies for a set of transactions. * diff --git a/src/txmempool.h b/src/txmempool.h index eb7e44a8c68..bf033474b02 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -51,11 +51,11 @@ static const uint32_t MEMPOOL_HEIGHT = 0x7FFFFFFF; /** How much linearization cost required for TxGraph clusters to have * "acceptable" quality, if they cannot be optimally linearized with less cost. */ -static constexpr uint64_t ACCEPTABLE_COST = 75'000; +inline constexpr uint64_t ACCEPTABLE_COST = 75'000; /** How much work we ask TxGraph to do after a mempool change occurs (either * due to a changeset being applied, a new block being found, or a reorg). */ -static constexpr uint64_t POST_CHANGE_COST = 5 * ACCEPTABLE_COST; +inline constexpr uint64_t POST_CHANGE_COST = 5 * ACCEPTABLE_COST; /** * Test whether the LockPoints height and time are still valid on the current chain diff --git a/src/util/rbf.h b/src/util/rbf.h index 387ca5bd66c..44fa3ec9a55 100644 --- a/src/util/rbf.h +++ b/src/util/rbf.h @@ -9,7 +9,7 @@ class CTransaction; -static constexpr uint32_t MAX_BIP125_RBF_SEQUENCE{0xfffffffd}; +inline constexpr uint32_t MAX_BIP125_RBF_SEQUENCE{0xfffffffd}; /** Check whether the sequence numbers on this transaction are signaling opt-in to replace-by-fee, * according to BIP 125. Allow opt-out of transaction replacement by setting nSequence > diff --git a/src/util/sock.h b/src/util/sock.h index 97da86dfd65..66243970452 100644 --- a/src/util/sock.h +++ b/src/util/sock.h @@ -21,7 +21,7 @@ class CThreadInterrupt; * Maximum time to wait for I/O readiness. * It will take up until this time to break off in case of an interruption. */ -static constexpr auto MAX_WAIT_FOR_IO = 1s; +inline constexpr auto MAX_WAIT_FOR_IO = 1s; inline bool IOErrorIsPermanent(int err) { diff --git a/src/validation.h b/src/validation.h index d89ad3539e4..52480e14018 100644 --- a/src/validation.h +++ b/src/validation.h @@ -75,7 +75,7 @@ class SignalInterrupt; /** Block files containing a block-height within MIN_BLOCKS_TO_KEEP of ActiveChain().Tip() will not be pruned. */ static const unsigned int MIN_BLOCKS_TO_KEEP = 288; static const signed int DEFAULT_CHECKBLOCKS = 6; -static constexpr int DEFAULT_CHECKLEVEL{3}; +inline constexpr int DEFAULT_CHECKLEVEL{3}; // Require that user allocate at least 550 MiB for block & undo files (blk???.dat and rev???.dat) // At 1MB per block, 288 blocks = 288MB. // Add 15% for Undo data = 331MB @@ -87,10 +87,10 @@ static constexpr int DEFAULT_CHECKLEVEL{3}; static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES{550_MiB}; /** Maximum number of dedicated script-checking threads allowed */ -static constexpr int MAX_SCRIPTCHECK_THREADS{15}; +inline constexpr int MAX_SCRIPTCHECK_THREADS{15}; /** Maximum number of dedicated threads allowed for prefetching block input prevouts */ -static constexpr int32_t MAX_PREVOUTFETCH_THREADS{16}; +inline constexpr int32_t MAX_PREVOUTFETCH_THREADS{16}; /** Current sync state passed to tip changed callbacks. */ enum class SynchronizationState { diff --git a/src/wallet/coincontrol.h b/src/wallet/coincontrol.h index f329de688a7..f67649f7e44 100644 --- a/src/wallet/coincontrol.h +++ b/src/wallet/coincontrol.h @@ -25,7 +25,7 @@ const int DEFAULT_MAX_DEPTH = 9999999; const int DEFAULT_WALLET_TX_VERSION = CTransaction::CURRENT_VERSION; //! Default for -avoidpartialspends -static constexpr bool DEFAULT_AVOIDPARTIALSPENDS = false; +inline constexpr bool DEFAULT_AVOIDPARTIALSPENDS = false; class PreselectedInput { diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h index 2457cf95ee2..cfa866db55d 100644 --- a/src/wallet/coinselection.h +++ b/src/wallet/coinselection.h @@ -20,9 +20,9 @@ namespace wallet { //! lower bound for randomly-chosen target change amount -static constexpr CAmount CHANGE_LOWER{50000}; +inline constexpr CAmount CHANGE_LOWER{50000}; //! upper bound for randomly-chosen target change amount -static constexpr CAmount CHANGE_UPPER{1000000}; +inline constexpr CAmount CHANGE_UPPER{1000000}; /** A UTXO under consideration for use in funding a new transaction. */ struct COutput { diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 6cebae052bf..ccf8ae10d34 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -58,7 +58,7 @@ public: }; //! Constant representing an unknown spkm creation time -static constexpr int64_t UNKNOWN_TIME = std::numeric_limits::max(); +inline constexpr int64_t UNKNOWN_TIME = std::numeric_limits::max(); //! Default for -keypool static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 9b1bb8b6ddc..6d26b386bea 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -140,14 +140,14 @@ constexpr CAmount HIGH_TX_FEE_PER_KB{COIN / 100}; //! -maxtxfee will warn if called with a higher fee than this amount (in satoshis) constexpr CAmount HIGH_MAX_TX_FEE{100 * HIGH_TX_FEE_PER_KB}; //! Pre-calculated constants for input size estimation in *virtual size* -static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91; +inline constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91; class CCoinControl; //! Default for -addresstype constexpr OutputType DEFAULT_ADDRESS_TYPE{OutputType::BECH32}; -static constexpr uint64_t KNOWN_WALLET_FLAGS = +inline constexpr uint64_t KNOWN_WALLET_FLAGS = WALLET_FLAG_AVOID_REUSE | WALLET_FLAG_BLANK_WALLET | WALLET_FLAG_KEY_ORIGIN_METADATA @@ -156,7 +156,7 @@ static constexpr uint64_t KNOWN_WALLET_FLAGS = | WALLET_FLAG_DESCRIPTORS | WALLET_FLAG_EXTERNAL_SIGNER; -static constexpr uint64_t MUTABLE_WALLET_FLAGS = +inline constexpr uint64_t MUTABLE_WALLET_FLAGS = WALLET_FLAG_AVOID_REUSE; static const std::map WALLET_FLAG_TO_STRING{