diff --git a/.github/ci-test-each-commit-exec.py b/.github/ci-test-each-commit-exec.py index 3b2eaeeb596..959a1579aea 100755 --- a/.github/ci-test-each-commit-exec.py +++ b/.github/ci-test-each-commit-exec.py @@ -42,6 +42,8 @@ def main(): "-DBUILD_BENCH=ON", "-DBUILD_FUZZ_BINARY=ON", "-DWITH_USDT=ON", + "-DBUILD_KERNEL_LIB=ON", + "-DBUILD_KERNEL_TEST=ON", "-DCMAKE_CXX_FLAGS=-Wno-error=unused-member-function", ]) run(["cmake", "--build", "build", "-j", str(num_procs)]) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c3379efd49..3801c187faa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -205,7 +205,7 @@ jobs: job-type: [standard, fuzz] include: - job-type: standard - generate-options: '-DBUILD_GUI=ON -DWITH_ZMQ=ON -DBUILD_BENCH=ON -DWERROR=ON' + generate-options: '-DBUILD_GUI=ON -DWITH_ZMQ=ON -DBUILD_BENCH=ON -DBUILD_KERNEL_LIB=ON -DBUILD_UTIL_CHAINSTATE=ON -DWERROR=ON' job-name: 'Windows native, VS 2022' - job-type: fuzz generate-options: '-DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON -DVCPKG_MANIFEST_FEATURES="wallet" -DBUILD_GUI=OFF -DBUILD_FOR_FUZZING=ON -DWERROR=ON' @@ -283,7 +283,7 @@ jobs: $exeName = $_.Name # Skip as they currently do not have manifests - if ($exeName -eq "fuzz.exe" -or $exeName -eq "bench_bitcoin.exe" -or $exeName -eq "test_bitcoin-qt.exe") { + if ($exeName -eq "fuzz.exe" -or $exeName -eq "bench_bitcoin.exe" -or $exeName -eq "test_bitcoin-qt.exe" -or $exeName -eq "test_kernel.exe" -or $exeName -eq "bitcoin-chainstate.exe") { Write-Host "Skipping $exeName (no manifest present)" return } @@ -310,6 +310,7 @@ jobs: BITCOINTX: '${{ github.workspace }}\build\bin\Release\bitcoin-tx.exe' BITCOINUTIL: '${{ github.workspace }}\build\bin\Release\bitcoin-util.exe' BITCOINWALLET: '${{ github.workspace }}\build\bin\Release\bitcoin-wallet.exe' + BITCOINCHAINSTATE: '${{ github.workspace }}\build\bin\Release\bitcoin-chainstate.exe' TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }} run: py -3 test/functional/test_runner.py --jobs $NUMBER_OF_PROCESSORS --ci --quiet --tmpdirprefix="${RUNNER_TEMP}" --combinedlogslen=99999999 --timeout-factor=${TEST_RUNNER_TIMEOUT_FACTOR} ${TEST_RUNNER_EXTRA} @@ -402,7 +403,7 @@ jobs: $exeName = $_.Name # Skip as they currently do not have manifests - if ($exeName -eq "fuzz.exe" -or $exeName -eq "bench_bitcoin.exe") { + if ($exeName -eq "fuzz.exe" -or $exeName -eq "bench_bitcoin.exe" -or $exeName -eq "test_kernel.exe") { Write-Host "Skipping $exeName (no manifest present)" return } diff --git a/CMakeLists.txt b/CMakeLists.txt index c50e2f6d3f8..3749cf7c60e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,6 +105,7 @@ option(BUILD_UTIL "Build bitcoin-util executable." ${BUILD_TESTS}) option(BUILD_UTIL_CHAINSTATE "Build experimental bitcoin-chainstate executable." OFF) option(BUILD_KERNEL_LIB "Build experimental bitcoinkernel library." ${BUILD_UTIL_CHAINSTATE}) +option(BUILD_KERNEL_TEST "Build tests for the experimental bitcoinkernel library." ${BUILD_KERNEL_LIB}) option(ENABLE_WALLET "Enable wallet." ON) if(ENABLE_WALLET) @@ -210,6 +211,7 @@ if(BUILD_FOR_FUZZING) set(BUILD_UTIL OFF) set(BUILD_UTIL_CHAINSTATE OFF) set(BUILD_KERNEL_LIB OFF) + set(BUILD_KERNEL_TEST OFF) set(BUILD_WALLET_TOOL OFF) set(BUILD_GUI OFF) set(ENABLE_EXTERNAL_SIGNER OFF) @@ -667,6 +669,7 @@ message(" bitcoin-util ........................ ${BUILD_UTIL}") message(" bitcoin-wallet ...................... ${BUILD_WALLET_TOOL}") message(" bitcoin-chainstate (experimental) ... ${BUILD_UTIL_CHAINSTATE}") message(" libbitcoinkernel (experimental) ..... ${BUILD_KERNEL_LIB}") +message(" kernel-test (experimental) .......... ${BUILD_KERNEL_TEST}") message("Optional features:") message(" wallet support ...................... ${ENABLE_WALLET}") message(" external signer ..................... ${ENABLE_EXTERNAL_SIGNER}") diff --git a/ci/test/00_setup_env_mac_cross.sh b/ci/test/00_setup_env_mac_cross.sh index 027741dab4e..c7de0334721 100755 --- a/ci/test/00_setup_env_mac_cross.sh +++ b/ci/test/00_setup_env_mac_cross.sh @@ -17,4 +17,4 @@ export XCODE_BUILD_ID=15A240d export RUN_UNIT_TESTS=false export RUN_FUNCTIONAL_TESTS=false export GOAL="deploy" -export BITCOIN_CONFIG="-DBUILD_GUI=ON -DREDUCE_EXPORTS=ON" +export BITCOIN_CONFIG="-DBUILD_GUI=ON -DBUILD_KERNEL_LIB=ON -DREDUCE_EXPORTS=ON" diff --git a/ci/test/00_setup_env_mac_native.sh b/ci/test/00_setup_env_mac_native.sh index a188ed39897..41b97b02f1c 100755 --- a/ci/test/00_setup_env_mac_native.sh +++ b/ci/test/00_setup_env_mac_native.sh @@ -10,7 +10,7 @@ export CONTAINER_NAME="ci_mac_native" # macos does not use a container, but the export PIP_PACKAGES="--break-system-packages pycapnp zmq" export GOAL="install deploy" export CMAKE_GENERATOR="Ninja" -export BITCOIN_CONFIG="-DBUILD_GUI=ON -DWITH_ZMQ=ON -DREDUCE_EXPORTS=ON -DCMAKE_EXE_LINKER_FLAGS='-Wl,-stack_size -Wl,0x80000'" +export BITCOIN_CONFIG="-DBUILD_GUI=ON -DWITH_ZMQ=ON -DBUILD_KERNEL_LIB=ON -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_KERNEL_TEST=ON -DREDUCE_EXPORTS=ON -DCMAKE_EXE_LINKER_FLAGS='-Wl,-stack_size -Wl,0x80000'" export CI_OS_NAME="macos" export NO_DEPENDS=1 export OSX_SDK="" diff --git a/ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh b/ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh index 9f7704a923e..10417779416 100755 --- a/ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh +++ b/ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh @@ -13,4 +13,4 @@ export PACKAGES="python3-zmq python3-pip clang-17 llvm-17 libc++abi-17-dev libc+ export PIP_PACKAGES="--break-system-packages pycapnp" export DEP_OPTS="NO_WALLET=1 CC=clang-17 CXX='clang++-17 -stdlib=libc++'" export GOAL="install" -export BITCOIN_CONFIG="-DREDUCE_EXPORTS=ON -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_KERNEL_LIB=ON -DBUILD_SHARED_LIBS=ON" +export BITCOIN_CONFIG="-DREDUCE_EXPORTS=ON -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_KERNEL_LIB=ON -DBUILD_KERNEL_TEST=ON -DBUILD_SHARED_LIBS=ON" diff --git a/ci/test/00_setup_env_win64.sh b/ci/test/00_setup_env_win64.sh index f929f34c68f..1ea67230fbe 100755 --- a/ci/test/00_setup_env_win64.sh +++ b/ci/test/00_setup_env_win64.sh @@ -13,5 +13,5 @@ export PACKAGES="g++-mingw-w64-x86-64-posix nsis" export RUN_UNIT_TESTS=false export RUN_FUNCTIONAL_TESTS=false export GOAL="deploy" -export BITCOIN_CONFIG="-DREDUCE_EXPORTS=ON -DBUILD_GUI_TESTS=OFF \ +export BITCOIN_CONFIG="-DREDUCE_EXPORTS=ON -DBUILD_GUI_TESTS=OFF -DBUILD_KERNEL_LIB=ON -DBUILD_KERNEL_TEST=ON \ -DCMAKE_CXX_FLAGS='-Wno-error=maybe-uninitialized'" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bcadd675346..aed40610bea 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -404,28 +404,30 @@ endif() if(BUILD_KERNEL_LIB) add_subdirectory(kernel) -endif() - -if(BUILD_UTIL_CHAINSTATE) - add_executable(bitcoin-chainstate - bitcoin-chainstate.cpp - ) - add_windows_application_manifest(bitcoin-chainstate) - # TODO: The `SKIP_BUILD_RPATH` property setting can be deleted - # in the future after reordering Guix script commands to - # perform binary checks after the installation step. - # Relevant discussions: - # - https://github.com/hebasto/bitcoin/pull/236#issuecomment-2183120953 - # - https://github.com/bitcoin/bitcoin/pull/30312#issuecomment-2191235833 - set_target_properties(bitcoin-chainstate PROPERTIES - SKIP_BUILD_RPATH OFF - ) - target_link_libraries(bitcoin-chainstate - PRIVATE - core_interface - bitcoinkernel - ) - install_binary_component(bitcoin-chainstate INTERNAL) + 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) + # TODO: The `SKIP_BUILD_RPATH` property setting can be deleted + # in the future after reordering Guix script commands to + # perform binary checks after the installation step. + # Relevant discussions: + # - https://github.com/hebasto/bitcoin/pull/236#issuecomment-2183120953 + # - https://github.com/bitcoin/bitcoin/pull/30312#issuecomment-2191235833 + set_target_properties(bitcoin-chainstate PROPERTIES + SKIP_BUILD_RPATH OFF + ) + target_link_libraries(bitcoin-chainstate + PRIVATE + core_interface + bitcoinkernel + ) + install_binary_component(bitcoin-chainstate INTERNAL) + endif() endif() diff --git a/src/bitcoin-chainstate.cpp b/src/bitcoin-chainstate.cpp index 46e6f06e27f..310ca95c085 100644 --- a/src/bitcoin-chainstate.cpp +++ b/src/bitcoin-chainstate.cpp @@ -1,53 +1,135 @@ -// Copyright (c) 2022 The Bitcoin Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. -// -// The bitcoin-chainstate executable serves to surface the dependencies required -// by a program wishing to use Bitcoin Core's consensus engine as it is right -// now. -// -// DEVELOPER NOTE: Since this is a "demo-only", experimental, etc. executable, -// it may diverge from Bitcoin Core's coding style. -// -// It is part of the libbitcoinkernel project. - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include