diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 559ad4933fef..115cb1d06570 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,17 +19,25 @@ concurrency: env: CI_FAILFAST_TEST_LEAVE_DANGLING: 1 # GHA does not care about dangling processes and setting this variable avoids killing the CI script itself on error - MAKEJOBS: '-j10' + MAKEJOBS: '-j8' jobs: test-each-commit: name: 'test each commit' - runs-on: ubuntu-24.04 + runs-on: [runs-on,runner=16cpu-linux-x64,"run-id=${{ github.run_id }}"] if: github.event_name == 'pull_request' && github.event.pull_request.commits != 1 timeout-minutes: 360 # Use maximum time, see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes. Assuming a worst case time of 1 hour per commit, this leads to a --max-count=6 below. env: MAX_COUNT: 6 + CCACHE_DIR: /tmp/.ccache steps: + - name: Configure cache + uses: runs-on/cache@v4 + with: + path: /tmp/.ccache + key: ${{ runner.os }}-ccache-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-ccache- - name: Determine fetch depth run: echo "FETCH_DEPTH=$((${{ github.event.pull_request.commits }} + 2))" >> "$GITHUB_ENV" - uses: actions/checkout@v4 @@ -65,210 +73,221 @@ jobs: EXCLUDE_MERGE_BASE_ANCESTORS=^${MERGE_BASE}^@ fi echo "TEST_BASE=$(git rev-list -n$((${{ env.MAX_COUNT }} + 1)) --reverse HEAD $EXCLUDE_MERGE_BASE_ANCESTORS | head -1)" >> "$GITHUB_ENV" - - run: | + - name: Install dependencies + run: | sudo apt-get update - sudo apt-get install clang ccache build-essential cmake pkg-config python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev qtbase5-dev qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y + sudo apt-get install ccache build-essential cmake pkg-config python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev qtbase5-dev qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y + # Temp hack to install clang-17 + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 17 + - name: Configure ccache + run: | + ccache --max-size=16G + ccache -z - name: Compile and run tests run: | # Run tests on commits after the last merge commit and before the PR head commit # Use clang++, because it is a bit faster and uses less memory than g++ - git rebase --exec "echo Running test-one-commit on \$( git log -1 ) && CC=clang CXX=clang++ cmake -B build -DWITH_ZMQ=ON -DBUILD_GUI=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWITH_BDB=ON -DWITH_NATPMP=ON -DWITH_MINIUPNPC=ON -DWITH_USDT=ON && cmake --build build -j $(nproc) && ctest --test-dir build -j $(nproc) && ./build/test/functional/test_runner.py -j $(( $(nproc) * 2 ))" ${{ env.TEST_BASE }} - - macos-native-x86_64: - name: 'macOS 13 native, x86_64, no depends, sqlite only, gui' - # Use latest image, but hardcode version to avoid silent upgrades (and breaks). - # See: https://github.com/actions/runner-images#available-images. - runs-on: macos-13 - - # No need to run on the read-only mirror, unless it is a PR. - if: github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request' - - timeout-minutes: 120 - - env: - DANGER_RUN_CI_ON_HOST: 1 - FILE_ENV: './ci/test/00_setup_env_mac_native.sh' - BASE_ROOT_DIR: ${{ github.workspace }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Clang version - run: | - sudo xcode-select --switch /Applications/Xcode_15.0.app - clang --version - - - name: Install Homebrew packages - env: - HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 - run: | - # A workaround for "The `brew link` step did not complete successfully" error. - brew install --quiet python@3 || brew link --overwrite python@3 - brew install --quiet automake libtool pkg-config gnu-getopt ccache boost libevent miniupnpc libnatpmp zeromq qt@5 qrencode - - - name: Set Ccache directory - run: echo "CCACHE_DIR=${RUNNER_TEMP}/ccache_dir" >> "$GITHUB_ENV" - - - name: Restore Ccache cache - id: ccache-cache - uses: actions/cache/restore@v4 - with: - path: ${{ env.CCACHE_DIR }} - key: ${{ github.job }}-ccache-${{ github.run_id }} - restore-keys: ${{ github.job }}-ccache- - - - name: CI script - run: ./ci/test_run_all.sh - - - name: Save Ccache cache - uses: actions/cache/save@v4 - if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true' - with: - path: ${{ env.CCACHE_DIR }} - # https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache - key: ${{ github.job }}-ccache-${{ github.run_id }} - - win64-native: - name: 'Win64 native, VS 2022' - # Use latest image, but hardcode version to avoid silent upgrades (and breaks). - # See: https://github.com/actions/runner-images#available-images. - runs-on: windows-2022 - - # No need to run on the read-only mirror, unless it is a PR. - if: github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request' - - env: - PYTHONUTF8: 1 - TEST_RUNNER_TIMEOUT_FACTOR: 40 - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Remove non-MSVC tool installations - run: | - Remove-Item -Path "$env:ProgramFiles/CMake" -Recurse -Force - - - name: Configure Developer Command Prompt for Microsoft Visual C++ - # Using microsoft/setup-msbuild is not enough. - uses: ilammy/msvc-dev-cmd@v1 - with: - arch: x64 - - - name: Get tool information - run: | - cmake -version | Tee-Object -FilePath "cmake_version" - Write-Output "---" - msbuild -version | Tee-Object -FilePath "msbuild_version" - $env:VCToolsVersion | Tee-Object -FilePath "toolset_version" - py -3 --version - Write-Host "PowerShell version $($PSVersionTable.PSVersion.ToString())" - - - name: Using vcpkg with MSBuild - run: | - Set-Location "$env:VCPKG_INSTALLATION_ROOT" - Add-Content -Path "triplets\x64-windows.cmake" -Value "set(VCPKG_BUILD_TYPE release)" - Add-Content -Path "triplets\x64-windows-static.cmake" -Value "set(VCPKG_BUILD_TYPE release)" - - - name: vcpkg tools cache - uses: actions/cache@v4 - with: - path: C:/vcpkg/downloads/tools - key: ${{ github.job }}-vcpkg-tools - - - name: Restore vcpkg binary cache - uses: actions/cache/restore@v4 - id: vcpkg-binary-cache - with: - path: ~/AppData/Local/vcpkg/archives - key: ${{ github.job }}-vcpkg-binary-${{ hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json') }} - - - name: Generate build system - run: | - cmake -B build --preset vs2022-static -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWERROR=ON - - - name: Save vcpkg binary cache - uses: actions/cache/save@v4 - if: github.event_name != 'pull_request' && steps.vcpkg-binary-cache.outputs.cache-hit != 'true' - with: - path: ~/AppData/Local/vcpkg/archives - key: ${{ github.job }}-vcpkg-binary-${{ hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json') }} - - - name: Build - working-directory: build - run: | - cmake --build . -j $env:NUMBER_OF_PROCESSORS --config Release - - - name: Run test suite - working-directory: build - run: | - ctest -j $env:NUMBER_OF_PROCESSORS -C Release - - - name: Run functional tests - working-directory: build - env: - BITCOIND: '${{ github.workspace }}\build\src\Release\bitcoind.exe' - BITCOINCLI: '${{ github.workspace }}\build\src\Release\bitcoin-cli.exe' - BITCOINUTIL: '${{ github.workspace }}\build\src\Release\bitcoin-util.exe' - BITCOINWALLET: '${{ github.workspace }}\build\src\Release\bitcoin-wallet.exe' - TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }} - shell: cmd - run: py -3 test\functional\test_runner.py --jobs %NUMBER_OF_PROCESSORS% --ci --quiet --tmpdirprefix=%RUNNER_TEMP% --combinedlogslen=99999999 --timeout-factor=%TEST_RUNNER_TIMEOUT_FACTOR% %TEST_RUNNER_EXTRA% - - - name: Clone fuzz corpus - run: | - git clone --depth=1 https://github.com/bitcoin-core/qa-assets "$env:RUNNER_TEMP\qa-assets" - Set-Location "$env:RUNNER_TEMP\qa-assets" - Write-Host "Using qa-assets repo from commit ..." - git log -1 - - - name: Run fuzz binaries - working-directory: build - env: - BITCOINFUZZ: '${{ github.workspace }}\build\src\test\fuzz\Release\fuzz.exe' - shell: cmd - run: py -3 test\fuzz\test_runner.py --par %NUMBER_OF_PROCESSORS% --loglevel DEBUG %RUNNER_TEMP%\qa-assets\fuzz_seed_corpus - - asan-lsan-ubsan-integer-no-depends-usdt: - name: 'ASan + LSan + UBSan + integer, no depends, USDT' - runs-on: ubuntu-24.04 # has to match container in ci/test/00_setup_env_native_asan.sh for tracing tools - # No need to run on the read-only mirror, unless it is a PR. - if: github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request' - timeout-minutes: 120 - env: - FILE_ENV: "./ci/test/00_setup_env_native_asan.sh" - DANGER_CI_ON_HOST_CACHE_FOLDERS: 1 - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set Ccache directory - run: echo "CCACHE_DIR=${RUNNER_TEMP}/ccache_dir" >> "$GITHUB_ENV" - - - name: Set base root directory - run: echo "BASE_ROOT_DIR=${RUNNER_TEMP}" >> "$GITHUB_ENV" - - - name: Restore Ccache cache - id: ccache-cache - uses: actions/cache/restore@v4 - with: - path: ${{ env.CCACHE_DIR }} - key: ${{ github.job }}-ccache-${{ github.run_id }} - restore-keys: ${{ github.job }}-ccache- - - - name: Enable bpfcc script - # In the image build step, no external environment variables are available, - # so any settings will need to be written to the settings env file: - run: sed -i "s|\${INSTALL_BCC_TRACING_TOOLS}|true|g" ./ci/test/00_setup_env_native_asan.sh - - - name: CI script - run: ./ci/test_run_all.sh - - - name: Save Ccache cache - uses: actions/cache/save@v4 - if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true' - with: - path: ${{ env.CCACHE_DIR }} - # https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache - key: ${{ github.job }}-ccache-${{ github.run_id }} + git rebase --exec "echo Running test-one-commit on \$( git log -1 ) && CC='clang-17' CXX='clang++-17' cmake -B build -DWITH_CCACHE=ON -DWITH_ZMQ=ON -DBUILD_GUI=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWITH_BDB=ON -DWITH_NATPMP=ON -DWITH_MINIUPNPC=ON -DWITH_USDT=ON && cmake --build build -j $(nproc) && ctest --test-dir build -j $(nproc) && ./build/test/functional/test_runner.py -j $(( $(nproc) * 2 ))" ${{ env.TEST_BASE }} + - name: ccache statistics + run: ccache -s + + # macos-native-x86_64: + # name: 'macOS 13 native, x86_64, no depends, sqlite only, gui' + # # Use latest image, but hardcode version to avoid silent upgrades (and breaks). + # # See: https://github.com/actions/runner-images#available-images. + # runs-on: macos-13 + # + # # No need to run on the read-only mirror, unless it is a PR. + # if: github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request' + # + # timeout-minutes: 120 + # + # env: + # DANGER_RUN_CI_ON_HOST: 1 + # FILE_ENV: './ci/test/00_setup_env_mac_native.sh' + # BASE_ROOT_DIR: ${{ github.workspace }} + # + # steps: + # - name: Checkout + # uses: actions/checkout@v4 + # + # - name: Clang version + # run: | + # sudo xcode-select --switch /Applications/Xcode_15.0.app + # clang --version + # + # - name: Install Homebrew packages + # env: + # HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 + # run: | + # # A workaround for "The `brew link` step did not complete successfully" error. + # brew install --quiet python@3 || brew link --overwrite python@3 + # brew install --quiet automake libtool pkg-config gnu-getopt ccache boost libevent miniupnpc libnatpmp zeromq qt@5 qrencode + # + # - name: Set Ccache directory + # run: echo "CCACHE_DIR=${RUNNER_TEMP}/ccache_dir" >> "$GITHUB_ENV" + # + # - name: Restore Ccache cache + # id: ccache-cache + # uses: actions/cache/restore@v4 + # with: + # path: ${{ env.CCACHE_DIR }} + # key: ${{ github.job }}-ccache-${{ github.run_id }} + # restore-keys: ${{ github.job }}-ccache- + # + # - name: CI script + # run: ./ci/test_run_all.sh + # + # - name: Save Ccache cache + # uses: actions/cache/save@v4 + # if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true' + # with: + # path: ${{ env.CCACHE_DIR }} + # # https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache + # key: ${{ github.job }}-ccache-${{ github.run_id }} + # + # win64-native: + # name: 'Win64 native, VS 2022' + # # Use latest image, but hardcode version to avoid silent upgrades (and breaks). + # # See: https://github.com/actions/runner-images#available-images. + # runs-on: windows-2022 + # + # # No need to run on the read-only mirror, unless it is a PR. + # if: github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request' + # + # env: + # PYTHONUTF8: 1 + # TEST_RUNNER_TIMEOUT_FACTOR: 40 + # + # steps: + # - name: Checkout + # uses: actions/checkout@v4 + # + # - name: Remove non-MSVC tool installations + # run: | + # Remove-Item -Path "$env:ProgramFiles/CMake" -Recurse -Force + # + # - name: Configure Developer Command Prompt for Microsoft Visual C++ + # # Using microsoft/setup-msbuild is not enough. + # uses: ilammy/msvc-dev-cmd@v1 + # with: + # arch: x64 + # + # - name: Get tool information + # run: | + # cmake -version | Tee-Object -FilePath "cmake_version" + # Write-Output "---" + # msbuild -version | Tee-Object -FilePath "msbuild_version" + # $env:VCToolsVersion | Tee-Object -FilePath "toolset_version" + # py -3 --version + # Write-Host "PowerShell version $($PSVersionTable.PSVersion.ToString())" + # + # - name: Using vcpkg with MSBuild + # run: | + # Set-Location "$env:VCPKG_INSTALLATION_ROOT" + # Add-Content -Path "triplets\x64-windows.cmake" -Value "set(VCPKG_BUILD_TYPE release)" + # Add-Content -Path "triplets\x64-windows-static.cmake" -Value "set(VCPKG_BUILD_TYPE release)" + # + # - name: vcpkg tools cache + # uses: actions/cache@v4 + # with: + # path: C:/vcpkg/downloads/tools + # key: ${{ github.job }}-vcpkg-tools + # + # - name: Restore vcpkg binary cache + # uses: actions/cache/restore@v4 + # id: vcpkg-binary-cache + # with: + # path: ~/AppData/Local/vcpkg/archives + # key: ${{ github.job }}-vcpkg-binary-${{ hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json') }} + # + # - name: Generate build system + # run: | + # cmake -B build --preset vs2022-static -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWERROR=ON + # + # - name: Save vcpkg binary cache + # uses: actions/cache/save@v4 + # if: github.event_name != 'pull_request' && steps.vcpkg-binary-cache.outputs.cache-hit != 'true' + # with: + # path: ~/AppData/Local/vcpkg/archives + # key: ${{ github.job }}-vcpkg-binary-${{ hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json') }} + # + # - name: Build + # working-directory: build + # run: | + # cmake --build . -j $env:NUMBER_OF_PROCESSORS --config Release + # + # - name: Run test suite + # working-directory: build + # run: | + # ctest -j $env:NUMBER_OF_PROCESSORS -C Release + # + # - name: Run functional tests + # working-directory: build + # env: + # BITCOIND: '${{ github.workspace }}\build\src\Release\bitcoind.exe' + # BITCOINCLI: '${{ github.workspace }}\build\src\Release\bitcoin-cli.exe' + # BITCOINUTIL: '${{ github.workspace }}\build\src\Release\bitcoin-util.exe' + # BITCOINWALLET: '${{ github.workspace }}\build\src\Release\bitcoin-wallet.exe' + # TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }} + # shell: cmd + # run: py -3 test\functional\test_runner.py --jobs %NUMBER_OF_PROCESSORS% --ci --quiet --tmpdirprefix=%RUNNER_TEMP% --combinedlogslen=99999999 --timeout-factor=%TEST_RUNNER_TIMEOUT_FACTOR% %TEST_RUNNER_EXTRA% + # + # - name: Clone fuzz corpus + # run: | + # git clone --depth=1 https://github.com/bitcoin-core/qa-assets "$env:RUNNER_TEMP\qa-assets" + # Set-Location "$env:RUNNER_TEMP\qa-assets" + # Write-Host "Using qa-assets repo from commit ..." + # git log -1 + # + # - name: Run fuzz binaries + # working-directory: build + # env: + # BITCOINFUZZ: '${{ github.workspace }}\build\src\test\fuzz\Release\fuzz.exe' + # shell: cmd + # run: py -3 test\fuzz\test_runner.py --par %NUMBER_OF_PROCESSORS% --loglevel DEBUG %RUNNER_TEMP%\qa-assets\fuzz_seed_corpus + # + # asan-lsan-ubsan-integer-no-depends-usdt: + # name: 'ASan + LSan + UBSan + integer, no depends, USDT' + # runs-on: ubuntu-24.04 # has to match container in ci/test/00_setup_env_native_asan.sh for tracing tools + # # No need to run on the read-only mirror, unless it is a PR. + # if: github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request' + # timeout-minutes: 120 + # env: + # FILE_ENV: "./ci/test/00_setup_env_native_asan.sh" + # DANGER_CI_ON_HOST_CACHE_FOLDERS: 1 + # steps: + # - name: Checkout + # uses: actions/checkout@v4 + # + # - name: Set Ccache directory + # run: echo "CCACHE_DIR=${RUNNER_TEMP}/ccache_dir" >> "$GITHUB_ENV" + # + # - name: Set base root directory + # run: echo "BASE_ROOT_DIR=${RUNNER_TEMP}" >> "$GITHUB_ENV" + # + # - name: Restore Ccache cache + # id: ccache-cache + # uses: actions/cache/restore@v4 + # with: + # path: ${{ env.CCACHE_DIR }} + # key: ${{ github.job }}-ccache-${{ github.run_id }} + # restore-keys: ${{ github.job }}-ccache- + # + # - name: Enable bpfcc script + # # In the image build step, no external environment variables are available, + # # so any settings will need to be written to the settings env file: + # run: sed -i "s|\${INSTALL_BCC_TRACING_TOOLS}|true|g" ./ci/test/00_setup_env_native_asan.sh + # + # - name: CI script + # run: ./ci/test_run_all.sh + # + # - name: Save Ccache cache + # uses: actions/cache/save@v4 + # if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true' + # with: + # path: ${{ env.CCACHE_DIR }} + # # https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache + # key: ${{ github.job }}-ccache-${{ github.run_id }} diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 13ea3a29be80..7a4f4de23df2 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -4751,7 +4751,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, MaybeSendGetHeaders(pfrom, GetLocator(m_chainman.m_best_header), *peer); } return; - } else if (prev_block->nChainWork + CalculateClaimedHeadersWork({cmpctblock.header}) < GetAntiDoSWorkThreshold()) { + } else if (prev_block->nChainWork + CalculateClaimedHeadersWork({{cmpctblock.header}}) < GetAntiDoSWorkThreshold()) { // If we get a low-work header in a compact block, we can ignore it. LogPrint(BCLog::NET, "Ignoring low-work compact block from peer %d\n", pfrom.GetId()); return; @@ -4764,7 +4764,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, const CBlockIndex *pindex = nullptr; BlockValidationState state; - if (!m_chainman.ProcessNewBlockHeaders({cmpctblock.header}, /*min_pow_checked=*/true, state, &pindex)) { + if (!m_chainman.ProcessNewBlockHeaders({{cmpctblock.header}}, /*min_pow_checked=*/true, state, &pindex)) { if (state.IsInvalid()) { MaybePunishNodeForBlock(pfrom.GetId(), state, /*via_compact_block=*/true, "invalid header via cmpctblock"); return; @@ -5068,7 +5068,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, mapBlockSource.emplace(hash, std::make_pair(pfrom.GetId(), true)); // Check claimed work on this block against our anti-dos thresholds. - if (prev_block && prev_block->nChainWork + CalculateClaimedHeadersWork({pblock->GetBlockHeader()}) >= GetAntiDoSWorkThreshold()) { + if (prev_block && prev_block->nChainWork + CalculateClaimedHeadersWork({{pblock->GetBlockHeader()}}) >= GetAntiDoSWorkThreshold()) { min_pow_checked = true; } } diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index bfa7dad4a188..375352b18dd5 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -1096,7 +1096,7 @@ static RPCHelpMan submitheader() } BlockValidationState state; - chainman.ProcessNewBlockHeaders({h}, /*min_pow_checked=*/true, state); + chainman.ProcessNewBlockHeaders({{h}}, /*min_pow_checked=*/true, state); if (state.IsValid()) return UniValue::VNULL; if (state.IsError()) { throw JSONRPCError(RPC_VERIFY_ERROR, state.ToString()); diff --git a/src/test/blockfilter_index_tests.cpp b/src/test/blockfilter_index_tests.cpp index 067a32d6a40e..f6024f1ef357 100644 --- a/src/test/blockfilter_index_tests.cpp +++ b/src/test/blockfilter_index_tests.cpp @@ -103,7 +103,7 @@ bool BuildChainTestingSetup::BuildChain(const CBlockIndex* pindex, CBlockHeader header = block->GetBlockHeader(); BlockValidationState state; - if (!Assert(m_node.chainman)->ProcessNewBlockHeaders({header}, true, state, &pindex)) { + if (!Assert(m_node.chainman)->ProcessNewBlockHeaders({{header}}, true, state, &pindex)) { return false; } } diff --git a/src/test/fuzz/utxo_snapshot.cpp b/src/test/fuzz/utxo_snapshot.cpp index 21c305e22210..1241bba8be38 100644 --- a/src/test/fuzz/utxo_snapshot.cpp +++ b/src/test/fuzz/utxo_snapshot.cpp @@ -58,7 +58,7 @@ void initialize_chain() auto& chainman{*setup->m_node.chainman}; for (const auto& block : chain) { BlockValidationState dummy; - bool processed{chainman.ProcessNewBlockHeaders({*block}, true, dummy)}; + bool processed{chainman.ProcessNewBlockHeaders({{block->GetBlockHeader()}}, true, dummy)}; Assert(processed); const auto* index{WITH_LOCK(::cs_main, return chainman.m_blockman.LookupBlockIndex(block->GetHash()))}; Assert(index); @@ -137,7 +137,7 @@ void utxo_snapshot_fuzz(FuzzBufferType buffer) if constexpr (!INVALID) { for (const auto& block : *g_chain) { BlockValidationState dummy; - bool processed{chainman.ProcessNewBlockHeaders({*block}, true, dummy)}; + bool processed{chainman.ProcessNewBlockHeaders({{block->GetBlockHeader()}}, true, dummy)}; Assert(processed); const auto* index{WITH_LOCK(::cs_main, return chainman.m_blockman.LookupBlockIndex(block->GetHash()))}; Assert(index); diff --git a/src/test/validation_block_tests.cpp b/src/test/validation_block_tests.cpp index 015a5941edd7..f5c4204c55a2 100644 --- a/src/test/validation_block_tests.cpp +++ b/src/test/validation_block_tests.cpp @@ -101,7 +101,7 @@ std::shared_ptr MinerTestingSetup::FinalizeBlock(std::shared_ptr // submit block header, so that miner can get the block height from the // global state and the node has the topology of the chain BlockValidationState ignored; - BOOST_CHECK(Assert(m_node.chainman)->ProcessNewBlockHeaders({pblock->GetBlockHeader()}, true, ignored)); + BOOST_CHECK(Assert(m_node.chainman)->ProcessNewBlockHeaders({{pblock->GetBlockHeader()}}, true, ignored)); return pblock; } diff --git a/src/validation.cpp b/src/validation.cpp index 8f75b2e30a0c..04c04f5e3c32 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -70,6 +70,7 @@ #include #include #include +#include #include #include #include @@ -4136,7 +4137,7 @@ bool IsBlockMutated(const CBlock& block, bool check_witness_root) return false; } -arith_uint256 CalculateClaimedHeadersWork(const std::vector& headers) +arith_uint256 CalculateClaimedHeadersWork(std::span headers) { arith_uint256 total_work{0}; for (const CBlockHeader& header : headers) { @@ -4384,7 +4385,7 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida } // Exposed wrapper for AcceptBlockHeader -bool ChainstateManager::ProcessNewBlockHeaders(const std::vector& headers, bool min_pow_checked, BlockValidationState& state, const CBlockIndex** ppindex) +bool ChainstateManager::ProcessNewBlockHeaders(std::span headers, bool min_pow_checked, BlockValidationState& state, const CBlockIndex** ppindex) { AssertLockNotHeld(cs_main); { diff --git a/src/validation.h b/src/validation.h index f905d6e62403..35a8c971bae5 100644 --- a/src/validation.h +++ b/src/validation.h @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -407,7 +408,7 @@ bool HasValidProofOfWork(const std::vector& headers, const Consens bool IsBlockMutated(const CBlock& block, bool check_witness_root); /** Return the sum of the claimed work on a given set of headers. No verification of PoW is done. */ -arith_uint256 CalculateClaimedHeadersWork(const std::vector& headers); +arith_uint256 CalculateClaimedHeadersWork(std::span headers); enum class VerifyDBResult { SUCCESS, @@ -1217,12 +1218,12 @@ class ChainstateManager * May not be called in a * validationinterface callback. * - * @param[in] block The block headers themselves + * @param[in] headers The block headers themselves * @param[in] min_pow_checked True if proof-of-work anti-DoS checks have been done by caller for headers chain * @param[out] state This may be set to an Error state if any error occurred processing them * @param[out] ppindex If set, the pointer will be set to point to the last new block index object for the given headers */ - bool ProcessNewBlockHeaders(const std::vector& block, bool min_pow_checked, BlockValidationState& state, const CBlockIndex** ppindex = nullptr) LOCKS_EXCLUDED(cs_main); + bool ProcessNewBlockHeaders(std::span headers, bool min_pow_checked, BlockValidationState& state, const CBlockIndex** ppindex = nullptr) LOCKS_EXCLUDED(cs_main); /** * Sufficiently validate a block for disk storage (and store on disk).