diff --git a/depend/bitcoin/.github/actions/configure-docker/action.yml b/depend/bitcoin/.github/actions/configure-docker/action.yml index c78df86..09a1e6f 100644 --- a/depend/bitcoin/.github/actions/configure-docker/action.yml +++ b/depend/bitcoin/.github/actions/configure-docker/action.yml @@ -1,9 +1,12 @@ name: 'Configure Docker' description: 'Set up Docker build driver and configure build cache args' inputs: - use-cirrus: - description: 'Use cirrus cache' + cache-provider: + description: 'gha or cirrus cache provider' required: true + options: + - gh + - cirrus runs: using: 'composite' steps: @@ -32,7 +35,7 @@ runs: # which are set automatically when running on GitHub infra: https://docs.docker.com/build/cache/backends/gha/#synopsis # Use cirrus cache host - if [[ ${{ inputs.use-cirrus }} == 'true' ]]; then + if [[ ${{ inputs.cache-provider }} == 'cirrus' ]]; then url_args="url=${CIRRUS_CACHE_HOST},url_v2=${CIRRUS_CACHE_HOST}" else url_args="" diff --git a/depend/bitcoin/.github/workflows/ci.yml b/depend/bitcoin/.github/workflows/ci.yml index f0fb0f1..39dc017 100644 --- a/depend/bitcoin/.github/workflows/ci.yml +++ b/depend/bitcoin/.github/workflows/ci.yml @@ -33,15 +33,15 @@ jobs: name: 'determine runners' runs-on: ubuntu-latest outputs: - use-cirrus-runners: ${{ steps.runners.outputs.use-cirrus-runners }} + provider: ${{ steps.runners.outputs.provider }} steps: - id: runners run: | if [[ "${REPO_USE_CIRRUS_RUNNERS}" == "${{ github.repository }}" ]]; then - echo "use-cirrus-runners=true" >> "$GITHUB_OUTPUT" + echo "provider=cirrus" >> "$GITHUB_OUTPUT" echo "::notice title=Runner Selection::Using Cirrus Runners" else - echo "use-cirrus-runners=false" >> "$GITHUB_OUTPUT" + echo "provider=gha" >> "$GITHUB_OUTPUT" echo "::notice title=Runner Selection::Using GitHub-hosted runners" fi @@ -105,7 +105,7 @@ jobs: name: ${{ matrix.job-name }} # Use any image to support the xcode-select below, but hardcode version to avoid silent upgrades (and breaks). # See: https://github.com/actions/runner-images#available-images. - runs-on: macos-14 + runs-on: macos-15 # When a contributor maintains a fork of the repo, any pull request they make # to their own fork, or to the main repository, will trigger two CI runs: @@ -123,10 +123,10 @@ jobs: include: - job-type: standard file-env: './ci/test/00_setup_env_mac_native.sh' - job-name: 'macOS 14 native, arm64, no depends, sqlite only, gui' + job-name: 'macOS native, no depends, sqlite only, gui' - job-type: fuzz file-env: './ci/test/00_setup_env_mac_native_fuzz.sh' - job-name: 'macOS 14 native, arm64, fuzz' + job-name: 'macOS native, fuzz' env: DANGER_RUN_CI_ON_HOST: 1 @@ -145,8 +145,8 @@ jobs: # Use the earliest Xcode supported by the version of macOS denoted in # doc/release-notes-empty-template.md and providing at least the # minimum clang version denoted in doc/dependencies.md. - # See: https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes - sudo xcode-select --switch /Applications/Xcode_15.0.app + # See: https://developer.apple.com/documentation/xcode-release-notes/xcode-16-release-notes + sudo xcode-select --switch /Applications/Xcode_16.0.app clang --version - name: Install Homebrew packages @@ -211,11 +211,16 @@ jobs: steps: - *CHECKOUT - - 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 + - &SET_UP_VS + name: Set up VS Developer Prompt + shell: pwsh -Command "$PSVersionTable; $PSNativeCommandUseErrorActionPreference = $true; $ErrorActionPreference = 'Stop'; & '{0}'" + run: | + $vswherePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" + $installationPath = & $vswherePath -latest -property installationPath + & "${env:COMSPEC}" /s /c "`"$installationPath\Common7\Tools\vsdevcmd.bat`" -arch=x64 -no_logo && set" | foreach-object { + $name, $value = $_ -split '=', 2 + echo "$name=$value" >> $env:GITHUB_ENV + } - name: Get tool information shell: pwsh @@ -263,14 +268,26 @@ jobs: run: | cmake --build . -j $NUMBER_OF_PROCESSORS --config Release - - name: Get bitcoind manifest + - name: Check executable manifests if: matrix.job-type == 'standard' working-directory: build + shell: pwsh -Command "$PSVersionTable; $PSNativeCommandUseErrorActionPreference = $true; $ErrorActionPreference = 'Stop'; & '{0}'" run: | - mt.exe -nologo -inputresource:bin/Release/bitcoind.exe -out:bitcoind.manifest - cat bitcoind.manifest - echo - mt.exe -nologo -inputresource:bin/Release/bitcoind.exe -validate_manifest + mt.exe -nologo -inputresource:bin\Release\bitcoind.exe -out:bitcoind.manifest + Get-Content bitcoind.manifest + + Get-ChildItem -Filter "bin\Release\*.exe" | ForEach-Object { + $exeName = $_.Name + + # Skip as they currently do not have manifests + if ($exeName -eq "fuzz.exe" -or $exeName -eq "bench_bitcoin.exe" -or $exeName -eq "test_bitcoin-qt.exe" -or $exeName -eq "test_kernel.exe" -or $exeName -eq "bitcoin-chainstate.exe") { + Write-Host "Skipping $exeName (no manifest present)" + return + } + + Write-Host "Checking $exeName" + & mt.exe -nologo -inputresource:$_.FullName -validate_manifest + } - name: Run test suite if: matrix.job-type == 'standard' @@ -313,7 +330,7 @@ jobs: windows-cross: name: 'Linux->Windows cross, no tests' needs: runners - runs-on: ${{ needs.runners.outputs.use-cirrus-runners == 'true' && 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-sm' || 'ubuntu-24.04' }} + runs-on: ${{ needs.runners.outputs.provider == 'cirrus' && 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-sm' || 'ubuntu-24.04' }} if: ${{ vars.SKIP_BRANCH_PUSH != 'true' || github.event_name == 'pull_request' }} env: @@ -333,7 +350,7 @@ jobs: - name: Configure Docker uses: ./.github/actions/configure-docker with: - use-cirrus: ${{ needs.runners.outputs.use-cirrus-runners }} + cache-provider: ${{ needs.runners.outputs.provider }} - name: CI script run: ./ci/test_run_all.sh @@ -371,19 +388,26 @@ jobs: - name: Run bitcoind.exe run: ./bin/bitcoind.exe -version - - name: Find mt.exe tool - shell: pwsh - run: | - $sdk_dir = (Get-ItemProperty 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows Kits\Installed Roots' -Name KitsRoot10).KitsRoot10 - $sdk_latest = (Get-ChildItem "$sdk_dir\bin" -Directory | Where-Object { $_.Name -match '^\d+\.\d+\.\d+\.\d+$' } | Sort-Object Name -Descending | Select-Object -First 1).Name - "MT_EXE=${sdk_dir}bin\${sdk_latest}\x64\mt.exe" >> $env:GITHUB_ENV + - *SET_UP_VS - - name: Get bitcoind manifest - shell: pwsh + - name: Check executable manifests + shell: pwsh -Command "$PSVersionTable; $PSNativeCommandUseErrorActionPreference = $true; $ErrorActionPreference = 'Stop'; & '{0}'" run: | - & $env:MT_EXE -nologo -inputresource:bin\bitcoind.exe -out:bitcoind.manifest + mt.exe -nologo -inputresource:bin\bitcoind.exe -out:bitcoind.manifest Get-Content bitcoind.manifest - & $env:MT_EXE -nologo -inputresource:bin\bitcoind.exe -validate_manifest + + Get-ChildItem -Filter "bin\*.exe" | ForEach-Object { + $exeName = $_.Name + + # Skip as they currently do not have manifests + if ($exeName -eq "fuzz.exe" -or $exeName -eq "bench_bitcoin.exe" -or $exeName -eq "test_kernel.exe") { + Write-Host "Skipping $exeName (no manifest present)" + return + } + + Write-Host "Checking $exeName" + & mt.exe -nologo -inputresource:$_.FullName -validate_manifest + } - name: Run unit tests # Can't use ctest here like other jobs as we don't have a CMake build tree. @@ -423,7 +447,7 @@ jobs: ci-matrix: name: ${{ matrix.name }} needs: runners - runs-on: ${{ needs.runners.outputs.use-cirrus-runners == 'true' && matrix.cirrus-runner || matrix.fallback-runner }} + runs-on: ${{ needs.runners.outputs.provider == 'cirrus' && matrix.cirrus-runner || matrix.fallback-runner }} if: ${{ vars.SKIP_BRANCH_PUSH != 'true' || github.event_name == 'pull_request' }} timeout-minutes: ${{ matrix.timeout-minutes }} @@ -440,6 +464,7 @@ jobs: fallback-runner: 'ubuntu-24.04-arm' timeout-minutes: 120 file-env: './ci/test/00_setup_env_arm.sh' + provider: 'gha' - name: 'ASan + LSan + UBSan + integer, no depends, USDT' cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-md' # has to match container in ci/test/00_setup_env_native_asan.sh for tracing tools @@ -514,7 +539,7 @@ jobs: - name: Configure Docker uses: ./.github/actions/configure-docker with: - use-cirrus: ${{ needs.runners.outputs.use-cirrus-runners }} + cache-provider: ${{ matrix.provider || needs.runners.outputs.provider }} - name: Enable bpfcc script if: ${{ env.CONTAINER_NAME == 'ci_native_asan' }} @@ -551,7 +576,7 @@ jobs: - name: Configure Docker uses: ./.github/actions/configure-docker with: - use-cirrus: ${{ needs.runners.outputs.use-cirrus-runners }} + cache-provider: ${{ needs.runners.outputs.provider }} - name: CI script run: | diff --git a/depend/bitcoin/ci/lint/01_install.sh b/depend/bitcoin/ci/lint/01_install.sh index 75f8911..0d8cca9 100755 --- a/depend/bitcoin/ci/lint/01_install.sh +++ b/depend/bitcoin/ci/lint/01_install.sh @@ -41,10 +41,10 @@ python3 --version ${CI_RETRY_EXE} pip3 install \ codespell==2.4.1 \ lief==0.16.6 \ - mypy==1.4.1 \ - pyzmq==25.1.0 \ - ruff==0.5.5 \ - vulture==2.6 + mypy==1.18.2 \ + pyzmq==27.1.0 \ + ruff==0.13.2 \ + vulture==2.14 SHELLCHECK_VERSION=v0.11.0 curl -sL "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" | \ diff --git a/depend/bitcoin/ci/test/00_setup_env_native_fuzz_with_msan.sh b/depend/bitcoin/ci/test/00_setup_env_native_fuzz_with_msan.sh index c71772b..0d90605 100755 --- a/depend/bitcoin/ci/test/00_setup_env_native_fuzz_with_msan.sh +++ b/depend/bitcoin/ci/test/00_setup_env_native_fuzz_with_msan.sh @@ -7,12 +7,15 @@ export LC_ALL=C.UTF-8 export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04" +export APT_LLVM_V="21" 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" +# -lstdc++ to resolve link issues due to upstream packaging +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 -lstdc++" export MSAN_AND_LIBCXX_FLAGS="${MSAN_FLAGS} ${LIBCXX_FLAGS}" export CONTAINER_NAME="ci_native_fuzz_msan" +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="all" # Setting CMAKE_{C,CXX}_FLAGS_DEBUG flags to an empty string ensures that the flags set in MSAN_FLAGS remain unaltered. diff --git a/depend/bitcoin/ci/test/01_base_install.sh b/depend/bitcoin/ci/test/01_base_install.sh index 6944ab4..ce46098 100755 --- a/depend/bitcoin/ci/test/01_base_install.sh +++ b/depend/bitcoin/ci/test/01_base_install.sh @@ -58,23 +58,6 @@ fi if [[ -n "${USE_INSTRUMENTED_LIBCPP}" ]]; then ${CI_RETRY_EXE} git clone --depth=1 https://github.com/llvm/llvm-project -b "llvmorg-21.1.1" /llvm-project - if [ -n "${APT_LLVM_V}" ]; then - - 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 /cxx_build/ \ -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \ -DCMAKE_BUILD_TYPE=Release \ diff --git a/depend/bitcoin/ci/test/03_test_script.sh b/depend/bitcoin/ci/test/03_test_script.sh index 05e4d8f..cee09cd 100755 --- a/depend/bitcoin/ci/test/03_test_script.sh +++ b/depend/bitcoin/ci/test/03_test_script.sh @@ -130,7 +130,8 @@ if [[ "${RUN_TIDY}" == "true" ]]; then BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_EXPORT_COMPILE_COMMANDS=ON" fi -bash -c "cmake -S $BASE_ROOT_DIR -B ${BASE_BUILD_DIR} $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG" || ( +eval "CMAKE_ARGS=($BITCOIN_CONFIG_ALL $BITCOIN_CONFIG)" +cmake -S "$BASE_ROOT_DIR" -B "$BASE_BUILD_DIR" "${CMAKE_ARGS[@]}" || ( cd "${BASE_BUILD_DIR}" # shellcheck disable=SC2046 cat $(cmake -P "${BASE_ROOT_DIR}/ci/test/GetCMakeLogFiles.cmake") diff --git a/depend/bitcoin/cmake/module/Maintenance.cmake b/depend/bitcoin/cmake/module/Maintenance.cmake index 5f4b1d8..7f29bc9 100644 --- a/depend/bitcoin/cmake/module/Maintenance.cmake +++ b/depend/bitcoin/cmake/module/Maintenance.cmake @@ -96,24 +96,24 @@ function(add_macos_deploy_target) VERBATIM ) - string(REPLACE " " "-" osx_volname ${CLIENT_NAME}) + set(macos_zip "bitcoin-macos-app") if(CMAKE_HOST_APPLE) add_custom_command( - OUTPUT ${PROJECT_BINARY_DIR}/${osx_volname}.zip - COMMAND Python3::Interpreter ${PROJECT_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} ${osx_volname} -translations-dir=${QT_TRANSLATIONS_DIR} -zip + OUTPUT ${PROJECT_BINARY_DIR}/${macos_zip}.zip + COMMAND Python3::Interpreter ${PROJECT_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} -translations-dir=${QT_TRANSLATIONS_DIR} -zip=${macos_zip} DEPENDS ${PROJECT_BINARY_DIR}/${macos_app}/Contents/MacOS/Bitcoin-Qt VERBATIM ) add_custom_target(deploydir - DEPENDS ${PROJECT_BINARY_DIR}/${osx_volname}.zip + DEPENDS ${PROJECT_BINARY_DIR}/${macos_zip}.zip ) add_custom_target(deploy - DEPENDS ${PROJECT_BINARY_DIR}/${osx_volname}.zip + DEPENDS ${PROJECT_BINARY_DIR}/${macos_zip}.zip ) else() add_custom_command( OUTPUT ${PROJECT_BINARY_DIR}/dist/${macos_app}/Contents/MacOS/Bitcoin-Qt - COMMAND ${CMAKE_COMMAND} -E env OBJDUMP=${CMAKE_OBJDUMP} $ ${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} -translations-dir=${QT_TRANSLATIONS_DIR} DEPENDS ${PROJECT_BINARY_DIR}/${macos_app}/Contents/MacOS/Bitcoin-Qt VERBATIM ) @@ -128,13 +128,13 @@ function(add_macos_deploy_target) ) else() add_custom_command( - OUTPUT ${PROJECT_BINARY_DIR}/dist/${osx_volname}.zip + OUTPUT ${PROJECT_BINARY_DIR}/dist/${macos_zip}.zip WORKING_DIRECTORY dist - COMMAND ${PROJECT_SOURCE_DIR}/cmake/script/macos_zip.sh ${ZIP_EXECUTABLE} ${osx_volname}.zip + COMMAND ${PROJECT_SOURCE_DIR}/cmake/script/macos_zip.sh ${ZIP_EXECUTABLE} ${macos_zip}.zip VERBATIM ) add_custom_target(deploy - DEPENDS ${PROJECT_BINARY_DIR}/dist/${osx_volname}.zip + DEPENDS ${PROJECT_BINARY_DIR}/dist/${macos_zip}.zip ) endif() endif() diff --git a/depend/bitcoin/cmake/secp256k1.cmake b/depend/bitcoin/cmake/secp256k1.cmake index 15f1aac..5302f51 100644 --- a/depend/bitcoin/cmake/secp256k1.cmake +++ b/depend/bitcoin/cmake/secp256k1.cmake @@ -2,6 +2,8 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or https://opensource.org/license/mit/. +enable_language(C) + function(add_secp256k1 subdir) message("") message("Configuring secp256k1 subtree...") @@ -30,7 +32,6 @@ function(add_secp256k1 subdir) string(STRIP "${SECP256K1_APPEND_LDFLAGS} ${APPEND_LDFLAGS}" SECP256K1_APPEND_LDFLAGS) set(SECP256K1_APPEND_LDFLAGS ${SECP256K1_APPEND_LDFLAGS} CACHE STRING "" FORCE) # We want to build libsecp256k1 with the most tested RelWithDebInfo configuration. - enable_language(C) foreach(config IN LISTS CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES) if(config STREQUAL "") continue() diff --git a/depend/bitcoin/contrib/guix/libexec/build.sh b/depend/bitcoin/contrib/guix/libexec/build.sh index f23133f..bbf6c64 100755 --- a/depend/bitcoin/contrib/guix/libexec/build.sh +++ b/depend/bitcoin/contrib/guix/libexec/build.sh @@ -369,7 +369,7 @@ mkdir -p "$DISTSRC" ;; *darwin*) cmake --build build --target deploy ${V:+--verbose} - mv build/dist/Bitcoin-Core.zip "${OUTDIR}/${DISTNAME}-${HOST}-unsigned.zip" + mv build/dist/bitcoin-macos-app.zip "${OUTDIR}/${DISTNAME}-${HOST}-unsigned.zip" mkdir -p "unsigned-app-${HOST}" cp --target-directory="unsigned-app-${HOST}" \ contrib/macdeploy/detached-sig-create.sh diff --git a/depend/bitcoin/contrib/guix/symbol-check.py b/depend/bitcoin/contrib/guix/symbol-check.py index d808ef6..7804a2c 100755 --- a/depend/bitcoin/contrib/guix/symbol-check.py +++ b/depend/bitcoin/contrib/guix/symbol-check.py @@ -112,7 +112,6 @@ 'libfontconfig.so.1', # font support 'libfreetype.so.6', # font parsing 'libdl.so.2', # programming interface to dynamic linker -'libxcb-cursor.so.0', 'libxcb-icccm.so.4', 'libxcb-image.so.0', 'libxcb-shm.so.0', @@ -249,7 +248,7 @@ def check_MACHO_libraries(binary) -> bool: return ok def check_MACHO_min_os(binary) -> bool: - if binary.build_version.minos == [13,0,0]: + if binary.build_version.minos == [14,0,0]: return True return False diff --git a/depend/bitcoin/contrib/macdeploy/macdeployqtplus b/depend/bitcoin/contrib/macdeploy/macdeployqtplus index ba532d7..476ac13 100755 --- a/depend/bitcoin/contrib/macdeploy/macdeployqtplus +++ b/depend/bitcoin/contrib/macdeploy/macdeployqtplus @@ -390,12 +390,11 @@ Note, that the "dist" folder will be deleted before deploying on each run. Optionally, Qt translation files (.qm) can be added to the bundle.""") ap.add_argument("app_bundle", nargs=1, metavar="app-bundle", help="application bundle to be deployed") -ap.add_argument("appname", nargs=1, metavar="appname", help="name of the app being deployed") ap.add_argument("-verbose", nargs="?", const=True, help="Output additional debugging information") ap.add_argument("-no-plugins", dest="plugins", action="store_false", default=True, help="skip plugin deployment") ap.add_argument("-no-strip", dest="strip", action="store_false", default=True, help="don't run 'strip' on the binaries") ap.add_argument("-translations-dir", nargs=1, metavar="path", default=None, help="Path to Qt's translations. Base translations will automatically be added to the bundle's resources.") -ap.add_argument("-zip", nargs="?", const="", metavar="zip", help="create a .zip containing the app bundle") +ap.add_argument("-zip", nargs=1, metavar="zip", help="create a .zip containing the app bundle") config = ap.parse_args() @@ -404,7 +403,6 @@ verbose = config.verbose # ------------------------------------------------ app_bundle = config.app_bundle[0] -appname = config.appname[0] if not os.path.exists(app_bundle): sys.stderr.write(f"Error: Could not find app bundle \"{app_bundle}\"\n") @@ -416,10 +414,6 @@ if os.path.exists("dist"): print("+ Removing existing dist folder +") shutil.rmtree("dist") -if os.path.exists(appname + ".zip"): - print("+ Removing existing .zip +") - os.unlink(appname + ".zip") - # ------------------------------------------------ target = os.path.join("dist", "Bitcoin-Qt.app") @@ -466,18 +460,18 @@ if config.translations_dir: sys.stderr.write(f"Error: Could not find translation dir \"{config.translations_dir[0]}\"\n") sys.exit(1) -print("+ Adding Qt translations +") + print("+ Adding Qt translations +") -translations = Path(config.translations_dir[0]) + translations = Path(config.translations_dir[0]) -regex = re.compile('qt_[a-z]*(.qm|_[A-Z]*.qm)') + regex = re.compile('qt_[a-z]*(.qm|_[A-Z]*.qm)') -lang_files = [x for x in translations.iterdir() if regex.match(x.name)] + lang_files = [x for x in translations.iterdir() if regex.match(x.name)] -for file in lang_files: - if verbose: - print(file.as_posix(), "->", os.path.join(applicationBundle.resourcesPath, file.name)) - shutil.copy2(file.as_posix(), os.path.join(applicationBundle.resourcesPath, file.name)) + for file in lang_files: + if verbose: + print(file.as_posix(), "->", os.path.join(applicationBundle.resourcesPath, file.name)) + shutil.copy2(file.as_posix(), os.path.join(applicationBundle.resourcesPath, file.name)) # ------------------------------------------------ @@ -499,7 +493,13 @@ if platform.system() == "Darwin": # ------------------------------------------------ if config.zip is not None: - shutil.make_archive('{}'.format(appname), format='zip', root_dir='dist', base_dir='Bitcoin-Qt.app') + name = config.zip[0] + + if os.path.exists(name + ".zip"): + print("+ Removing existing .zip +") + os.unlink(name + ".zip") + + shutil.make_archive('{}'.format(name), format='zip', root_dir='dist', base_dir='Bitcoin-Qt.app') # ------------------------------------------------ diff --git a/depend/bitcoin/depends/funcs.mk b/depend/bitcoin/depends/funcs.mk index 28baf47..6c38334 100644 --- a/depend/bitcoin/depends/funcs.mk +++ b/depend/bitcoin/depends/funcs.mk @@ -36,9 +36,8 @@ define fetch_file_inner endef define fetch_file - ( test -f $$($(1)_source_dir)/$(4) || \ ( $(call fetch_file_inner,$(1),$(2),$(3),$(4),$(5)) || \ - $(call fetch_file_inner,$(1),$(FALLBACK_DOWNLOAD_PATH),$(3),$(4),$(5)))) + $(call fetch_file_inner,$(1),$(FALLBACK_DOWNLOAD_PATH),$(3),$(4),$(5))) endef # Shell script to create a source tarball in $(1)_source from local directory @@ -109,7 +108,7 @@ $(1)_prefixbin:=$($($(1)_type)_prefix)/bin/ $(1)_all_sources=$($(1)_file_name) $($(1)_extra_sources) #stamps -$(1)_fetched=$(SOURCES_PATH)/download-stamps/.stamp_fetched-$(1)-$($(1)_file_name).hash +$(1)_fetched=$(SOURCES_PATH)/download-stamps/.stamp_fetched-$(1)-$($(1)_version)-$($(1)_sha256_hash).hash $(1)_extracted=$$($(1)_extract_dir)/.stamp_extracted $(1)_preprocessed=$$($(1)_extract_dir)/.stamp_preprocessed $(1)_cleaned=$$($(1)_extract_dir)/.stamp_cleaned @@ -247,7 +246,6 @@ endif $($(1)_fetched): mkdir -p $$(@D) $(SOURCES_PATH) rm -f $$@ - touch $$@ cd $$(@D); $($(1)_fetch_cmds) cd $($(1)_source_dir); $(foreach source,$($(1)_all_sources),$(build_SHA256SUM) $(source) >> $$(@);) touch $$@ diff --git a/depend/bitcoin/depends/hosts/darwin.mk b/depend/bitcoin/depends/hosts/darwin.mk index 7ec2fd9..d33b681 100644 --- a/depend/bitcoin/depends/hosts/darwin.mk +++ b/depend/bitcoin/depends/hosts/darwin.mk @@ -1,4 +1,4 @@ -OSX_MIN_VERSION=13.0 +OSX_MIN_VERSION=14.0 OSX_SDK_VERSION=14.0 XCODE_VERSION=15.0 XCODE_BUILD_ID=15A240d diff --git a/depend/bitcoin/depends/packages/libxcb_util_cursor.mk b/depend/bitcoin/depends/packages/libxcb_util_cursor.mk index b308890..288afea 100644 --- a/depend/bitcoin/depends/packages/libxcb_util_cursor.mk +++ b/depend/bitcoin/depends/packages/libxcb_util_cursor.mk @@ -6,7 +6,7 @@ $(package)_sha256_hash=0e9c5446dc6f3beb8af6ebfcc9e27bcc6da6fe2860f7fc07b99144dfa $(package)_dependencies=libxcb libxcb_util_render libxcb_util_image define $(package)_set_vars -$(package)_config_opts = --disable-static +$(package)_config_opts = --disable-shared $(package)_config_opts += --disable-dependency-tracking --enable-option-checking endef diff --git a/depend/bitcoin/depends/packages/qrencode.mk b/depend/bitcoin/depends/packages/qrencode.mk index e3f6140..9aae62f 100644 --- a/depend/bitcoin/depends/packages/qrencode.mk +++ b/depend/bitcoin/depends/packages/qrencode.mk @@ -1,8 +1,9 @@ package=qrencode $(package)_version=4.1.1 -$(package)_download_path=https://fukuchi.org/works/qrencode/ +$(package)_download_path=https://github.com/fukuchi/libqrencode/archive/refs/tags/ +$(package)_download_file=v$($(package)_version).tar.gz $(package)_file_name=$(package)-$($(package)_version).tar.gz -$(package)_sha256_hash=da448ed4f52aba6bcb0cd48cac0dd51b8692bccc4cd127431402fca6f8171e8e +$(package)_sha256_hash=5385bc1b8c2f20f3b91d258bf8ccc8cf62023935df2d2676b5b67049f31a049c $(package)_patches=cmake_fixups.patch define $(package)_set_vars diff --git a/depend/bitcoin/depends/packages/systemtap.mk b/depend/bitcoin/depends/packages/systemtap.mk index c912e18..668099b 100644 --- a/depend/bitcoin/depends/packages/systemtap.mk +++ b/depend/bitcoin/depends/packages/systemtap.mk @@ -1,8 +1,8 @@ package=systemtap -$(package)_version=4.8 +$(package)_version=5.3 $(package)_download_path=https://sourceware.org/ftp/systemtap/releases/ $(package)_file_name=$(package)-$($(package)_version).tar.gz -$(package)_sha256_hash=cbd50a4eba5b261394dc454c12448ddec73e55e6742fda7f508f9fbc1331c223 +$(package)_sha256_hash=966a360fb73a4b65a8d0b51b389577b3c4f92a327e84aae58682103e8c65a69a $(package)_patches=remove_SDT_ASM_SECTION_AUTOGROUP_SUPPORT_check.patch define $(package)_preprocess_cmds diff --git a/depend/bitcoin/doc/build-unix.md b/depend/bitcoin/doc/build-unix.md index bfb3bd3..d9bbb35 100644 --- a/depend/bitcoin/doc/build-unix.md +++ b/depend/bitcoin/doc/build-unix.md @@ -81,8 +81,6 @@ the necessary parts of Qt, the libqrencode and pass `-DBUILD_GUI=ON`. Skip if yo sudo apt-get install qt6-base-dev qt6-tools-dev qt6-l10n-tools qt6-tools-dev-tools libgl-dev -For Qt 6.5 and later, the `libxcb-cursor0` package must be installed at runtime. - Additionally, to support Wayland protocol for modern desktop environments: sudo apt install qt6-wayland @@ -133,8 +131,6 @@ the necessary parts of Qt, the libqrencode and pass `-DBUILD_GUI=ON`. Skip if yo sudo dnf install qt6-qtbase-devel qt6-qttools-devel -For Qt 6.5 and later, the `xcb-util-cursor` package must be installed at runtime. - Additionally, to support Wayland protocol for modern desktop environments: sudo dnf install qt6-qtwayland @@ -182,8 +178,6 @@ the necessary parts of Qt, the libqrencode and pass `-DBUILD_GUI=ON`. Skip if yo 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 diff --git a/depend/bitcoin/doc/design/libraries.md b/depend/bitcoin/doc/design/libraries.md index 102b927..b20c803 100644 --- a/depend/bitcoin/doc/design/libraries.md +++ b/depend/bitcoin/doc/design/libraries.md @@ -8,7 +8,7 @@ | *libbitcoin_crypto* | Hardware-optimized functions for data encryption, hashing, message authentication, and key derivation. | | *libbitcoin_kernel* | Consensus engine and support library used for validation by *libbitcoin_node*. | | *libbitcoinqt* | GUI functionality used by *bitcoin-qt* and *bitcoin-gui* executables. | -| *libbitcoin_ipc* | IPC functionality used by *bitcoin-node*, *bitcoin-wallet*, *bitcoin-gui* executables to communicate when [`-DENABLE_IPC=ON`](multiprocess.md) is used. | +| *libbitcoin_ipc* | IPC functionality used by *bitcoin-node* and *bitcoin-gui* executables to communicate when [`-DENABLE_IPC=ON`](multiprocess.md) is used. | | *libbitcoin_node* | P2P and RPC server functionality used by *bitcoind* and *bitcoin-qt* executables. | | *libbitcoin_util* | Home for common functionality shared by different executables and libraries. Similar to *libbitcoin_common*, but lower-level (see [Dependencies](#dependencies)). | | *libbitcoin_wallet* | Wallet functionality used by *bitcoind* and *bitcoin-wallet* executables. | diff --git a/depend/bitcoin/doc/release-notes-empty-template.md b/depend/bitcoin/doc/release-notes-empty-template.md index 0e8dc77..7f419cb 100644 --- a/depend/bitcoin/doc/release-notes-empty-template.md +++ b/depend/bitcoin/doc/release-notes-empty-template.md @@ -36,7 +36,7 @@ Compatibility ============== Bitcoin Core is supported and tested on operating systems using the -Linux Kernel 3.17+, macOS 13+, and Windows 10+. Bitcoin +Linux Kernel 3.17+, macOS 14+, and Windows 10+. 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. diff --git a/depend/bitcoin/share/qt/Info.plist.in b/depend/bitcoin/share/qt/Info.plist.in index 5ff7361..e33f377 100644 --- a/depend/bitcoin/share/qt/Info.plist.in +++ b/depend/bitcoin/share/qt/Info.plist.in @@ -3,7 +3,7 @@ LSMinimumSystemVersion - 13 + 14 LSArchitecturePriority diff --git a/depend/bitcoin/share/setup.nsi.in b/depend/bitcoin/share/setup.nsi.in index 2160cc0..387d781 100644 --- a/depend/bitcoin/share/setup.nsi.in +++ b/depend/bitcoin/share/setup.nsi.in @@ -113,6 +113,19 @@ Section -post SEC0001 WriteRegStr HKCR "@CLIENT_TARNAME@" "" "URL:Bitcoin" WriteRegStr HKCR "@CLIENT_TARNAME@\DefaultIcon" "" $INSTDIR\@BITCOIN_GUI_NAME@@EXEEXT@ WriteRegStr HKCR "@CLIENT_TARNAME@\shell\open\command" "" '"$INSTDIR\@BITCOIN_GUI_NAME@@EXEEXT@" "%1"' + + # Lingering since fb2b05b1259d3e69e6e675adfa30b429424c7625 which removed the suffix + DeleteRegValue HKCU "${REGKEY} (64-bit)\Components" Main + DeleteRegKey HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name) (64-bit)" + Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name) (64-bit).lnk" + Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\$(^Name) (64-bit).lnk" + DeleteRegValue HKCU "${REGKEY} (64-bit)" StartMenuGroup + DeleteRegValue HKCU "${REGKEY} (64-bit)" Path + DeleteRegKey /IfEmpty HKCU "${REGKEY} (64-bit)\Components" + DeleteRegKey /IfEmpty HKCU "${REGKEY} (64-bit)" + + # Lingering since 77b2923f87131a407f7d4193c54db22375130403 + Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Bitcoin Core (testnet, 64-bit).lnk" SectionEnd # Macro for selecting uninstaller sections diff --git a/depend/bitcoin/src/CMakeLists.txt b/depend/bitcoin/src/CMakeLists.txt index f69a806..81c8577 100644 --- a/depend/bitcoin/src/CMakeLists.txt +++ b/depend/bitcoin/src/CMakeLists.txt @@ -292,8 +292,8 @@ if(BUILD_BITCOIN_BIN) add_executable(bitcoin bitcoin.cpp) add_windows_resources(bitcoin bitcoin-res.rc) add_windows_application_manifest(bitcoin) - target_link_libraries(bitcoin core_interface bitcoin_util) - install_binary_component(bitcoin) + target_link_libraries(bitcoin core_interface bitcoin_common bitcoin_util) + install_binary_component(bitcoin HAS_MANPAGE) endif() # Bitcoin Core bitcoind. @@ -407,27 +407,26 @@ if(BUILD_KERNEL_LIB) if (BUILD_KERNEL_TEST) add_subdirectory(test/kernel) endif() -endif() - -if(BUILD_UTIL_CHAINSTATE) - add_executable(bitcoin-chainstate - bitcoin-chainstate.cpp - ) - # TODO: The `SKIP_BUILD_RPATH` property setting can be deleted - # in the future after reordering Guix script commands to - # perform binary checks after the installation step. - # Relevant discussions: - # - https://github.com/hebasto/bitcoin/pull/236#issuecomment-2183120953 - # - https://github.com/bitcoin/bitcoin/pull/30312#issuecomment-2191235833 - set_target_properties(bitcoin-chainstate PROPERTIES - SKIP_BUILD_RPATH OFF - ) - target_link_libraries(bitcoin-chainstate - PRIVATE - core_interface - bitcoinkernel - ) - install_binary_component(bitcoin-chainstate INTERNAL) + if(BUILD_UTIL_CHAINSTATE) + add_executable(bitcoin-chainstate + bitcoin-chainstate.cpp + ) + # TODO: The `SKIP_BUILD_RPATH` property setting can be deleted + # in the future after reordering Guix script commands to + # perform binary checks after the installation step. + # Relevant discussions: + # - https://github.com/hebasto/bitcoin/pull/236#issuecomment-2183120953 + # - https://github.com/bitcoin/bitcoin/pull/30312#issuecomment-2191235833 + set_target_properties(bitcoin-chainstate PROPERTIES + SKIP_BUILD_RPATH OFF + ) + target_link_libraries(bitcoin-chainstate + PRIVATE + core_interface + bitcoinkernel + ) + install_binary_component(bitcoin-chainstate INTERNAL) + endif() endif() diff --git a/depend/bitcoin/src/bench/verify_script.cpp b/depend/bitcoin/src/bench/verify_script.cpp index 8d7e92a..062f9a0 100644 --- a/depend/bitcoin/src/bench/verify_script.cpp +++ b/depend/bitcoin/src/bench/verify_script.cpp @@ -24,7 +24,7 @@ static void VerifyScriptBench(benchmark::Bench& bench) { ECC_Context ecc_context{}; - const uint32_t flags{SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH}; + const script_verify_flags flags{SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH}; const int witnessversion = 0; // Key pair. diff --git a/depend/bitcoin/src/bitcoin-chainstate.cpp b/depend/bitcoin/src/bitcoin-chainstate.cpp index 24127d0..4a4bd87 100644 --- a/depend/bitcoin/src/bitcoin-chainstate.cpp +++ b/depend/bitcoin/src/bitcoin-chainstate.cpp @@ -72,7 +72,7 @@ class TestValidationInterface : public ValidationInterface // IWYU pragma: keep #include +#include #include #include #include @@ -47,7 +48,7 @@ Run '%s help' to see additional commands (e.g. for testing and debugging). )"; struct CommandLine { - bool use_multiprocess{false}; + std::optional use_multiprocess; bool show_version{false}; bool show_help{false}; std::string_view command; @@ -55,6 +56,7 @@ struct CommandLine { }; CommandLine ParseCommandLine(int argc, char* argv[]); +bool UseMultiprocess(const CommandLine& cmd); static void ExecCommand(const std::vector& args, std::string_view argv0); int main(int argc, char* argv[]) @@ -78,9 +80,9 @@ int main(int argc, char* argv[]) return EXIT_FAILURE; } } else if (cmd.command == "gui") { - args.emplace_back(cmd.use_multiprocess ? "bitcoin-gui" : "bitcoin-qt"); + args.emplace_back(UseMultiprocess(cmd) ? "bitcoin-gui" : "bitcoin-qt"); } else if (cmd.command == "node") { - args.emplace_back(cmd.use_multiprocess ? "bitcoin-node" : "bitcoind"); + args.emplace_back(UseMultiprocess(cmd) ? "bitcoin-node" : "bitcoind"); } else if (cmd.command == "rpc") { args.emplace_back("bitcoin-cli"); // Since "bitcoin rpc" is a new interface that doesn't need to be @@ -143,6 +145,30 @@ CommandLine ParseCommandLine(int argc, char* argv[]) return cmd; } +bool UseMultiprocess(const CommandLine& cmd) +{ + // If -m or -M options were explicitly specified, there is no need to + // further parse arguments to determine which to use. + if (cmd.use_multiprocess) return *cmd.use_multiprocess; + + ArgsManager args; + args.SetDefaultFlags(ArgsManager::ALLOW_ANY); + std::string error_message; + auto argv{cmd.args}; + argv.insert(argv.begin(), nullptr); + if (!args.ParseParameters(argv.size(), argv.data(), error_message)) { + tfm::format(std::cerr, "Warning: failed to parse subcommand command line options: %s\n", error_message); + } + if (!args.ReadConfigFiles(error_message, true)) { + tfm::format(std::cerr, "Warning: failed to parse subcommand config: %s\n", error_message); + } + args.SelectConfigNetwork(args.GetChainTypeString()); + + // If any -ipc* options are set these need to be processed by a + // multiprocess-capable binary. + return args.IsArgSet("-ipcbind") || args.IsArgSet("-ipcconnect") || args.IsArgSet("-ipcfd"); +} + //! Execute the specified bitcoind, bitcoin-qt or other command line in `args` //! using src, bin and libexec directory paths relative to this executable, where //! the path to this executable is specified in `wrapper_argv0`. diff --git a/depend/bitcoin/src/bitcoind.cpp b/depend/bitcoin/src/bitcoind.cpp index ceb3c99..a4373da 100644 --- a/depend/bitcoin/src/bitcoind.cpp +++ b/depend/bitcoin/src/bitcoind.cpp @@ -132,11 +132,16 @@ static bool ParseArgs(NodeContext& node, int argc, char* argv[]) return true; } -static bool ProcessInitCommands(ArgsManager& args) +static bool ProcessInitCommands(interfaces::Init& init, ArgsManager& args) { // Process help and version before taking care about datadir if (HelpRequested(args) || args.GetBoolArg("-version", false)) { - std::string strUsage = CLIENT_NAME " daemon version " + FormatFullVersion() + "\n"; + std::string strUsage = CLIENT_NAME " daemon version " + FormatFullVersion(); + if (const char* exe_name{init.exeName()}) { + strUsage += " "; + strUsage += exe_name; + } + strUsage += "\n"; if (args.GetBoolArg("-version", false)) { strUsage += FormatParagraph(LicenseInfo()); @@ -277,7 +282,7 @@ MAIN_FUNCTION ArgsManager& args = *Assert(node.args); if (!ParseArgs(node, argc, argv)) return EXIT_FAILURE; // Process early info return commands such as -help or -version - if (ProcessInitCommands(args)) return EXIT_SUCCESS; + if (ProcessInitCommands(*init, args)) return EXIT_SUCCESS; // Start application if (!AppInit(node) || !Assert(node.shutdown_signal)->wait()) { diff --git a/depend/bitcoin/src/chain.cpp b/depend/bitcoin/src/chain.cpp index 4e2d1bf..3dd2263 100644 --- a/depend/bitcoin/src/chain.cpp +++ b/depend/bitcoin/src/chain.cpp @@ -5,6 +5,7 @@ #include #include +#include #include std::string CBlockFileInfo::ToString() const @@ -158,18 +159,26 @@ int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& fr /** Find the last common ancestor two blocks have. * Both pa and pb must be non-nullptr. */ const CBlockIndex* LastCommonAncestor(const CBlockIndex* pa, const CBlockIndex* pb) { + // First rewind to the last common height (the forking point cannot be past one of the two). if (pa->nHeight > pb->nHeight) { pa = pa->GetAncestor(pb->nHeight); } else if (pb->nHeight > pa->nHeight) { pb = pb->GetAncestor(pa->nHeight); } - - while (pa != pb && pa && pb) { + while (pa != pb) { + // Jump back until pa and pb have a common "skip" ancestor. + while (pa->pskip != pb->pskip) { + // This logic relies on the property that equal-height blocks have equal-height skip + // pointers. + Assume(pa->nHeight == pb->nHeight); + Assume(pa->pskip->nHeight == pb->pskip->nHeight); + pa = pa->pskip; + pb = pb->pskip; + } + // At this point, pa and pb are different, but have equal pskip. The forking point lies in + // between pa/pb on the one end, and pa->pskip/pb->pskip on the other end. pa = pa->pprev; pb = pb->pprev; } - - // Eventually all chain branches meet at the genesis block. - assert(pa == pb); return pa; } diff --git a/depend/bitcoin/src/common/args.cpp b/depend/bitcoin/src/common/args.cpp index ff30ec5..d44cd43 100644 --- a/depend/bitcoin/src/common/args.cpp +++ b/depend/bitcoin/src/common/args.cpp @@ -266,7 +266,13 @@ std::optional ArgsManager::GetArgFlags(const std::string& name) co return search->second.m_flags; } } - return std::nullopt; + return m_default_flags; +} + +void ArgsManager::SetDefaultFlags(std::optional flags) +{ + LOCK(cs_args); + m_default_flags = flags; } fs::path ArgsManager::GetPathArg(std::string arg, const fs::path& default_value) const diff --git a/depend/bitcoin/src/common/args.h b/depend/bitcoin/src/common/args.h index da19cbd..d907ad7 100644 --- a/depend/bitcoin/src/common/args.h +++ b/depend/bitcoin/src/common/args.h @@ -137,6 +137,7 @@ class ArgsManager std::string m_network GUARDED_BY(cs_args); std::set m_network_only_args GUARDED_BY(cs_args); std::map> m_available_args GUARDED_BY(cs_args); + std::optional m_default_flags GUARDED_BY(cs_args){}; bool m_accept_any_command GUARDED_BY(cs_args){true}; std::list m_config_sections GUARDED_BY(cs_args); std::optional m_config_path GUARDED_BY(cs_args); @@ -375,10 +376,15 @@ class ArgsManager /** * Return Flags for known arg. - * Return nullopt for unknown arg. + * Return default flags for unknown arg. */ std::optional GetArgFlags(const std::string& name) const; + /** + * Set default flags to return for an unknown arg. + */ + void SetDefaultFlags(std::optional); + /** * Get settings file path, or return false if read-write settings were * disabled with -nosettings. diff --git a/depend/bitcoin/src/common/system.cpp b/depend/bitcoin/src/common/system.cpp index 7af792d..35a6f44 100644 --- a/depend/bitcoin/src/common/system.cpp +++ b/depend/bitcoin/src/common/system.cpp @@ -11,19 +11,25 @@ #include #include -#ifndef WIN32 -#include -#else -#include +#ifdef WIN32 #include +#include +#include +#else +#include +#include #endif #ifdef HAVE_MALLOPT_ARENA_MAX #include #endif +#include +#include +#include #include #include +#include #include #include #include @@ -105,6 +111,22 @@ int GetNumCores() return std::thread::hardware_concurrency(); } +std::optional GetTotalRAM() +{ + [[maybe_unused]] auto clamp{[](uint64_t v) { return size_t(std::min(v, uint64_t{std::numeric_limits::max()})); }}; +#ifdef WIN32 + if (MEMORYSTATUSEX m{}; (m.dwLength = sizeof(m), GlobalMemoryStatusEx(&m))) return clamp(m.ullTotalPhys); +#elif defined(__APPLE__) || \ + defined(__FreeBSD__) || \ + defined(__NetBSD__) || \ + defined(__OpenBSD__) || \ + defined(__illumos__) || \ + defined(__linux__) + if (long p{sysconf(_SC_PHYS_PAGES)}, s{sysconf(_SC_PAGESIZE)}; p > 0 && s > 0) return clamp(1ULL * p * s); +#endif + return std::nullopt; +} + // Obtain the application startup time (used for uptime calculation) int64_t GetStartupTime() { diff --git a/depend/bitcoin/src/common/system.h b/depend/bitcoin/src/common/system.h index a4b56be..2184f1d 100644 --- a/depend/bitcoin/src/common/system.h +++ b/depend/bitcoin/src/common/system.h @@ -9,6 +9,7 @@ #include // IWYU pragma: keep #include +#include #include // Application startup time (used for uptime calculation) @@ -29,4 +30,9 @@ void runCommand(const std::string& strCommand); */ int GetNumCores(); +/** + * Return the total RAM available on the current system, if detectable. + */ +std::optional GetTotalRAM(); + #endif // BITCOIN_COMMON_SYSTEM_H diff --git a/depend/bitcoin/src/compat/compat.h b/depend/bitcoin/src/compat/compat.h index 05210b7..acb57b2 100644 --- a/depend/bitcoin/src/compat/compat.h +++ b/depend/bitcoin/src/compat/compat.h @@ -75,14 +75,6 @@ typedef unsigned int SOCKET; typedef SSIZE_T ssize_t; #endif -// The type of the option value passed to getsockopt & setsockopt -// differs between Windows and non-Windows. -#ifndef WIN32 -typedef void* sockopt_arg_type; -#else -typedef char* sockopt_arg_type; -#endif - #ifdef WIN32 // Export main() and ensure working ASLR when using mingw-w64. // Exporting a symbol will prevent the linker from stripping diff --git a/depend/bitcoin/src/consensus/params.h b/depend/bitcoin/src/consensus/params.h index 6344349..f33ff15 100644 --- a/depend/bitcoin/src/consensus/params.h +++ b/depend/bitcoin/src/consensus/params.h @@ -6,6 +6,7 @@ #ifndef BITCOIN_CONSENSUS_PARAMS_H #define BITCOIN_CONSENSUS_PARAMS_H +#include