Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport: merge bitcoin#22951, #23137, #23293, #23439, #23152, #23517, #23637, #24080, #25485, #24565 (auxiliary backports: part 20) #6334

Merged
merged 10 commits into from
Oct 26, 2024
Merged
17 changes: 15 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ AC_ARG_WITH([boost-process],
[boost_process=$withval],
[boost_process=no])

AC_ARG_ENABLE([lto],
[AS_HELP_STRING([--enable-lto],[build using LTO (default is no)])],
[enable_lto=$enableval],
[enable_lto=no])

AC_LANG_PUSH([C++])

dnl Check for a flag to turn compiler warnings into errors. This is helpful for checks which may
Expand Down Expand Up @@ -392,6 +397,11 @@ else
fi
fi

if test "x$enable_lto" = "xyes"; then
AX_CHECK_COMPILE_FLAG([-flto], [LTO_CXXFLAGS="$LTO_CXXFLAGS -flto"], [AC_MSG_ERROR([compile failed with -flto])], [$CXXFLAG_WERROR])
AX_CHECK_LINK_FLAG([-flto], [LTO_LDFLAGS="$LTO_LDFLAGS -flto"], [AC_MSG_ERROR([link failed with -flto])], [$CXXFLAG_WERROR])
fi

if test "x$enable_stacktraces" != xno; then
AC_CHECK_HEADERS([execinfo.h], [], [enable_stacktraces=no])
fi
Expand Down Expand Up @@ -1886,6 +1896,8 @@ AC_SUBST(GPROF_LDFLAGS)
AC_SUBST(HARDENED_CXXFLAGS)
AC_SUBST(HARDENED_CPPFLAGS)
AC_SUBST(HARDENED_LDFLAGS)
AC_SUBST(LTO_CXXFLAGS)
AC_SUBST(LTO_LDFLAGS)
AC_SUBST(PIC_FLAGS)
AC_SUBST(PIE_FLAGS)
AC_SUBST(SANITIZER_CXXFLAGS)
Expand Down Expand Up @@ -1985,6 +1997,7 @@ echo " crash hooks enabled = $enable_crashhooks"
echo " miner enabled = $enable_miner"
echo " gprof enabled = $enable_gprof"
echo " werror = $enable_werror"
echo " LTO = $enable_lto"
echo
echo " target os = $host_os"
echo " build os = $build_os"
Expand All @@ -1993,7 +2006,7 @@ echo " CC = $CC"
echo " CFLAGS = $PTHREAD_CFLAGS $CFLAGS"
echo " CPPFLAGS = $DEBUG_CPPFLAGS $HARDENED_CPPFLAGS $CPPFLAGS"
echo " CXX = $CXX"
echo " CXXFLAGS = $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $WARN_CXXFLAGS $NOWARN_CXXFLAGS $ERROR_CXXFLAGS $GPROF_CXXFLAGS $CXXFLAGS"
echo " LDFLAGS = $PTHREAD_LIBS $HARDENED_LDFLAGS $GPROF_LDFLAGS $LDFLAGS"
echo " CXXFLAGS = $LTO_CXXFLAGS $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $WARN_CXXFLAGS $NOWARN_CXXFLAGS $ERROR_CXXFLAGS $GPROF_CXXFLAGS $CXXFLAGS"
echo " LDFLAGS = $LTO_LDFLAGS $PTHREAD_LIBS $HARDENED_LDFLAGS $GPROF_LDFLAGS $LDFLAGS"
echo " ARFLAGS = $ARFLAGS"
echo
16 changes: 8 additions & 8 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ print-%: FORCE

DIST_SUBDIRS = secp256k1

