diff --git a/.cirrus.yml b/.cirrus.yml index c047bacd88fd..0d45f8e1b81d 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -143,7 +143,7 @@ task: FILE_ENV: "./ci/test/00_setup_env_native_previous_releases.sh" task: - name: 'TSan, depends, gui' + name: 'TSan, depends, no gui' << : *GLOBAL_TASK_TEMPLATE persistent_worker: labels: diff --git a/.github/ci-test-each-commit-exec.py b/.github/ci-test-each-commit-exec.py index 14b84cf1f221..3b2eaeeb5964 100755 --- a/.github/ci-test-each-commit-exec.py +++ b/.github/ci-test-each-commit-exec.py @@ -17,18 +17,25 @@ def run(cmd, **kwargs): def main(): - print("Running test-one-commit on ...") + print("Running tests on commit ...") run(["git", "log", "-1"]) num_procs = int(run(["nproc"], stdout=subprocess.PIPE).stdout) - # Use clang++, because it is a bit faster and uses less memory than g++ run([ "cmake", "-B", "build", + "-Werror=dev", + # Use clang++, because it is a bit faster and uses less memory than g++ "-DCMAKE_C_COMPILER=clang", "-DCMAKE_CXX_COMPILER=clang++", + # Use mold, because it is faster than the default linker + "-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=mold", + # Use Debug build type for more debug checks, but enable optimizations + "-DAPPEND_CXXFLAGS='-O3 -g2'", + "-DAPPEND_CFLAGS='-O3 -g2'", + "-DCMAKE_BUILD_TYPE=Debug", "-DWERROR=ON", "-DWITH_ZMQ=ON", "-DBUILD_GUI=ON", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69c119d73719..d2526abdc38d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,7 +77,7 @@ jobs: git config user.name "CI" - run: | sudo apt-get update - sudo apt-get install clang ccache build-essential cmake ninja-build pkgconf python3-zmq libevent-dev libboost-dev libsqlite3-dev systemtap-sdt-dev libzmq3-dev qt6-base-dev qt6-tools-dev qt6-l10n-tools libqrencode-dev -y + sudo apt-get install clang mold ccache build-essential cmake ninja-build pkgconf python3-zmq libevent-dev libboost-dev libsqlite3-dev systemtap-sdt-dev libzmq3-dev qt6-base-dev qt6-tools-dev qt6-l10n-tools libqrencode-dev -y - name: Compile and run tests run: | # Run tests on commits after the last merge commit and before the PR head commit @@ -223,7 +223,7 @@ jobs: - name: Generate build system run: | - cmake -B build --preset vs2022 -DCMAKE_TOOLCHAIN_FILE="${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" ${{ matrix.generate-options }} + cmake -B build -Werror=dev --preset vs2022 -DCMAKE_TOOLCHAIN_FILE="${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" ${{ matrix.generate-options }} - name: Save vcpkg binary cache uses: actions/cache/save@v4 @@ -260,6 +260,7 @@ jobs: env: BITCOIND: '${{ github.workspace }}\build\bin\Release\bitcoind.exe' BITCOINCLI: '${{ github.workspace }}\build\bin\Release\bitcoin-cli.exe' + 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' TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }} @@ -389,16 +390,19 @@ jobs: (Get-Content "test/config.ini") -replace '(?<=^SRCDIR=).*', '${{ github.workspace }}' -replace '(?<=^BUILDDIR=).*', '${{ github.workspace }}' -replace '(?<=^RPCAUTH=).*', '${{ github.workspace }}/share/rpcauth/rpcauth.py' | Set-Content "test/config.ini" Get-Content "test/config.ini" - - name: Run util tests - run: py -3 test/util/test_runner.py + - name: Set previous release directory + run: | + echo "PREVIOUS_RELEASES_DIR=${{ runner.temp }}/previous_releases" >> "$GITHUB_ENV" - - name: Run rpcauth test - run: py -3 test/util/rpcauth-test.py + - name: Get previous releases + working-directory: test + run: ./get_previous_releases.py --target-dir $PREVIOUS_RELEASES_DIR - name: Run functional tests env: # TODO: Fix the excluded test and re-enable it. - EXCLUDE: '--exclude wallet_multiwallet.py' + # feature_unsupported_utxo_db.py fails on windows because of emojis in the test data directory + EXCLUDE: '--exclude wallet_multiwallet.py,feature_unsupported_utxo_db.py' 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 $EXCLUDE $TEST_RUNNER_EXTRA diff --git a/CMakeLists.txt b/CMakeLists.txt index f7241020815c..42552b9613eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -590,11 +590,9 @@ set(Python3_FIND_FRAMEWORK LAST CACHE STRING "") set(Python3_FIND_UNVERSIONED_NAMES FIRST CACHE STRING "") mark_as_advanced(Python3_FIND_FRAMEWORK Python3_FIND_UNVERSIONED_NAMES) find_package(Python3 3.10 COMPONENTS Interpreter) -if(Python3_EXECUTABLE) - set(PYTHON_COMMAND ${Python3_EXECUTABLE}) -else() +if(NOT TARGET Python3::Interpreter) list(APPEND configure_warnings - "Minimum required Python not found. Utils and rpcauth tests are disabled." + "Minimum required Python not found." ) endif() @@ -638,8 +636,6 @@ add_subdirectory(doc) add_subdirectory(src) -include(cmake/tests.cmake) - include(Maintenance) setup_split_debug_script() add_maintenance_targets() diff --git a/CMakePresets.json b/CMakePresets.json index 05b055d40bc4..d478af3e70b1 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,6 +1,5 @@ { "version": 3, - "cmakeMinimumRequired": {"major": 3, "minor": 21, "patch": 0}, "configurePresets": [ { "name": "vs2022", @@ -62,6 +61,7 @@ "name": "dev-mode", "displayName": "Developer mode, with all features/dependencies enabled", "binaryDir": "${sourceDir}/build_dev_mode", + "errors": {"dev": true}, "cacheVariables": { "BUILD_BENCH": "ON", "BUILD_CLI": "ON", diff --git a/README.md b/README.md index 7e524461c509..cfabb7f6723b 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Translations ------------ Changes to translations as well as new translations can be submitted to -[Bitcoin Core's Transifex page](https://www.transifex.com/bitcoin/bitcoin/). +[Bitcoin Core's Transifex page](https://explore.transifex.com/bitcoin/bitcoin/). Translations are periodically pulled from Transifex and merged into the git repository. See the [translation process](doc/translation_process.md) for details on how this works. diff --git a/ci/lint/04_install.sh b/ci/lint/01_install.sh similarity index 97% rename from ci/lint/04_install.sh rename to ci/lint/01_install.sh index c1e39dc93e2a..a00d95da73a9 100755 --- a/ci/lint/04_install.sh +++ b/ci/lint/01_install.sh @@ -6,6 +6,8 @@ export LC_ALL=C +set -o errexit -o pipefail -o xtrace + export CI_RETRY_EXE="/ci_retry --" pushd "/" diff --git a/ci/lint_imagefile b/ci/lint_imagefile index 9da3747e0838..b32380769de5 100644 --- a/ci/lint_imagefile +++ b/ci/lint_imagefile @@ -12,7 +12,7 @@ ENV LC_ALL=C.UTF-8 COPY ./ci/retry/retry /ci_retry COPY ./.python-version /.python-version COPY ./ci/lint/container-entrypoint.sh /entrypoint.sh -COPY ./ci/lint/04_install.sh /install.sh +COPY ./ci/lint/01_install.sh /install.sh RUN /install.sh && \ echo 'alias lint="./ci/lint/06_script.sh"' >> ~/.bashrc && \ diff --git a/ci/lint_run_all.sh b/ci/lint_run_all.sh index ab3f4392dcb4..427e24e17fb6 100755 --- a/ci/lint_run_all.sh +++ b/ci/lint_run_all.sh @@ -13,6 +13,6 @@ cp "./ci/retry/retry" "/ci_retry" cp "./.python-version" "/.python-version" mkdir --parents "/test/lint" cp --recursive "./test/lint/test_runner" "/test/lint/" -set -o errexit; source ./ci/lint/04_install.sh +set -o errexit; source ./ci/lint/01_install.sh set -o errexit ./ci/lint/06_script.sh diff --git a/ci/test/00_setup_env_arm.sh b/ci/test/00_setup_env_arm.sh index 45dabb8f383d..ce019784f908 100755 --- a/ci/test/00_setup_env_arm.sh +++ b/ci/test/00_setup_env_arm.sh @@ -16,6 +16,7 @@ export USE_BUSY_BOX=true export RUN_UNIT_TESTS=true export RUN_FUNCTIONAL_TESTS=false export GOAL="install" +export CI_LIMIT_STACK_SIZE=1 # -Wno-psabi is to disable ABI warnings: "note: parameter passing for argument of type ... changed in GCC 7.1" # This could be removed once the ABI change warning does not show up by default export BITCOIN_CONFIG="-DREDUCE_EXPORTS=ON -DCMAKE_CXX_FLAGS='-Wno-psabi -Wno-error=maybe-uninitialized'" diff --git a/ci/test/00_setup_env_i686_multiprocess.sh b/ci/test/00_setup_env_i686_multiprocess.sh index 3144cf22fc51..e19a45d169c8 100755 --- a/ci/test/00_setup_env_i686_multiprocess.sh +++ b/ci/test/00_setup_env_i686_multiprocess.sh @@ -13,7 +13,7 @@ export CI_IMAGE_PLATFORM="linux/amd64" export PACKAGES="llvm clang g++-multilib" export DEP_OPTS="DEBUG=1 MULTIPROCESS=1" export GOAL="install" -export TEST_RUNNER_EXTRA="--v2transport" +export TEST_RUNNER_EXTRA="--v2transport --usecli" export BITCOIN_CONFIG="\ -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_C_COMPILER='clang;-m32' \ diff --git a/ci/test/00_setup_env_mac_native.sh b/ci/test/00_setup_env_mac_native.sh index 1b4bee1566f3..65917b950602 100755 --- a/ci/test/00_setup_env_mac_native.sh +++ b/ci/test/00_setup_env_mac_native.sh @@ -11,7 +11,7 @@ export LC_ALL=C.UTF-8 export PIP_PACKAGES="--break-system-packages zmq" export GOAL="install deploy" export CMAKE_GENERATOR="Ninja" -export BITCOIN_CONFIG="-DBUILD_GUI=ON -DWITH_ZMQ=ON -DREDUCE_EXPORTS=ON" +export BITCOIN_CONFIG="-DBUILD_GUI=ON -DWITH_ZMQ=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_mac_native_fuzz.sh b/ci/test/00_setup_env_mac_native_fuzz.sh index cacf2423ac30..d8a61fbac73a 100755 --- a/ci/test/00_setup_env_mac_native_fuzz.sh +++ b/ci/test/00_setup_env_mac_native_fuzz.sh @@ -7,7 +7,7 @@ export LC_ALL=C.UTF-8 export CMAKE_GENERATOR="Ninja" -export BITCOIN_CONFIG="-DBUILD_FOR_FUZZING=ON" +export BITCOIN_CONFIG="-DBUILD_FOR_FUZZING=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_asan.sh b/ci/test/00_setup_env_native_asan.sh index b2650ada0cf8..a1dd5aa968f0 100755 --- a/ci/test/00_setup_env_native_asan.sh +++ b/ci/test/00_setup_env_native_asan.sh @@ -23,11 +23,12 @@ export APT_LLVM_V="20" export PACKAGES="systemtap-sdt-dev clang-${APT_LLVM_V} llvm-${APT_LLVM_V} libclang-rt-${APT_LLVM_V}-dev python3-zmq qt6-base-dev qt6-tools-dev qt6-l10n-tools libevent-dev libboost-dev libzmq3-dev libqrencode-dev libsqlite3-dev ${BPFCC_PACKAGE}" export NO_DEPENDS=1 export GOAL="install" +export CI_LIMIT_STACK_SIZE=1 export BITCOIN_CONFIG="\ -DWITH_USDT=ON -DWITH_ZMQ=ON -DBUILD_GUI=ON \ -DSANITIZERS=address,float-divide-by-zero,integer,undefined \ - -DCMAKE_C_COMPILER=clang-${APT_LLVM_V} \ - -DCMAKE_CXX_COMPILER=clang++-${APT_LLVM_V} \ + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_C_FLAGS='-ftrivial-auto-var-init=pattern' \ -DCMAKE_CXX_FLAGS='-ftrivial-auto-var-init=pattern' \ -DAPPEND_CXXFLAGS='-std=c++23' \ diff --git a/ci/test/00_setup_env_native_fuzz.sh b/ci/test/00_setup_env_native_fuzz.sh index c5220211fc56..f80c4d988deb 100755 --- a/ci/test/00_setup_env_native_fuzz.sh +++ b/ci/test/00_setup_env_native_fuzz.sh @@ -19,9 +19,8 @@ export CI_CONTAINER_CAP="--cap-add SYS_PTRACE" # If run with (ASan + LSan), the export BITCOIN_CONFIG="\ -DBUILD_FOR_FUZZING=ON \ -DSANITIZERS=fuzzer,address,undefined,float-divide-by-zero,integer \ - -DCMAKE_C_COMPILER=clang-${APT_LLVM_V} \ - -DCMAKE_CXX_COMPILER=clang++-${APT_LLVM_V} \ + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_C_FLAGS='-ftrivial-auto-var-init=pattern' \ -DCMAKE_CXX_FLAGS='-ftrivial-auto-var-init=pattern' \ " -export LLVM_SYMBOLIZER_PATH="/usr/bin/llvm-symbolizer-${APT_LLVM_V}" diff --git a/ci/test/00_setup_env_native_fuzz_with_msan.sh b/ci/test/00_setup_env_native_fuzz_with_msan.sh index fe107a74ba7d..c71772b8e2cb 100755 --- a/ci/test/00_setup_env_native_fuzz_with_msan.sh +++ b/ci/test/00_setup_env_native_fuzz_with_msan.sh @@ -7,13 +7,12 @@ export LC_ALL=C.UTF-8 export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04" -LIBCXX_DIR="/msan/cxx_build/" +LIBCXX_DIR="/cxx_build/" export MSAN_FLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -g -O1 -fno-optimize-sibling-calls" LIBCXX_FLAGS="-nostdinc++ -nostdlib++ -isystem ${LIBCXX_DIR}include/c++/v1 -L${LIBCXX_DIR}lib -Wl,-rpath,${LIBCXX_DIR}lib -lc++ -lc++abi -lpthread -Wno-unused-command-line-argument" export MSAN_AND_LIBCXX_FLAGS="${MSAN_FLAGS} ${LIBCXX_FLAGS}" export CONTAINER_NAME="ci_native_fuzz_msan" -export PACKAGES="ninja-build" export DEP_OPTS="DEBUG=1 NO_QT=1 CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'" export GOAL="all" # Setting CMAKE_{C,CXX}_FLAGS_DEBUG flags to an empty string ensures that the flags set in MSAN_FLAGS remain unaltered. @@ -26,7 +25,7 @@ export BITCOIN_CONFIG="\ -DSANITIZERS=fuzzer,memory \ -DAPPEND_CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE -U_FORTIFY_SOURCE' \ " -export USE_MEMORY_SANITIZER="true" +export USE_INSTRUMENTED_LIBCPP="MemoryWithOrigins" export RUN_UNIT_TESTS="false" export RUN_FUNCTIONAL_TESTS="false" export RUN_FUZZ_TESTS=true diff --git a/ci/test/00_setup_env_native_msan.sh b/ci/test/00_setup_env_native_msan.sh index 756c3d30271d..80b259889723 100755 --- a/ci/test/00_setup_env_native_msan.sh +++ b/ci/test/00_setup_env_native_msan.sh @@ -7,15 +7,17 @@ export LC_ALL=C.UTF-8 export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04" -LIBCXX_DIR="/msan/cxx_build/" +export APT_LLVM_V="20" +LIBCXX_DIR="/cxx_build/" export MSAN_FLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -g -O1 -fno-optimize-sibling-calls" LIBCXX_FLAGS="-nostdinc++ -nostdlib++ -isystem ${LIBCXX_DIR}include/c++/v1 -L${LIBCXX_DIR}lib -Wl,-rpath,${LIBCXX_DIR}lib -lc++ -lc++abi -lpthread -Wno-unused-command-line-argument" export MSAN_AND_LIBCXX_FLAGS="${MSAN_FLAGS} ${LIBCXX_FLAGS}" export CONTAINER_NAME="ci_native_msan" -export PACKAGES="ninja-build" +export PACKAGES="clang-${APT_LLVM_V} llvm-${APT_LLVM_V} llvm-${APT_LLVM_V}-dev libclang-${APT_LLVM_V}-dev libclang-rt-${APT_LLVM_V}-dev" export DEP_OPTS="DEBUG=1 NO_QT=1 CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'" export GOAL="install" +export CI_LIMIT_STACK_SIZE=1 # Setting CMAKE_{C,CXX}_FLAGS_DEBUG flags to an empty string ensures that the flags set in MSAN_FLAGS remain unaltered. # _FORTIFY_SOURCE is not compatible with MSAN. export BITCOIN_CONFIG="\ @@ -25,4 +27,4 @@ export BITCOIN_CONFIG="\ -DSANITIZERS=memory \ -DAPPEND_CPPFLAGS='-U_FORTIFY_SOURCE' \ " -export USE_MEMORY_SANITIZER="true" +export USE_INSTRUMENTED_LIBCPP="MemoryWithOrigins" diff --git a/ci/test/00_setup_env_native_previous_releases.sh b/ci/test/00_setup_env_native_previous_releases.sh index 2a26c4c578b7..7a7544b3e1ef 100755 --- a/ci/test/00_setup_env_native_previous_releases.sh +++ b/ci/test/00_setup_env_native_previous_releases.sh @@ -15,6 +15,7 @@ export TEST_RUNNER_EXTRA="--previous-releases --coverage --extended --exclude fe export RUN_UNIT_TESTS_SEQUENTIAL="true" export RUN_UNIT_TESTS="false" export GOAL="install" +export CI_LIMIT_STACK_SIZE=1 export DOWNLOAD_PREVIOUS_RELEASES="true" export BITCOIN_CONFIG="\ -DWITH_ZMQ=ON -DBUILD_GUI=ON -DREDUCE_EXPORTS=ON \ diff --git a/ci/test/00_setup_env_native_tsan.sh b/ci/test/00_setup_env_native_tsan.sh index b341adfec53c..2079ca731e3b 100755 --- a/ci/test/00_setup_env_native_tsan.sh +++ b/ci/test/00_setup_env_native_tsan.sh @@ -9,8 +9,12 @@ export LC_ALL=C.UTF-8 export CONTAINER_NAME=ci_native_tsan export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04" export APT_LLVM_V="20" -export PACKAGES="clang-${APT_LLVM_V} llvm-${APT_LLVM_V} libclang-rt-${APT_LLVM_V}-dev libc++abi-${APT_LLVM_V}-dev libc++-${APT_LLVM_V}-dev python3-zmq" -export DEP_OPTS="CC=clang-${APT_LLVM_V} CXX='clang++-${APT_LLVM_V} -stdlib=libc++'" +LIBCXX_DIR="/cxx_build/" +LIBCXX_FLAGS="-fsanitize=thread -nostdinc++ -nostdlib++ -isystem ${LIBCXX_DIR}include/c++/v1 -L${LIBCXX_DIR}lib -Wl,-rpath,${LIBCXX_DIR}lib -lc++ -lc++abi -lpthread -Wno-unused-command-line-argument" +export PACKAGES="clang-${APT_LLVM_V} llvm-${APT_LLVM_V} llvm-${APT_LLVM_V}-dev libclang-${APT_LLVM_V}-dev libclang-rt-${APT_LLVM_V}-dev python3-zmq" +export DEP_OPTS="CC=clang CXX=clang++ CXXFLAGS='${LIBCXX_FLAGS}' NO_QT=1" export GOAL="install" +export CI_LIMIT_STACK_SIZE=1 export BITCOIN_CONFIG="-DWITH_ZMQ=ON -DSANITIZERS=thread \ --DAPPEND_CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER -DDEBUG_LOCKCONTENTION -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES'" +-DAPPEND_CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKCONTENTION -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES'" +export USE_INSTRUMENTED_LIBCPP="Thread" diff --git a/ci/test/01_base_install.sh b/ci/test/01_base_install.sh index d61aaca3f0ca..b68dc7781a9e 100755 --- a/ci/test/01_base_install.sh +++ b/ci/test/01_base_install.sh @@ -6,11 +6,11 @@ export LC_ALL=C.UTF-8 -set -ex +set -o errexit -o pipefail -o xtrace -CFG_DONE="ci.base-install-done" # Use a global git setting to remember whether this script ran to avoid running it twice +CFG_DONE="${BASE_ROOT_DIR}/ci.base-install-done" # Use a global setting to remember whether this script ran to avoid running it twice -if [ "$(git config --global ${CFG_DONE})" == "true" ]; then +if [ "$( cat "${CFG_DONE}" || true )" == "done" ]; then echo "Skip base install" exit 0 fi @@ -44,32 +44,42 @@ elif [ "$CI_OS_NAME" != "macos" ]; then ${CI_RETRY_EXE} bash -c "apt-get install --no-install-recommends --no-upgrade -y $PACKAGES $CI_BASE_PACKAGES" fi +if [ -n "${APT_LLVM_V}" ]; then + update-alternatives --install /usr/bin/clang++ clang++ "/usr/bin/clang++-${APT_LLVM_V}" 100 + update-alternatives --install /usr/bin/clang clang "/usr/bin/clang-${APT_LLVM_V}" 100 + update-alternatives --install /usr/bin/llvm-symbolizer llvm-symbolizer "/usr/bin/llvm-symbolizer-${APT_LLVM_V}" 100 +fi + if [ -n "$PIP_PACKAGES" ]; then # shellcheck disable=SC2086 ${CI_RETRY_EXE} pip3 install --user $PIP_PACKAGES fi -if [[ ${USE_MEMORY_SANITIZER} == "true" ]]; then - ${CI_RETRY_EXE} git clone --depth=1 https://github.com/llvm/llvm-project -b "llvmorg-20.1.0" /msan/llvm-project - - cmake -G Ninja -B /msan/clang_build/ \ - -DLLVM_ENABLE_PROJECTS="clang" \ - -DCMAKE_BUILD_TYPE=Release \ - -DLLVM_TARGETS_TO_BUILD=Native \ - -DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi;libunwind" \ - -S /msan/llvm-project/llvm - - ninja -C /msan/clang_build/ "$MAKEJOBS" - ninja -C /msan/clang_build/ install-runtimes - - update-alternatives --install /usr/bin/clang++ clang++ /msan/clang_build/bin/clang++ 100 - update-alternatives --install /usr/bin/clang clang /msan/clang_build/bin/clang 100 - update-alternatives --install /usr/bin/llvm-symbolizer llvm-symbolizer /msan/clang_build/bin/llvm-symbolizer 100 +if [[ -n "${USE_INSTRUMENTED_LIBCPP}" ]]; then + if [ -n "${APT_LLVM_V}" ]; then + ${CI_RETRY_EXE} git clone --depth=1 https://github.com/llvm/llvm-project -b "llvmorg-$( clang --version | sed --silent 's@.*clang version \([0-9.]*\).*@\1@p' )" /llvm-project + else + ${CI_RETRY_EXE} git clone --depth=1 https://github.com/llvm/llvm-project -b "llvmorg-20.1.8" /llvm-project + + cmake -G Ninja -B /clang_build/ \ + -DLLVM_ENABLE_PROJECTS="clang" \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_TARGETS_TO_BUILD=Native \ + -DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi;libunwind" \ + -S /llvm-project/llvm + + ninja -C /clang_build/ "$MAKEJOBS" + ninja -C /clang_build/ install-runtimes + + update-alternatives --install /usr/bin/clang++ clang++ /clang_build/bin/clang++ 100 + update-alternatives --install /usr/bin/clang clang /clang_build/bin/clang 100 + update-alternatives --install /usr/bin/llvm-symbolizer llvm-symbolizer /clang_build/bin/llvm-symbolizer 100 + fi - cmake -G Ninja -B /msan/cxx_build/ \ + cmake -G Ninja -B /cxx_build/ \ -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \ -DCMAKE_BUILD_TYPE=Release \ - -DLLVM_USE_SANITIZER=MemoryWithOrigins \ + -DLLVM_USE_SANITIZER="${USE_INSTRUMENTED_LIBCPP}" \ -DCMAKE_C_COMPILER=clang \ -DCMAKE_CXX_COMPILER=clang++ \ -DLLVM_TARGETS_TO_BUILD=Native \ @@ -77,13 +87,13 @@ if [[ ${USE_MEMORY_SANITIZER} == "true" ]]; then -DLIBCXXABI_USE_LLVM_UNWINDER=OFF \ -DLIBCXX_ABI_DEFINES="_LIBCPP_ABI_BOUNDED_ITERATORS;_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY;_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING;_LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR;_LIBCPP_ABI_BOUNDED_UNIQUE_PTR" \ -DLIBCXX_HARDENING_MODE=debug \ - -S /msan/llvm-project/runtimes + -S /llvm-project/runtimes - ninja -C /msan/cxx_build/ "$MAKEJOBS" + ninja -C /cxx_build/ "$MAKEJOBS" # Clear no longer needed source folder - du -sh /msan/llvm-project - rm -rf /msan/llvm-project + du -sh /llvm-project + rm -rf /llvm-project fi if [[ "${RUN_TIDY}" == "true" ]]; then @@ -105,4 +115,4 @@ if [ -n "$XCODE_VERSION" ] && [ ! -d "${DEPENDS_DIR}/SDKs/${OSX_SDK_BASENAME}" ] tar -C "${DEPENDS_DIR}/SDKs" -xf "$OSX_SDK_PATH" fi -git config --global ${CFG_DONE} "true" +echo -n "done" > "${CFG_DONE}" diff --git a/ci/test/02_run_container.sh b/ci/test/02_run_container.sh index 9616018e31e7..33e250c3e53a 100755 --- a/ci/test/02_run_container.sh +++ b/ci/test/02_run_container.sh @@ -153,13 +153,9 @@ CI_EXEC () { export -f CI_EXEC # Normalize all folders to BASE_ROOT_DIR -CI_EXEC rsync --archive --stats --human-readable "${BASE_READ_ONLY_DIR}/" "${BASE_ROOT_DIR}" || echo "Nothing to copy from ${BASE_READ_ONLY_DIR}/" +CI_EXEC rsync --recursive --perms --stats --human-readable "${BASE_READ_ONLY_DIR}/" "${BASE_ROOT_DIR}" || echo "Nothing to copy from ${BASE_READ_ONLY_DIR}/" CI_EXEC "${BASE_ROOT_DIR}/ci/test/01_base_install.sh" -# Fixes permission issues when there is a container UID/GID mismatch with the owner -# of the git source code directory. -CI_EXEC git config --global --add safe.directory \"*\" - CI_EXEC mkdir -p "${BINS_SCRATCH_DIR}" CI_EXEC "${BASE_ROOT_DIR}/ci/test/03_test_script.sh" diff --git a/ci/test/03_test_script.sh b/ci/test/03_test_script.sh index 3394c50b8bd5..13bfea1f2279 100755 --- a/ci/test/03_test_script.sh +++ b/ci/test/03_test_script.sh @@ -99,7 +99,7 @@ if [ -z "$NO_DEPENDS" ]; then bash -c "$SHELL_OPTS make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS LOG=1" fi if [ "$DOWNLOAD_PREVIOUS_RELEASES" = "true" ]; then - test/get_previous_releases.py -b -t "$PREVIOUS_RELEASES_DIR" + test/get_previous_releases.py --target-dir "$PREVIOUS_RELEASES_DIR" fi BITCOIN_CONFIG_ALL="-DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON" @@ -115,33 +115,51 @@ PRINT_CCACHE_STATISTICS="ccache --version | head -n 1 && ccache --show-stats" # Folder where the build is done. BASE_BUILD_DIR=${BASE_BUILD_DIR:-$BASE_SCRATCH_DIR/build-$HOST} -mkdir -p "${BASE_BUILD_DIR}" -cd "${BASE_BUILD_DIR}" -BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_INSTALL_PREFIX=$BASE_OUTDIR" +BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_INSTALL_PREFIX=$BASE_OUTDIR -Werror=dev" if [[ "${RUN_TIDY}" == "true" ]]; then BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_EXPORT_COMPILE_COMMANDS=ON" fi -bash -c "cmake -S $BASE_ROOT_DIR $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( (cat $(cmake -P "${BASE_ROOT_DIR}/ci/test/GetCMakeLogFiles.cmake")) && false)" +bash -c "cmake -S $BASE_ROOT_DIR -B ${BASE_BUILD_DIR} $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG" || ( + # shellcheck disable=SC2046 + cat $(cmake -P "${BASE_ROOT_DIR}/ci/test/GetCMakeLogFiles.cmake") + false +) -bash -c "cmake --build . $MAKEJOBS --target all $GOAL" || ( echo "Build failure. Verbose build follows." && cmake --build . --target all "$GOAL" --verbose ; false ) +# shellcheck disable=SC2086 +cmake --build "${BASE_BUILD_DIR}" "$MAKEJOBS" --target all $GOAL || ( + echo "Build failure. Verbose build follows." + # shellcheck disable=SC2086 + cmake --build "${BASE_BUILD_DIR}" -j1 --target all $GOAL --verbose + false +) bash -c "${PRINT_CCACHE_STATISTICS}" du -sh "${DEPENDS_DIR}"/*/ du -sh "${PREVIOUS_RELEASES_DIR}" +if [ -n "${CI_LIMIT_STACK_SIZE}" ]; then + ulimit -s 512 +fi + if [ -n "$USE_VALGRIND" ]; then "${BASE_ROOT_DIR}/ci/test/wrap-valgrind.sh" fi if [ "$RUN_CHECK_DEPS" = "true" ]; then - "${BASE_ROOT_DIR}/contrib/devtools/check-deps.sh" . + "${BASE_ROOT_DIR}/contrib/devtools/check-deps.sh" "${BASE_BUILD_DIR}" fi if [ "$RUN_UNIT_TESTS" = "true" ]; then - DIR_UNIT_TEST_DATA="${DIR_UNIT_TEST_DATA}" LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" CTEST_OUTPUT_ON_FAILURE=ON ctest --stop-on-failure "${MAKEJOBS}" --timeout $(( TEST_RUNNER_TIMEOUT_FACTOR * 60 )) + DIR_UNIT_TEST_DATA="${DIR_UNIT_TEST_DATA}" \ + LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" \ + CTEST_OUTPUT_ON_FAILURE=ON \ + ctest --test-dir "${BASE_BUILD_DIR}" \ + --stop-on-failure \ + "${MAKEJOBS}" \ + --timeout $(( TEST_RUNNER_TIMEOUT_FACTOR * 60 )) fi if [ "$RUN_UNIT_TESTS_SEQUENTIAL" = "true" ]; then @@ -151,7 +169,16 @@ fi if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then # parses TEST_RUNNER_EXTRA as an array which allows for multiple arguments such as TEST_RUNNER_EXTRA='--exclude "rpc_bind.py --ipv6"' eval "TEST_RUNNER_EXTRA=($TEST_RUNNER_EXTRA)" - LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" test/functional/test_runner.py --ci "${MAKEJOBS}" --tmpdirprefix "${BASE_SCRATCH_DIR}"/test_runner/ --ansi --combinedlogslen=99999999 --timeout-factor="${TEST_RUNNER_TIMEOUT_FACTOR}" "${TEST_RUNNER_EXTRA[@]}" --quiet --failfast + LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" \ + "${BASE_BUILD_DIR}/test/functional/test_runner.py" \ + --ci "${MAKEJOBS}" \ + --tmpdirprefix "${BASE_SCRATCH_DIR}/test_runner/" \ + --ansi \ + --combinedlogslen=99999999 \ + --timeout-factor="${TEST_RUNNER_TIMEOUT_FACTOR}" \ + "${TEST_RUNNER_EXTRA[@]}" \ + --quiet \ + --failfast fi if [ "${RUN_TIDY}" = "true" ]; then @@ -185,5 +212,11 @@ fi if [ "$RUN_FUZZ_TESTS" = "true" ]; then # shellcheck disable=SC2086 - LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" test/fuzz/test_runner.py ${FUZZ_TESTS_CONFIG} "${MAKEJOBS}" -l DEBUG "${DIR_FUZZ_IN}" --empty_min_time=60 + LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" \ + "${BASE_BUILD_DIR}/test/fuzz/test_runner.py" \ + ${FUZZ_TESTS_CONFIG} \ + "${MAKEJOBS}" \ + -l DEBUG \ + "${DIR_FUZZ_IN}" \ + --empty_min_time=60 fi diff --git a/cmake/module/AddBoostIfNeeded.cmake b/cmake/module/AddBoostIfNeeded.cmake index ecd0d6f2aba1..e2eaf5565ac1 100644 --- a/cmake/module/AddBoostIfNeeded.cmake +++ b/cmake/module/AddBoostIfNeeded.cmake @@ -17,17 +17,29 @@ function(add_boost_if_needed) directory and other added INTERFACE properties. ]=] - # We cannot rely on find_package(Boost ...) to work properly without - # Boost_NO_BOOST_CMAKE set until we require a more recent Boost because - # upstream did not ship proper CMake files until 1.82.0. - # Until then, we rely on CMake's FindBoost module. - # See: https://cmake.org/cmake/help/latest/policy/CMP0167.html - if(POLICY CMP0167) - cmake_policy(SET CMP0167 OLD) + if(CMAKE_HOST_APPLE) + find_program(HOMEBREW_EXECUTABLE brew) + if(HOMEBREW_EXECUTABLE) + execute_process( + COMMAND ${HOMEBREW_EXECUTABLE} --prefix boost + OUTPUT_VARIABLE Boost_ROOT + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + endif() + endif() + + find_package(Boost 1.73.0 REQUIRED CONFIG) + mark_as_advanced(Boost_INCLUDE_DIR boost_headers_DIR) + # Workaround for a bug in NetBSD pkgsrc. + # See: https://github.com/NetBSD/pkgsrc/issues/167. + if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD") + get_filename_component(_boost_include_dir "${boost_headers_DIR}/../../../include/" ABSOLUTE) + set_target_properties(Boost::headers PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${_boost_include_dir} + ) + unset(_boost_include_dir) endif() - set(Boost_NO_BOOST_CMAKE ON) - find_package(Boost 1.73.0 REQUIRED) - mark_as_advanced(Boost_INCLUDE_DIR) set_target_properties(Boost::headers PROPERTIES IMPORTED_GLOBAL TRUE) target_compile_definitions(Boost::headers INTERFACE # We don't use multi_index serialization. @@ -45,34 +57,24 @@ function(add_boost_if_needed) # older than 1.80. # See: https://github.com/boostorg/config/pull/430. set(CMAKE_REQUIRED_DEFINITIONS -DBOOST_NO_CXX98_FUNCTION_BASE) - set(CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIR}) - include(CMakePushCheckState) - cmake_push_check_state() - include(TryAppendCXXFlags) + get_target_property(CMAKE_REQUIRED_INCLUDES Boost::headers INTERFACE_INCLUDE_DIRECTORIES) set(CMAKE_REQUIRED_FLAGS ${working_compiler_werror_flag}) set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + include(CheckCXXSourceCompiles) check_cxx_source_compiles(" #include " NO_DIAGNOSTICS_BOOST_NO_CXX98_FUNCTION_BASE ) - cmake_pop_check_state() if(NO_DIAGNOSTICS_BOOST_NO_CXX98_FUNCTION_BASE) target_compile_definitions(Boost::headers INTERFACE BOOST_NO_CXX98_FUNCTION_BASE ) - else() - set(CMAKE_REQUIRED_DEFINITIONS) endif() # Some package managers, such as vcpkg, vendor Boost.Test separately # from the rest of the headers, so we have to check for it individually. if(BUILD_TESTS AND DEFINED VCPKG_TARGET_TRIPLET) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -DBOOST_TEST_NO_MAIN) - include(CheckIncludeFileCXX) - check_include_file_cxx(boost/test/included/unit_test.hpp HAVE_BOOST_INCLUDED_UNIT_TEST_H) - if(NOT HAVE_BOOST_INCLUDED_UNIT_TEST_H) - message(FATAL_ERROR "Building test_bitcoin executable requested but boost/test/included/unit_test.hpp header not available.") - endif() + find_package(boost_included_unit_test_framework ${Boost_VERSION} EXACT REQUIRED CONFIG) endif() endfunction() diff --git a/cmake/module/FindQRencode.cmake b/cmake/module/FindQRencode.cmake index 39e3b8b679be..575bfecc8b1a 100644 --- a/cmake/module/FindQRencode.cmake +++ b/cmake/module/FindQRencode.cmake @@ -21,16 +21,16 @@ endif() find_path(QRencode_INCLUDE_DIR NAMES qrencode.h - PATHS ${PC_QRencode_INCLUDE_DIRS} + HINTS ${PC_QRencode_INCLUDE_DIRS} ) find_library(QRencode_LIBRARY_RELEASE NAMES qrencode - PATHS ${PC_QRencode_LIBRARY_DIRS} + HINTS ${PC_QRencode_LIBRARY_DIRS} ) find_library(QRencode_LIBRARY_DEBUG NAMES qrencoded qrencode - PATHS ${PC_QRencode_LIBRARY_DIRS} + HINTS ${PC_QRencode_LIBRARY_DIRS} ) include(SelectLibraryConfigurations) select_library_configurations(QRencode) diff --git a/cmake/module/Maintenance.cmake b/cmake/module/Maintenance.cmake index d09559c5a9ae..52fc7faba9f9 100644 --- a/cmake/module/Maintenance.cmake +++ b/cmake/module/Maintenance.cmake @@ -19,7 +19,7 @@ function(setup_split_debug_script) endfunction() function(add_maintenance_targets) - if(NOT PYTHON_COMMAND) + if(NOT TARGET Python3::Interpreter) return() endif() @@ -31,13 +31,13 @@ function(add_maintenance_targets) add_custom_target(check-symbols COMMAND ${CMAKE_COMMAND} -E echo "Running symbol and dynamic library checks..." - COMMAND ${PYTHON_COMMAND} ${PROJECT_SOURCE_DIR}/contrib/guix/symbol-check.py ${executables} + COMMAND Python3::Interpreter ${PROJECT_SOURCE_DIR}/contrib/guix/symbol-check.py ${executables} VERBATIM ) add_custom_target(check-security COMMAND ${CMAKE_COMMAND} -E echo "Checking binary security..." - COMMAND ${PYTHON_COMMAND} ${PROJECT_SOURCE_DIR}/contrib/guix/security-check.py ${executables} + COMMAND Python3::Interpreter ${PROJECT_SOURCE_DIR}/contrib/guix/security-check.py ${executables} VERBATIM ) endfunction() @@ -100,7 +100,7 @@ function(add_macos_deploy_target) if(CMAKE_HOST_APPLE) add_custom_command( OUTPUT ${PROJECT_BINARY_DIR}/${osx_volname}.zip - COMMAND ${PYTHON_COMMAND} ${PROJECT_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} ${osx_volname} -translations-dir=${QT_TRANSLATIONS_DIR} -zip + COMMAND Python3::Interpreter ${PROJECT_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} ${osx_volname} -translations-dir=${QT_TRANSLATIONS_DIR} -zip DEPENDS ${PROJECT_BINARY_DIR}/${macos_app}/Contents/MacOS/Bitcoin-Qt VERBATIM ) @@ -113,7 +113,7 @@ function(add_macos_deploy_target) else() add_custom_command( OUTPUT ${PROJECT_BINARY_DIR}/dist/${macos_app}/Contents/MacOS/Bitcoin-Qt - COMMAND OBJDUMP=${CMAKE_OBJDUMP} ${PYTHON_COMMAND} ${PROJECT_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} ${osx_volname} -translations-dir=${QT_TRANSLATIONS_DIR} + COMMAND ${CMAKE_COMMAND} -E env OBJDUMP=${CMAKE_OBJDUMP} $ ${PROJECT_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} ${osx_volname} -translations-dir=${QT_TRANSLATIONS_DIR} DEPENDS ${PROJECT_BINARY_DIR}/${macos_app}/Contents/MacOS/Bitcoin-Qt VERBATIM ) diff --git a/cmake/tests.cmake b/cmake/tests.cmake deleted file mode 100644 index 279132980017..000000000000 --- a/cmake/tests.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# 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/. - -if(TARGET bitcoin-util AND TARGET bitcoin-tx AND PYTHON_COMMAND) - add_test(NAME util_test_runner - COMMAND ${CMAKE_COMMAND} -E env BITCOINUTIL=$ BITCOINTX=$ ${PYTHON_COMMAND} ${PROJECT_BINARY_DIR}/test/util/test_runner.py - ) -endif() - -if(PYTHON_COMMAND) - add_test(NAME util_rpcauth_test - COMMAND ${PYTHON_COMMAND} ${PROJECT_BINARY_DIR}/test/util/rpcauth-test.py - ) -endif() diff --git a/contrib/asmap/README.md b/contrib/asmap/README.md index 0a9d95e49c70..849281c5da82 100644 --- a/contrib/asmap/README.md +++ b/contrib/asmap/README.md @@ -9,7 +9,7 @@ Example usage: python3 asmap-tool.py encode /path/to/input.file /path/to/output.file python3 asmap-tool.py decode /path/to/input.file /path/to/output.file python3 asmap-tool.py diff /path/to/first.file /path/to/second.file -python3 asmap-tool.py diff-addrs /path/to/first.file /path/to/second.file addrs.file +python3 asmap-tool.py diff_addrs /path/to/first.file /path/to/second.file addrs.file ``` These commands may take a few minutes to run with `python3`, depending on the amount of data involved and your machine specs. @@ -43,7 +43,7 @@ increases output size by outputting strictly non-overlapping network ranges. ### Comparing ASmaps AS control of IP networks changes frequently, therefore it can be useful to get -the changes between to ASmaps via the `diff` and `diff_addrs` commands. +the changes between two ASmaps via the `diff` and `diff_addrs` commands. `diff` takes two ASmap files, and returns a file detailing the changes in the state of a network's AS assignment between the first and the second file. diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build index 715568c15436..ee285bf322cf 100755 --- a/contrib/guix/guix-build +++ b/contrib/guix/guix-build @@ -73,19 +73,7 @@ mkdir -p "$VERSION_BASE" # SOURCE_DATE_EPOCH should not unintentionally be set ################ -if [ -n "$SOURCE_DATE_EPOCH" ] && [ -z "$FORCE_SOURCE_DATE_EPOCH" ]; then -cat << EOF -ERR: Environment variable SOURCE_DATE_EPOCH is set which may break reproducibility. - - Aborting... - -Hint: You may want to: - 1. Unset this variable: \`unset SOURCE_DATE_EPOCH\` before rebuilding - 2. Set the 'FORCE_SOURCE_DATE_EPOCH' environment variable if you insist on - using your own epoch -EOF -exit 1 -fi +check_source_date_epoch ################ # Build directories should not exist diff --git a/contrib/guix/guix-codesign b/contrib/guix/guix-codesign index dedee135b4ab..ac7aae3a1802 100755 --- a/contrib/guix/guix-codesign +++ b/contrib/guix/guix-codesign @@ -67,6 +67,12 @@ EOF exit 1 fi +################ +# SOURCE_DATE_EPOCH should not unintentionally be set +################ + +check_source_date_epoch + ################ # The codesignature git worktree should not be dirty ################ diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh index ae98eba7444a..2b47e1645da9 100755 --- a/contrib/guix/libexec/build.sh +++ b/contrib/guix/libexec/build.sh @@ -242,6 +242,7 @@ mkdir -p "$DISTSRC" cmake -S . -B build \ --toolchain "${BASEPREFIX}/${HOST}/toolchain.cmake" \ -DWITH_CCACHE=OFF \ + -Werror=dev \ ${CONFIGFLAGS} # Build Bitcoin Core diff --git a/contrib/guix/libexec/prelude.bash b/contrib/guix/libexec/prelude.bash index f7fc932dfd32..d25c371a10c6 100644 --- a/contrib/guix/libexec/prelude.bash +++ b/contrib/guix/libexec/prelude.bash @@ -21,6 +21,26 @@ check_tools() { done } +################ +# SOURCE_DATE_EPOCH should not unintentionally be set +################ + +check_source_date_epoch() { + if [ -n "$SOURCE_DATE_EPOCH" ] && [ -z "$FORCE_SOURCE_DATE_EPOCH" ]; then + cat << EOF +ERR: Environment variable SOURCE_DATE_EPOCH is set which may break reproducibility. + + Aborting... + +Hint: You may want to: + 1. Unset this variable: \`unset SOURCE_DATE_EPOCH\` before rebuilding + 2. Set the 'FORCE_SOURCE_DATE_EPOCH' environment variable if you insist on + using your own epoch +EOF + exit 1 + fi +} + check_tools cat env readlink dirname basename git ################ diff --git a/contrib/signet/miner b/contrib/signet/miner index c6ce7f92730f..8c7edc56a32f 100755 --- a/contrib/signet/miner +++ b/contrib/signet/miner @@ -95,7 +95,6 @@ def finish_block(block, signet_solution, grind_cmd): newheadhex = subprocess.run(cmd, stdout=subprocess.PIPE, input=b"", check=True).stdout.strip() newhead = from_hex(CBlockHeader(), newheadhex.decode('utf8')) block.nNonce = newhead.nNonce - block.rehash() return block def new_block(tmpl, reward_spk, *, blocktime=None, poolid=None): @@ -482,15 +481,15 @@ def do_generate(args): # report bstr = "block" if gen.is_mine else "backup block" - next_delta = gen.next_block_delta(block.nBits, block.hash) + next_delta = gen.next_block_delta(block.nBits, block.hash_hex) next_delta += block.nTime - time.time() - next_is_mine = gen.next_block_is_mine(block.hash) + next_is_mine = gen.next_block_is_mine(block.hash_hex) - logging.debug("Block hash %s payout to %s", block.hash, reward_addr) + logging.debug("Block hash %s payout to %s", block.hash_hex, reward_addr) logging.info("Mined %s at height %d; next in %s (%s)", bstr, tmpl["height"], seconds_to_hms(next_delta), ("mine" if next_is_mine else "backup")) if r != "": - logging.warning("submitblock returned %s for height %d hash %s", r, tmpl["height"], block.hash) - lastheader = block.hash + logging.warning("submitblock returned %s for height %d hash %s", r, tmpl["height"], block.hash_hex) + lastheader = block.hash_hex def do_calibrate(args): if args.nbits is not None and args.seconds is not None: diff --git a/contrib/tracing/mempool_monitor.py b/contrib/tracing/mempool_monitor.py index 22efa91783f4..eb29b374158b 100755 --- a/contrib/tracing/mempool_monitor.py +++ b/contrib/tracing/mempool_monitor.py @@ -66,7 +66,7 @@ int trace_added(struct pt_regs *ctx) { struct added_event added = {}; void *phash = NULL; - bpf_usdt_readarg(1, ctx, phash); + bpf_usdt_readarg(1, ctx, &phash); bpf_probe_read_user(&added.hash, sizeof(added.hash), phash); bpf_usdt_readarg(2, ctx, &added.vsize); bpf_usdt_readarg(3, ctx, &added.fee); @@ -78,9 +78,9 @@ int trace_removed(struct pt_regs *ctx) { struct removed_event removed = {}; void *phash = NULL, *preason = NULL; - bpf_usdt_readarg(1, ctx, phash); + bpf_usdt_readarg(1, ctx, &phash); bpf_probe_read_user(&removed.hash, sizeof(removed.hash), phash); - bpf_usdt_readarg(2, ctx, preason); + bpf_usdt_readarg(2, ctx, &preason); bpf_probe_read_user_str(&removed.reason, sizeof(removed.reason), preason); bpf_usdt_readarg(3, ctx, &removed.vsize); bpf_usdt_readarg(4, ctx, &removed.fee); @@ -93,9 +93,9 @@ int trace_rejected(struct pt_regs *ctx) { struct rejected_event rejected = {}; void *phash = NULL, *preason = NULL; - bpf_usdt_readarg(1, ctx, phash); + bpf_usdt_readarg(1, ctx, &phash); bpf_probe_read_user(&rejected.hash, sizeof(rejected.hash), phash); - bpf_usdt_readarg(2, ctx, preason); + bpf_usdt_readarg(2, ctx, &preason); bpf_probe_read_user_str(&rejected.reason, sizeof(rejected.reason), preason); rejected_events.perf_submit(ctx, &rejected, sizeof(rejected)); return 0; @@ -104,12 +104,12 @@ int trace_replaced(struct pt_regs *ctx) { struct replaced_event replaced = {}; void *phash_replaced = NULL, *phash_replacement = NULL; - bpf_usdt_readarg(1, ctx, phash_replaced); + bpf_usdt_readarg(1, ctx, &phash_replaced); bpf_probe_read_user(&replaced.replaced_hash, sizeof(replaced.replaced_hash), phash_replaced); bpf_usdt_readarg(2, ctx, &replaced.replaced_vsize); bpf_usdt_readarg(3, ctx, &replaced.replaced_fee); bpf_usdt_readarg(4, ctx, &replaced.replaced_entry_time); - bpf_usdt_readarg(5, ctx, phash_replacement); + bpf_usdt_readarg(5, ctx, &phash_replacement); bpf_probe_read_user(&replaced.replacement_hash, sizeof(replaced.replacement_hash), phash_replacement); bpf_usdt_readarg(6, ctx, &replaced.replacement_vsize); bpf_usdt_readarg(7, ctx, &replaced.replacement_fee); diff --git a/contrib/tracing/p2p_monitor.py b/contrib/tracing/p2p_monitor.py index 78225366d9c8..51af60375137 100755 --- a/contrib/tracing/p2p_monitor.py +++ b/contrib/tracing/p2p_monitor.py @@ -54,7 +54,7 @@ bpf_probe_read_user_str(&msg.peer_addr, sizeof(msg.peer_addr), paddr); bpf_usdt_readarg(3, ctx, &pconn_type); bpf_probe_read_user_str(&msg.peer_conn_type, sizeof(msg.peer_conn_type), pconn_type); - bpf_usdt_readarg(4, ctx, &pconn_type); + bpf_usdt_readarg(4, ctx, &pmsg_type); bpf_probe_read_user_str(&msg.msg_type, sizeof(msg.msg_type), pmsg_type); bpf_usdt_readarg(5, ctx, &msg.msg_size); @@ -71,7 +71,7 @@ bpf_probe_read_user_str(&msg.peer_addr, sizeof(msg.peer_addr), paddr); bpf_usdt_readarg(3, ctx, &pconn_type); bpf_probe_read_user_str(&msg.peer_conn_type, sizeof(msg.peer_conn_type), pconn_type); - bpf_usdt_readarg(4, ctx, &pconn_type); + bpf_usdt_readarg(4, ctx, &pmsg_type); bpf_probe_read_user_str(&msg.msg_type, sizeof(msg.msg_type), pmsg_type); bpf_usdt_readarg(5, ctx, &msg.msg_size); @@ -179,7 +179,7 @@ def loop(screen, bpf, peers): info_panel = panel.new_panel(win) info_panel.hide() - ROWS_AVALIABLE_FOR_LIST = curses.LINES - 5 + ROWS_AVAILABLE_FOR_LIST = curses.LINES - 5 scroll = 0 while True: @@ -191,7 +191,7 @@ def loop(screen, bpf, peers): if (ch == curses.KEY_DOWN or ch == ord("j")) and cur_list_pos < len( peers.keys()) -1 and info_panel.hidden(): cur_list_pos += 1 - if cur_list_pos >= ROWS_AVALIABLE_FOR_LIST: + if cur_list_pos >= ROWS_AVAILABLE_FOR_LIST: scroll += 1 if (ch == curses.KEY_UP or ch == ord("k")) and cur_list_pos > 0 and info_panel.hidden(): cur_list_pos -= 1 @@ -203,14 +203,14 @@ def loop(screen, bpf, peers): else: info_panel.hide() screen.erase() - render(screen, peers, cur_list_pos, scroll, ROWS_AVALIABLE_FOR_LIST, info_panel) + render(screen, peers, cur_list_pos, scroll, ROWS_AVAILABLE_FOR_LIST, info_panel) curses.panel.update_panels() screen.refresh() except KeyboardInterrupt: exit() -def render(screen, peers, cur_list_pos, scroll, ROWS_AVALIABLE_FOR_LIST, info_panel): +def render(screen, peers, cur_list_pos, scroll, ROWS_AVAILABLE_FOR_LIST, info_panel): """ renders the list of peers and details panel This code is unrelated to USDT, BCC and BPF. @@ -223,7 +223,7 @@ def render(screen, peers, cur_list_pos, scroll, ROWS_AVALIABLE_FOR_LIST, info_pa 1, 0, (" Navigate with UP/DOWN or J/K and select a peer with ENTER or SPACE to see individual P2P messages"), curses.A_NORMAL) screen.addstr(3, 0, header_format % ("PEER", "OUTBOUND", "INBOUND", "TYPE", "ADDR"), curses.A_BOLD | curses.A_UNDERLINE) - peer_list = sorted(peers.keys())[scroll:ROWS_AVALIABLE_FOR_LIST+scroll] + peer_list = sorted(peers.keys())[scroll:ROWS_AVAILABLE_FOR_LIST+scroll] for i, peer_id in enumerate(peer_list): peer = peers[peer_id] screen.addstr(i + 4, 0, diff --git a/depends/README.md b/depends/README.md index 627662e9091d..db3098921e0b 100644 --- a/depends/README.md +++ b/depends/README.md @@ -33,6 +33,10 @@ To build dependencies for the current arch+OS: pkg install bash cmake curl gmake +Skip the following packages if you don't intend to use the GUI and will build with [`NO_QT=1`](#dependency-options): + + pkg install bison ninja pkgconf python3 + To build dependencies for the current arch+OS: gmake @@ -53,6 +57,18 @@ To build dependencies for the current arch+OS: gmake +### Alpine + + apk add bash build-base cmake curl make patch + +Skip the following packages if you don't intend to use the GUI and will build with [`NO_QT=1`](#dependency-options): + + apk add bison linux-headers samurai pkgconf python3 + +To build dependencies for the current arch+OS: + + make + ## Configuring Bitcoin Core **When configuring Bitcoin Core, CMake by default will ignore the depends output.** In diff --git a/depends/builders/freebsd.mk b/depends/builders/freebsd.mk index 18316f492ee9..910de28bf36f 100644 --- a/depends/builders/freebsd.mk +++ b/depends/builders/freebsd.mk @@ -3,3 +3,7 @@ build_freebsd_CXX=clang++ build_freebsd_SHA256SUM = sha256sum build_freebsd_DOWNLOAD = curl --location --fail --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -o + +# freebsd host on freebsd builder: override freebsd host preferences. +freebsd_CC = clang +freebsd_CXX = clang++ diff --git a/depends/builders/openbsd.mk b/depends/builders/openbsd.mk index 4b3214ae810f..6aeb14312587 100644 --- a/depends/builders/openbsd.mk +++ b/depends/builders/openbsd.mk @@ -7,3 +7,7 @@ build_openbsd_DOWNLOAD = curl --location --fail --connect-timeout $(DOWNLOAD_CON build_openbsd_TAR = gtar # openBSD touch doesn't understand -h build_openbsd_TOUCH = touch -m -t 200001011200 + +# openbsd host on openbsd builder: override openbsd host preferences. +openbsd_CC = clang +openbsd_CXX = clang++ diff --git a/depends/funcs.mk b/depends/funcs.mk index b499b6a78fe2..28baf47147a5 100644 --- a/depends/funcs.mk +++ b/depends/funcs.mk @@ -8,9 +8,11 @@ $(1)_ar=$$($$($(1)_type)_AR) $(1)_ranlib=$$($$($(1)_type)_RANLIB) $(1)_nm=$$($$($(1)_type)_NM) $(1)_cflags=$$($$($(1)_type)_CFLAGS) \ - $$($$($(1)_type)_$$(release_type)_CFLAGS) + $$($$($(1)_type)_$$(release_type)_CFLAGS) \ + -pipe -std=$(C_STANDARD) $(1)_cxxflags=$$($$($(1)_type)_CXXFLAGS) \ - $$($$($(1)_type)_$$(release_type)_CXXFLAGS) + $$($$($(1)_type)_$$(release_type)_CXXFLAGS) \ + -pipe -std=$(CXX_STANDARD) $(1)_ldflags=$$($$($(1)_type)_LDFLAGS) \ $$($$($(1)_type)_$$(release_type)_LDFLAGS) \ -L$$($($(1)_type)_prefix)/lib @@ -224,6 +226,7 @@ $(1)_cmake=env CC="$$($(1)_cc)" \ -DCMAKE_INSTALL_LIBDIR=lib/ \ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ -DCMAKE_VERBOSE_MAKEFILE:BOOL=$(V) \ + -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY:BOOL=TRUE \ $$($(1)_config_opts) ifeq ($($(1)_type),build) $(1)_cmake += -DCMAKE_INSTALL_RPATH:PATH="$$($($(1)_type)_prefix)/lib" diff --git a/depends/hosts/darwin.mk b/depends/hosts/darwin.mk index 6f39718effde..7ec2fd96caab 100644 --- a/depends/hosts/darwin.mk +++ b/depends/hosts/darwin.mk @@ -60,8 +60,8 @@ darwin_CXX=$(clangxx_prog) --target=$(host) \ -iwithsysroot/usr/include/c++/v1 \ -iwithsysroot/usr/include -iframeworkwithsysroot/System/Library/Frameworks -darwin_CFLAGS=-pipe -std=$(C_STANDARD) -mmacos-version-min=$(OSX_MIN_VERSION) -darwin_CXXFLAGS=-pipe -std=$(CXX_STANDARD) -mmacos-version-min=$(OSX_MIN_VERSION) +darwin_CFLAGS=-mmacos-version-min=$(OSX_MIN_VERSION) +darwin_CXXFLAGS=-mmacos-version-min=$(OSX_MIN_VERSION) darwin_LDFLAGS=-Wl,-platform_version,macos,$(OSX_MIN_VERSION),$(OSX_SDK_VERSION) ifneq ($(build_os),darwin) diff --git a/depends/hosts/freebsd.mk b/depends/hosts/freebsd.mk index 009d215f82f8..b69535cc800e 100644 --- a/depends/hosts/freebsd.mk +++ b/depends/hosts/freebsd.mk @@ -1,5 +1,5 @@ -freebsd_CFLAGS=-pipe -std=$(C_STANDARD) -freebsd_CXXFLAGS=-pipe -std=$(CXX_STANDARD) +freebsd_CFLAGS= +freebsd_CXXFLAGS= freebsd_release_CFLAGS=-O2 freebsd_release_CXXFLAGS=$(freebsd_release_CFLAGS) diff --git a/depends/hosts/linux.mk b/depends/hosts/linux.mk index e2f34265d153..41958f9978be 100644 --- a/depends/hosts/linux.mk +++ b/depends/hosts/linux.mk @@ -1,5 +1,5 @@ -linux_CFLAGS=-pipe -std=$(C_STANDARD) -linux_CXXFLAGS=-pipe -std=$(CXX_STANDARD) +linux_CFLAGS= +linux_CXXFLAGS= ifneq ($(LTO),) linux_AR = $(host_toolchain)gcc-ar diff --git a/depends/hosts/mingw32.mk b/depends/hosts/mingw32.mk index 4628f7255df4..7db6afaef6a1 100644 --- a/depends/hosts/mingw32.mk +++ b/depends/hosts/mingw32.mk @@ -5,8 +5,8 @@ ifneq ($(shell $(SHELL) $(.SHELLFLAGS) "command -v $(host)-g++-posix"),) mingw32_CXX := $(host)-g++-posix endif -mingw32_CFLAGS=-pipe -std=$(C_STANDARD) -mingw32_CXXFLAGS=-pipe -std=$(CXX_STANDARD) +mingw32_CFLAGS= +mingw32_CXXFLAGS= ifneq ($(LTO),) mingw32_AR = $(host_toolchain)gcc-ar diff --git a/depends/hosts/netbsd.mk b/depends/hosts/netbsd.mk index d2b79f9d5bf3..0e1256c34e89 100644 --- a/depends/hosts/netbsd.mk +++ b/depends/hosts/netbsd.mk @@ -1,5 +1,5 @@ -netbsd_CFLAGS=-pipe -std=$(C_STANDARD) -netbsd_CXXFLAGS=-pipe -std=$(CXX_STANDARD) +netbsd_CFLAGS= +netbsd_CXXFLAGS= ifneq ($(LTO),) netbsd_AR = $(host_toolchain)gcc-ar diff --git a/depends/hosts/openbsd.mk b/depends/hosts/openbsd.mk index 53595689b62e..5ab3f53eae64 100644 --- a/depends/hosts/openbsd.mk +++ b/depends/hosts/openbsd.mk @@ -1,5 +1,5 @@ -openbsd_CFLAGS=-pipe -std=$(C_STANDARD) -openbsd_CXXFLAGS=-pipe -std=$(CXX_STANDARD) +openbsd_CFLAGS= +openbsd_CXXFLAGS= openbsd_release_CFLAGS=-O2 openbsd_release_CXXFLAGS=$(openbsd_release_CFLAGS) diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 938e9971ba88..312f19e294dc 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -1,10 +1,29 @@ package=boost -$(package)_version=1.81.0 -$(package)_download_path=https://archives.boost.io/release/$($(package)_version)/source/ -$(package)_file_name=boost_$(subst .,_,$($(package)_version)).tar.gz -$(package)_sha256_hash=205666dea9f6a7cfed87c7a6dfbeb52a2c1b9de55712c9c1a87735d7181452b6 +$(package)_version = 1.88.0 +$(package)_download_path = https://github.com/boostorg/boost/releases/download/boost-$($(package)_version) +$(package)_file_name = boost-$($(package)_version)-cmake.tar.gz +$(package)_sha256_hash = dcea50f40ba1ecfc448fdf886c0165cf3e525fef2c9e3e080b9804e8117b9694 +$(package)_patches = skip_compiled_targets.patch +$(package)_build_subdir = build + +define $(package)_set_vars + $(package)_config_opts = -DBOOST_INCLUDE_LIBRARIES="multi_index;signals2;test" + $(package)_config_opts += -DBOOST_TEST_HEADERS_ONLY=ON + $(package)_config_opts += -DBOOST_ENABLE_MPI=OFF + $(package)_config_opts += -DBOOST_ENABLE_PYTHON=OFF + $(package)_config_opts += -DBOOST_INSTALL_LAYOUT=system + $(package)_config_opts += -DBUILD_TESTING=OFF + $(package)_config_opts += -DCMAKE_DISABLE_FIND_PACKAGE_ICU=ON +endef + +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/skip_compiled_targets.patch +endef + +define $(package)_config_cmds + $($(package)_cmake) -S .. -B . +endef define $(package)_stage_cmds - mkdir -p $($(package)_staging_prefix_dir)/include && \ - cp -r boost $($(package)_staging_prefix_dir)/include + $(MAKE) DESTDIR=$($(package)_staging_dir) install endef diff --git a/depends/packages/libevent.mk b/depends/packages/libevent.mk index dadd3b1b75da..e9153b71f39d 100644 --- a/depends/packages/libevent.mk +++ b/depends/packages/libevent.mk @@ -5,6 +5,7 @@ $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb $(package)_patches=cmake_fixups.patch $(package)_patches += netbsd_fixup.patch +$(package)_patches += winver_fixup.patch $(package)_build_subdir=build # When building for Windows, we set _WIN32_WINNT to target the same Windows @@ -21,7 +22,8 @@ endef define $(package)_preprocess_cmds patch -p1 < $($(package)_patch_dir)/cmake_fixups.patch && \ - patch -p1 < $($(package)_patch_dir)/netbsd_fixup.patch + patch -p1 < $($(package)_patch_dir)/netbsd_fixup.patch && \ + patch -p1 < $($(package)_patch_dir)/winver_fixup.patch endef define $(package)_config_cmds diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 7802cd915ee1..b6f100f28cdc 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -9,6 +9,7 @@ qrencode_darwin_packages = qrencode qrencode_mingw32_packages = qrencode qt_linux_packages:=qt expat libxcb xcb_proto libXau xproto freetype fontconfig libxkbcommon libxcb_util libxcb_util_cursor libxcb_util_render libxcb_util_keysyms libxcb_util_image libxcb_util_wm +qt_freebsd_packages:=$(qt_linux_packages) qt_darwin_packages=qt qt_mingw32_packages=qt ifneq ($(host),$(build)) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index bd7d432897b8..4daffeb1aa38 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -7,7 +7,8 @@ $(package)_sha256_hash=$(qt_details_qtbase_sha256_hash) ifneq ($(host),$(build)) $(package)_dependencies := native_$(package) endif -$(package)_linux_dependencies=freetype fontconfig libxcb libxkbcommon libxcb_util libxcb_util_cursor libxcb_util_render libxcb_util_keysyms libxcb_util_image libxcb_util_wm +$(package)_linux_dependencies := freetype fontconfig libxcb libxkbcommon libxcb_util libxcb_util_cursor libxcb_util_render libxcb_util_keysyms libxcb_util_image libxcb_util_wm +$(package)_freebsd_dependencies := $($(package)_linux_dependencies) $(package)_patches_path := $(qt_details_patches_path) $(package)_patches := dont_hardcode_pwd.patch $(package)_patches += qtbase-moc-ignore-gcc-macro.patch @@ -146,6 +147,7 @@ $(package)_config_opts_linux += -xcb ifneq ($(LTO),) $(package)_config_opts_linux += -ltcg endif +$(package)_config_opts_freebsd := $$($(package)_config_opts_linux) $(package)_config_opts_mingw32 := -no-dbus $(package)_config_opts_mingw32 += -no-freetype diff --git a/depends/patches/boost/skip_compiled_targets.patch b/depends/patches/boost/skip_compiled_targets.patch new file mode 100644 index 000000000000..32b69ce69536 --- /dev/null +++ b/depends/patches/boost/skip_compiled_targets.patch @@ -0,0 +1,136 @@ +cmake: Add `BOOST_TEST_HEADERS_ONLY` configuration variable + +This change allows the build to be configured to install only the +Boost.Test headers required for using the headers-only variant of the +Unit Test Framework. + +Upstream commit: 097e97820e654ead9c477b47443a545cef5d3b12 + + +--- a/libs/test/CMakeLists.txt ++++ b/libs/test/CMakeLists.txt +@@ -30,60 +30,70 @@ set(_boost_test_dependencies + Boost::utility + ) + +-# Compiled targets ++option(BOOST_TEST_HEADERS_ONLY "Boost.Test: Only install headers" OFF) + +-function(boost_test_add_library name) ++set(_boost_test_libraries "") + +- add_library(boost_${name} ${ARGN}) +- add_library(Boost::${name} ALIAS boost_${name}) ++if (NOT BOOST_TEST_HEADERS_ONLY) + +- target_include_directories(boost_${name} PUBLIC include) +- target_link_libraries(boost_${name} PUBLIC ${_boost_test_dependencies}) ++ # Compiled targets + +- target_compile_definitions(boost_${name} +- PUBLIC BOOST_TEST_NO_LIB +- # Source files already define BOOST_TEST_SOURCE +- # PRIVATE BOOST_TEST_SOURCE +- ) ++ function(boost_test_add_library name) + +- if(BUILD_SHARED_LIBS) +- target_compile_definitions(boost_${name} PUBLIC BOOST_TEST_DYN_LINK) +- else() +- target_compile_definitions(boost_${name} PUBLIC BOOST_TEST_STATIC_LINK) +- endif() ++ add_library(boost_${name} ${ARGN}) ++ add_library(Boost::${name} ALIAS boost_${name}) + +-endfunction() ++ target_include_directories(boost_${name} PUBLIC include) ++ target_link_libraries(boost_${name} PUBLIC ${_boost_test_dependencies}) + +-boost_test_add_library(prg_exec_monitor +- src/cpp_main.cpp +- src/debug.cpp +- src/execution_monitor.cpp +-) ++ target_compile_definitions(boost_${name} ++ PUBLIC BOOST_TEST_NO_LIB ++ # Source files already define BOOST_TEST_SOURCE ++ # PRIVATE BOOST_TEST_SOURCE ++ ) + +-set(SOURCES +- src/compiler_log_formatter.cpp +- src/debug.cpp +- src/decorator.cpp +- src/execution_monitor.cpp +- src/framework.cpp +- src/junit_log_formatter.cpp +- src/plain_report_formatter.cpp +- src/progress_monitor.cpp +- src/results_collector.cpp +- src/results_reporter.cpp +- src/test_framework_init_observer.cpp +- src/test_tools.cpp +- src/test_tree.cpp +- src/unit_test_log.cpp +- src/unit_test_main.cpp +- src/unit_test_monitor.cpp +- src/unit_test_parameters.cpp +- src/xml_log_formatter.cpp +- src/xml_report_formatter.cpp +-) ++ if(BUILD_SHARED_LIBS) ++ target_compile_definitions(boost_${name} PUBLIC BOOST_TEST_DYN_LINK) ++ else() ++ target_compile_definitions(boost_${name} PUBLIC BOOST_TEST_STATIC_LINK) ++ endif() ++ ++ endfunction() + +-boost_test_add_library(test_exec_monitor STATIC ${SOURCES} src/test_main.cpp) +-boost_test_add_library(unit_test_framework ${SOURCES}) ++ boost_test_add_library(prg_exec_monitor ++ src/cpp_main.cpp ++ src/debug.cpp ++ src/execution_monitor.cpp ++ ) ++ ++ set(SOURCES ++ src/compiler_log_formatter.cpp ++ src/debug.cpp ++ src/decorator.cpp ++ src/execution_monitor.cpp ++ src/framework.cpp ++ src/junit_log_formatter.cpp ++ src/plain_report_formatter.cpp ++ src/progress_monitor.cpp ++ src/results_collector.cpp ++ src/results_reporter.cpp ++ src/test_framework_init_observer.cpp ++ src/test_tools.cpp ++ src/test_tree.cpp ++ src/unit_test_log.cpp ++ src/unit_test_main.cpp ++ src/unit_test_monitor.cpp ++ src/unit_test_parameters.cpp ++ src/xml_log_formatter.cpp ++ src/xml_report_formatter.cpp ++ ) ++ ++ boost_test_add_library(test_exec_monitor STATIC ${SOURCES} src/test_main.cpp) ++ boost_test_add_library(unit_test_framework ${SOURCES}) ++ ++ set(_boost_test_libraries boost_prg_exec_monitor boost_test_exec_monitor boost_unit_test_framework) ++ ++endif() + + # Header-only targets + +@@ -107,7 +117,7 @@ if(BOOST_SUPERPROJECT_VERSION AND NOT CMAKE_VERSION VERSION_LESS 3.13) + + boost_install( + TARGETS +- boost_prg_exec_monitor boost_test_exec_monitor boost_unit_test_framework ++ ${_boost_test_libraries} + boost_included_prg_exec_monitor boost_included_test_exec_monitor boost_included_unit_test_framework + VERSION ${BOOST_SUPERPROJECT_VERSION} + HEADER_DIRECTORY include diff --git a/depends/patches/libevent/winver_fixup.patch b/depends/patches/libevent/winver_fixup.patch new file mode 100644 index 000000000000..4995c356f942 --- /dev/null +++ b/depends/patches/libevent/winver_fixup.patch @@ -0,0 +1,122 @@ +Cherry-picked from a14ff91254f40cf36e0fee199e26fb11260fab49. + +move _WIN32_WINNT defintions before first #include + +_WIN32_WINNT and WIN32_LEAN_AND_MEAN need to be defined +before the windows.h is included for the first time. +Avoid the confusion of indirect #include by defining +before any. + +diff --git a/event_iocp.c b/event_iocp.c +index 6b2a2e15..4955e426 100644 +--- a/event_iocp.c ++++ b/event_iocp.c +@@ -23,12 +23,14 @@ + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +-#include "evconfig-private.h" + + #ifndef _WIN32_WINNT + /* Minimum required for InitializeCriticalSectionAndSpinCount */ + #define _WIN32_WINNT 0x0403 + #endif ++ ++#include "evconfig-private.h" ++ + #include + #include + #include +diff --git a/evthread_win32.c b/evthread_win32.c +index 2ec80560..8647f72b 100644 +--- a/evthread_win32.c ++++ b/evthread_win32.c +@@ -23,18 +23,21 @@ + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +-#include "event2/event-config.h" +-#include "evconfig-private.h" + + #ifdef _WIN32 + #ifndef _WIN32_WINNT + /* Minimum required for InitializeCriticalSectionAndSpinCount */ + #define _WIN32_WINNT 0x0403 + #endif +-#include + #define WIN32_LEAN_AND_MEAN ++#endif ++ ++#include "event2/event-config.h" ++#include "evconfig-private.h" ++ ++#ifdef _WIN32 ++#include + #include +-#undef WIN32_LEAN_AND_MEAN + #include + #endif + +diff --git a/evutil.c b/evutil.c +index 9817f086..8537ffe8 100644 +--- a/evutil.c ++++ b/evutil.c +@@ -24,6 +24,14 @@ + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + ++#ifdef _WIN32 ++#ifndef _WIN32_WINNT ++/* For structs needed by GetAdaptersAddresses */ ++#define _WIN32_WINNT 0x0501 ++#endif ++#define WIN32_LEAN_AND_MEAN ++#endif ++ + #include "event2/event-config.h" + #include "evconfig-private.h" + +@@ -31,15 +39,10 @@ + #include + #include + #include +-#define WIN32_LEAN_AND_MEAN + #include +-#undef WIN32_LEAN_AND_MEAN + #include + #include + #include +-#undef _WIN32_WINNT +-/* For structs needed by GetAdaptersAddresses */ +-#define _WIN32_WINNT 0x0501 + #include + #include + #endif +diff --git a/listener.c b/listener.c +index f5c00c9c..d1080e76 100644 +--- a/listener.c ++++ b/listener.c +@@ -24,16 +24,19 @@ + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + ++#ifdef _WIN32 ++#ifndef _WIN32_WINNT ++/* Minimum required for InitializeCriticalSectionAndSpinCount */ ++#define _WIN32_WINNT 0x0403 ++#endif ++#endif ++ + #include "event2/event-config.h" + #include "evconfig-private.h" + + #include + + #ifdef _WIN32 +-#ifndef _WIN32_WINNT +-/* Minimum required for InitializeCriticalSectionAndSpinCount */ +-#define _WIN32_WINNT 0x0403 +-#endif + #include + #include + #include diff --git a/depends/toolchain.cmake.in b/depends/toolchain.cmake.in index a38cb6135b06..34984b85b1db 100644 --- a/depends/toolchain.cmake.in +++ b/depends/toolchain.cmake.in @@ -92,6 +92,22 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(QT_TRANSLATIONS_DIR "${CMAKE_CURRENT_LIST_DIR}/translations") +# The following is only necessary when using cmake from Nix or NixOS, because +# Nix patches cmake to remove the root directory `/` from +# CMAKE_SYSTEM_PREFIX_PATH. Adding it back is harmless on other platforms and +# necessary on Nix because without it cmake find_path, find_package, etc +# functions do not know where to look in CMAKE_FIND_ROOT_PATH for dependencies +# (https://github.com/bitcoin/bitcoin/issues/32428). +# +# TODO: longer term, it may be possible to use a dependency provider, which +# would bring the find_package calls completely under our control, making this +# patch unnecessary. +# +# Make sure we only append once, as this file may be called repeatedly. +if(NOT "/" IN_LIST CMAKE_PREFIX_PATH) + list(APPEND CMAKE_PREFIX_PATH "/") +endif() + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE) # The find_package(Qt ...) function internally uses find_library() # calls for all dependencies to ensure their availability. @@ -101,7 +117,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE) endif() -if(CMAKE_SYSTEM_NAME STREQUAL "Linux") +if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|FreeBSD)$") # Customize pkg-config behavior for finding dependencies # of the xcb QPA platform plugin: # 1. Restrict search paths to the depends. diff --git a/doc/REST-interface.md b/doc/REST-interface.md index fbed4a36b20d..0fee78129a6f 100644 --- a/doc/REST-interface.md +++ b/doc/REST-interface.md @@ -79,6 +79,13 @@ Responds with 404 if the block doesn't exist. Given a height: returns hash of block in best-block-chain at height provided. Responds with 404 if block not found. +#### Spent transaction outputs +`GET /rest/spenttxouts/.` + +Given a block hash: returns a collection of spent transaction output lists, +one per transaction in the block. +Responds with 404 if the block doesn't exist or its undo data is not available. + #### Chaininfos `GET /rest/chaininfo.json` diff --git a/doc/bips.md b/doc/bips.md index a95b3159ecb3..97645d0eebe4 100644 --- a/doc/bips.md +++ b/doc/bips.md @@ -58,7 +58,8 @@ BIPs that are implemented by Bitcoin Core: Validation rules for Taproot (including Schnorr signatures and Tapscript leaves) are implemented as of **v0.21.0** ([PR 19953](https://github.com/bitcoin/bitcoin/pull/19953)), with mainnet activation as of **v0.21.1** ([PR 21377](https://github.com/bitcoin/bitcoin/pull/21377), - [PR 21686](https://github.com/bitcoin/bitcoin/pull/21686)). + [PR 21686](https://github.com/bitcoin/bitcoin/pull/21686)), + always active as of **v24.0** ([PR 23536](https://github.com/bitcoin/bitcoin/pull/23536)). * [`BIP 350`](https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki): Addresses for native v1+ segregated Witness outputs use Bech32m instead of Bech32 as of **v22.0** ([PR 20861](https://github.com/bitcoin/bitcoin/pull/20861)). * [`BIP 371`](https://github.com/bitcoin/bips/blob/master/bip-0371.mediawiki): Taproot fields for PSBT as of **v24.0** ([PR 22558](https://github.com/bitcoin/bitcoin/pull/22558)). * [`BIP 379`](https://github.com/bitcoin/bips/blob/master/bip-0379.md): Miniscript was partially implemented in **v24.0** ([PR 24148](https://github.com/bitcoin/bitcoin/pull/24148)), and fully implemented as of **v26.0** ([PR 27255](https://github.com/bitcoin/bitcoin/pull/27255)). diff --git a/doc/build-freebsd.md b/doc/build-freebsd.md index 52dc94547ee1..35ef1408718c 100644 --- a/doc/build-freebsd.md +++ b/doc/build-freebsd.md @@ -95,6 +95,6 @@ cmake -B build -DENABLE_WALLET=OFF ### 2. Compile ```bash -cmake --build build # Use "-j N" for N parallel jobs. -ctest --test-dir build # Use "-j N" for N parallel tests. Some tests are disabled if Python 3 is not available. +cmake --build build # Append "-j N" for N parallel jobs. +ctest --test-dir build # Append "-j N" for N parallel tests. Some tests are disabled if Python 3 is not available. ``` diff --git a/doc/build-netbsd.md b/doc/build-netbsd.md index da51c8744a08..79cce2ff7a7f 100644 --- a/doc/build-netbsd.md +++ b/doc/build-netbsd.md @@ -12,7 +12,7 @@ Install the required dependencies the usual way you [install software on NetBSD] The example commands below use `pkgin`. ```bash -pkgin install git cmake pkg-config boost-headers libevent +pkgin install git cmake pkg-config boost libevent ``` NetBSD currently ships with an older version of `gcc` than is needed to build. You should upgrade your `gcc` and then pass this new version to the configure script. @@ -110,6 +110,6 @@ Run `cmake -B build -LH` to see the full list of available options. Build and run the tests: ```bash -cmake --build build # Use "-j N" for N parallel jobs. -ctest --test-dir build # Use "-j N" for N parallel tests. Some tests are disabled if Python 3 is not available. +cmake --build build # Append "-j N" for N parallel jobs. +ctest --test-dir build # Append "-j N" for N parallel tests. Some tests are disabled if Python 3 is not available. ``` diff --git a/doc/build-openbsd.md b/doc/build-openbsd.md index 8929e3b742a1..f3fae6456b92 100644 --- a/doc/build-openbsd.md +++ b/doc/build-openbsd.md @@ -89,8 +89,8 @@ Run `cmake -B build -LH` to see the full list of available options. ### 2. Compile ```bash -cmake --build build # Use "-j N" for N parallel jobs. -ctest --test-dir build # Use "-j N" for N parallel tests. Some tests are disabled if Python 3 is not available. +cmake --build build # Append "-j N" for N parallel jobs. +ctest --test-dir build # Append "-j N" for N parallel tests. Some tests are disabled if Python 3 is not available. ``` ## Resource limits diff --git a/doc/build-osx.md b/doc/build-osx.md index 08e2e54c2aa1..ab4726d92d39 100644 --- a/doc/build-osx.md +++ b/doc/build-osx.md @@ -182,8 +182,8 @@ After configuration, you are ready to compile. Run the following in your terminal to compile Bitcoin Core: ``` bash -cmake --build build # Use "-j N" here for N parallel jobs. -ctest --test-dir build # Use "-j N" for N parallel tests. Some tests are disabled if Python 3 is not available. +cmake --build build # Append "-j N" here for N parallel jobs. +ctest --test-dir build # Append "-j N" for N parallel tests. Some tests are disabled if Python 3 is not available. ``` ### 3. Deploy (optional) diff --git a/doc/build-unix.md b/doc/build-unix.md index a4e6af232332..760d6a2a25e6 100644 --- a/doc/build-unix.md +++ b/doc/build-unix.md @@ -9,8 +9,12 @@ To Build ```bash cmake -B build -cmake --build build # use "-j N" for N parallel jobs -cmake --install build # optional +``` +Run `cmake -B build -LH` to see the full list of available options. + +```bash +cmake --build build # Append "-j N" for N parallel jobs +cmake --install build # Optional ``` See below for instructions on how to [install the dependencies on popular Linux @@ -139,6 +143,45 @@ The GUI will be able to encode addresses in QR codes unless this feature is expl Otherwise, if you don't need QR encoding support, use the `-DWITH_QRENCODE=OFF` option to disable this feature in order to compile the GUI. +### Alpine + +#### Dependency Build Instructions + +Build requirements: + + apk add build-base cmake linux-headers pkgconf python3 + +Now, you can either build from self-compiled [depends](#dependencies) or install the required dependencies: + + apk add libevent-dev boost-dev + +SQLite is required for the descriptor wallet: + + apk add sqlite-dev + +To build Bitcoin Core without wallet, see [*Disable-wallet mode*](#disable-wallet-mode) + +ZMQ dependencies (provides ZMQ API): + + apk add zeromq-dev + +User-Space, Statically Defined Tracing (USDT) is not supported or tested on Alpine Linux at this time. + +GUI dependencies: + +Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compile the GUI, we need to install +the necessary parts of Qt, the libqrencode and pass `-DBUILD_GUI=ON`. Skip if you don't intend to use the GUI. + + apk add qt6-qtbase-dev qt6-qttools-dev + +For Qt 6.5 and later, the `xcb-util-cursor` package must be installed at runtime. + +The GUI will be able to encode addresses in QR codes unless this feature is explicitly disabled. To install libqrencode, run: + + apk add libqrencode-dev + +Otherwise, if you don't need QR encoding support, use the `-DWITH_QRENCODE=OFF` option to disable this feature in order to compile the GUI. + ## Dependencies See [dependencies.md](dependencies.md) for a complete overview, and @@ -156,13 +199,6 @@ In this case there is no dependency on SQLite. Mining is also possible in disable-wallet mode using the `getblocktemplate` RPC call. -Additional Configure Flags --------------------------- -A list of additional configure flags can be displayed with: - - cmake -B build -LH - - Setup and Build Example: Arch Linux ----------------------------------- This example lists the steps necessary to setup and build a command line only distribution of the latest changes on Arch Linux: diff --git a/doc/build-windows-msvc.md b/doc/build-windows-msvc.md index 151c175031a7..2d85d223e97b 100644 --- a/doc/build-windows-msvc.md +++ b/doc/build-windows-msvc.md @@ -54,33 +54,43 @@ In the following instructions, the "Debug" configuration can be specified instea ``` cmake -B build --preset vs2022-static # It might take a while if the vcpkg binary cache is unpopulated or invalidated. -cmake --build build --config Release # Use "-j N" for N parallel jobs. -ctest --test-dir build --build-config Release # Use "-j N" for N parallel tests. Some tests are disabled if Python 3 is not available. +cmake --build build --config Release # Append "-j N" for N parallel jobs. +ctest --test-dir build --build-config Release # Append "-j N" for N parallel tests. Some tests are disabled if Python 3 is not available. cmake --install build --config Release # Optional. ``` -If building with `BUILD_GUI=ON`, vcpkg installation during the build -configuration step might fail because of extremely long paths required during -vcpkg installation if your vcpkg instance is installed in the default Visual -Studio directory. This can be avoided without modifying your vcpkg root -directory by changing vcpkg's intermediate build directory with the -`--x-buildtrees-root` argument to something shorter, for example: +### 5. Building with Dynamic Linking without GUI + +``` +cmake -B build --preset vs2022 -DBUILD_GUI=OFF # It might take a while if the vcpkg binary cache is unpopulated or invalidated. +cmake --build build --config Release # Append "-j N" for N parallel jobs. +ctest --test-dir build --build-config Release # Append "-j N" for N parallel tests. Some tests are disabled if Python 3 is not available. +``` + +### 6. vcpkg-specific Issues and Workarounds + +vcpkg installation during the configuration step might fail for various reasons unrelated to Bitcoin Core. + +If the failure is due to a "Buildtrees path … is too long" error, which is often encountered when building +with `BUILD_GUI=ON` and using the default vcpkg installation provided by Visual Studio, you can +specify a shorter path to store intermediate build files by using +the [`--x-buildtrees-root`](https://learn.microsoft.com/en-us/vcpkg/commands/common-options#buildtrees-root) option: ```powershell cmake -B build --preset vs2022-static -DVCPKG_INSTALL_OPTIONS="--x-buildtrees-root=C:\vcpkg" ``` -### 5. Building with Dynamic Linking without GUI +If vcpkg installation fails with the message "Paths with embedded space may be handled incorrectly", which +can occur if your local Bitcoin Core repository path contains spaces, you can override the vcpkg install directory +by setting the [`VCPKG_INSTALLED_DIR`](https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/users/buildsystems/cmake-integration.md#vcpkg_installed_dir) variable: -``` -cmake -B build --preset vs2022 -DBUILD_GUI=OFF # It might take a while if the vcpkg binary cache is unpopulated or invalidated. -cmake --build build --config Release # Use "-j N" for N parallel jobs. -ctest --test-dir build --build-config Release # Use "-j N" for N parallel tests. Some tests are disabled if Python 3 is not available. +```powershell +cmake -B build --preset vs2022-static -DVCPKG_INSTALLED_DIR="C:\path_without_spaces" ``` ## Performance Notes -### 6. vcpkg Manifest Default Features +### 7. vcpkg Manifest Default Features One can skip vcpkg manifest default features to speedup the configuration step. For example, the following invocation will skip all features except for "wallet" and "tests" and their dependencies: @@ -90,6 +100,6 @@ cmake -B build --preset vs2022 -DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON -DVCPKG_M Available features are listed in the [`vcpkg.json`](/vcpkg.json) file. -### 7. Antivirus Software +### 8. Antivirus Software To improve the build process performance, one might add the Bitcoin repository directory to the Microsoft Defender Antivirus exclusions. diff --git a/doc/build-windows.md b/doc/build-windows.md index 03af0654cea2..84db7fa4b5f6 100644 --- a/doc/build-windows.md +++ b/doc/build-windows.md @@ -47,9 +47,9 @@ This means you cannot use a directory that is located directly on the host Windo Build using: - gmake -C depends HOST=x86_64-w64-mingw32 # Use "-j N" for N parallel jobs. + gmake -C depends HOST=x86_64-w64-mingw32 # Append "-j N" for N parallel jobs. cmake -B build --toolchain depends/x86_64-w64-mingw32/toolchain.cmake - cmake --build build # Use "-j N" for N parallel jobs. + cmake --build build # Append "-j N" for N parallel jobs. ## Depends system diff --git a/doc/descriptors.md b/doc/descriptors.md index 928e8806c6a6..292773fccf91 100644 --- a/doc/descriptors.md +++ b/doc/descriptors.md @@ -69,6 +69,7 @@ Output descriptors currently support: - `tr(c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5,sortedmulti_a(2,2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4,5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc))` describes a P2TR output with the `c6...` x-only pubkey as internal key, and a single `multi_a` script that needs 2 signatures with 2 specified x-only keys, which will be sorted lexicographically. - `wsh(sortedmulti(2,[6f53d49c/44h/1h/0h]tpubDDjsCRDQ9YzyaAq9rspCfq8RZFrWoBpYnLxK6sS2hS2yukqSczgcYiur8Scx4Hd5AZatxTuzMtJQJhchufv1FRFanLqUP7JHwusSSpfcEp2/0/*,[e6807791/44h/1h/0h]tpubDDAfvogaaAxaFJ6c15ht7Tq6ZmiqFYfrSmZsHu7tHXBgnjMZSHAeHSwhvjARNA6Qybon4ksPksjRbPDVp7yXA1KjTjSd5x18KHqbppnXP1s/0/*,[367c9cfa/44h/1h/0h]tpubDDtPnSgWYk8dDnaDwnof4ehcnjuL5VoUt1eW2MoAed1grPHuXPDnkX1fWMvXfcz3NqFxPbhqNZ3QBdYjLz2hABeM9Z2oqMR1Gt2HHYDoCgh/0/*))#av0kxgw0` describes a *2-of-3* multisig. For brevity, the internal "change" descriptor accompanying the above external "receiving" descriptor is not included here, but it typically differs only in the xpub derivation steps, ending in `/1/*` for change addresses. - `wsh(thresh(4,pk([7258e4f9/44h/1h/0h]tpubDCZrkQoEU3845aFKUu9VQBYWZtrTwxMzcxnBwKFCYXHD6gEXvtFcxddCCLFsEwmxQaG15izcHxj48SXg1QS5FQGMBx5Ak6deXKPAL7wauBU/0/*),s:pk([c80b1469/44h/1h/0h]tpubDD3UwwHoNUF4F3Vi5PiUVTc3ji1uThuRfFyBexTSHoAcHuWW2z8qEE2YujegcLtgthr3wMp3ZauvNG9eT9xfJyxXCfNty8h6rDBYU8UU1qq/0/*),s:pk([4e5024fe/44h/1h/0h]tpubDDLrpPymPLSCJyCMLQdmcWxrAWwsqqssm5NdxT2WSdEBPSXNXxwbeKtsHAyXPpLkhUyKovtZgCi47QxVpw9iVkg95UUgeevyAqtJ9dqBqa1/0/*),s:pk([3b1d1ee9/44h/1h/0h]tpubDCmDTANBWPzf6d8Ap1J5Ku7J1Ay92MpHMrEV7M5muWxCrTBN1g5f1NPcjMEL6dJHxbvEKNZtYCdowaSTN81DAyLsmv6w6xjJHCQNkxrsrfu/0/*),sln:after(840000),sln:after(1050000),sln:after(1260000)))#k28080kv` describes a Miniscript multisig with spending policy: `thresh(4,pk(key_1),pk(key_2),pk(key_3),pk(key_4),after(t1),after(t2),after(t3))` that starts as 4-of-4 and "decays" to 3-of-4, 2-of-4, and finally 1-of-4 at each future halvening block height. For brevity, the internal "change" descriptor accompanying the above external "receiving" descriptor is not included here, but it typically differs only in the xpub derivation steps, ending in `/1/*` for change addresses. +- `tr(musig(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL,xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y)/0/*)` describes a MuSig2 multisig with key derivation. The internal keys are derived at `m/0/*` from the aggregate key computed from the 2 participants. ## Reference diff --git a/doc/design/multiprocess.md b/doc/design/multiprocess.md index 11e81527ce1b..e72f2a031371 100644 --- a/doc/design/multiprocess.md +++ b/doc/design/multiprocess.md @@ -4,27 +4,6 @@ Guide to the design and architecture of the Bitcoin Core multiprocess feature _This document describes the design of the multiprocess feature. For usage information, see the top-level [multiprocess.md](../multiprocess.md) file._ -## Table of contents - -- [Introduction](#introduction) -- [Current Architecture](#current-architecture) -- [Proposed Architecture](#proposed-architecture) -- [Component Overview: Navigating the IPC Framework](#component-overview-navigating-the-ipc-framework) -- [Design Considerations](#design-considerations) - - [Selection of Cap’n Proto](#selection-of-capn-proto) - - [Hiding IPC](#hiding-ipc) - - [Interface Definition Maintenance](#interface-definition-maintenance) - - [Interface Stability](#interface-stability) -- [Security Considerations](#security-considerations) -- [Example Use Cases and Flows](#example-use-cases-and-flows) - - [Retrieving a Block Hash](#retrieving-a-block-hash) -- [Future Enhancements](#future-enhancements) -- [Conclusion](#conclusion) -- [Appendices](#appendices) - - [Glossary of Terms](#glossary-of-terms) - - [References](#references) -- [Acknowledgements](#acknowledgements) - ## Introduction The Bitcoin Core software has historically employed a monolithic architecture. The existing design has integrated functionality like P2P network operations, wallet management, and a GUI into a single executable. While effective, it has limitations in flexibility, security, and scalability. This project introduces changes that transition Bitcoin Core to a more modular architecture. It aims to enhance security, improve usability, and facilitate maintenance and development of the software in the long run. @@ -136,7 +115,7 @@ The libmultiprocess runtime is designed to place as few constraints as possible ### Interface Definition Maintenance -The choice to maintain interface definitions and C++ type mappings as `.capnp` files in the [`src/ipc/capnp/`](../../src/ipc/capnp/) was mostly done for convenience, and probably something that could be improved in the future. +The choice to maintain interface definitions and C++ type mappings as `.capnp` files in the [`src/ipc/capnp/`](../../src/ipc/capnp/) was mostly done for convenience, and is probably something that could be improved in the future. In the current design, class names, method names, and parameter names are duplicated between C++ interfaces in [`src/interfaces/`](../../src/interfaces/) and Cap’n Proto files in [`src/ipc/capnp/`](../../src/ipc/capnp/). While this keeps C++ interface headers simple and free of references to IPC, it is a maintenance burden because it means inconsistencies between C++ declarations and Cap’n Proto declarations will result in compile errors. (Static type checking ensures these are not runtime errors.) diff --git a/doc/design/p2qrh.md b/doc/design/p2qrh.md index f73b0acb2a06..98a7251d1c65 100644 --- a/doc/design/p2qrh.md +++ b/doc/design/p2qrh.md @@ -156,7 +156,9 @@ The equivalent needs to be implemented for PQC algorithms implemented in [libbit | | descriptorprocesspsbt | Handles PSBTs with P2QRH descriptor data | | | walletcreatefundedpsbt | Creates new PSBTs with P2QRH outputs | | | utxoupdatepsbt | Updates PSBT data for P2QRH inputs/outputs | -| Raw Transaction Operations | signrawtransactionwithwallet | Signs P2QRH inputs using wallet keys | +| Raw Transaction Operations | signrawtransactionwithwallet | Signs P2QRH inputs using wallet keys +| | testmempoolaccept | testmempoolaccept "signedhex" | +| | sendrawtransaction | sendrawtransaction "signedhex" | | | createrawtransaction| createrawtransaction '[]' '{"bc1r...":0.01}' | | signrawtransactionwithkey | Signs P2QRH inputs with specified keys | | | decoderawtransaction | Decodes transactions with P2QRH inputs/outputs | @@ -200,3 +202,98 @@ The equivalent needs to be implemented for PQC algorithms implemented in [libbit ``` $ build/test/functional/rpc_validateaddress.py ``` + +## Modifications + +### bad-txns-nonstandard-inputs + +``` +$ b-reg testmempoolaccept '["'''$RAW_P2QRH_SPEND_TX'''"]' +[ + { + "txid": "824244091bece2eb03a6f0dec6c8f87619dc687f10f4da03465cefd27c3007f7", + "wtxid": "9f3f2fbe411d6c69b1882bbf884124511592f888d2129b105f5d577cd2bfa917", + "allowed": false, + "reject-reason": "bad-txns-nonstandard-inputs", + "reject-details": "bad-txns-nonstandard-inputs" + } +] +``` + +To allow for P2QRH (witness v3, similar to P2TR) funding transactions, you need to update the policy logic so that P2QRH outputs are considered standard, just like P2TR (Taproot) outputs. +What needs to change: + +1. In AreInputsStandard, currently only witness v0 and v1 (P2WPKH, P2WSH, P2TR) are considered standard. P2QRH (witness v3) is not, so funding transactions to P2QRH are not allowed. +1. In IsStandard, the Solver function returns WITNESS_UNKNOWN for any witness version it doesn't recognize, including v3. This means P2QRH outputs are not considered standard. + +How to fix: + +1. Update Solver to recognize P2QRH as a standard type. +** Add a new TxoutType for P2QRH (e.g., WITNESS_V3_P2QRH). +** In Solver, if witnessversion == 3 && witnessprogram.size() == WITNESS_V3_P2QRH_SIZE, return TxoutType::WITNESS_V3_P2QRH. +1. Update IsStandard to allow P2QRH outputs. +** Accept TxoutType::WITNESS_V3_P2QRH as standard. +1. Update AreInputsStandard to allow spending from P2QRH outputs. +** Accept TxoutType::WITNESS_V3_P2QRH as standard, not just WITNESS_V1_TAPROOT. + + +### Witness version reserved for soft-fork upgrades + +``` +$ b-reg testmempoolaccept '["'''$RAW_P2QRH_SPEND_TX'''"]' +[ + { + "txid": "824244091bece2eb03a6f0dec6c8f87619dc687f10f4da03465cefd27c3007f7", + "wtxid": "9f3f2fbe411d6c69b1882bbf884124511592f888d2129b105f5d577cd2bfa917", + "allowed": false, + "reject-reason": "non-mandatory-script-verify-flag (Witness version reserved for soft-fork upgrades)", + "reject-details": "non-mandatory-script-verify-flag (Witness version reserved for soft-fork upgrades), input 0 of 824244091bece2eb03a6f0dec6c8f87619dc687f10f4da03465cefd27c3007f7 (wtxid 9f3f2fbe411d6c69b1882bbf884124511592f888d2129b105f5d577cd2bfa917), spending 6745235727bf162d190553f7da087d8484b73716f2fcf774b8c56245f5f9e619:0" + } +] +``` + +### Invalid Taproot control block size + +``` +$ b-reg testmempoolaccept '["'''$RAW_P2QRH_SPEND_TX'''"]' +[ + { + "txid": "824244091bece2eb03a6f0dec6c8f87619dc687f10f4da03465cefd27c3007f7", + "wtxid": "9f3f2fbe411d6c69b1882bbf884124511592f888d2129b105f5d577cd2bfa917", + "allowed": false, + "reject-reason": "mandatory-script-verify-flag-failed (Invalid Taproot control block size)", + "reject-details": "mandatory-script-verify-flag-failed (Invalid Taproot control block size), input 0 of 824244091bece2eb03a6f0dec6c8f87619dc687f10f4da03465cefd27c3007f7 (wtxid 9f3f2fbe411d6c69b1882bbf884124511592f888d2129b105f5d577cd2bfa917), spending 6745235727bf162d190553f7da087d8484b73716f2fcf774b8c56245f5f9e619:0" + } +] +``` + +### Taproot version reserved for soft-fork upgrades + +``` +$ b-reg testmempoolaccept '["'''$RAW_P2QRH_SPEND_TX'''"]' +[ + { + "txid": "61829641ab32b14a65de0d9e93feedcdd1ee7b5e40d01c43a4ca72815fa886a8", + "wtxid": "eeaaf921f323be39e2b8314bd4ebe7275b784eac9697634bbff975e735961213", + "allowed": false, + "reject-reason": "non-mandatory-script-verify-flag (Taproot version reserved for soft-fork upgrades)", + "reject-details": "non-mandatory-script-verify-flag (Taproot version reserved for soft-fork upgrades), input 0 of 61829641ab32b14a65de0d9e93feedcdd1ee7b5e40d01c43a4ca72815fa886a8 (wtxid eeaaf921f323be39e2b8314bd4ebe7275b784eac9697634bbff975e735961213), spending 6745235727bf162d190553f7da087d8484b73716f2fcf774b8c56245f5f9e619:0" + } +] +``` + +### Stack size must be exactly one after execution + +``` +$ b-reg testmempoolaccept '["'''$RAW_P2QRH_SPEND_TX'''"]' +[ + { + "txid": "61829641ab32b14a65de0d9e93feedcdd1ee7b5e40d01c43a4ca72815fa886a8", + "wtxid": "eeaaf921f323be39e2b8314bd4ebe7275b784eac9697634bbff975e735961213", + "allowed": false, + "reject-reason": "mandatory-script-verify-flag-failed (Stack size must be exactly one after execution)", + "reject-details": "mandatory-script-verify-flag-failed (Stack size must be exactly one after execution), input 0 of 61829641ab32b14a65de0d9e93feedcdd1ee7b5e40d01c43a4ca72815fa886a8 (wtxid eeaaf921f323be39e2b8314bd4ebe7275b784eac9697634bbff975e735961213), spending 6745235727bf162d190553f7da087d8484b73716f2fcf774b8c56245f5f9e619:0" + } +] + +``` diff --git a/doc/developer-notes.md b/doc/developer-notes.md index 2d0dc2b3ab98..220343ab321c 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -1,56 +1,6 @@ -Developer Notes -=============== - - -**Table of Contents** - -- [Developer Notes](#developer-notes) - - [Coding Style (General)](#coding-style-general) - - [Coding Style (C++)](#coding-style-c) - - [Coding Style (Python)](#coding-style-python) - - [Coding Style (Doxygen-compatible comments)](#coding-style-doxygen-compatible-comments) - - [Generating Documentation](#generating-documentation) - - [Development tips and tricks](#development-tips-and-tricks) - - [Compiling for debugging](#compiling-for-debugging) - - [Show sources in debugging](#show-sources-in-debugging) - - [`debug.log`](#debuglog) - - [Signet, testnet, and regtest modes](#signet-testnet-and-regtest-modes) - - [DEBUG_LOCKORDER](#debug_lockorder) - - [DEBUG_LOCKCONTENTION](#debug_lockcontention) - - [Valgrind suppressions file](#valgrind-suppressions-file) - - [Compiling for test coverage](#compiling-for-test-coverage) - - [Performance profiling with perf](#performance-profiling-with-perf) - - [Sanitizers](#sanitizers) - - [Locking/mutex usage notes](#lockingmutex-usage-notes) - - [Threads](#threads) - - [Ignoring IDE/editor files](#ignoring-ideeditor-files) -- [Development guidelines](#development-guidelines) - - [General Bitcoin Core](#general-bitcoin-core) - - [Wallet](#wallet) - - [General C++](#general-c) - - [C++ data structures](#c-data-structures) - - [Strings and formatting](#strings-and-formatting) - - [Shadowing](#shadowing) - - [Lifetimebound](#lifetimebound) - - [Threads and synchronization](#threads-and-synchronization) - - [Scripts](#scripts) - - [Shebang](#shebang) - - [Source code organization](#source-code-organization) - - [GUI](#gui) - - [Subtrees](#subtrees) - - [Upgrading LevelDB](#upgrading-leveldb) - - [File Descriptor Counts](#file-descriptor-counts) - - [Consensus Compatibility](#consensus-compatibility) - - [Scripted diffs](#scripted-diffs) - - [Suggestions and examples](#suggestions-and-examples) - - [Release notes](#release-notes) - - [RPC interface guidelines](#rpc-interface-guidelines) - - [Internal interface guidelines](#internal-interface-guidelines) - - - -Coding Style (General) ----------------------- +# Developer Notes + +## Coding Style (General) Various coding styles have been used during the history of the codebase, and the result is not very consistent. However, we're now trying to converge to @@ -60,8 +10,7 @@ commits. Do not submit patches solely to modify the style of existing code. -Coding Style (C++) ------------------- +## Coding Style (C++) - **Indentation and whitespace rules** as specified in [src/.clang-format](/src/.clang-format). You can use the provided @@ -71,7 +20,7 @@ tool to clean up patches automatically before submission. - Braces on the same line for everything else. - 4 space indentation (no tabs) for every block except namespaces. - No indentation for `public`/`protected`/`private` or for `namespace`. - - No extra spaces inside parenthesis; don't do `( this )`. + - No extra spaces inside parentheses; don't do `( this )`. - No space after function names; one space after `if`, `for` and `while`. - If an `if` only has a single-statement `then`-clause, it can appear on the same line as the `if`, without braces. In every other case, @@ -171,8 +120,7 @@ public: } // namespace foo ``` -Coding Style (C++ functions and methods) --------------------- +### Coding Style (C++ functions and methods) - When ordering function parameters, place input parameters first, then any in-out parameters, followed by any output parameters. @@ -192,8 +140,7 @@ Coding Style (C++ functions and methods) non-optional in-out and output parameters should usually be references, as they cannot be null. -Coding Style (C++ named arguments) ------------------------------- +### Coding Style (C++ named arguments) When passing named arguments, use a format that clang-tidy understands. The argument names can otherwise not be verified by clang-tidy. @@ -237,14 +184,11 @@ To run clang-tidy on the changed source lines: git diff | ( cd ./src/ && clang-tidy-diff -p2 -path ../build -j $(nproc) ) ``` -Coding Style (Python) ---------------------- +## Coding Style (Python) Refer to [/test/functional/README.md#style-guidelines](/test/functional/README.md#style-guidelines). - -Coding Style (Doxygen-compatible comments) ------------------------------------------- +## Coding Style (Doxygen-compatible comments) Bitcoin Core uses [Doxygen](https://www.doxygen.nl/) to generate its official documentation. @@ -319,7 +263,7 @@ but the above styles are favored. Recommendations: -- Avoiding duplicating type and input/output information in function +- Avoid duplicating type and input/output information in function descriptions. - Use backticks (``) to refer to `argument` names in function and @@ -348,8 +292,7 @@ Linux: `sudo apt install doxygen graphviz` MacOS: `brew install doxygen graphviz` -Development tips and tricks ---------------------------- +## Development tips and tricks ### Compiling for debugging @@ -393,7 +336,7 @@ ln -s /path/to/project/root/src src 4. If your IDE has an option for this, change your breakpoints to use the file name only. -### `debug.log` +### debug.log If the code is behaving strangely, take a look in the `debug.log` file in the data directory; error and debugging messages are written there. @@ -532,7 +475,7 @@ cmake -B build -DCMAKE_C_COMPILER="clang" \ -DAPPEND_CFLAGS="-fprofile-instr-generate -fcoverage-mapping" \ -DAPPEND_CXXFLAGS="-fprofile-instr-generate -fcoverage-mapping" \ -DAPPEND_LDFLAGS="-fprofile-instr-generate -fcoverage-mapping" -cmake --build build # Use "-j N" here for N parallel jobs. +cmake --build build # Append "-j N" here for N parallel jobs. ``` Generating the raw profile data based on `ctest` and functional tests execution: @@ -542,8 +485,8 @@ Generating the raw profile data based on `ctest` and functional tests execution: mkdir -p build/raw_profile_data # Run tests to generate profiles -LLVM_PROFILE_FILE="$(pwd)/build/raw_profile_data/%m_%p.profraw" ctest --test-dir build # Use "-j N" here for N parallel jobs. -LLVM_PROFILE_FILE="$(pwd)/build/raw_profile_data/%m_%p.profraw" build/test/functional/test_runner.py # Use "-j N" here for N parallel jobs +LLVM_PROFILE_FILE="$(pwd)/build/raw_profile_data/%m_%p.profraw" ctest --test-dir build # Append "-j N" here for N parallel jobs. +LLVM_PROFILE_FILE="$(pwd)/build/raw_profile_data/%m_%p.profraw" build/test/functional/test_runner.py # Append "-j N" here for N parallel jobs # Merge all the raw profile data into a single file find build/raw_profile_data -name "*.profraw" | xargs llvm-profdata merge -o build/coverage.profdata @@ -583,7 +526,7 @@ cmake -B build \ -DCMAKE_C_FLAGS="-fprofile-instr-generate -fcoverage-mapping" \ -DCMAKE_CXX_FLAGS="-fprofile-instr-generate -fcoverage-mapping" \ -DBUILD_FOR_FUZZING=ON -cmake --build build # Use "-j N" here for N parallel jobs. +cmake --build build # Append "-j N" here for N parallel jobs. ``` Running fuzz tests with one or more targets @@ -713,8 +656,7 @@ Additional resources: * [GCC Instrumentation Options](https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html) * [Google Sanitizers Wiki](https://github.com/google/sanitizers/wiki) -Locking/mutex usage notes -------------------------- +## Locking/mutex usage notes The code is multi-threaded and uses mutexes and the `LOCK` and `TRY_LOCK` macros to protect data structures. @@ -730,8 +672,7 @@ between the various components is a goal, with any necessary locking done by the components (e.g. see the self-contained `FillableSigningProvider` class and its `cs_KeyStore` lock for example). -Threads -------- +## Threads - [Main thread (`bitcoind`)](https://doxygen.bitcoincore.org/bitcoind_8cpp.html#a0ddf1224851353fc92bfbff6f499fa97) : Started from `main()` in `bitcoind.cpp`. Responsible for starting up and @@ -784,22 +725,19 @@ Threads - [ThreadI2PAcceptIncoming (`b-i2paccept`)](https://doxygen.bitcoincore.org/class_c_connman.html#a57787b4f9ac847d24065fbb0dd6e70f8) : Listens for and accepts incoming I2P connections through the I2P SAM proxy. -Development guidelines -============================ +# Development guidelines A few non-style-related recommendations for developers, as well as points to pay attention to for reviewers of Bitcoin Core code. -General Bitcoin Core ----------------------- +## General Bitcoin Core - New features should be exposed on RPC first, then can be made available in the GUI. - *Rationale*: RPC allows for better automatic testing. The test suite for the GUI is very limited. -Logging -------- +## Logging The macros `LogInfo`, `LogDebug`, `LogTrace`, `LogWarning` and `LogError` are available for logging messages. They should be used as follows: @@ -837,8 +775,7 @@ Note that the format strings and parameters of `LogDebug` and `LogTrace` are only evaluated if the logging category is enabled, so you must be careful to avoid side-effects in those expressions. -General C++ -------------- +## General C++ For general C++ guidelines, you may refer to the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/). @@ -859,8 +796,7 @@ Common misconceptions are clarified in those sections: - *Rationale*: This avoids memory and resource leaks, and ensures exception safety. -C++ data structures --------------------- +## C++ data structures - Never use the `std::map []` syntax when reading from a map, but instead use `.find()`. @@ -953,8 +889,7 @@ int GetInt(Tabs tab) *Rationale*: The comment documents skipping `default:` label, and it complies with `clang-format` rules. The assertion prevents firing of `-Wreturn-type` warning on some compilers. -Strings and formatting ------------------------- +## Strings and formatting - Use `std::string`, avoid C string manipulation functions. @@ -988,8 +923,7 @@ Strings and formatting checks. If a use of strings is sensitive to this, take care to check the string for embedded NULL characters first and reject it if there are any. -Shadowing --------------- +## Shadowing Although the shadowing warning (`-Wshadow`) is not enabled by default (it prevents issues arising from using a different variable with the same name), @@ -998,8 +932,7 @@ please name variables so that their names do not shadow variables defined in the When using nested cycles, do not name the inner cycle variable the same as in the outer cycle, etc. -Lifetimebound --------------- +## Lifetimebound The [Clang `lifetimebound` attribute](https://clang.llvm.org/docs/AttributeReference.html#lifetimebound) @@ -1008,8 +941,7 @@ potentially see a compile-time warning if the object has a shorter lifetime from the invalid use of a temporary. You can use the attribute by adding a `LIFETIMEBOUND` annotation defined in `src/attributes.h`; please grep the codebase for examples. -Threads and synchronization ----------------------------- +## Threads and synchronization - Prefer `Mutex` type to `RecursiveMutex` one. @@ -1110,13 +1042,11 @@ TRY_LOCK(cs_vNodes, lockNodes); } ``` -Scripts --------------------------- +## Scripts Write scripts in Python or Rust rather than bash, when possible. -Source code organization --------------------------- +## Source code organization - Implementation code should go into the `.cpp` file and not the `.h`, unless necessary due to template usage or when performance due to inlining is critical. @@ -1150,8 +1080,7 @@ namespace { - *Rationale*: Avoids confusion about the namespace context. -GUI ------ +## GUI - Do not display or manipulate dialogs in model code (classes `*Model`). @@ -1172,8 +1101,7 @@ GUI - *Rationale*: Blocking the GUI thread can increase latency, and lead to hangs and deadlocks. -Subtrees ----------- +## Subtrees Several parts of the repository are subtrees of software maintained elsewhere. @@ -1203,8 +1131,7 @@ The ultimate upstream of the few externally managed subtrees are: - Used by leveldb for hardware acceleration of CRC32C checksums for data integrity. - Upstream at https://github.com/google/crc32c ; maintained by Google. -Upgrading LevelDB ---------------------- +## Upgrading LevelDB Extra care must be taken when upgrading LevelDB. This section explains issues you must be aware of. @@ -1229,7 +1156,7 @@ $ lsof -p $(pidof bitcoind) |\ mem = 119, fd = 0 ``` -The `mem` value shows how many files are mmap'ed, and the `fd` value shows you +The `mem` value shows how many files are mmap'ed, and the `fd` value shows how many file descriptors these files are using. You should check that `fd` is a small number (usually 0 on 64-bit hosts). @@ -1250,8 +1177,7 @@ would be to revert the upstream fix before applying the updates to Bitcoin's copy of LevelDB. In general, you should be wary of any upstream changes affecting what data is returned from LevelDB queries. -Scripted diffs --------------- +## Scripted diffs For reformatting and refactoring commits where the changes can be easily automated using a bash script, we use scripted-diff commits. The bash script is included in the commit message and our CI job checks that @@ -1307,8 +1233,7 @@ To find all previous uses of scripted diffs in the repository, do: git log --grep="-BEGIN VERIFY SCRIPT-" ``` -Release notes -------------- +## Release notes Release notes should be written for any PR that: @@ -1321,8 +1246,7 @@ Release notes should be added to a PR-specific release note file at `/doc/release-notes-.md` to avoid conflicts between multiple PRs. All `release-notes*` files are merged into a single `release-notes-.md` file prior to the release. -RPC interface guidelines --------------------------- +## RPC interface guidelines A few guidelines for introducing and reviewing new RPC interfaces: @@ -1430,8 +1354,7 @@ A few guidelines for modifying existing RPC interfaces: - *Rationale*: Changes in RPC JSON structure can break downstream application compatibility. Implementation of `deprecatedrpc` provides a grace period for downstream applications to migrate. Release notes provide notification to downstream users. -Internal interface guidelines ------------------------------ +## Internal interface guidelines Internal interfaces between parts of the codebase that are meant to be independent (node, wallet, GUI), are defined in diff --git a/doc/managing-wallets.md b/doc/managing-wallets.md index 0e052bd8dbbd..3ff9834506b6 100644 --- a/doc/managing-wallets.md +++ b/doc/managing-wallets.md @@ -144,12 +144,15 @@ If the wallet passphrase is too complex and is subsequently forgotten or lost, t Legacy wallets (traditional non-descriptor wallets) can be migrated to become Descriptor wallets through the use of the `migratewallet` RPC. Migrated wallets will have all of their addresses and private keys added to -a newly created Descriptor wallet that has the same name as the original wallet. Because Descriptor -wallets do not support having private keys and watch-only scripts, there may be up to two +a newly created Descriptor wallet that has the same name as the original wallet. As Descriptor +wallets do not support having both private keys and watch-only scripts, there may be up to two additional wallets created after migration. In addition to a descriptor wallet of the same name, there may also be a wallet named `_watchonly` and `_solvables`. `_watchonly` -contains all of the watchonly scripts. `_solvables` contains any scripts which the wallet -knows but is not watching the corresponding P2(W)SH scripts. +contains all of the watchonly scripts. `_solvables` contains any scripts that the wallet +knows but for which it is not watching the corresponding P2(W)SH scripts. If the legacy wallet +contains only watch-only scripts and no private keys, then only the `_watchonly` wallet +will be created and the descriptor wallet with the same name will not be created. Additionally, +the created watch-only descriptor wallet will not have private keys enabled. Migrated wallets will also generate new addresses differently. While the same BIP 32 seed will be used, the BIP 44, 49, 84, and 86 standard derivation paths will be used. After migrating, a new diff --git a/doc/p2p-bad-ports.md b/doc/p2p-bad-ports.md index 4f717f97a297..5e78eb799d3d 100644 --- a/doc/p2p-bad-ports.md +++ b/doc/p2p-bad-ports.md @@ -87,10 +87,14 @@ incoming connections. 1720: h323hostcall 1723: pptp 2049: nfs + 3306: MySQL + 3389: RDP / Windows Remote Desktop 3659: apple-sasl / PasswordServer 4045: lockd 5060: sip 5061: sips + 5432: PostgreSQL + 5900: VNC 6000: X11 6566: sane-port 6665: Alternate IRC @@ -100,6 +104,7 @@ incoming connections. 6669: Alternate IRC 6697: IRC + TLS 10080: Amanda + 27017: MongoDB For further information see: diff --git a/doc/policy/packages.md b/doc/policy/packages.md index febdbbf13ca6..4c45470e24ef 100644 --- a/doc/policy/packages.md +++ b/doc/policy/packages.md @@ -8,11 +8,9 @@ Graph (a directed edge exists between a transaction that spends the output of an For every transaction `t` in a **topologically sorted** package, if any of its parents are present in the package, they appear somewhere in the list before `t`. -A **child-with-unconfirmed-parents** package is a topologically sorted package that consists of -exactly one child and all of its unconfirmed parents (no other transactions may be present). -The last transaction in the package is the child, and its package can be canonically defined based -on the current state: each of its inputs must be available in the UTXO set as of the current chain -tip or some preceding transaction in the package. +A **child-with-parents** package is a topologically sorted package that consists of exactly one child and at least one +of its unconfirmed parents. Not all unconfirmed parents need to be present but no other transactions may be present; the +parent of a parent should not be in this package (unless this "grandparent" is also a direct parent of the child). ## Package Mempool Acceptance Rules @@ -73,7 +71,7 @@ The following rules are enforced for all packages: The following rules are only enforced for packages to be submitted to the mempool (not enforced for test accepts): -* Packages must be child-with-unconfirmed-parents packages. This also means packages must contain at +* Packages must be child-with-parents packages. This also means packages must contain at least 1 transaction. (#31096) - *Rationale*: This allows for fee-bumping by CPFP. Allowing multiple parents makes it possible diff --git a/doc/productivity.md b/doc/productivity.md index 022f89259ba9..4509e23cde1f 100644 --- a/doc/productivity.md +++ b/doc/productivity.md @@ -1,29 +1,6 @@ -Productivity Notes -================== - -Table of Contents ------------------ - -* [General](#general) - * [Cache compilations with `ccache`](#cache-compilations-with-ccache) - * [Disable features when generating the build system](#disable-features-when-generating-the-build-system) - * [Make use of your threads with `-j`](#make-use-of-your-threads-with--j) - * [Only build what you need](#only-build-what-you-need) - * [Compile on multiple machines](#compile-on-multiple-machines) - * [Multiple working directories with `git worktrees`](#multiple-working-directories-with-git-worktrees) - * [Interactive "dummy rebases" for fixups and execs with `git merge-base`](#interactive-dummy-rebases-for-fixups-and-execs-with-git-merge-base) -* [Writing code](#writing-code) - * [Format C/C++ diffs with `clang-format-diff.py`](#format-cc-diffs-with-clang-format-diffpy) - * [Format Python diffs with `yapf-diff.py`](#format-python-diffs-with-yapf-diffpy) -* [Rebasing/Merging code](#rebasingmerging-code) - * [More conflict context with `merge.conflictstyle diff3`](#more-conflict-context-with-mergeconflictstyle-diff3) -* [Reviewing code](#reviewing-code) - * [Reduce mental load with `git diff` options](#reduce-mental-load-with-git-diff-options) - * [Reference PRs easily with `refspec`s](#reference-prs-easily-with-refspecs) - * [Diff the diffs with `git range-diff`](#diff-the-diffs-with-git-range-diff) - -General ------- +# Productivity Notes + +## General ### Cache compilations with `ccache` @@ -50,7 +27,7 @@ You _must not_ set base_dir to "/", or anywhere that contains system headers (ac During the generation of the build system only essential build options are enabled by default to save on compilation time. -Run `cmake -B build -LH` to see the full list of available options. GUI tools, such as `ccmake` and `cmake-gui`, can be also helpful. +Run `cmake -B build -LH` to see the full list of available options. GUI tools, such as `ccmake` and `cmake-gui`, can also be helpful. ### Make use of your threads with `-j` @@ -113,8 +90,7 @@ This synergizes well with [`ccache`](#cache-compilations-with-ccache) as objects You can also set up [upstream refspecs](#reference-prs-easily-with-refspecs) to refer to pull requests easier in the above `git worktree` commands. -Writing code ------------- +## Writing code ### Format C/C++ diffs with `clang-format-diff.py` @@ -124,8 +100,7 @@ See [contrib/devtools/README.md](/contrib/devtools/README.md#clang-format-diff.p Usage is exactly the same as [`clang-format-diff.py`](#format-cc-diffs-with-clang-format-diffpy). You can get it [here](https://github.com/MarcoFalke/yapf-diff). -Rebasing/Merging code -------------- +## Rebasing/Merging code ### More conflict context with `merge.conflictstyle diff3` @@ -153,8 +128,7 @@ theirs This may make it much clearer what caused the conflict. In this style, you can often just look at what changed between *original* and *theirs*, and mechanically apply that to *yours* (or the other way around). -Reviewing code --------------- +## Reviewing code ### Reduce mental load with `git diff` options @@ -164,9 +138,17 @@ When reviewing patches that change symbol names in many places, use `git diff -- When reviewing patches that move code around, try using `git diff --patience commit~:old/file.cpp commit:new/file/name.cpp`, and ignoring everything except the moved body of code which should show up as neither `+` or `-` lines. In case it was not a pure move, this may even work when combined with the `-w` or `--word-diff` options described above. `--color-moved=dimmed-zebra` will also dim the coloring of moved hunks in the diff on compatible terminals. +### Fetch commits directly + +Before inspecting any remotely created commit locally, it has to be fetched. +This is possible via `git fetch origin `. Even commits not +part of any branch or tag can be fetched as long as the remote has not garbage +collected them. + + ### Reference PRs easily with `refspec`s -When looking at other's pull requests, it may make sense to add the following section to your `.git/config` file: +As an alternative to fetching commits directly, when looking at pull requests by others, it may make sense to add the following section to your `.git/config` file: ``` [remote "upstream-pull"] @@ -176,6 +158,37 @@ When looking at other's pull requests, it may make sense to add the following se This will add an `upstream-pull` remote to your git repository, which can be fetched using `git fetch --all` or `git fetch upstream-pull`. It will download and store on disk quite a lot of data (all PRs, including merged and closed ones). Afterwards, you can use `upstream-pull/NUMBER/head` in arguments to `git show`, `git checkout` and anywhere a commit id would be acceptable to see the changes from pull request NUMBER. +### Fetch and update PRs individually + +The refspec remote is quite resource-heavy, and it is possible to fetch PRs singularly from the remote. To do this you can run: + +```bash +# Individual fetch +git fetch upstream pull//head + +# Fetch with automatic branch creation and switch +git fetch upstream pull//head:pr- && git switch pr- +``` + +...from the command line, substituting `` with the PR number you want to fetch/update. + +> [!NOTE] +> The remote named "upstream" here must be the one that the pull request was opened against. +> e.g. github.com/bitcoin/bitcoin.git or for the GUI github.com/bitcoin-core/gui + +Make these easier to use by adding aliases to your git config: + +``` +[alias] + # Fetch a single Pull Request and switch to it in a new branch, with `git pr 12345` + pr = "!f() { git fetch upstream pull/$1/head:pr-$1 && git switch pr-$1; }; f"; + + # Update a Pull Request branch, even after a force push, and even if checked out, with `git pru 12345` + pru = "!f() { git fetch --update-head-ok -f upstream pull/$1/head:pr-$1; }; f"; +``` + +Then a simple `git pr 12345` will fetch and check out that pr from upstream. + ### Diff the diffs with `git range-diff` It is very common for contributors to rebase their pull requests, or make changes to commits (perhaps in response to review) that are not at the head of their branch. This poses a problem for reviewers as when the contributor force pushes, the reviewer is no longer sure that his previous reviews of commits are still valid (as the commit hashes can now be different even though the diff is semantically the same). [git range-diff](https://git-scm.com/docs/git-range-diff) (Git >= 2.19) can help solve this problem by diffing the diffs. diff --git a/doc/release-30635.md b/doc/release-30635.md new file mode 100644 index 000000000000..0ec68e93cc5d --- /dev/null +++ b/doc/release-30635.md @@ -0,0 +1,5 @@ +Updated RPCs +------------ + +- The waitfornewblock now takes an optional `current_tip` argument. It is also no longer hidden. (#30635) +- The waitforblock and waitforblockheight RPCs are no longer hidden. (#30635) diff --git a/doc/release-notes-31385.md b/doc/release-notes-31385.md new file mode 100644 index 000000000000..2db108d1005b --- /dev/null +++ b/doc/release-notes-31385.md @@ -0,0 +1,14 @@ +RPC + +The `submitpackage` RPC, which allows submissions of child-with-parents +packages, no longer requires that all unconfirmed parents be present. The +package may contain other in-mempool ancestors as well. (#31385) + +P2P + +Opportunistic 1-parent-1-child package relay has been improved to handle +situations when the child already has unconfirmed parent(s) in the mempool. +This means that 1p1c packages can be accepted and propagate, even if they are +connected to broader topologies: multi-parent-1-child (where only 1 parent +requires fee-bumping), grandparent-parent-child (where only parent requires +fee-bumping) etc. (#31385) diff --git a/doc/release-notes-32425.md b/doc/release-notes-32425.md new file mode 100644 index 000000000000..c57653bf67fa --- /dev/null +++ b/doc/release-notes-32425.md @@ -0,0 +1,14 @@ +Updated settings +---------------- + +- Previously, `-proxy` specified the proxy for all networks (except I2P which + uses `-i2psam`) and only the Tor proxy could have been specified separately + via `-onion`. Now, the syntax of `-proxy` has been extended and it is possible + to specify separately the proxy for IPv4, IPv6, Tor and CJDNS by appending `=` + followed by the network name, for example `-proxy=127.0.0.1:5555=ipv6` + configures a proxy only for IPv6. The `-proxy` option can be used multiple + times to define different proxies for different networks, such as + `-proxy=127.0.0.1:4444=ipv4 -proxy=10.0.0.1:6666=ipv6`. Later settings + override earlier ones for the same network; this can be used to remove an + earlier all-networks proxy and use direct connections only for a given + network, for example `-proxy=127.0.0.1:5555 -proxy=0=cjdns`. (#32425) diff --git a/doc/release-notes-32521.md b/doc/release-notes-32521.md new file mode 100644 index 000000000000..aa9ebac37f5f --- /dev/null +++ b/doc/release-notes-32521.md @@ -0,0 +1,9 @@ +### Policy + +The maximum number of potentially executed legacy signature operations in a +single standard transaction is now limited to 2500. Signature operations in all +previous output scripts, in all input scripts, as well as all P2SH redeem +scripts (if there are any) are counted toward the limit. The new limit is +assumed to not affect any known typically formed standard transactions. The +change was done to prepare for a possible BIP54 deployment in the future. +(#32521) diff --git a/doc/release-notes-32530.md b/doc/release-notes-32530.md new file mode 100644 index 000000000000..3e2d4a256ac5 --- /dev/null +++ b/doc/release-notes-32530.md @@ -0,0 +1,4 @@ +# Updated Settings + +- The `-maxmempool` and `-dbcache` startup parameters are now capped on 32-bit systems to 500MB and + 1GiB respectively. diff --git a/doc/release-notes-32540.md b/doc/release-notes-32540.md new file mode 100644 index 000000000000..dfc920cd48da --- /dev/null +++ b/doc/release-notes-32540.md @@ -0,0 +1,5 @@ +New RPCs +-------- + +- A new REST API endpoint (`/rest/spenttxouts/BLOCKHASH`) has been introduced for + efficiently fetching spent transaction outputs using the block's undo data (#32540). diff --git a/doc/release-notes-32604.md b/doc/release-notes-32604.md new file mode 100644 index 000000000000..d4d3726e86e0 --- /dev/null +++ b/doc/release-notes-32604.md @@ -0,0 +1,10 @@ +Logging +------- +Unconditional logging to disk is now rate limited by giving each source location +a quota of 1MiB per hour. Unconditional logging is any logging with a log level +higher than debug, that is `info`, `warning`, and `error`. All logs will be +prefixed with `[*]` if there is at least one source location that is currently +being suppressed. (#32604) + +When `-logsourcelocations` is enabled, the log output now contains the entire +function signature instead of just the function name. (#32604) diff --git a/doc/release-notes-32618.md b/doc/release-notes-32618.md new file mode 100644 index 000000000000..f231e3c1d5cf --- /dev/null +++ b/doc/release-notes-32618.md @@ -0,0 +1,7 @@ +Wallet +------ + +* Since descriptor wallets do not allow mixing watchonly and non-watchonly descriptors, +the `include_watchonly` option (and its variants in naming) are removed from all RPCs +that had it. +* The `iswatchonly` field is removed from any RPCs that returned it. diff --git a/doc/release-notes-32845.md b/doc/release-notes-32845.md new file mode 100644 index 000000000000..4730f29dea8a --- /dev/null +++ b/doc/release-notes-32845.md @@ -0,0 +1,9 @@ +Updated RPCs +------------ + +- `unloadwallet` - Return RPC_INVALID_PARAMETER when both the RPC wallet endpoint +and wallet_name parameters are unspecified. Previously the RPC failed with a JSON +parsing error. +- `getdescriptoractivity` - Mark blockhashes and scanobjects arguments as required, +so the user receives a clear help message when either is missing. As in `unloadwallet`, +previously the RPC failed with a JSON parsing error. diff --git a/doc/release-notes-32944-28710-32438-31250.md b/doc/release-notes-32944-28710-32438-31250.md new file mode 100644 index 000000000000..437e5c500e1f --- /dev/null +++ b/doc/release-notes-32944-28710-32438-31250.md @@ -0,0 +1,12 @@ +# Legacy Wallet Removal + +BDB legacy wallets can no longer be created or loaded. They can be migrated to +the new descriptor wallet format. Refer to the `migratewallet` RPC for more +details. + +The legacy wallet removal drops redundant options in the bitcoin-wallet tool, +such as `-withinternalbdb`, `-legacy`, and `-descriptors`. Moreover, the +legacy-only RPCs `addmultisigaddress`, `dumpprivkey`, `dumpwallet`, +`importaddress`, `importmulti`, `importprivkey`, `importpubkey`, +`importwallet`, `newkeypool`, `sethdseed`, and `upgradewallet`, are removed. +(#32944, #28710, #32438, #31250) diff --git a/doc/release-notes-33004.md b/doc/release-notes-33004.md new file mode 100644 index 000000000000..c8a869f5046e --- /dev/null +++ b/doc/release-notes-33004.md @@ -0,0 +1,6 @@ +Updated settings +---------------- + +* The `-natpmp` option is now set to `1` by default. This means nodes with `-listen` enabled (the + default) but running behind a firewall, such as a local network router, will be reachable if the + firewall/router supports any of the `PCP` or `NAT-PMP` protocols. diff --git a/doc/release-notes-empty-template.md b/doc/release-notes-empty-template.md index fdb0d7c8b131..0e8dc7704e76 100644 --- a/doc/release-notes-empty-template.md +++ b/doc/release-notes-empty-template.md @@ -96,4 +96,4 @@ Thanks to everyone who directly contributed to this release: As well as to everyone that helped with translations on -[Transifex](https://www.transifex.com/bitcoin/bitcoin/). +[Transifex](https://explore.transifex.com/bitcoin/bitcoin/). diff --git a/doc/release-notes/release-notes-28.2.md b/doc/release-notes/release-notes-28.2.md new file mode 100644 index 000000000000..057b1b43d8e3 --- /dev/null +++ b/doc/release-notes/release-notes-28.2.md @@ -0,0 +1,83 @@ +Bitcoin Core version 28.2 is now available from: + + + +This release includes new features, various bug fixes and performance +improvements, as well as updated translations. + +Please report bugs using the issue tracker at GitHub: + + + +To receive security and update notifications, please subscribe to: + + + +How to Upgrade +============== + +If you are running an older version, shut it down. Wait until it has completely +shut down (which might take a few minutes in some cases), then run the +installer (on Windows) or just copy over `/Applications/Bitcoin-Qt` (on macOS) +or `bitcoind`/`bitcoin-qt` (on Linux). + +Upgrading directly from a version of Bitcoin Core that has reached its EOL is +possible, but it might take some time if the data directory needs to be migrated. Old +wallet versions of Bitcoin Core are generally supported. + +Compatibility +============== + +Bitcoin Core is supported and extensively tested on operating systems +using the Linux Kernel 3.17+, macOS 11.0+, and Windows 7 and newer. Bitcoin +Core should also work on most other UNIX-like systems but is not as +frequently tested on them. It is not recommended to use Bitcoin Core on +unsupported systems. + +Notable changes +=============== + +### Build + +- #31407 guix: Notarize MacOS app bundle and codesign all MacOS and Windows binaries +- #31500 depends: Fix compiling libevent package on NetBSD +- #31627 depends: Fix spacing issue +- #32070 build: use make < 3.82 syntax for define directive +- #32439 guix: accomodate migration to codeberg +- #32568 depends: use "mkdir -p" when installing xproto +- #32693 depends: fix cmake compatibility error for freetype + +### Test + +- #32286 test: Handle empty string returned by CLI as None in RPC tests +- #32336 test: Suppress upstream -Wduplicate-decl-specifier in bpfcc + +### Tracing + +- #31623 tracing: Rename the MIN macro to TRACEPOINT_TEST_MIN in log_raw_p2p_msgs + +### Doc + +- #32003 doc: remove note about macOS self-signing + +### Misc + +- #31611 doc: upgrade license to 2025 +- #32187 refactor: Remove spurious virtual from final ~CZMQNotificationInterface + +Credits +======= + +Thanks to everyone who directly contributed to this release: +- 0xB10C +- achow101 +- Brandon Odiwuor +- fanquake +- Hennadii Stepanov +- josibake +- kehiy +- MarcoFalke +- Sjors Provoost + +As well as to everyone that helped with translations on +[Transifex](https://www.transifex.com/bitcoin/bitcoin/). diff --git a/doc/release-process.md b/doc/release-process.md index 1c5810d0238d..9159b8cc8c88 100644 --- a/doc/release-process.md +++ b/doc/release-process.md @@ -57,10 +57,10 @@ Release Process - Clear the release notes and move them to the wiki (see "Write the release notes" below). - Translations on Transifex: - Pull translations from Transifex into the master branch. - - Create [a new resource](https://www.transifex.com/bitcoin/bitcoin/content/) named after the major version with the slug `qt-translation-x`, where `RRR` is the major branch number padded with zeros. Use `src/qt/locale/bitcoin_en.xlf` to create it. + - Create [a new resource](https://app.transifex.com/bitcoin/bitcoin/content/) named after the major version with the slug `qt-translation-x`, where `RRR` is the major branch number padded with zeros. Use `src/qt/locale/bitcoin_en.xlf` to create it. - In the project workflow settings, ensure that [Translation Memory Fill-up](https://help.transifex.com/en/articles/6224817-setting-up-translation-memory-fill-up) is enabled and that [Translation Memory Context Matching](https://help.transifex.com/en/articles/6224753-translation-memory-with-context) is disabled. - Update the Transifex slug in [`.tx/config`](/.tx/config) to the slug of the resource created in the first step. This identifies which resource the translations will be synchronized from. - - Make an announcement that translators can start translating for the new version. You can use one of the [previous announcements](https://www.transifex.com/bitcoin/communication/) as a template. + - Make an announcement that translators can start translating for the new version. You can use one of the [previous announcements](https://app.transifex.com/bitcoin/communication/) as a template. - Change the auto-update URL for the resource to `master`, e.g. `https://raw.githubusercontent.com/bitcoin/bitcoin/master/src/qt/locale/bitcoin_en.xlf`. (Do this only after the previous steps, to prevent an auto-update from interfering.) #### After branch-off (on the major release branch) diff --git a/doc/tor.md b/doc/tor.md index 854169714b48..839c02eea9fe 100644 --- a/doc/tor.md +++ b/doc/tor.md @@ -59,7 +59,7 @@ outgoing connections, but more is possible. service provider. ------------------------------------------------------------------------ -If -proxy or -onion is specified multiple times, later occurences override +If -proxy or -onion is specified multiple times, later occurrences override earlier ones and command line overrides the config file. UNIX domain sockets may be used for proxy connections. Set `-onion` or `-proxy` to the local socket path with the prefix `unix:` (e.g. `-onion=unix:/home/me/torsocket`). diff --git a/doc/translation_process.md b/doc/translation_process.md index 2f113fe5b59f..07f50ca49ba1 100644 --- a/doc/translation_process.md +++ b/doc/translation_process.md @@ -41,7 +41,7 @@ git commit ### Creating a Transifex account Visit the [Transifex Signup](https://app.transifex.com/signup/open-source/) page to create an account. Take note of your username and password, as they will be required to configure the command-line tool. -You can find the Bitcoin translation project at [https://www.transifex.com/bitcoin/bitcoin/](https://explore.transifex.com/bitcoin/bitcoin/). +You can find the Bitcoin translation project at [https://explore.transifex.com/bitcoin/bitcoin/](https://explore.transifex.com/bitcoin/bitcoin/). ### Installing the Transifex client command-line tool The client is used to fetch updated translations. Please check installation instructions and any other details at https://developers.transifex.com/docs/cli. diff --git a/doc/zmq.md b/doc/zmq.md index cb15444a4860..b88c93a6bfce 100644 --- a/doc/zmq.md +++ b/doc/zmq.md @@ -84,7 +84,7 @@ For instance: $ bitcoind -zmqpubhashtx=tcp://127.0.0.1:28332 \ -zmqpubhashtx=tcp://192.168.1.2:28332 \ -zmqpubhashblock="tcp://[::1]:28333" \ - -zmqpubrawtx=ipc:///tmp/bitcoind.tx.raw \ + -zmqpubrawtx=unix:/tmp/bitcoind.tx.raw \ -zmqpubhashtxhwm=10000 `bitcoin node` or `bitcoin gui` can also be substituted for `bitcoind`. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 96a6790e612c..7f02b9258c09 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,7 +31,7 @@ message("Configuring secp256k1 subtree...") set(SECP256K1_DISABLE_SHARED ON CACHE BOOL "" FORCE) set(SECP256K1_ENABLE_MODULE_ECDH OFF CACHE BOOL "" FORCE) set(SECP256K1_ENABLE_MODULE_RECOVERY ON CACHE BOOL "" FORCE) -set(SECP256K1_ENABLE_MODULE_MUSIG OFF CACHE BOOL "" FORCE) +set(SECP256K1_ENABLE_MODULE_MUSIG ON CACHE BOOL "" FORCE) set(SECP256K1_BUILD_BENCHMARK OFF CACHE BOOL "" FORCE) set(SECP256K1_BUILD_TESTS ${BUILD_TESTS} CACHE BOOL "" FORCE) set(SECP256K1_BUILD_EXHAUSTIVE_TESTS ${BUILD_TESTS} CACHE BOOL "" FORCE) @@ -161,6 +161,7 @@ add_library(bitcoin_common STATIC EXCLUDE_FROM_ALL key.cpp key_io.cpp merkleblock.cpp + musig.cpp net_permissions.cpp net_types.cpp netaddress.cpp @@ -277,6 +278,7 @@ add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL node/timeoffsets.cpp node/transaction.cpp node/txdownloadman_impl.cpp + node/txorphanage.cpp node/txreconciliation.cpp node/utxo_snapshot.cpp node/warnings.cpp @@ -308,7 +310,6 @@ add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL txdb.cpp txgraph.cpp txmempool.cpp - txorphanage.cpp txrequest.cpp validation.cpp validationinterface.cpp diff --git a/src/addrdb.cpp b/src/addrdb.cpp index 889f7b3859b1..129bbf215430 100644 --- a/src/addrdb.cpp +++ b/src/addrdb.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2022 The Bitcoin Core developers +// Copyright (c) 2009-present The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -24,6 +24,7 @@ #include #include #include +#include #include namespace { @@ -61,7 +62,6 @@ bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data FILE *file = fsbridge::fopen(pathTmp, "wb"); AutoFile fileout{file}; if (fileout.IsNull()) { - fileout.fclose(); remove(pathTmp); LogError("%s: Failed to open file %s\n", __func__, fs::PathToString(pathTmp)); return false; @@ -69,17 +69,22 @@ bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data // Serialize if (!SerializeDB(fileout, data)) { - fileout.fclose(); + (void)fileout.fclose(); remove(pathTmp); return false; } if (!fileout.Commit()) { - fileout.fclose(); + (void)fileout.fclose(); remove(pathTmp); LogError("%s: Failed to flush file %s\n", __func__, fs::PathToString(pathTmp)); return false; } - fileout.fclose(); + if (fileout.fclose() != 0) { + const int errno_save{errno}; + remove(pathTmp); + LogError("Failed to close file %s after commit: %s", fs::PathToString(pathTmp), SysErrorString(errno_save)); + return false; + } // replace existing file, if any, with new file if (!RenameOver(pathTmp, path)) { @@ -150,7 +155,7 @@ bool CBanDB::Write(const banmap_t& banSet) bool CBanDB::Read(banmap_t& banSet) { if (fs::exists(m_banlist_dat)) { - LogPrintf("banlist.dat ignored because it can only be read by " CLIENT_NAME " version 22.x. Remove %s to silence this warning.\n", fs::quoted(fs::PathToString(m_banlist_dat))); + LogWarning("banlist.dat ignored because it can only be read by " CLIENT_NAME " version 22.x. Remove %s to silence this warning.", fs::quoted(fs::PathToString(m_banlist_dat))); } // If the JSON banlist does not exist, then recreate it if (!fs::exists(m_banlist_json)) { @@ -162,7 +167,7 @@ bool CBanDB::Read(banmap_t& banSet) if (!common::ReadSettings(m_banlist_json, settings, errors)) { for (const auto& err : errors) { - LogPrintf("Cannot load banlist %s: %s\n", fs::PathToString(m_banlist_json), err); + LogWarning("Cannot load banlist %s: %s", fs::PathToString(m_banlist_json), err); } return false; } @@ -170,7 +175,7 @@ bool CBanDB::Read(banmap_t& banSet) try { BanMapFromJson(settings[JSON_KEY], banSet); } catch (const std::runtime_error& e) { - LogPrintf("Cannot parse banlist %s: %s\n", fs::PathToString(m_banlist_json), e.what()); + LogWarning("Cannot parse banlist %s: %s", fs::PathToString(m_banlist_json), e.what()); return false; } @@ -199,11 +204,11 @@ util::Result> LoadAddrman(const NetGroupManager& netgro const auto path_addr{args.GetDataDirNet() / "peers.dat"}; try { DeserializeFileDB(path_addr, *addrman); - LogPrintf("Loaded %i addresses from peers.dat %dms\n", addrman->Size(), Ticks(SteadyClock::now() - start)); + LogInfo("Loaded %i addresses from peers.dat %dms", addrman->Size(), Ticks(SteadyClock::now() - start)); } catch (const DbNotFoundError&) { // Addrman can be in an inconsistent state after failure, reset it addrman = std::make_unique(netgroupman, deterministic, /*consistency_check_ratio=*/check_addrman); - LogPrintf("Creating peers.dat because the file was not found (%s)\n", fs::quoted(fs::PathToString(path_addr))); + LogInfo("Creating peers.dat because the file was not found (%s)", fs::quoted(fs::PathToString(path_addr))); DumpPeerAddresses(args, *addrman); } catch (const InvalidAddrManVersionError&) { if (!RenameOver(path_addr, (fs::path)path_addr + ".bak")) { @@ -211,7 +216,7 @@ util::Result> LoadAddrman(const NetGroupManager& netgro } // Addrman can be in an inconsistent state after failure, reset it addrman = std::make_unique(netgroupman, deterministic, /*consistency_check_ratio=*/check_addrman); - LogPrintf("Creating new peers.dat because the file version was not compatible (%s). Original backed up to peers.dat.bak\n", fs::quoted(fs::PathToString(path_addr))); + LogWarning("Creating new peers.dat because the file version was not compatible (%s). Original backed up to peers.dat.bak", fs::quoted(fs::PathToString(path_addr))); DumpPeerAddresses(args, *addrman); } catch (const std::exception& e) { return util::Error{strprintf(_("Invalid or corrupt peers.dat (%s). If you believe this is a bug, please report it to %s. As a workaround, you can move the file (%s) out of the way (rename, move, or delete) to have a new one created on the next start."), @@ -231,7 +236,7 @@ std::vector ReadAnchors(const fs::path& anchors_db_path) std::vector anchors; try { DeserializeFileDB(anchors_db_path, CAddress::V2_DISK(anchors)); - LogPrintf("Loaded %i addresses from %s\n", anchors.size(), fs::quoted(fs::PathToString(anchors_db_path.filename()))); + LogInfo("Loaded %i addresses from %s", anchors.size(), fs::quoted(fs::PathToString(anchors_db_path.filename()))); } catch (const std::exception&) { anchors.clear(); } diff --git a/src/addresstype.cpp b/src/addresstype.cpp index 4403c6486cd2..f4054d1cbd98 100644 --- a/src/addresstype.cpp +++ b/src/addresstype.cpp @@ -87,6 +87,12 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) addressRet = tap; return true; } + case TxoutType::WITNESS_V3_P2QRH: { + WitnessV3P2QRH p2qrh; + std::copy(vSolutions[0].begin(), vSolutions[0].end(), p2qrh.begin()); + addressRet = p2qrh; + return true; + } case TxoutType::ANCHOR: { addressRet = PayToAnchor(); return true; diff --git a/src/banman.cpp b/src/banman.cpp index 2964a37de017..32a3cda62596 100644 --- a/src/banman.cpp +++ b/src/banman.cpp @@ -39,7 +39,7 @@ void BanMan::LoadBanlist() LogDebug(BCLog::NET, "Loaded %d banned node addresses/subnets %dms\n", m_banned.size(), Ticks(SteadyClock::now() - start)); } else { - LogPrintf("Recreating the banlist database\n"); + LogInfo("Recreating the banlist database"); m_banned = {}; m_is_dirty = true; } diff --git a/src/bench/CMakeLists.txt b/src/bench/CMakeLists.txt index 905187fbb008..32d10264d644 100644 --- a/src/bench/CMakeLists.txt +++ b/src/bench/CMakeLists.txt @@ -35,6 +35,7 @@ add_executable(bench_bitcoin mempool_eviction.cpp mempool_stress.cpp merkle_root.cpp + obfuscation.cpp parse_hex.cpp peer_eviction.cpp poly1305.cpp @@ -48,9 +49,10 @@ add_executable(bench_bitcoin sign_transaction.cpp streams_findbyte.cpp strencodings.cpp + txgraph.cpp + txorphanage.cpp util_time.cpp verify_script.cpp - xor.cpp ) include(TargetDataSources) diff --git a/src/bench/checkqueue.cpp b/src/bench/checkqueue.cpp index 7255b4f1376e..c7aed5b78d6c 100644 --- a/src/bench/checkqueue.cpp +++ b/src/bench/checkqueue.cpp @@ -8,6 +8,7 @@ #include #include #include +#include