mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-15 07:46:56 +02:00
1e5d3b4f0ddoc: add release note for mining option validation (Sjors Provoost)0317f52022ci: enforce iwyu for touched files (Sjors Provoost)8c58f63578refactor: have mining files include what they use (Sjors Provoost)3bb6498fb0mining: store block create options in NodeContext (Sjors Provoost)4637cd157dmining: reject invalid block create options (Sjors Provoost)8daac1d6ebmining: add block create option helpers (Sjors Provoost)128da7c3ffminer: add block_max_weight to BlockCreateOptions (Sjors Provoost)fa81e51eaemining: parse block creation args in mining_args (Sjors Provoost)020166080cmining: use interface for tests, bench and fuzzers (Sjors Provoost)44082bea47interfaces: make Mining use const NodeContext (Sjors Provoost)d4368e059cmove-only: add node/mining_types.h (Sjors Provoost)6aeb1fbea2test: cover IPC blockmaxweight policy (Sjors Provoost)63b23ea1e9test: regression test for waitNext mining policy (Sjors Provoost)24750f8b31test: add createNewBlock failure helper (Sjors Provoost)63ee9cd15btest: misc interface_ipc_mining.py improvements (Sjors Provoost) Pull request description: Although this PR is primarily a refactor, _there are behavior changes_ documented in the release note: - the IPC mining interface now rejects out-of-range block template options instead of silently clamping them; - startup now rejects `-blockmaxweight` values lower than `-blockreservedweight`, instead of allowing them to be clamped later. The interaction between node startup options like `-blockreservedweight` and runtime options, especially those passed via IPC, is confusing. They're combined in `BlockAssembler::Options`, which this PR gets rid of in favour of `BlockCreateOptions`. `BlockCreateOptions` is used by interface clients. As before, IPC clients have access to a safe / sane subset, whereas RPC and test code can use all fields. The same type is also used to store mining defaults parsed once during node startup in `NodeContext`. The maximum block weight setting (`block_max_weight`) is optional. When read from startup options it matches `-blockmaxweight`; when provided by callers it is a runtime override. `Merge()` fills unset fields from startup defaults while preserving caller-provided values. This all happens in commits `mining: add block create option helpers` and `mining: store block create options in NodeContext`, and requires some preparation to keep things easy to review. We get rid of `BlockAssembler::Options` but this is used in many tests. Since large churn is inevitable, we might as well switch all tests, bench and fuzzers over to the Mining interface. The `mining: use interface for tests, bench and fuzzers` commit does that, dramatically reducing direct use of `BlockAssembler`. Two exceptions are documented in the commit message. Because `test_block_validity` wasn't available via the interface and the block_assemble benchmark needs it, it's moved from `BlockAssembler::Options` to `BlockCreateOptions` (still not exposed via IPC). We need access to mining related structs from both the miner and node initialization code. To avoid having to pull in all of `BlockAssembler` for the latter, the `move-only: add node/mining_types.h` commit introduces `node/mining_types.h` and moves `BlockCreateOptions`, `BlockWaitOptions` and `BlockCheckOptions` there from `src/node/types.h`. I considered also moving `DEFAULT_BLOCK_MAX_WEIGHT`, `DEFAULT_BLOCK_RESERVED_WEIGHT`, `MINIMUM_BLOCK_RESERVED_WEIGHT` and `DEFAULT_BLOCK_MIN_TX_FEE` there from `policy.h`, since they are distinct from relay policy and not needed by the kernel. But this seems more appropriate for a follow-up and requires additional discussion. --- I kept variable renaming and other formatting changes to a minimum to ease review with `--color-moved=dimmed-zebra`. ## Commit summary Tests and test cleanup: - `test: misc interface_ipc_mining.py improvements` - `test: add assert_create_fails helper` - `test: regression test for waitNext mining policy` - `test: cover IPC blockmaxweight policy` Refactoring test/bench/fuzz callers: - `interfaces: make Mining use const NodeContext` - `mining: use interface for tests, bench and fuzzers` Moving mining interface types: - `move-only: add node/mining_types.h` Separating startup defaults from runtime options: - `mining: parse block creation args in mining_args`: adds `node/mining_args.{h,cpp}` and moves mining option parsing out of `init.cpp`, without storing the parsed values yet. - `miner: add block_max_weight to BlockCreateOptions`: moves the runtime maximum block weight setting into `BlockCreateOptions` as an optional value, so it can later be defaulted from startup args when unset. - `mining: add block create option helpers`: centralizes block template option defaulting and merging, removes `BlockAssembler::Options`, and preserves behavior except for dropping the `Specified ` prefix from startup option error messages. - `mining: reject invalid block create options`: checks typed `BlockCreateOptions` before block template creation, so invalid runtime options are rejected instead of silently clamped. Startup validation also rejects `-blockmaxweight` values lower than `-blockreservedweight`. - `mining: store block create options in NodeContext`: stores the startup mining options in `NodeContext` as `BlockCreateOptions`, so startup defaults and runtime overrides can be merged with the same option type. Include hygiene, CI and release note: - `refactor: have mining files include what they use` - `ci: enforce iwyu for touched files` - `doc: add release note for mining option validation` ACKs for top commit: w0xlt: reACK1e5d3b4f0dsedited: ACK1e5d3b4f0dryanofsky: Code review ACK1e5d3b4f0d. Looks good, thanks for the updates! Tree-SHA512: 28c715023cb78f02775caa787b243c994bd0f8ce4559afc8db9301e93400ebbc74963626a4afe65ae15bcc16b9192d051a745839f4c804848d50746ea5a224b4
436 lines
10 KiB
CMake
436 lines
10 KiB
CMake
# Copyright (c) 2023-present The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or https://opensource.org/license/mit/.
|
|
|
|
include(AddWindowsResources)
|
|
|
|
configure_file(${PROJECT_SOURCE_DIR}/cmake/bitcoin-build-config.h.in bitcoin-build-config.h USE_SOURCE_PERMISSIONS @ONLY)
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
#=============================
|
|
# Subprojects
|
|
#=============================
|
|
# Subprojects include subdirectories that do or could have tests
|
|
# and/or benchmark binaries, such as all subtrees and univalue.
|
|
# These need to be included before CMAKE_*_OUTPUT_DIRECTORY variables
|
|
# are set, so output locations of subproject tests and libraries are
|
|
# not overridden.
|
|
include(../cmake/crc32c.cmake)
|
|
include(../cmake/leveldb.cmake)
|
|
include(../cmake/minisketch.cmake)
|
|
add_subdirectory(univalue)
|
|
if (ENABLE_IPC AND NOT WITH_EXTERNAL_LIBMULTIPROCESS)
|
|
include(../cmake/libmultiprocess.cmake)
|
|
add_libmultiprocess(ipc/libmultiprocess)
|
|
endif()
|
|
include(../cmake/secp256k1.cmake)
|
|
add_secp256k1(secp256k1)
|
|
|
|
# Set top-level target output locations.
|
|
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
|
|
endif()
|
|
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
|
|
endif()
|
|
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
|
|
endif()
|
|
|
|
set(IS_SOURCE_TARBALL FALSE)
|
|
# git will expand the next line to "set(IS_SOURCE_TARBALL TRUE)" inside archives:
|
|
#$Format:%nset(IS_SOURCE_TARBALL TRUE)$
|
|
if(NOT IS_SOURCE_TARBALL AND PROJECT_IS_TOP_LEVEL)
|
|
find_package(Git QUIET)
|
|
endif()
|
|
add_custom_target(generate_build_info
|
|
BYPRODUCTS ${PROJECT_BINARY_DIR}/src/bitcoin-build-info.h
|
|
COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DBUILD_INFO_HEADER_PATH=${PROJECT_BINARY_DIR}/src/bitcoin-build-info.h -DSOURCE_DIR=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/cmake/script/GenerateBuildInfo.cmake
|
|
COMMENT "Generating bitcoin-build-info.h"
|
|
VERBATIM
|
|
)
|
|
add_library(bitcoin_clientversion STATIC
|
|
clientversion.cpp
|
|
)
|
|
target_link_libraries(bitcoin_clientversion
|
|
PRIVATE
|
|
core_interface
|
|
)
|
|
add_dependencies(bitcoin_clientversion generate_build_info)
|
|
|
|
add_subdirectory(crypto)
|
|
add_subdirectory(util)
|
|
if(ENABLE_IPC)
|
|
add_subdirectory(ipc)
|
|
else()
|
|
add_library(bitcoin_ipc STATIC EXCLUDE_FROM_ALL ipc/stub.cpp)
|
|
endif()
|
|
|
|
add_library(bitcoin_consensus STATIC EXCLUDE_FROM_ALL
|
|
arith_uint256.cpp
|
|
consensus/merkle.cpp
|
|
consensus/tx_check.cpp
|
|
hash.cpp
|
|
primitives/block.cpp
|
|
primitives/transaction.cpp
|
|
pubkey.cpp
|
|
script/interpreter.cpp
|
|
script/script.cpp
|
|
script/script_error.cpp
|
|
uint256.cpp
|
|
)
|
|
target_link_libraries(bitcoin_consensus
|
|
PRIVATE
|
|
core_interface
|
|
bitcoin_crypto
|
|
secp256k1
|
|
)
|
|
|
|
if(WITH_ZMQ)
|
|
add_subdirectory(zmq)
|
|
endif()
|
|
|
|
# Home for common functionality shared by different executables and libraries.
|
|
# Similar to `bitcoin_util` library, but higher-level.
|
|
add_library(bitcoin_common STATIC EXCLUDE_FROM_ALL
|
|
addresstype.cpp
|
|
base58.cpp
|
|
bech32.cpp
|
|
chain.cpp
|
|
chainparams.cpp
|
|
chainparamsbase.cpp
|
|
coins.cpp
|
|
common/args.cpp
|
|
common/bloom.cpp
|
|
common/config.cpp
|
|
common/init.cpp
|
|
common/interfaces.cpp
|
|
common/license_info.cpp
|
|
common/messages.cpp
|
|
common/netif.cpp
|
|
common/pcp.cpp
|
|
common/run_command.cpp
|
|
common/settings.cpp
|
|
common/signmessage.cpp
|
|
common/system.cpp
|
|
common/url.cpp
|
|
compressor.cpp
|
|
core_io.cpp
|
|
deploymentinfo.cpp
|
|
external_signer.cpp
|
|
init/common.cpp
|
|
kernel/chainparams.cpp
|
|
key.cpp
|
|
key_io.cpp
|
|
merkleblock.cpp
|
|
musig.cpp
|
|
net_permissions.cpp
|
|
net_types.cpp
|
|
netaddress.cpp
|
|
netbase.cpp
|
|
outputtype.cpp
|
|
policy/feerate.cpp
|
|
policy/policy.cpp
|
|
pow.cpp
|
|
protocol.cpp
|
|
psbt.cpp
|
|
rpc/rawtransaction_util.cpp
|
|
rpc/request.cpp
|
|
rpc/util.cpp
|
|
scheduler.cpp
|
|
script/descriptor.cpp
|
|
script/miniscript.cpp
|
|
script/parsing.cpp
|
|
script/sign.cpp
|
|
script/signingprovider.cpp
|
|
script/solver.cpp
|
|
)
|
|
target_link_libraries(bitcoin_common
|
|
PRIVATE
|
|
core_interface
|
|
bitcoin_consensus
|
|
bitcoin_util
|
|
univalue
|
|
secp256k1
|
|
$<TARGET_NAME_IF_EXISTS:USDT::headers>
|
|
$<$<PLATFORM_ID:Windows>:ws2_32>
|
|
)
|
|
|
|
include(InstallBinaryComponent)
|
|
|
|
if(ENABLE_WALLET)
|
|
add_subdirectory(wallet)
|
|
|
|
if(BUILD_WALLET_TOOL)
|
|
add_executable(bitcoin-wallet
|
|
bitcoin-wallet.cpp
|
|
init/bitcoin-wallet.cpp
|
|
wallet/wallettool.cpp
|
|
)
|
|
add_windows_resources(bitcoin-wallet bitcoin-wallet-res.rc)
|
|
add_windows_application_manifest(bitcoin-wallet)
|
|
target_link_libraries(bitcoin-wallet
|
|
core_interface
|
|
bitcoin_wallet
|
|
bitcoin_common
|
|
bitcoin_util
|
|
)
|
|
install_binary_component(bitcoin-wallet HAS_MANPAGE)
|
|
endif()
|
|
endif()
|
|
|
|
|
|
# P2P and RPC server functionality used by `bitcoind` and `bitcoin-qt` executables.
|
|
add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL
|
|
addrdb.cpp
|
|
addrman.cpp
|
|
banman.cpp
|
|
bip324.cpp
|
|
blockencodings.cpp
|
|
blockfilter.cpp
|
|
consensus/tx_verify.cpp
|
|
dbwrapper.cpp
|
|
deploymentstatus.cpp
|
|
flatfile.cpp
|
|
headerssync.cpp
|
|
httprpc.cpp
|
|
httpserver.cpp
|
|
i2p.cpp
|
|
index/base.cpp
|
|
index/blockfilterindex.cpp
|
|
index/coinstatsindex.cpp
|
|
index/txindex.cpp
|
|
index/txospenderindex.cpp
|
|
init.cpp
|
|
kernel/chain.cpp
|
|
kernel/checks.cpp
|
|
kernel/coinstats.cpp
|
|
kernel/context.cpp
|
|
kernel/cs_main.cpp
|
|
kernel/disconnected_transactions.cpp
|
|
kernel/mempool_removal_reason.cpp
|
|
mapport.cpp
|
|
net.cpp
|
|
net_processing.cpp
|
|
netgroup.cpp
|
|
node/abort.cpp
|
|
node/blockmanager_args.cpp
|
|
node/blockstorage.cpp
|
|
node/caches.cpp
|
|
node/chainstate.cpp
|
|
node/chainstatemanager_args.cpp
|
|
node/coin.cpp
|
|
node/coins_view_args.cpp
|
|
node/connection_types.cpp
|
|
node/context.cpp
|
|
node/database_args.cpp
|
|
node/eviction.cpp
|
|
node/interface_ui.cpp
|
|
node/interfaces.cpp
|
|
node/kernel_notifications.cpp
|
|
node/mempool_args.cpp
|
|
node/mempool_persist.cpp
|
|
node/mempool_persist_args.cpp
|
|
node/miner.cpp
|
|
node/mining_args.cpp
|
|
node/mini_miner.cpp
|
|
node/minisketchwrapper.cpp
|
|
node/peerman_args.cpp
|
|
node/psbt.cpp
|
|
node/timeoffsets.cpp
|
|
node/transaction.cpp
|
|
node/txdownloadman_impl.cpp
|
|
node/txorphanage.cpp
|
|
node/txreconciliation.cpp
|
|
node/utxo_snapshot.cpp
|
|
node/warnings.cpp
|
|
noui.cpp
|
|
policy/ephemeral_policy.cpp
|
|
policy/fees/block_policy_estimator.cpp
|
|
policy/fees/block_policy_estimator_args.cpp
|
|
policy/packages.cpp
|
|
policy/rbf.cpp
|
|
policy/settings.cpp
|
|
policy/truc_policy.cpp
|
|
private_broadcast.cpp
|
|
rest.cpp
|
|
rpc/blockchain.cpp
|
|
rpc/external_signer.cpp
|
|
rpc/fees.cpp
|
|
rpc/mempool.cpp
|
|
rpc/mining.cpp
|
|
rpc/net.cpp
|
|
rpc/node.cpp
|
|
rpc/output_script.cpp
|
|
rpc/rawtransaction.cpp
|
|
rpc/server.cpp
|
|
rpc/server_util.cpp
|
|
rpc/signmessage.cpp
|
|
rpc/txoutproof.cpp
|
|
script/sigcache.cpp
|
|
signet.cpp
|
|
torcontrol.cpp
|
|
txdb.cpp
|
|
txgraph.cpp
|
|
txmempool.cpp
|
|
txrequest.cpp
|
|
validation.cpp
|
|
validationinterface.cpp
|
|
versionbits.cpp
|
|
$<$<TARGET_EXISTS:bitcoin_wallet>:wallet/init.cpp>
|
|
$<$<NOT:$<TARGET_EXISTS:bitcoin_wallet>>:dummywallet.cpp>
|
|
)
|
|
target_link_libraries(bitcoin_node
|
|
PRIVATE
|
|
core_interface
|
|
bitcoin_common
|
|
bitcoin_util
|
|
$<TARGET_NAME_IF_EXISTS:bitcoin_zmq>
|
|
leveldb
|
|
minisketch
|
|
univalue
|
|
Boost::headers
|
|
$<TARGET_NAME_IF_EXISTS:libevent::core>
|
|
$<TARGET_NAME_IF_EXISTS:libevent::extra>
|
|
$<TARGET_NAME_IF_EXISTS:libevent::pthreads>
|
|
$<TARGET_NAME_IF_EXISTS:USDT::headers>
|
|
)
|
|
if(WITH_EMBEDDED_ASMAP)
|
|
target_compile_definitions(bitcoin_node PRIVATE ENABLE_EMBEDDED_ASMAP=1)
|
|
include(TargetDataSources)
|
|
target_raw_data_sources(bitcoin_node NAMESPACE node::data
|
|
node/data/ip_asn.dat
|
|
)
|
|
endif()
|
|
|
|
# Bitcoin wrapper executable that can call other executables.
|
|
if(BUILD_BITCOIN_BIN)
|
|
add_executable(bitcoin bitcoin.cpp)
|
|
add_windows_resources(bitcoin bitcoin-res.rc)
|
|
add_windows_application_manifest(bitcoin)
|
|
target_link_libraries(bitcoin core_interface bitcoin_common bitcoin_util)
|
|
install_binary_component(bitcoin HAS_MANPAGE)
|
|
endif()
|
|
|
|
# Bitcoin Core bitcoind.
|
|
if(BUILD_DAEMON)
|
|
add_executable(bitcoind
|
|
bitcoind.cpp
|
|
init/bitcoind.cpp
|
|
)
|
|
add_windows_resources(bitcoind bitcoind-res.rc)
|
|
add_windows_application_manifest(bitcoind)
|
|
target_link_libraries(bitcoind
|
|
core_interface
|
|
bitcoin_node
|
|
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
|
|
)
|
|
install_binary_component(bitcoind HAS_MANPAGE)
|
|
endif()
|
|
if(ENABLE_IPC AND BUILD_DAEMON)
|
|
add_executable(bitcoin-node
|
|
bitcoind.cpp
|
|
init/bitcoin-node.cpp
|
|
)
|
|
target_link_libraries(bitcoin-node
|
|
core_interface
|
|
bitcoin_node
|
|
bitcoin_ipc
|
|
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
|
|
)
|
|
install_binary_component(bitcoin-node INTERNAL)
|
|
endif()
|
|
|
|
|
|
add_library(bitcoin_cli STATIC EXCLUDE_FROM_ALL
|
|
compat/stdin.cpp
|
|
rpc/client.cpp
|
|
)
|
|
target_link_libraries(bitcoin_cli
|
|
PUBLIC
|
|
core_interface
|
|
univalue
|
|
)
|
|
|
|
|
|
# Bitcoin Core RPC client
|
|
if(BUILD_CLI)
|
|
add_executable(bitcoin-cli bitcoin-cli.cpp init/basic.cpp)
|
|
add_windows_resources(bitcoin-cli bitcoin-cli-res.rc)
|
|
add_windows_application_manifest(bitcoin-cli)
|
|
target_link_libraries(bitcoin-cli
|
|
core_interface
|
|
bitcoin_cli
|
|
bitcoin_common
|
|
bitcoin_ipc
|
|
bitcoin_util
|
|
)
|
|
install_binary_component(bitcoin-cli HAS_MANPAGE)
|
|
endif()
|
|
|
|
|
|
if(BUILD_TX)
|
|
add_executable(bitcoin-tx bitcoin-tx.cpp)
|
|
add_windows_resources(bitcoin-tx bitcoin-tx-res.rc)
|
|
add_windows_application_manifest(bitcoin-tx)
|
|
target_link_libraries(bitcoin-tx
|
|
core_interface
|
|
bitcoin_common
|
|
bitcoin_util
|
|
univalue
|
|
)
|
|
install_binary_component(bitcoin-tx HAS_MANPAGE)
|
|
endif()
|
|
|
|
|
|
if(BUILD_UTIL)
|
|
add_executable(bitcoin-util bitcoin-util.cpp)
|
|
add_windows_resources(bitcoin-util bitcoin-util-res.rc)
|
|
add_windows_application_manifest(bitcoin-util)
|
|
target_link_libraries(bitcoin-util
|
|
core_interface
|
|
bitcoin_common
|
|
bitcoin_util
|
|
)
|
|
install_binary_component(bitcoin-util HAS_MANPAGE)
|
|
endif()
|
|
|
|
|
|
if(BUILD_GUI)
|
|
add_subdirectory(qt)
|
|
endif()
|
|
|
|
|
|
if(BUILD_KERNEL_LIB)
|
|
add_subdirectory(kernel)
|
|
if (BUILD_KERNEL_TEST)
|
|
add_subdirectory(test/kernel)
|
|
endif()
|
|
if(BUILD_UTIL_CHAINSTATE)
|
|
add_executable(bitcoin-chainstate
|
|
bitcoin-chainstate.cpp
|
|
)
|
|
add_windows_application_manifest(bitcoin-chainstate)
|
|
target_link_libraries(bitcoin-chainstate
|
|
PRIVATE
|
|
core_interface
|
|
bitcoinkernel
|
|
)
|
|
install_binary_component(bitcoin-chainstate INTERNAL)
|
|
endif()
|
|
endif()
|
|
|
|
|
|
add_subdirectory(test/util)
|
|
if(BUILD_BENCH)
|
|
add_subdirectory(bench)
|
|
endif()
|
|
|
|
if(BUILD_TESTS)
|
|
add_subdirectory(test)
|
|
endif()
|
|
|
|
if(BUILD_FUZZ_BINARY)
|
|
add_subdirectory(test/fuzz)
|
|
endif()
|