AM_LDFLAGS = $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS) $(SANITIZER_LDFLAGS)
AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(HARDENED_CXXFLAGS) $(WARN_CXXFLAGS) $(NOWARN_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS) $(SANITIZER_CXXFLAGS)
AM_LDFLAGS = $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS) $(SANITIZER_LDFLAGS) $(LTO_LDFLAGS)
AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(HARDENED_CXXFLAGS) $(WARN_CXXFLAGS) $(NOWARN_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS) $(SANITIZER_CXXFLAGS) $(LTO_CXXFLAGS)
AM_CPPFLAGS = $(DEBUG_CPPFLAGS) $(HARDENED_CPPFLAGS)
AM_LIBTOOLFLAGS = --preserve-dup-deps
PTHREAD_FLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_LIBS)
Expand Down Expand Up @@ -142,11 +142,10 @@ BITCOIN_CORE_H = \
bech32.h \
bip324.h \
blockencodings.h \
bloom.h \
common/bloom.h \
cachemap.h \
cachemultimap.h \
blockfilter.h \
bloom.h \
chain.h \
chainparams.h \
chainparamsbase.h \
Expand All @@ -161,6 +160,7 @@ BITCOIN_CORE_H = \
coinjoin/server.h \
coinjoin/util.h \
coins.h \
common/bloom.h \
compat.h \
compat/assumptions.h \
compat/byteswap.h \
Expand Down Expand Up @@ -258,7 +258,6 @@ BITCOIN_CORE_H = \
memusage.h \
merkleblock.h \
messagesigner.h \
miner.h \
minisketchwrapper.h \
net.h \
net_permissions.h \
Expand All @@ -275,6 +274,7 @@ BITCOIN_CORE_H = \
node/connection_types.h \
node/context.h \
node/eviction.h \
node/miner.h \
node/psbt.h \
node/transaction.h \
node/ui_interface.h \
Expand Down Expand Up @@ -494,7 +494,6 @@ libbitcoin_server_a_SOURCES = \
masternode/payments.cpp \
masternode/sync.cpp \
masternode/utils.cpp \
miner.cpp \
minisketchwrapper.cpp \
net.cpp \
netfulfilledman.cpp \
Expand All @@ -507,6 +506,7 @@ libbitcoin_server_a_SOURCES = \
node/context.cpp \
node/eviction.cpp \
node/interfaces.cpp \
node/miner.cpp \
node/psbt.cpp \
node/transaction.cpp \
node/ui_interface.cpp \
Expand Down Expand Up @@ -699,11 +699,11 @@ crypto_libbitcoin_crypto_arm_shani_a_SOURCES = crypto/sha256_arm_shani.cpp
libbitcoin_consensus_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
libbitcoin_consensus_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_consensus_a_SOURCES = \
amount.h \
arith_uint256.cpp \
arith_uint256.h \
bls/bls.cpp \
bls/bls.h \
consensus/amount.h \
consensus/merkle.cpp \
consensus/merkle.h \
consensus/params.h \
Expand Down Expand Up @@ -743,9 +743,9 @@ libbitcoin_common_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_common_a_SOURCES = \
base58.cpp \
bech32.cpp \
bloom.cpp \
chainparams.cpp \
coins.cpp \
common/bloom.cpp \
compressor.cpp \
core_read.cpp \
core_write.cpp \
Expand Down
2 changes: 1 addition & 1 deletion src/addressindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef BITCOIN_ADDRESSINDEX_H
#define BITCOIN_ADDRESSINDEX_H

#include <amount.h>
#include <consensus/amount.h>
#include <serialize.h>
#include <uint256.h>
#include <util/underlying.h>
Expand Down
2 changes: 1 addition & 1 deletion src/banman.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define BITCOIN_BANMAN_H

#include <addrdb.h>
#include <bloom.h>
#include <common/bloom.h>
#include <fs.h>
#include <net_types.h> // For banmap_t
#include <sync.h>
Expand Down
2 changes: 1 addition & 1 deletion src/bench/rollingbloom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


#include <bench/bench.h>
#include <bloom.h>
#include <common/bloom.h>

static void RollingBloom(benchmark::Bench& bench)
{
Expand Down
2 changes: 1 addition & 1 deletion src/coinjoin/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef BITCOIN_COINJOIN_COMMON_H
#define BITCOIN_COINJOIN_COMMON_H

#include <amount.h>
#include <consensus/amount.h>
#include <primitives/transaction.h>

#include <array>
Expand Down
3 changes: 2 additions & 1 deletion src/coinjoin/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#ifndef BITCOIN_COINJOIN_OPTIONS_H
#define BITCOIN_COINJOIN_OPTIONS_H

#include <amount.h>
#include <consensus/amount.h>

#include <atomic>
#include <mutex>

Expand Down
2 changes: 1 addition & 1 deletion src/bloom.cpp → src/common/bloom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <bloom.h>
#include <common/bloom.h>

#include <evo/assetlocktx.h>
#include <evo/providertx.h>
Expand Down
6 changes: 3 additions & 3 deletions src/bloom.h → src/common/bloom.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_BLOOM_H
#define BITCOIN_BLOOM_H
#ifndef BITCOIN_COMMON_BLOOM_H
#define BITCOIN_COMMON_BLOOM_H

#include <serialize.h>
#include <span.h>
Expand Down Expand Up @@ -133,4 +133,4 @@ class CRollingBloomFilter
int nHashFuncs;
};

#endif // BITCOIN_BLOOM_H
#endif // BITCOIN_COMMON_BLOOM_H
13 changes: 7 additions & 6 deletions src/amount.h → src/consensus/amount.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_AMOUNT_H
#define BITCOIN_AMOUNT_H
#ifndef BITCOIN_CONSENSUS_AMOUNT_H
#define BITCOIN_CONSENSUS_AMOUNT_H

#include <stdint.h>
#include <cstdint>

/** Amount in satoshis (Can be negative) */
typedef int64_t CAmount;

static const CAmount COIN = 100000000;
/** The amount of satoshis in one BTC. */
static constexpr CAmount COIN = 100000000;

/** No amount larger than this (in satoshi) is valid.
*
Expand All @@ -22,7 +23,7 @@ static const 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 const CAmount MAX_MONEY = 21000000 * COIN;
static constexpr CAmount MAX_MONEY = 21000000 * COIN;
inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }

#endif // BITCOIN_AMOUNT_H
#endif // BITCOIN_CONSENSUS_AMOUNT_H
2 changes: 0 additions & 2 deletions src/consensus/consensus.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,5 @@ static const int COINBASE_MATURITY = 100;
/** Flags for nSequence and nLockTime locks */
/** Interpret sequence numbers as relative lock-time constraints. */
static constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE = (1 << 0);
/** Use GetMedianTimePast() instead of nTime for end point timestamp. */
static constexpr unsigned int LOCKTIME_MEDIAN_TIME_PAST = (1 << 1);

