diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..8304daf5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,506 @@ +############################################################################### +# Copyright (c) 2014-2020 libbitcoin-consensus developers (see COPYING). +# +# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY +# +############################################################################### + +name: Continuous Integration Build + +on: [ pull_request, push, workflow_dispatch ] + +jobs: + autotools: + + strategy: + fail-fast: false + + matrix: + include: + - os: ubuntu-22.04 + cxx: "clang++-13" + link: "dynamic" + optimization: "size" + assert: "debug" + coverage: "nocov" + boost: "--build-boost" + icu: "" + cc: "clang-13" + flags: "-Os -fPIE" + packager: "apt" + packages: "" + + - os: ubuntu-22.04 + cxx: "clang++-13" + link: "static" + optimization: "size" + assert: "ndebug" + coverage: "nocov" + boost: "--build-boost" + icu: "--build-icu --with-icu" + cc: "clang-13" + flags: "-Os -fPIE" + packager: "apt" + packages: "" + + - os: ubuntu-22.04 + cxx: "g++-11" + link: "dynamic" + optimization: "size" + assert: "ndebug" + coverage: "nocov" + boost: "--build-boost" + icu: "" + cc: "gcc-11" + flags: "-Os -fPIE" + packager: "apt" + packages: "" + + - os: ubuntu-22.04 + cxx: "g++-11" + link: "static" + optimization: "debug" + assert: "ndebug" + coverage: "cov" + boost: "--build-boost" + icu: "--build-icu --with-icu" + cc: "gcc-11" + flags: "-Og -g --coverage -fPIE" + packager: "apt" + packages: "lcov" + + - os: macos-latest + cxx: "clang++-14" + link: "dynamic" + optimization: "size" + assert: "ndebug" + coverage: "nocov" + boost: "" + icu: "--with-icu" + cc: "clang-14" + flags: "-Os -fPIE" + packager: "brew" + packages: "boost icu4c" + + - os: macos-latest + cxx: "clang++-14" + link: "static" + optimization: "size" + assert: "ndebug" + coverage: "nocov" + boost: "--build-boost" + icu: "--build-icu --with-icu" + cc: "clang-14" + flags: "-Os -fvisibility=hidden -fPIE" + packager: "brew" + packages: "" + + + runs-on: ${{ matrix.os }} + + env: + CC: '${{ matrix.cc }}' + CXX: '${{ matrix.cxx }}' + CFLAGS: '${{ matrix.flags }}' + CXXFLAGS: '${{ matrix.flags }}' + CI_REPOSITORY: '${{ github.repository }}' + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Prepare toolchain [apt] + if: ${{ matrix.packager == 'apt' }} + run: | + sudo apt-get update + sudo apt-get install git build-essential autoconf automake libtool pkg-config ${{ matrix.packages }} + + - name: Prepare toolchain [brew] + if: ${{ matrix.packager == 'brew' }} + run: | + brew install autoconf automake libtool pkg-config ${{ matrix.packages }} + + - name: Denormalize parameterization + run: | + if [[ ${{ matrix.assert }} == 'ndebug' ]]; then + echo "ASSERT_NDEBUG=--enable-ndebug" >> $GITHUB_ENV + else + echo "ASSERT_NDEBUG=--disable-ndebug" >> $GITHUB_ENV + fi + if [[ ${{ matrix.link }} == 'dynamic' ]]; then + echo "LINKAGE=--disable-static" >> $GITHUB_ENV + else + echo "LINKAGE=--disable-shared" >> $GITHUB_ENV + fi + if [[ ${{ matrix.link }} == 'dynamic' ]]; then + echo "LDFLAGS=-Wl,-rpath,${{ github.workspace }}/prefixenv/lib" >> $GITHUB_ENV + fi + + - name: Execute install.sh + run: > + ./install.sh + --build-dir=${{ github.workspace }}/build + --prefix=${{ github.workspace }}/prefixenv + ${{ env.LINKAGE }} + ${{ env.ASSERT_NDEBUG }} + ${{ matrix.boost }} + ${{ matrix.icu }} + + - name: Coveralls Calculation + if: ${{ matrix.coverage == 'cov' }} + run: | + lcov --directory . --capture --output-file coverage.info + lcov --remove coverage.info "/usr/*" "${{ github.workspace }}/prefixenv/*" "${{ github.workspace }}/build/*" "${{ github.workspace }}/examples/*" "${{ github.workspace }}/test/*" --output-file coverage.info + lcov --list coverage.info + + - name: Coveralls.io Upload + if: ${{ matrix.coverage == 'cov' }} + uses: coverallsapp/github-action@master + with: + path-to-lcov: "./coverage.info" + github-token: ${{ secrets.github_token }} + + - name: Failure display available binaries + if: ${{ failure() }} + run: | + ls -la /usr/bin + + - name: Failure display selected compiler version + if: ${{ failure() }} + run: | + ${CC} -v + ${CXX} -v + + - name: Failure display default compiler version + if: ${{ failure() }} + run: | + clang -v + gcc -v + + - name: Failure display env + if: ${{ failure() }} + run: | + env + + - name: Failure list libdir + if: ${{ failure() }} + run: | + ls -la ${{ github.workspace }}/prefixenv/lib + + - name: Failure display boost bootstrap.log [--build-boost] + if: ${{ failure() && (matrix.boost == '--build-boost') }} + run: | + cat ${{ github.workspace }}/build/build-*/bootstrap.log + + - name: Failure display otool output + if: ${{ failure() && (matrix.os == 'macos-latest') }} + run: | + otool -L ${{ github.workspace }}/test/.libs/libbitcoin-consensus-test + + - name: Failure display DYLD_PRINT_LIBRARIES + if: ${{ failure() && (matrix.os == 'macos-latest') }} + run: | + DYLD_PRINT_LIBRARIES=1 ${{ github.workspace }}/test/.libs/libbitcoin-consensus-test + + - name: Failure display pkgconfig + if: ${{ failure() }} + run: | + ls ${{ github.workspace }}/prefixenv/lib/pkgconfig/ + cat ${{ github.workspace }}/prefixenv/lib/pkgconfig/*.pc + + cmake: + + strategy: + fail-fast: false + + matrix: + include: + - os: ubuntu-22.04 + cxx: "clang++-13" + link: "dynamic" + optimization: "size" + assert: "debug" + coverage: "nocov" + boost: "--build-boost" + icu: "" + cc: "clang-13" + flags: "-Os -fPIE" + packager: "apt" + packages: "" + + - os: ubuntu-22.04 + cxx: "clang++-13" + link: "static" + optimization: "size" + assert: "ndebug" + coverage: "nocov" + boost: "--build-boost" + icu: "--build-icu --with-icu" + cc: "clang-13" + flags: "-Os -fPIE" + packager: "apt" + packages: "" + + - os: ubuntu-22.04 + cxx: "g++-11" + link: "dynamic" + optimization: "size" + assert: "ndebug" + coverage: "nocov" + boost: "--build-boost" + icu: "" + cc: "gcc-11" + flags: "-Os -fPIE" + packager: "apt" + packages: "" + + - os: ubuntu-22.04 + cxx: "g++-11" + link: "static" + optimization: "debug" + assert: "ndebug" + coverage: "nocov" + boost: "--build-boost" + icu: "--build-icu --with-icu" + cc: "gcc-11" + flags: "-Og -fPIE" + packager: "apt" + packages: "" + + - os: macos-latest + cxx: "clang++-14" + link: "dynamic" + optimization: "size" + assert: "ndebug" + coverage: "nocov" + boost: "" + icu: "--with-icu" + cc: "clang-14" + flags: "-Os -fPIE" + packager: "brew" + packages: "boost icu4c" + + - os: macos-latest + cxx: "clang++-14" + link: "static" + optimization: "size" + assert: "ndebug" + coverage: "nocov" + boost: "--build-boost" + icu: "--build-icu --with-icu" + cc: "clang-14" + flags: "-Os -fvisibility=hidden -fPIE" + packager: "brew" + packages: "" + + + runs-on: ${{ matrix.os }} + + env: + CC: '${{ matrix.cc }}' + CXX: '${{ matrix.cxx }}' + CFLAGS: '${{ matrix.flags }}' + CXXFLAGS: '${{ matrix.flags }}' + CI_REPOSITORY: '${{ github.repository }}' + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Prepare toolchain [apt] + if: ${{ matrix.packager == 'apt' }} + run: | + sudo apt-get update + sudo apt-get install git build-essential autoconf automake libtool pkg-config ${{ matrix.packages }} + + - name: Prepare toolchain [brew] + if: ${{ matrix.packager == 'brew' }} + run: | + brew install autoconf automake libtool pkg-config ${{ matrix.packages }} + + - name: Denormalize parameterization + run: | + if [[ ${{ matrix.packager }} == 'brew' ]]; then + echo "CMAKE_LIBRARY_PATH=/usr/local/lib" >> $GITHUB_ENV + fi + if [[ ${{ matrix.assert }} == 'ndebug' ]]; then + echo "ASSERT_NDEBUG=--enable-ndebug -Denable-ndebug=yes" >> $GITHUB_ENV + else + echo "ASSERT_NDEBUG=--disable-ndebug -Denable-ndebug=no" >> $GITHUB_ENV + fi + if [[ ${{ matrix.link }} == 'dynamic' ]]; then + echo "LINKAGE=--disable-static" >> $GITHUB_ENV + else + echo "LINKAGE=--disable-shared" >> $GITHUB_ENV + fi + if [[ ${{ matrix.link }} == 'dynamic' ]]; then + echo "LDFLAGS=-Wl,-rpath,${{ github.workspace }}/prefixenv/lib" >> $GITHUB_ENV + fi + + - name: Execute install-cmake.sh + run: > + ./install-cmake.sh + --build-dir=${{ github.workspace }}/build + --prefix=${{ github.workspace }}/prefixenv + ${{ env.LINKAGE }} + ${{ env.ASSERT_NDEBUG }} + ${{ matrix.boost }} + ${{ matrix.icu }} + + - name: Coveralls Calculation + if: ${{ matrix.coverage == 'cov' }} + run: | + lcov --directory . --capture --output-file coverage.info + lcov --remove coverage.info "/usr/*" "${{ github.workspace }}/prefixenv/*" "${{ github.workspace }}/build/*" "${{ github.workspace }}/examples/*" "${{ github.workspace }}/test/*" --output-file coverage.info + lcov --list coverage.info + + - name: Coveralls.io Upload + if: ${{ matrix.coverage == 'cov' }} + uses: coverallsapp/github-action@master + with: + path-to-lcov: "./coverage.info" + github-token: ${{ secrets.github_token }} + + - name: Failure display available binaries + if: ${{ failure() }} + run: | + ls -la /usr/bin + + - name: Failure display selected compiler version + if: ${{ failure() }} + run: | + ${CC} -v + ${CXX} -v + + - name: Failure display default compiler version + if: ${{ failure() }} + run: | + clang -v + gcc -v + + - name: Failure display env + if: ${{ failure() }} + run: | + env + + - name: Failure list libdir + if: ${{ failure() }} + run: | + ls -la ${{ github.workspace }}/prefixenv/lib + + - name: Failure display boost bootstrap.log [--build-boost] + if: ${{ failure() && (matrix.boost == '--build-boost') }} + run: | + cat ${{ github.workspace }}/build/build-*/bootstrap.log + + - name: Failure display otool output + if: ${{ failure() && (matrix.os == 'macos-latest') }} + run: | + otool -L ${{ github.workspace }}/test/.libs/libbitcoin-consensus-test + + - name: Failure display DYLD_PRINT_LIBRARIES + if: ${{ failure() && (matrix.os == 'macos-latest') }} + run: | + DYLD_PRINT_LIBRARIES=1 ${{ github.workspace }}/test/.libs/libbitcoin-consensus-test + + - name: Failure display pkgconfig + if: ${{ failure() }} + run: | + ls ${{ github.workspace }}/prefixenv/lib/pkgconfig/ + cat ${{ github.workspace }}/prefixenv/lib/pkgconfig/*.pc + + - name: Failure display cmake specific libraries + if: ${{ failure() }} + run: | + ls ${{ github.workspace }}/prefixenv/lib/cmake + + - name: Failure display cmake LastTest.log + if: ${{ failure() }} + run: | + cat ${{ github.workspace }}/Testing/Temporary/LastTest.log + + msbuild: + strategy: + fail-fast: false + + matrix: + include: + - os: windows-latest + configuration: "StaticRelease" + platform: "Win32" + version: "vs2022" + tests: "*" + + - os: windows-latest + configuration: "StaticDebug" + platform: "Win32" + version: "vs2022" + tests: "*" + + - os: windows-latest + configuration: "StaticRelease" + platform: "x64" + version: "vs2022" + tests: "*" + + - os: windows-latest + configuration: "StaticDebug" + platform: "x64" + version: "vs2022" + tests: "*" + + runs-on: ${{ matrix.os }} + + steps: + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.1 + + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Initialize SDK + shell: powershell + run: | + try { + Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/p/?LinkId=323507" -OutFile "sdksetup.exe" + + $FeatureList = "OptionId.WindowsDesktopSoftwareDevelopmentKit OptionId.NetFxSoftwareDevelopmentKit" + $Args = "/q /norestart /features $FeatureList" + $setup = Start-Process -PassThru -FilePath "sdksetup.exe" -ArgumentList $Args + + $setup.WaitForExit() + if ($setup.ExitCode -ne 0) { + Write-Host "Test execution failure: " $setup.ExitCode -ForegroundColor Red; + exit $setup.ExitCode; + } + } + catch { + $ERR = $_; + Write-Host "Initialization failure: " $ERR -ForegroundColor Red; + exit $ERR; + } + + - name: Execute build + run: .\build.cmd .. ${{ matrix.platform }} ${{ matrix.configuration }} ${{ matrix.version }} + + - name: Execute tests + shell: powershell + run: | + Write-Host "Locating test executables..." -ForegroundColor Yellow; + $BC_TEST_EXES = @(Get-ChildItem -Path "$env:${{ github.workspace }}\bin" -recurse | Where-Object { $_.Name -eq "libbitcoin-consensus-test.exe" }); + If ($BC_TEST_EXES.Count -ne 1) { + Write-Host "Failure, invalid count of test executables." -ForegroundColor Red; + exit 1; + } + Write-Host "Found single test executable: " $BC_TEST_EXES.FullName -ForegroundColor Green; + $BC_TEST_SINGLETON = $BC_TEST_EXES.FullName; + Write-Host "Executing $BC_TEST_SINGLETON $env:BOOST_UNIT_TEST_OPTIONS" -ForegroundColor Yellow; + try { + Invoke-Expression "$BC_TEST_SINGLETON --run_test=${{ matrix.tests }} $env:BOOST_UNIT_TEST_OPTIONS" + } + catch { + $ERR = $_; + Write-Host "Test execution failure: " $ERR -ForegroundColor Red; + exit $ERR; + } + Write-Host "Test execution complete." -ForegroundColor Green; diff --git a/Makefile.am b/Makefile.am index ef761232..d3366f91 100644 --- a/Makefile.am +++ b/Makefile.am @@ -90,7 +90,9 @@ test_libbitcoin_consensus_test_SOURCES = \ test/consensus__script_verify.cpp \ test/consensus__verify_flags_to_script_flags.cpp \ test/main.cpp \ - test/script.hpp + test/script.hpp \ + test/test.cpp \ + test/test.hpp endif WITH_TESTS diff --git a/build.cmd b/build.cmd index 447f268d..cbb89a23 100644 --- a/build.cmd +++ b/build.cmd @@ -7,8 +7,10 @@ REM ########################################################################### @echo off SETLOCAL ENABLEEXTENSIONS SET "parent=%~dp0" -SET "path_base=%~1" -SET "nuget_pkg_path=%~1\.nuget\packages" +SET "relative_path_base=%~1" +call cd /d "%relative_path_base%" +SET "path_base=%cd%" +SET "nuget_pkg_path=%path_base%\.nuget\packages" SET "msbuild_args=/verbosity:minimal /p:Platform=%~2 /p:Configuration=%~3" SET "proj_version=%~4" SET "msbuild_exe=msbuild" @@ -62,7 +64,7 @@ IF %ERRORLEVEL% NEQ 0 ( exit /b 1 ) call cd /d "%path_base%\%~1\builds\msvc\%proj_version%" -call "%msbuild_exe%" %msbuild_args% %~1.sln +call "%msbuild_exe%" %msbuild_args% %~1.sln /p:PreBuildEventUseInBuild=false /p:PostBuildEventUseInBuild=false IF %ERRORLEVEL% NEQ 0 ( call :failure "%msbuild_exe% %msbuild_args% %~1.sln failed." exit /b 1 @@ -79,7 +81,7 @@ IF %ERRORLEVEL% NEQ 0 ( exit /b 1 ) call cd /d "%path_base%\%~1\builds\msvc\%proj_version%" -call "%msbuild_exe%" %msbuild_args% /target:%~1:Rebuild %~1.sln +call "%msbuild_exe%" %msbuild_args% /target:%~1:Rebuild %~1.sln /p:PreBuildEventUseInBuild=false /p:PostBuildEventUseInBuild=false IF %ERRORLEVEL% NEQ 0 ( call :failure "%msbuild_exe% %msbuild_args% /target:%~1:Rebuild %~1.sln" exit /b 1 @@ -90,7 +92,7 @@ exit /b 0 :depends call :pending "nuget restoring dependencies for %~1..." -call nuget restore "%path_base%\%~1\builds\msvc\%proj_version%\%~1.sln" -Outputdir "%nuget_pkg_path%" +call nuget restore "%path_base%\%~1\builds\msvc\%proj_version%\%~1.sln" -OutputDirectory "%nuget_pkg_path%" IF %ERRORLEVEL% NEQ 0 ( call :failure "nuget restore failed." exit /b 1 diff --git a/builds/cmake/CMakeLists.txt b/builds/cmake/CMakeLists.txt index 32c3eb5f..5943ef36 100644 --- a/builds/cmake/CMakeLists.txt +++ b/builds/cmake/CMakeLists.txt @@ -34,7 +34,7 @@ else () set( VERSION "${PACKAGE_VERSION}" ) endif () -set( CMAKE_CXX_STANDARD 11 ) +set( CMAKE_CXX_STANDARD 20 ) set( CMAKE_CXX_STANDARD_REQUIRED ON ) # Add compiler options @@ -45,9 +45,6 @@ add_compile_options( "-Wall" ) # Warn on extra stuff. add_compile_options( "-Wextra" ) -# Be really annoying. -add_compile_options( "-Wpedantic" ) - # Disallow warning on style order of declarations. add_compile_options( "-Wno-reorder" ) @@ -60,6 +57,9 @@ add_compile_options( "-Wno-missing-braces" ) # Ignore comments within comments or commenting of backslash extended lines. add_compile_options( "-Wno-comment" ) +# Suppress warning for copy of implicitly generated copy constructor. +add_compile_options( "-Wno-deprecated-copy" ) + # Suppress frequent warning in cloned files. add_compile_options( "-Wno-unused-parameter" ) @@ -98,222 +98,330 @@ endif() # Initialize HAVE_BYTESWAP_H variable checking for byteswap.h #------------------------------------------------------------------------------ check_include_files( "byteswap.h" HAVE_BYTESWAP_H ) -if (!HAVE_BYTESWAP_H) - set( HAVE_BYTESWAP_H 0 ) +if (HAVE_BYTESWAP_H) + add_definitions( -DHAVE_BYTESWAP_H ) endif() -add_definitions( -DHAVE_BYTESWAP_H=${HAVE_BYTESWAP_H} ) - # Initialize HAVE_ENDIAN_H variable checking for endian.h #------------------------------------------------------------------------------ check_include_files( "endian.h" HAVE_ENDIAN_H ) -if (!HAVE_ENDIAN_H) - set( HAVE_ENDIAN_H 0 ) +if (HAVE_ENDIAN_H) + add_definitions( -DHAVE_ENDIAN_H ) endif() -add_definitions( -DHAVE_ENDIAN_H=${HAVE_ENDIAN_H} ) - # Initialize HAVE_SYS_ENDIAN_H variable checking for sys/endian.h #------------------------------------------------------------------------------ check_include_files( "sys/endian.h" HAVE_SYS_ENDIAN_H ) -if (!HAVE_SYS_ENDIAN_H) - set( HAVE_SYS_ENDIAN_H 0 ) +if (HAVE_SYS_ENDIAN_H) + add_definitions( -DHAVE_SYS_ENDIAN_H ) endif() -add_definitions( -DHAVE_SYS_ENDIAN_H=${HAVE_SYS_ENDIAN_H} ) - # On HAVE_BYTESWAP_H, test for bswap_16 #------------------------------------------------------------------------------ if (HAVE_BYTESWAP_H) check_symbol_exists( "bswap_16" "byteswap.h" HAVE_DECL_BSWAP_16 ) - add_definitions( -DHAVE_DECL_BSWAP_16=${HAVE_DECL_BSWAP_16} ) + if (HAVE_DECL_BSWAP_16) + add_definitions( -DHAVE_DECL_BSWAP_16=1 ) + else() + add_definitions( -DHAVE_DECL_BSWAP_16=0 ) + endif() endif() # On HAVE_BYTESWAP_H, test for bswap_32 #------------------------------------------------------------------------------ if (HAVE_BYTESWAP_H) check_symbol_exists( "bswap_32" "byteswap.h" HAVE_DECL_BSWAP_32 ) - add_definitions( -DHAVE_DECL_BSWAP_32=${HAVE_DECL_BSWAP_32} ) + if (HAVE_DECL_BSWAP_32) + add_definitions( -DHAVE_DECL_BSWAP_32=1 ) + else() + add_definitions( -DHAVE_DECL_BSWAP_32=0 ) + endif() endif() # On HAVE_BYTESWAP_H, test for bswap_64 #------------------------------------------------------------------------------ if (HAVE_BYTESWAP_H) check_symbol_exists( "bswap_64" "byteswap.h" HAVE_DECL_BSWAP_64 ) - add_definitions( -DHAVE_DECL_BSWAP_64=${HAVE_DECL_BSWAP_64} ) + if (HAVE_DECL_BSWAP_64) + add_definitions( -DHAVE_DECL_BSWAP_64=1 ) + else() + add_definitions( -DHAVE_DECL_BSWAP_64=0 ) + endif() endif() # On HAVE_ENDIAN_H, test for le16toh #------------------------------------------------------------------------------ if (HAVE_ENDIAN_H) check_symbol_exists( "le16toh" "endian.h" HAVE_DECL_LE16TOH ) - add_definitions( -DHAVE_DECL_LE16TOH=${HAVE_DECL_LE16TOH} ) + if (HAVE_DECL_LE16TOH) + add_definitions( -DHAVE_DECL_LE16TOH=1 ) + else() + add_definitions( -DHAVE_DECL_LE16TOH=0 ) + endif() endif() # On HAVE_ENDIAN_H, test for le32toh #------------------------------------------------------------------------------ if (HAVE_ENDIAN_H) check_symbol_exists( "le32toh" "endian.h" HAVE_DECL_LE32TOH ) - add_definitions( -DHAVE_DECL_LE32TOH=${HAVE_DECL_LE32TOH} ) + if (HAVE_DECL_LE32TOH) + add_definitions( -DHAVE_DECL_LE32TOH=1 ) + else() + add_definitions( -DHAVE_DECL_LE32TOH=0 ) + endif() endif() # On HAVE_ENDIAN_H, test for le64toh #------------------------------------------------------------------------------ if (HAVE_ENDIAN_H) check_symbol_exists( "le64toh" "endian.h" HAVE_DECL_LE64TOH ) - add_definitions( -DHAVE_DECL_LE64TOH=${HAVE_DECL_LE64TOH} ) + if (HAVE_DECL_LE64TOH) + add_definitions( -DHAVE_DECL_LE64TOH=1 ) + else() + add_definitions( -DHAVE_DECL_LE64TOH=0 ) + endif() endif() # On HAVE_ENDIAN_H, test for htole16 #------------------------------------------------------------------------------ if (HAVE_ENDIAN_H) check_symbol_exists( "htole16" "endian.h" HAVE_DECL_HTOLE16 ) - add_definitions( -DHAVE_DECL_HTOLE16=${HAVE_DECL_HTOLE16} ) + if (HAVE_DECL_HTOLE16) + add_definitions( -DHAVE_DECL_HTOLE16=1 ) + else() + add_definitions( -DHAVE_DECL_HTOLE16=0 ) + endif() endif() # On HAVE_ENDIAN_H, test for htole32 #------------------------------------------------------------------------------ if (HAVE_ENDIAN_H) check_symbol_exists( "htole32" "endian.h" HAVE_DECL_HTOLE32 ) - add_definitions( -DHAVE_DECL_HTOLE32=${HAVE_DECL_HTOLE32} ) + if (HAVE_DECL_HTOLE32) + add_definitions( -DHAVE_DECL_HTOLE32=1 ) + else() + add_definitions( -DHAVE_DECL_HTOLE32=0 ) + endif() endif() # On HAVE_ENDIAN_H, test for htole64 #------------------------------------------------------------------------------ if (HAVE_ENDIAN_H) check_symbol_exists( "htole64" "endian.h" HAVE_DECL_HTOLE64 ) - add_definitions( -DHAVE_DECL_HTOLE64=${HAVE_DECL_HTOLE64} ) + if (HAVE_DECL_HTOLE64) + add_definitions( -DHAVE_DECL_HTOLE64=1 ) + else() + add_definitions( -DHAVE_DECL_HTOLE64=0 ) + endif() endif() # On HAVE_ENDIAN_H, test for be16toh #------------------------------------------------------------------------------ if (HAVE_ENDIAN_H) check_symbol_exists( "be16toh" "endian.h" HAVE_DECL_BE16TOH ) - add_definitions( -DHAVE_DECL_BE16TOH=${HAVE_DECL_BE16TOH} ) + if (HAVE_DECL_BE16TOH) + add_definitions( -DHAVE_DECL_BE16TOH=1 ) + else() + add_definitions( -DHAVE_DECL_BE16TOH=0 ) + endif() endif() # On HAVE_ENDIAN_H, test for be32toh #------------------------------------------------------------------------------ if (HAVE_ENDIAN_H) check_symbol_exists( "be32toh" "endian.h" HAVE_DECL_BE32TOH ) - add_definitions( -DHAVE_DECL_BE32TOH=${HAVE_DECL_BE32TOH} ) + if (HAVE_DECL_BE32TOH) + add_definitions( -DHAVE_DECL_BE32TOH=1 ) + else() + add_definitions( -DHAVE_DECL_BE32TOH=0 ) + endif() endif() # On HAVE_ENDIAN_H, test for be64toh #------------------------------------------------------------------------------ if (HAVE_ENDIAN_H) check_symbol_exists( "be64toh" "endian.h" HAVE_DECL_BE64TOH ) - add_definitions( -DHAVE_DECL_BE64TOH=${HAVE_DECL_BE64TOH} ) + if (HAVE_DECL_BE64TOH) + add_definitions( -DHAVE_DECL_BE64TOH=1 ) + else() + add_definitions( -DHAVE_DECL_BE64TOH=0 ) + endif() endif() # On HAVE_ENDIAN_H, test for htobe16 #------------------------------------------------------------------------------ if (HAVE_ENDIAN_H) check_symbol_exists( "htobe16" "endian.h" HAVE_DECL_HTOBE16 ) - add_definitions( -DHAVE_DECL_HTOBE16=${HAVE_DECL_HTOBE16} ) + if (HAVE_DECL_HTOBE16) + add_definitions( -DHAVE_DECL_HTOBE16=1 ) + else() + add_definitions( -DHAVE_DECL_HTOBE16=0 ) + endif() endif() # On HAVE_ENDIAN_H, test for htobe32 #------------------------------------------------------------------------------ if (HAVE_ENDIAN_H) check_symbol_exists( "htobe32" "endian.h" HAVE_DECL_HTOBE32 ) - add_definitions( -DHAVE_DECL_HTOBE32=${HAVE_DECL_HTOBE32} ) + if (HAVE_DECL_HTOBE32) + add_definitions( -DHAVE_DECL_HTOBE32=1 ) + else() + add_definitions( -DHAVE_DECL_HTOBE32=0 ) + endif() endif() # On HAVE_ENDIAN_H, test for htobe64 #------------------------------------------------------------------------------ if (HAVE_ENDIAN_H) check_symbol_exists( "htobe64" "endian.h" HAVE_DECL_HTOBE64 ) - add_definitions( -DHAVE_DECL_HTOBE64=${HAVE_DECL_HTOBE64} ) + if (HAVE_DECL_HTOBE64) + add_definitions( -DHAVE_DECL_HTOBE64=1 ) + else() + add_definitions( -DHAVE_DECL_HTOBE64=0 ) + endif() endif() # On HAVE_SYS_ENDIAN_H, test for le16toh #------------------------------------------------------------------------------ if (HAVE_SYS_ENDIAN_H) check_symbol_exists( "le16toh" "sys/endian.h" HAVE_DECL_LE16TOH ) - add_definitions( -DHAVE_DECL_LE16TOH=${HAVE_DECL_LE16TOH} ) + if (HAVE_DECL_LE16TOH) + add_definitions( -DHAVE_DECL_LE16TOH=1 ) + else() + add_definitions( -DHAVE_DECL_LE16TOH=0 ) + endif() endif() # On HAVE_SYS_ENDIAN_H, test for le32toh #------------------------------------------------------------------------------ if (HAVE_SYS_ENDIAN_H) check_symbol_exists( "le32toh" "sys/endian.h" HAVE_DECL_LE32TOH ) - add_definitions( -DHAVE_DECL_LE32TOH=${HAVE_DECL_LE32TOH} ) + if (HAVE_DECL_LE32TOH) + add_definitions( -DHAVE_DECL_LE32TOH=1 ) + else() + add_definitions( -DHAVE_DECL_LE32TOH=0 ) + endif() endif() # On HAVE_SYS_ENDIAN_H, test for le64toh #------------------------------------------------------------------------------ if (HAVE_SYS_ENDIAN_H) check_symbol_exists( "le64toh" "sys/endian.h" HAVE_DECL_LE64TOH ) - add_definitions( -DHAVE_DECL_LE64TOH=${HAVE_DECL_LE64TOH} ) + if (HAVE_DECL_LE64TOH) + add_definitions( -DHAVE_DECL_LE64TOH=1 ) + else() + add_definitions( -DHAVE_DECL_LE64TOH=0 ) + endif() endif() # On HAVE_SYS_ENDIAN_H, test for htole16 #------------------------------------------------------------------------------ if (HAVE_SYS_ENDIAN_H) check_symbol_exists( "htole16" "sys/endian.h" HAVE_DECL_HTOLE16 ) - add_definitions( -DHAVE_DECL_HTOLE16=${HAVE_DECL_HTOLE16} ) + if (HAVE_DECL_HTOLE16) + add_definitions( -DHAVE_DECL_HTOLE16=1 ) + else() + add_definitions( -DHAVE_DECL_HTOLE16=0 ) + endif() endif() # On HAVE_SYS_ENDIAN_H, test for htole32 #------------------------------------------------------------------------------ if (HAVE_SYS_ENDIAN_H) check_symbol_exists( "htole32" "sys/endian.h" HAVE_DECL_HTOLE32 ) - add_definitions( -DHAVE_DECL_HTOLE32=${HAVE_DECL_HTOLE32} ) + if (HAVE_DECL_HTOLE32) + add_definitions( -DHAVE_DECL_HTOLE32=1 ) + else() + add_definitions( -DHAVE_DECL_HTOLE32=0 ) + endif() endif() # On HAVE_SYS_ENDIAN_H, test for htole64 #------------------------------------------------------------------------------ if (HAVE_SYS_ENDIAN_H) check_symbol_exists( "htole64" "sys/endian.h" HAVE_DECL_HTOLE64 ) - add_definitions( -DHAVE_DECL_HTOLE64=${HAVE_DECL_HTOLE64} ) + if (HAVE_DECL_HTOLE64) + add_definitions( -DHAVE_DECL_HTOLE64=1 ) + else() + add_definitions( -DHAVE_DECL_HTOLE64=0 ) + endif() endif() # On HAVE_SYS_ENDIAN_H, test for be16toh #------------------------------------------------------------------------------ if (HAVE_SYS_ENDIAN_H) check_symbol_exists( "be16toh" "sys/endian.h" HAVE_DECL_BE16TOH ) - add_definitions( -DHAVE_DECL_BE16TOH=${HAVE_DECL_BE16TOH} ) + if (HAVE_DECL_BE16TOH) + add_definitions( -DHAVE_DECL_BE16TOH=1 ) + else() + add_definitions( -DHAVE_DECL_BE16TOH=0 ) + endif() endif() # On HAVE_SYS_ENDIAN_H, test for be32toh #------------------------------------------------------------------------------ if (HAVE_SYS_ENDIAN_H) check_symbol_exists( "be32toh" "sys/endian.h" HAVE_DECL_BE32TOH ) - add_definitions( -DHAVE_DECL_BE32TOH=${HAVE_DECL_BE32TOH} ) + if (HAVE_DECL_BE32TOH) + add_definitions( -DHAVE_DECL_BE32TOH=1 ) + else() + add_definitions( -DHAVE_DECL_BE32TOH=0 ) + endif() endif() # On HAVE_SYS_ENDIAN_H, test for be64toh #------------------------------------------------------------------------------ if (HAVE_SYS_ENDIAN_H) check_symbol_exists( "be64toh" "sys/endian.h" HAVE_DECL_BE64TOH ) - add_definitions( -DHAVE_DECL_BE64TOH=${HAVE_DECL_BE64TOH} ) + if (HAVE_DECL_BE64TOH) + add_definitions( -DHAVE_DECL_BE64TOH=1 ) + else() + add_definitions( -DHAVE_DECL_BE64TOH=0 ) + endif() endif() # On HAVE_SYS_ENDIAN_H, test for htobe16 #------------------------------------------------------------------------------ if (HAVE_SYS_ENDIAN_H) check_symbol_exists( "htobe16" "sys/endian.h" HAVE_DECL_HTOBE16 ) - add_definitions( -DHAVE_DECL_HTOBE16=${HAVE_DECL_HTOBE16} ) + if (HAVE_DECL_HTOBE16) + add_definitions( -DHAVE_DECL_HTOBE16=1 ) + else() + add_definitions( -DHAVE_DECL_HTOBE16=0 ) + endif() endif() # On HAVE_SYS_ENDIAN_H, test for htobe32 #------------------------------------------------------------------------------ if (HAVE_SYS_ENDIAN_H) check_symbol_exists( "htobe32" "sys/endian.h" HAVE_DECL_HTOBE32 ) - add_definitions( -DHAVE_DECL_HTOBE32=${HAVE_DECL_HTOBE32} ) + if (HAVE_DECL_HTOBE32) + add_definitions( -DHAVE_DECL_HTOBE32=1 ) + else() + add_definitions( -DHAVE_DECL_HTOBE32=0 ) + endif() endif() # On HAVE_SYS_ENDIAN_H, test for htobe64 #------------------------------------------------------------------------------ if (HAVE_SYS_ENDIAN_H) check_symbol_exists( "htobe64" "sys/endian.h" HAVE_DECL_HTOBE64 ) - add_definitions( -DHAVE_DECL_HTOBE64=${HAVE_DECL_HTOBE64} ) + if (HAVE_DECL_HTOBE64) + add_definitions( -DHAVE_DECL_HTOBE64=1 ) + else() + add_definitions( -DHAVE_DECL_HTOBE64=0 ) + endif() +endif() + +if (BUILD_SHARED_LIBS) + set( Boost_USE_STATIC_LIBS "off" ) +else() + set( Boost_USE_STATIC_LIBS "on" ) endif() # Find boost #------------------------------------------------------------------------------ -find_package( Boost 1.72.0 REQUIRED COMPONENTS +find_package( Boost 1.76.0 REQUIRED COMPONENTS unit_test_framework ) set( boost_unit_test_framework_LIBS "-lboost_unit_test_framework" ) @@ -329,7 +437,7 @@ set( boost_LDFLAGS "-L${Boost_LIBRARY_DIR}" ) # Find secp256k1 #------------------------------------------------------------------------------ -find_package( Secp256K1 0.1.0.19 REQUIRED ) +find_package( Secp256K1 0.1.0.20 REQUIRED ) # Define project common includes directories #------------------------------------------------------------------------------ @@ -445,7 +553,9 @@ if (with-tests) "../../test/consensus__script_verify.cpp" "../../test/consensus__verify_flags_to_script_flags.cpp" "../../test/main.cpp" - "../../test/script.hpp" ) + "../../test/script.hpp" + "../../test/test.cpp" + "../../test/test.hpp" ) add_test( NAME libbitcoin-consensus-test COMMAND libbitcoin-consensus-test --run_test=* diff --git a/builds/msvc/.gitignore b/builds/msvc/.gitignore index 930593aa..d2758af7 100644 --- a/builds/msvc/.gitignore +++ b/builds/msvc/.gitignore @@ -1,3 +1,5 @@ +*.bin +*.json *.suo *.opensdf *.sdf diff --git a/builds/msvc/build/build_all.bat b/builds/msvc/build/build_all.bat index 0d864f43..2c7a821e 100644 --- a/builds/msvc/build/build_all.bat +++ b/builds/msvc/build/build_all.bat @@ -1,7 +1,9 @@ @ECHO OFF CALL nuget_all.bat ECHO. +CALL build_base.bat vs2022 libbitcoin-consensus "Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build" +CALL build_base.bat vs2019 libbitcoin-consensus "Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build" CALL build_base.bat vs2017 libbitcoin-consensus "Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build" -CALL build_base.bat vs2015 libbitcoin-consensus "Microsoft Visual Studio 14.0\VC" -CALL build_base.bat vs2013 libbitcoin-consensus "Microsoft Visual Studio 12.0\VC" +REM CALL build_base.bat vs2015 libbitcoin-consensus "Microsoft Visual Studio 14.0\VC" +REM CALL build_base.bat vs2013 libbitcoin-consensus "Microsoft Visual Studio 12.0\VC" PAUSE diff --git a/builds/msvc/build/build_base.bat b/builds/msvc/build/build_base.bat index b399466b..2ec0e456 100644 --- a/builds/msvc/build/build_base.bat +++ b/builds/msvc/build/build_base.bat @@ -21,7 +21,7 @@ CALL "%environment%" x86 > nul ECHO Platform=x86 ECHO Configuration=StaticDebug -msbuild /m /v:n /p:Configuration=StaticDebug /p:Platform=Win32 %solution% > %log% +msbuild /m /v:n /p:Configuration=StaticDebug /p:Platform=Win32 %solution% >> %log% IF errorlevel 1 GOTO error ECHO Configuration=StaticRelease msbuild /m /v:n /p:Configuration=StaticRelease /p:Platform=Win32 %solution% >> %log% diff --git a/builds/msvc/build/nuget_all.bat b/builds/msvc/build/nuget_all.bat index a4814ae3..bd9bbe6d 100644 --- a/builds/msvc/build/nuget_all.bat +++ b/builds/msvc/build/nuget_all.bat @@ -1,12 +1,12 @@ @ECHO OFF +ECHO Downloading libbitcoin vs2022 dependencies from NuGet +CALL nuget.exe install ..\vs2022\libbitcoin-consensus\packages.config +CALL nuget.exe install ..\vs2022\libbitcoin-consensus-test\packages.config +ECHO. +ECHO Downloading libbitcoin vs2019 dependencies from NuGet +CALL nuget.exe install ..\vs2019\libbitcoin-consensus\packages.config +CALL nuget.exe install ..\vs2019\libbitcoin-consensus-test\packages.config +ECHO. ECHO Downloading libbitcoin vs2017 dependencies from NuGet CALL nuget.exe install ..\vs2017\libbitcoin-consensus\packages.config CALL nuget.exe install ..\vs2017\libbitcoin-consensus-test\packages.config -ECHO. -ECHO Downloading libbitcoin vs2015 dependencies from NuGet -CALL nuget.exe install ..\vs2015\libbitcoin-consensus\packages.config -CALL nuget.exe install ..\vs2015\libbitcoin-consensus-test\packages.config -ECHO. -ECHO Downloading libbitcoin vs2013 dependencies from NuGet -CALL nuget.exe install ..\vs2013\libbitcoin-consensus\packages.config -CALL nuget.exe install ..\vs2013\libbitcoin-consensus-test\packages.config diff --git a/builds/msvc/debug.natvis b/builds/msvc/debug.natvis new file mode 100644 index 00000000..be483a7c --- /dev/null +++ b/builds/msvc/debug.natvis @@ -0,0 +1,20 @@ + + + + + + + { m_backend } + + + + + { m_data } + + + diff --git a/builds/msvc/properties/Common.props b/builds/msvc/properties/Common.props index 72588d6e..5e3d913e 100644 --- a/builds/msvc/properties/Common.props +++ b/builds/msvc/properties/Common.props @@ -12,10 +12,34 @@ - true + /Zc:__cplusplus %(AdditionalOptions) UNICODE;_UNICODE;%(PreprocessorDefinitions) - Level3 - + + + + Level4 + false + false + true + + + + true + true + false + false + stdc11 + stdcpp14 + stdcpp17 + stdcpp20 + false + true + true + + + + Level4 + \ No newline at end of file diff --git a/builds/msvc/properties/Messages.props b/builds/msvc/properties/Messages.props index 06a1ab09..034c6105 100644 --- a/builds/msvc/properties/Messages.props +++ b/builds/msvc/properties/Messages.props @@ -6,9 +6,11 @@ + + - + diff --git a/builds/msvc/vs2013/libbitcoin-consensus-test/libbitcoin-consensus-test.props b/builds/msvc/vs2013/libbitcoin-consensus-test/libbitcoin-consensus-test.props index 0d41ee60..087b1c10 100644 --- a/builds/msvc/vs2013/libbitcoin-consensus-test/libbitcoin-consensus-test.props +++ b/builds/msvc/vs2013/libbitcoin-consensus-test/libbitcoin-consensus-test.props @@ -20,12 +20,13 @@ - 4018;4244;4267;4715;4800;4996;%(DisableSpecificWarnings) + + 4018;4100;4244;4267;4715;4800;4996;%(DisableSpecificWarnings) BOOST_TEST_DYN_LINK;%(PreprocessorDefinitions) - "$(TargetPath)" --run_test=* --show_progress=no --result_code=no --detect_memory_leak=0 --report_level=no --build_info=yes + "$(TargetPath)" --run_test=* --show_progress=no --build_info=yes @@ -60,6 +61,3 @@ - - - diff --git a/builds/msvc/vs2013/libbitcoin-consensus-test/libbitcoin-consensus-test.vcxproj b/builds/msvc/vs2013/libbitcoin-consensus-test/libbitcoin-consensus-test.vcxproj index b88ae576..f0735a62 100644 --- a/builds/msvc/vs2013/libbitcoin-consensus-test/libbitcoin-consensus-test.vcxproj +++ b/builds/msvc/vs2013/libbitcoin-consensus-test/libbitcoin-consensus-test.vcxproj @@ -1,6 +1,6 @@ - 4018;4244;4267;4715;4800;4996;%(DisableSpecificWarnings) + + + + + + 4018;4244;4267;4715;4800;4996;4100;4701;4702;4456;4127;%(DisableSpecificWarnings) false BCK_DLL;%(PreprocessorDefinitions) BCK_STATIC;%(PreprocessorDefinitions) diff --git a/builds/msvc/vs2013/libbitcoin-consensus/libbitcoin-consensus.vcxproj b/builds/msvc/vs2013/libbitcoin-consensus/libbitcoin-consensus.vcxproj index 26fb004c..e05d5f04 100644 --- a/builds/msvc/vs2013/libbitcoin-consensus/libbitcoin-consensus.vcxproj +++ b/builds/msvc/vs2013/libbitcoin-consensus/libbitcoin-consensus.vcxproj @@ -1,6 +1,6 @@ - 4018;4244;4267;4715;4800;4996;%(DisableSpecificWarnings) + + 4018;4100;4244;4267;4715;4800;4996;%(DisableSpecificWarnings) BOOST_TEST_DYN_LINK;%(PreprocessorDefinitions) - "$(TargetPath)" --run_test=* --show_progress=no --result_code=no --detect_memory_leak=0 --report_level=no --build_info=yes + "$(TargetPath)" --run_test=* --show_progress=no --build_info=yes @@ -60,6 +61,3 @@ - - - diff --git a/builds/msvc/vs2015/libbitcoin-consensus-test/libbitcoin-consensus-test.vcxproj b/builds/msvc/vs2015/libbitcoin-consensus-test/libbitcoin-consensus-test.vcxproj index df6709c4..e7507bb5 100644 --- a/builds/msvc/vs2015/libbitcoin-consensus-test/libbitcoin-consensus-test.vcxproj +++ b/builds/msvc/vs2015/libbitcoin-consensus-test/libbitcoin-consensus-test.vcxproj @@ -1,6 +1,6 @@ - - - + + + diff --git a/builds/msvc/vs2015/libbitcoin-consensus/libbitcoin-consensus.props b/builds/msvc/vs2015/libbitcoin-consensus/libbitcoin-consensus.props index 5bbe6650..a5341ba9 100644 --- a/builds/msvc/vs2015/libbitcoin-consensus/libbitcoin-consensus.props +++ b/builds/msvc/vs2015/libbitcoin-consensus/libbitcoin-consensus.props @@ -19,7 +19,12 @@ - 4018;4244;4267;4715;4800;4996;%(DisableSpecificWarnings) + + + + + + 4018;4244;4267;4715;4800;4996;4100;4701;4702;4456;4127;%(DisableSpecificWarnings) false BCK_DLL;%(PreprocessorDefinitions) BCK_STATIC;%(PreprocessorDefinitions) diff --git a/builds/msvc/vs2015/libbitcoin-consensus/libbitcoin-consensus.vcxproj b/builds/msvc/vs2015/libbitcoin-consensus/libbitcoin-consensus.vcxproj index 72c13645..0b42184e 100644 --- a/builds/msvc/vs2015/libbitcoin-consensus/libbitcoin-consensus.vcxproj +++ b/builds/msvc/vs2015/libbitcoin-consensus/libbitcoin-consensus.vcxproj @@ -1,6 +1,6 @@ - + diff --git a/builds/msvc/vs2017/libbitcoin-consensus-test/packages.config b/builds/msvc/vs2017/libbitcoin-consensus-test/packages.config deleted file mode 100644 index 1ddea618..00000000 --- a/builds/msvc/vs2017/libbitcoin-consensus-test/packages.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - diff --git a/builds/msvc/vs2022/.vs/libbitcoin-consensus/FileContentIndex/.gitignore b/builds/msvc/vs2022/.vs/libbitcoin-consensus/FileContentIndex/.gitignore new file mode 100644 index 00000000..4f4fa42b --- /dev/null +++ b/builds/msvc/vs2022/.vs/libbitcoin-consensus/FileContentIndex/.gitignore @@ -0,0 +1,2 @@ +*.vsidx +*.lock diff --git a/builds/msvc/vs2017/libbitcoin-consensus-test/libbitcoin-consensus-test.props b/builds/msvc/vs2022/libbitcoin-consensus-test/libbitcoin-consensus-test.props similarity index 93% rename from builds/msvc/vs2017/libbitcoin-consensus-test/libbitcoin-consensus-test.props rename to builds/msvc/vs2022/libbitcoin-consensus-test/libbitcoin-consensus-test.props index 0d41ee60..087b1c10 100644 --- a/builds/msvc/vs2017/libbitcoin-consensus-test/libbitcoin-consensus-test.props +++ b/builds/msvc/vs2022/libbitcoin-consensus-test/libbitcoin-consensus-test.props @@ -20,12 +20,13 @@ - 4018;4244;4267;4715;4800;4996;%(DisableSpecificWarnings) + + 4018;4100;4244;4267;4715;4800;4996;%(DisableSpecificWarnings) BOOST_TEST_DYN_LINK;%(PreprocessorDefinitions) - "$(TargetPath)" --run_test=* --show_progress=no --result_code=no --detect_memory_leak=0 --report_level=no --build_info=yes + "$(TargetPath)" --run_test=* --show_progress=no --build_info=yes @@ -60,6 +61,3 @@ - - - diff --git a/builds/msvc/vs2017/libbitcoin-consensus-test/libbitcoin-consensus-test.vcxproj b/builds/msvc/vs2022/libbitcoin-consensus-test/libbitcoin-consensus-test.vcxproj similarity index 75% rename from builds/msvc/vs2017/libbitcoin-consensus-test/libbitcoin-consensus-test.vcxproj rename to builds/msvc/vs2022/libbitcoin-consensus-test/libbitcoin-consensus-test.vcxproj index 8d9f2b40..bdd36683 100644 --- a/builds/msvc/vs2017/libbitcoin-consensus-test/libbitcoin-consensus-test.vcxproj +++ b/builds/msvc/vs2022/libbitcoin-consensus-test/libbitcoin-consensus-test.vcxproj @@ -1,6 +1,6 @@ + + + + + diff --git a/builds/msvc/vs2017/libbitcoin-consensus.import.props b/builds/msvc/vs2022/libbitcoin-consensus.import.props similarity index 84% rename from builds/msvc/vs2017/libbitcoin-consensus.import.props rename to builds/msvc/vs2022/libbitcoin-consensus.import.props index ed197827..fceab9d7 100644 --- a/builds/msvc/vs2017/libbitcoin-consensus.import.props +++ b/builds/msvc/vs2022/libbitcoin-consensus.import.props @@ -16,15 +16,6 @@ $(ProjectDir)..\..\..\..\..\libbitcoin-consensus\include\;%(AdditionalIncludeDirectories) - - - - - - - - - _WIN32_WINNT=0x0600;%(PreprocessorDefinitions) BCK_STATIC;%(PreprocessorDefinitions) diff --git a/builds/msvc/vs2017/libbitcoin-consensus.import.xml b/builds/msvc/vs2022/libbitcoin-consensus.import.xml similarity index 100% rename from builds/msvc/vs2017/libbitcoin-consensus.import.xml rename to builds/msvc/vs2022/libbitcoin-consensus.import.xml diff --git a/builds/msvc/vs2017/libbitcoin-consensus.sln b/builds/msvc/vs2022/libbitcoin-consensus.sln similarity index 100% rename from builds/msvc/vs2017/libbitcoin-consensus.sln rename to builds/msvc/vs2022/libbitcoin-consensus.sln diff --git a/builds/msvc/vs2017/libbitcoin-consensus/libbitcoin-consensus.props b/builds/msvc/vs2022/libbitcoin-consensus/libbitcoin-consensus.props similarity index 84% rename from builds/msvc/vs2017/libbitcoin-consensus/libbitcoin-consensus.props rename to builds/msvc/vs2022/libbitcoin-consensus/libbitcoin-consensus.props index 5bbe6650..a5341ba9 100644 --- a/builds/msvc/vs2017/libbitcoin-consensus/libbitcoin-consensus.props +++ b/builds/msvc/vs2022/libbitcoin-consensus/libbitcoin-consensus.props @@ -19,7 +19,12 @@ - 4018;4244;4267;4715;4800;4996;%(DisableSpecificWarnings) + + + + + + 4018;4244;4267;4715;4800;4996;4100;4701;4702;4456;4127;%(DisableSpecificWarnings) false BCK_DLL;%(PreprocessorDefinitions) BCK_STATIC;%(PreprocessorDefinitions) diff --git a/builds/msvc/vs2017/libbitcoin-consensus/libbitcoin-consensus.vcxproj b/builds/msvc/vs2022/libbitcoin-consensus/libbitcoin-consensus.vcxproj similarity index 93% rename from builds/msvc/vs2017/libbitcoin-consensus/libbitcoin-consensus.vcxproj rename to builds/msvc/vs2022/libbitcoin-consensus/libbitcoin-consensus.vcxproj index 89409332..252289e8 100644 --- a/builds/msvc/vs2017/libbitcoin-consensus/libbitcoin-consensus.vcxproj +++ b/builds/msvc/vs2022/libbitcoin-consensus/libbitcoin-consensus.vcxproj @@ -1,13 +1,13 @@ - v141 + v143 {6C521D95-00CE-4120-97D1-430E2870D738} libbitcoin-consensus @@ -129,12 +129,15 @@ - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + + + + diff --git a/builds/msvc/vs2017/libbitcoin-consensus/libbitcoin-consensus.vcxproj.filters b/builds/msvc/vs2022/libbitcoin-consensus/libbitcoin-consensus.vcxproj.filters similarity index 98% rename from builds/msvc/vs2017/libbitcoin-consensus/libbitcoin-consensus.vcxproj.filters rename to builds/msvc/vs2022/libbitcoin-consensus/libbitcoin-consensus.vcxproj.filters index 17709f09..82257a3d 100644 --- a/builds/msvc/vs2017/libbitcoin-consensus/libbitcoin-consensus.vcxproj.filters +++ b/builds/msvc/vs2022/libbitcoin-consensus/libbitcoin-consensus.vcxproj.filters @@ -1,6 +1,6 @@ - + diff --git a/configure.ac b/configure.ac index ad7a7393..3b527175 100644 --- a/configure.ac +++ b/configure.ac @@ -69,9 +69,9 @@ AC_ARG_VAR([CC], "C compiler to use, such as gcc or clang") AC_ARG_VAR([CXX], "C++ compiler to use, such as g++ or clang++") AC_ARG_VAR([PKG_CONFIG_PATH], "Additional directories for package discovery.") -# Check for baseline language coverage in the compiler for the C++11 standard. +# Check for baseline language coverage in the compiler for the C++20 standard. #------------------------------------------------------------------------------ -AX_CXX_COMPILE_STDCXX_11([noext], [mandatory]) +AX_CXX_COMPILE_STDCXX([20], [noext], [mandatory]) # Process options. @@ -345,17 +345,17 @@ AC_CHECK_HEADERS([sys/endian.h], # Check dependencies. #============================================================================== -# Require Boost of at least version 1.72.0 and output ${boost_CPPFLAGS/LDFLAGS}. +# Require Boost of at least version 1.76.0 and output ${boost_CPPFLAGS/LDFLAGS}. #------------------------------------------------------------------------------ AS_CASE([${CC}], [*], - [AX_BOOST_BASE([1.72.0], + [AX_BOOST_BASE([1.76.0], [AC_SUBST([boost_CPPFLAGS], [${BOOST_CPPFLAGS}]) AC_SUBST([boost_ISYS_CPPFLAGS], [`echo ${BOOST_CPPFLAGS} | $SED s/^-I/-isystem/g | $SED s/' -I'/' -isystem'/g`]) AC_SUBST([boost_LDFLAGS], [${BOOST_LDFLAGS}]) AC_MSG_NOTICE([boost_CPPFLAGS : ${boost_CPPFLAGS}]) AC_MSG_NOTICE([boost_ISYS_CPPFLAGS : ${boost_ISYS_CPPFLAGS}]) AC_MSG_NOTICE([boost_LDFLAGS : ${boost_LDFLAGS}])], - [AC_MSG_ERROR([Boost 1.72.0 or later is required but was not found.])])]) + [AC_MSG_ERROR([Boost 1.76.0 or later is required but was not found.])])]) AS_CASE([${enable_isystem}],[yes], [AC_SUBST([boost_BUILD_CPPFLAGS], [${boost_ISYS_CPPFLAGS}])], @@ -369,13 +369,13 @@ AS_CASE([${with_tests}], [yes], AC_MSG_NOTICE([boost_unit_test_framework_LIBS : ${boost_unit_test_framework_LIBS}])], [AC_SUBST([boost_unit_test_framework_LIBS], [])]) -# Require secp256k1 of at least version 0.1.0.19 and output ${secp256k1_CPPFLAGS/LIBS/PKG}. +# Require secp256k1 of at least version 0.1.0.20 and output ${secp256k1_CPPFLAGS/LIBS/PKG}. #------------------------------------------------------------------------------ -PKG_CHECK_MODULES([secp256k1], [libsecp256k1 >= 0.1.0.19], - [secp256k1_INCLUDEDIR="`$PKG_CONFIG --variable=includedir "libsecp256k1 >= 0.1.0.19" 2>/dev/null`" - secp256k1_OTHER_CFLAGS="`$PKG_CONFIG --cflags-only-other "libsecp256k1 >= 0.1.0.19" 2>/dev/null`"], - [AC_MSG_ERROR([libsecp256k1 >= 0.1.0.19 is required but was not found.])]) -AC_SUBST([secp256k1_PKG], ['libsecp256k1 >= 0.1.0.19']) +PKG_CHECK_MODULES([secp256k1], [libsecp256k1 >= 0.1.0.20], + [secp256k1_INCLUDEDIR="`$PKG_CONFIG --variable=includedir "libsecp256k1 >= 0.1.0.20" 2>/dev/null`" + secp256k1_OTHER_CFLAGS="`$PKG_CONFIG --cflags-only-other "libsecp256k1 >= 0.1.0.20" 2>/dev/null`"], + [AC_MSG_ERROR([libsecp256k1 >= 0.1.0.20 is required but was not found.])]) +AC_SUBST([secp256k1_PKG], ['libsecp256k1 >= 0.1.0.20']) AC_SUBST([secp256k1_CPPFLAGS], [${secp256k1_CFLAGS}]) AS_IF([test x${secp256k1_INCLUDEDIR} != "x"], [AC_SUBST([secp256k1_ISYS_CPPFLAGS], ["-isystem${secp256k1_INCLUDEDIR} ${secp256k1_OTHER_CFLAGS}"])], @@ -395,11 +395,11 @@ AC_MSG_NOTICE([secp256k1_BUILD_CPPFLAGS : ${secp256k1_BUILD_CPPFLAGS}]) # Set flags. #============================================================================== -# Require c++11 for all c++ products. +# Require c++20 for all c++ products. #------------------------------------------------------------------------------ AS_CASE([${CC}], [*], - [AX_CHECK_COMPILE_FLAG([-std=c++11], - [CXXFLAGS="$CXXFLAGS -std=c++11"])]) + [AX_CHECK_COMPILE_FLAG([-std=c++20], + [CXXFLAGS="$CXXFLAGS -std=c++20"])]) # Warn on all stuff. #------------------------------------------------------------------------------ @@ -425,22 +425,6 @@ AS_CASE([${CC}], [*], [AX_CHECK_COMPILE_FLAG([-Wextra], [CXXFLAGS="$CXXFLAGS -Wextra"])]) -# Be really annoying. -#------------------------------------------------------------------------------ -AS_CASE([${CC}], [*], - [AX_CHECK_COMPILE_FLAG([-Wpedantic], - [CFLAGS="$CFLAGS -Wpedantic"], - [AX_CHECK_COMPILE_FLAG([-pedantic], - [CFLAGS="$CFLAGS -pedantic"])])]) - -# Be really annoying. -#------------------------------------------------------------------------------ -AS_CASE([${CC}], [*], - [AX_CHECK_COMPILE_FLAG([-Wpedantic], - [CXXFLAGS="$CXXFLAGS -Wpedantic"], - [AX_CHECK_COMPILE_FLAG([-pedantic], - [CXXFLAGS="$CXXFLAGS -pedantic"])])]) - # Disallow warning on style order of declarations. #------------------------------------------------------------------------------ AS_CASE([${CC}], [*], @@ -465,6 +449,12 @@ AS_CASE([${CC}], [*], [AX_CHECK_COMPILE_FLAG([-Wno-comment], [CXXFLAGS="$CXXFLAGS -Wno-comment"])]) +# Suppress warning for copy of implicitly generated copy constructor. +#------------------------------------------------------------------------------ +AS_CASE([${CC}], [*], + [AX_CHECK_COMPILE_FLAG([-Wno-deprecated-copy], + [CXXFLAGS="$CXXFLAGS -Wno-deprecated-copy"])]) + # Conflict in stdlib under clang. Enabled in clang only. #------------------------------------------------------------------------------ AS_CASE([${CC}], [*clang*], diff --git a/include/bitcoin/consensus.hpp b/include/bitcoin/consensus.hpp index 8c8822d1..d2646855 100644 --- a/include/bitcoin/consensus.hpp +++ b/include/bitcoin/consensus.hpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2014-2020 libbitcoin-consensus developers (see COPYING). +// Copyright (c) 2014-2021 libbitcoin-consensus developers (see COPYING). // // GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY // diff --git a/include/bitcoin/consensus/export.hpp b/include/bitcoin/consensus/export.hpp index 7d53513b..bd3bf281 100644 --- a/include/bitcoin/consensus/export.hpp +++ b/include/bitcoin/consensus/export.hpp @@ -20,6 +20,8 @@ #define LIBBITCOIN_CONSENSUS_EXPORT_HPP #include +#include +#include #include #include @@ -29,7 +31,7 @@ namespace consensus { /** * Result values from calling verify_script. */ -typedef enum verify_result_type +typedef enum verify_result { // Logical result verify_result_eval_false = 0, @@ -93,13 +95,17 @@ typedef enum verify_result_type // BIP65/BIP112 (shared codes) verify_result_negative_locktime, - verify_result_unsatisfied_locktime + verify_result_unsatisfied_locktime, + + // Deserialization errors + verify_value_overflow, + verify_evaluation_throws } verify_result; /** * Flags to use when calling verify_script. */ -typedef enum verify_flags_type +typedef enum : uint32_t { /** * Set no flags. @@ -209,26 +215,62 @@ typedef enum verify_flags_type /** * SCRIPT_VERIFY_WITNESS_PUBKEYTYPE (bip141/bip143 p2wsh/p2wpkh policy). */ - verify_flags_witness_public_key_compressed = (1U << 15) + verify_flags_witness_public_key_compressed = (1U << 15), + + /** + * Set all flags. + */ + verify_flags_all = 0x7fff } verify_flags; +typedef std::vector chunk; +typedef std::vector stack; +typedef struct output +{ + chunk script; + uint64_t value; +} output; +typedef std::vector outputs; + +// TODO: this is ready for test. +#ifdef UNTESTED +/** + * Verify that all transaction inputs correctly spend the corresponding + * previous outputs, considering any additional constraints specified by flags. + * This avoids repeated deserialization of the transaction for each input. + * @param[in] transaction The transaction with the input scripts to verify. + * @param[in] prevouts The public key scripts to verify against (in order). + * @param[in] flags Verification constraint flags. + * @returns A script verification result code. + */ +BCK_API verify_result verify_script(const chunk& transaction, + const outputs& prevouts, uint32_t flags) noexcept; +#endif + /** * Verify that the transaction input correctly spends the previous output, * considering any additional constraints specified by flags. - * @param[in] transaction The transaction with the script to verify. - * @param[in] transaction_size The byte length of the transaction. - * @param[in] prevout_script The script public key to verify against. - * @param[in] prevout_script_size The byte length of the script public key. - * @param[in] prevout_value The value of the output being spent. - * @param[in] tx_input_index The zero-based index of the transaction - * input with signature to be verified. - * @param[in] flags Verification constraint flags. - * @returns A script verification result code. + * @param[in] transaction The transaction with the input script to verify. + * @param[in] prevout The public key script to verify against. + * @param[in] input_index The zero-based index of the transaction input. + * @param[in] flags Verification constraint flags. + * @returns A script verification result code. + */ + BCK_API verify_result verify_script(const chunk& transaction, + const output& prevout, uint32_t input_index, uint32_t flags) noexcept; + + /** + * Verify that the unsigned input correctly spends the previous output, + * considering any additional constraints specified by flags. This is useful + * for evaluating script execution without a transaction (checksig excluded). + * @param[in] prevout The public key script to verify against. + * @param[in] input_script The (unsigned) script sig to verify. + * @param[in] witness The input's witness stack to verify (or empty). + * @param[in] flags Verification constraint flags. + * @returns A script verification result code. */ - BCK_API verify_result_type verify_script(const unsigned char* transaction, - size_t transaction_size, const unsigned char* prevout_script, - size_t prevout_script_size, unsigned long long prevout_value, - unsigned int tx_input_index, unsigned int flags); + BCK_API verify_result verify_unsigned_script(const output& prevout, + const chunk& input_script, const stack& witness, uint32_t flags) noexcept; } // namespace consensus } // namespace libbitcoin diff --git a/include/bitcoin/consensus/version.hpp b/include/bitcoin/consensus/version.hpp index 1a147a27..51c70185 100644 --- a/include/bitcoin/consensus/version.hpp +++ b/include/bitcoin/consensus/version.hpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2014-2020 libbitcoin-consensus developers (see COPYING). +// Copyright (c) 2014-2021 libbitcoin-consensus developers (see COPYING). // // GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY // diff --git a/install-cmake.sh b/install-cmake.sh new file mode 100755 index 00000000..a807f9be --- /dev/null +++ b/install-cmake.sh @@ -0,0 +1,919 @@ +#!/bin/bash +############################################################################### +# Copyright (c) 2014-2020 libbitcoin-consensus developers (see COPYING). +# +# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY +# +############################################################################### +# Script to build and install libbitcoin-consensus. +# +# Script options: +# --build-boost Builds Boost libraries. +# --build-dir= Location of downloaded and intermediate files. +# --prefix= Library install location (defaults to /usr/local). +# --disable-shared Disables shared library builds. +# --disable-static Disables static library builds. +# --verbose Display verbose output (defaults to quiet on called tooling). +# --help Display usage, overriding script execution. +# +# Verified on Ubuntu 14.04, requires gcc-4.8 or newer. +# Verified on OSX 10.10, using MacPorts and Homebrew repositories, requires +# Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn) or newer. +# This script does not like spaces in the --prefix or --build-dir, sorry. +# Values (e.g. yes|no) in the '--disable-' options are not supported. +# All command line options are passed to 'configure' of each repo, with +# the exception of the --build- options, which are for the script only. +# Depending on the caller's permission to the --prefix or --build-dir +# directory, the script may need to be sudo'd. + +# Define constants. +#============================================================================== +# Sentinel for comparison of sequential build. +#------------------------------------------------------------------------------ +SEQUENTIAL=1 + +# Git clone parameters. +#------------------------------------------------------------------------------ +if [[ $GIT_CLONE_PARAMS ]]; then + display_message "Using shell-defined GIT_CLONE_PARAMS value." +else + GIT_CLONE_PARAMS="" +fi + +# The default build directory. +#------------------------------------------------------------------------------ +BUILD_DIR="build-libbitcoin-consensus" + +# Git clone parameters. +#------------------------------------------------------------------------------ +GIT_CLONE_PARAMS="--depth 1 --single-branch" + +PRESUMED_CI_PROJECT_PATH=$(pwd) + +# Boost archive. +#------------------------------------------------------------------------------ +BOOST_URL="http://downloads.sourceforge.net/project/boost/boost/1.78.0/boost_1_78_0.tar.bz2" +BOOST_ARCHIVE="boost_1_78_0.tar.bz2" + + +# Define utility functions. +#============================================================================== +configure_links() +{ + # Configure dynamic linker run-time bindings when installing to system. + if [[ ($OS == Linux) && ($PREFIX == "/usr/local") ]]; then + ldconfig + fi +} + +configure_options() +{ + display_message "configure options:" + for OPTION in "$@"; do + if [[ $OPTION ]]; then + display_message "$OPTION" + fi + done + + ./configure "$@" +} + +create_directory() +{ + local DIRECTORY="$1" + + rm -rf "$DIRECTORY" + mkdir "$DIRECTORY" +} + +display_heading_message() +{ + printf "\n********************** %s **********************\n" "$@" +} + +display_message() +{ + printf "%s\n" "$@" +} + +display_error() +{ + >&2 printf "%s\n" "$@" +} + +initialize_git() +{ + display_heading_message "Initialize git" + + # Initialize git repository at the root of the current directory. + git init + git config user.name anonymous +} + +# make_project_directory project_name jobs [configure_options] +make_project_directory() +{ + local PROJ_NAME=$1 + local JOBS=$2 + local TEST=$3 + shift 3 + + push_directory "$PROJ_NAME" + local PROJ_CONFIG_DIR + PROJ_CONFIG_DIR=$(pwd) + + ./autogen.sh + + configure_options "$@" + make_jobs "$JOBS" + + if [[ $TEST == true ]]; then + make_tests "$JOBS" + fi + + make install + configure_links + pop_directory +} + +# make_jobs jobs [make_options] +make_jobs() +{ + local JOBS=$1 + shift 1 + + VERBOSITY="" + if [[ DISPLAY_VERBOSE ]]; then + VERBOSITY="VERBOSE=1" + fi + + SEQUENTIAL=1 + # Avoid setting -j1 (causes problems on single threaded systems [TRAVIS]). + if [[ $JOBS > $SEQUENTIAL ]]; then + make -j"$JOBS" "$@" $VERBOSITY + else + make "$@" $VERBOSITY + fi +} + +# make_tests jobs +make_tests() +{ + local JOBS=$1 + + disable_exit_on_error + + # Build and run unit tests relative to the primary directory. + # VERBOSE=1 ensures test runner output sent to console (gcc). + make_jobs "$JOBS" check "VERBOSE=1" + local RESULT=$? + + # Test runners emit to the test.log file. + if [[ -e "test.log" ]]; then + cat "test.log" + fi + + if [[ $RESULT -ne 0 ]]; then + exit $RESULT + fi + + enable_exit_on_error +} + +pop_directory() +{ + popd >/dev/null +} + +push_directory() +{ + local DIRECTORY="$1" + + pushd "$DIRECTORY" >/dev/null +} + +enable_exit_on_error() +{ + set -e +} + +disable_exit_on_error() +{ + set +e +} + +display_help() +{ + display_message "Usage: ./install.sh [OPTION]..." + display_message "Manage the installation of libbitcoin-consensus." + display_message "Script options:" + display_message " --build-boost Builds Boost libraries." + display_message " --build-dir= Location of downloaded and intermediate files." + display_message " --prefix= Library install location (defaults to /usr/local)." + display_message " --disable-shared Disables shared library builds." + display_message " --disable-static Disables static library builds." + display_message " --help Display usage, overriding script execution." + display_message "" + display_message "All unrecognized options provided shall be passed as configuration options for " + display_message "all dependencies." +} + +# Define environment initialization functions +#============================================================================== +parse_command_line_options() +{ + for OPTION in "$@"; do + case $OPTION in + # Standard script options. + (--help) DISPLAY_HELP="yes";; + (--verbose) DISPLAY_VERBOSE="yes";; + + # Standard build options. + (--prefix=*) PREFIX="${OPTION#*=}";; + (--disable-shared) DISABLE_SHARED="yes";; + (--disable-static) DISABLE_STATIC="yes";; + + # Common project options. + + # Custom build options (in the form of --build-