#endif // BITCOIN_CONSENSUS_CONSENSUS_H
1 change: 1 addition & 0 deletions src/consensus/tx_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <consensus/consensus.h>
#include <consensus/tx_check.h>

#include <consensus/amount.h>
#include <primitives/transaction.h>
#include <consensus/validation.h>

Expand Down
2 changes: 1 addition & 1 deletion src/consensus/tx_verify.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef BITCOIN_CONSENSUS_TX_VERIFY_H
#define BITCOIN_CONSENSUS_TX_VERIFY_H

#include <amount.h>
#include <consensus/amount.h>

#include <stdint.h>
#include <vector>
Expand Down
2 changes: 1 addition & 1 deletion src/core_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef BITCOIN_CORE_IO_H
#define BITCOIN_CORE_IO_H

#include <amount.h>
#include <consensus/amount.h>
#include <attributes.h>

#include <string>
Expand Down
1 change: 1 addition & 0 deletions src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <core_io.h>

#include <consensus/amount.h>
#include <consensus/validation.h>
#include <key_io.h>
#include <primitives/transaction.h>
Expand Down
2 changes: 1 addition & 1 deletion src/evo/dmn_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef BITCOIN_EVO_DMN_TYPES_H
#define BITCOIN_EVO_DMN_TYPES_H

#include <amount.h>
#include <consensus/amount.h>

#include <limits>
#include <string_view>
Expand Down
2 changes: 1 addition & 1 deletion src/governance/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef BITCOIN_GOVERNANCE_CLASSES_H
#define BITCOIN_GOVERNANCE_CLASSES_H

#include <amount.h>
#include <consensus/amount.h>
#include <governance/object.h>
#include <script/script.h>
#include <script/standard.h>
Expand Down
2 changes: 1 addition & 1 deletion src/governance/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#include <governance/governance.h>

#include <bloom.h>
#include <chain.h>
#include <chainparams.h>
#include <common/bloom.h>
#include <consensus/validation.h>
#include <deploymentstatus.h>
#include <evo/deterministicmns.h>
Expand Down
4 changes: 2 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
#include <init.h>

#include <addrman.h>
#include <amount.h>
#include <banman.h>
#include <base58.h>
#include <blockfilter.h>
#include <chain.h>
#include <chainparams.h>
#include <context.h>
#include <consensus/amount.h>
#include <deploymentstatus.h>
#include <node/coinstats.h>
#include <fs.h>
Expand All @@ -31,7 +31,7 @@
#include <index/txindex.h>
#include <interfaces/node.h>
#include <mapport.h>
#include <miner.h>
#include <node/miner.h>
#include <net.h>
#include <net_permissions.h>
#include <net_processing.h>
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef BITCOIN_INTERFACES_NODE_H
#define BITCOIN_INTERFACES_NODE_H

#include <amount.h> // For CAmount
#include <consensus/amount.h> // For CAmount
#include <net.h> // For NodeId
#include <net_types.h> // For banmap_t
#include <netaddress.h> // For Network
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef BITCOIN_INTERFACES_WALLET_H
#define BITCOIN_INTERFACES_WALLET_H

#include <amount.h> // For CAmount
#include <consensus/amount.h> // For CAmount
#include <fs.h>
#include <interfaces/chain.h> // For ChainClient
#include <pubkey.h> // For CKeyID and CScriptID (definitions needed in CTxDestination instantiation)
Expand Down
2 changes: 1 addition & 1 deletion src/masternode/payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#include <masternode/payments.h>

#include <amount.h>
#include <chain.h>
#include <chainparams.h>
#include <consensus/amount.h>
#include <deploymentstatus.h>
#include <evo/deterministicmns.h>
#include <governance/classes.h>
Expand Down
2 changes: 1 addition & 1 deletion src/masternode/payments.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef BITCOIN_MASTERNODE_PAYMENTS_H
#define BITCOIN_MASTERNODE_PAYMENTS_H

#include <amount.h>
#include <consensus/amount.h>

#include <string>
#include <vector>
Expand Down
4 changes: 2 additions & 2 deletions src/merkleblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#ifndef BITCOIN_MERKLEBLOCK_H
#define BITCOIN_MERKLEBLOCK_H

#include <common/bloom.h>
#include <primitives/block.h>
#include <serialize.h>
#include <uint256.h>
#include <primitives/block.h>
#include <bloom.h>

#include <vector>

Expand Down
3 changes: 2 additions & 1 deletion src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
#define BITCOIN_NET_H

#include <bip324.h>
#include <bloom.h>
#include <chainparams.h>
#include <common/bloom.h>
#include <compat.h>
#include <consensus/amount.h>
#include <fs.h>
#include <crypto/siphash.h>
#include <hash.h>
Expand Down
Loading
Loading