Skip to content

Commit 875511c

Browse files
committed
Merge #79: Vendor 0.21.2
12d7ec3 Fix Bitcoin Core 0.21.2 upgrade (Tobin C. Harding) a4f30ef Vendor Bitcoin Core v0.21.2 (Tobin C. Harding) 8b3d23f Update README about vendoring (Tobin C. Harding) 3ca86b9 Remove the depend directory (Tobin C. Harding) 619611e Add Bitcoin Core vendor script (Tobin C. Harding) Pull request description: This is #77 without the version bump patch. Upgrade to a new way of vendoring Core and vendor version 0.21.2 - note please this will be directly followed by an upgrade to 0.21-final. Done separately to proof out the workflow of such an upgrade. ACKs for top commit: apoelstra: ACK 12d7ec3 Tree-SHA512: f708b4bda1a209afe7552ec0e691ed104847d4a4a5fae6cd13f2da8f3a205c0a652ced8883900b9ce312cb8f4f39f77f0abbdf3372016c5af7aeddc3e33984ba
2 parents f6a4db5 + 12d7ec3 commit 875511c

File tree

1,180 files changed

+91997
-36442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,180 files changed

+91997
-36442
lines changed

README.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,10 @@ For example, if we upgrade the Bitcoin Core code by a `Patch` version we also bu
2626
One side effect of this is that `crates.io` shows our release versions in yellow as if they were pre-release versions, this is due to us using a `-` which, in semantic versioning, implies a pre-release version.
2727

2828

29-
## Bitcoin Core subtree
29+
## Vendor Bitcoin Core
3030

31-
We use a git subtree to vendor the Bitcoin Core code. This can be seen from the following commits that were created using `git subtree add --prefix='depend/bitcoin' git@github.com:bitcoin/bitcoin.git v0.19.2 --squash`.
32-
```
33-
f751613e62 Squashed 'depend/bitcoin/' content from commit 204cc0f575
34-
264282188a Merge commit 'f751613e6203770fa94143b9aba1d116512f0ce7' as 'depend/bitcoin'
35-
```
36-
37-
To use a later version of Bitcoin Core, for example, v0.20.2
38-
```
39-
git subtree pull --prefix='depend/bitcoin' git@github.com:bitcoin/bitcoin.git v0.20.2 --squash
40-
```
31+
We use a script to vendor the Bitcoin Core code, the script takes the
32+
Bitcoin Core version number to vendor: `./vendor-bitcoin-core.sh 0.21.1`
4133

4234

4335
## MSRV

build.rs

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,22 @@ fn main() {
2121
let is_big_endian = env::var("CARGO_CFG_TARGET_ENDIAN").expect("No endian is set") == "big";
2222
let mut base_config = cc::Build::new();
2323
base_config
24-
.cpp(true)
25-
.include("depend/bitcoin/src")
2624
.include("depend/bitcoin/src/secp256k1/include")
2725
.define("__STDC_FORMAT_MACROS", None)
2826
.flag_if_supported("-Wno-implicit-fallthrough");
2927

28+
if target.contains("windows") {
29+
base_config.define("WIN32", "1");
30+
}
31+
32+
let mut secp_config = base_config.clone();
33+
let mut consensus_config = base_config;
34+
3035
// **Secp256k1**
3136
if !cfg!(feature = "external-secp") {
32-
base_config
37+
secp_config
3338
.include("depend/bitcoin/src/secp256k1")
39+
.include("depend/bitcoin/src/secp256k1/src")
3440
.flag_if_supported("-Wno-unused-function") // some ecmult stuff is defined but not used upstream
3541
.define("SECP256K1_BUILD", "1")
3642
// Bitcoin core defines libsecp to *not* use libgmp.
@@ -39,34 +45,40 @@ fn main() {
3945
.define("USE_SCALAR_INV_BUILTIN", "1")
4046
// Technically libconsensus doesn't require the recovery feautre, but `pubkey.cpp` does.
4147
.define("ENABLE_MODULE_RECOVERY", "1")
48+
.define("ECMULT_WINDOW_SIZE", "15")
49+
.define("ECMULT_GEN_PREC_BITS", "4")
50+
.define("ENABLE_MODULE_SCHNORRSIG", "1")
51+
.define("ENABLE_MODULE_EXTRAKEYS", "1")
4252
// The actual libsecp256k1 C code.
4353
.file("depend/bitcoin/src/secp256k1/src/secp256k1.c");
4454

4555
if is_big_endian {
46-
base_config.define("WORDS_BIGENDIAN", "1");
56+
secp_config.define("WORDS_BIGENDIAN", "1");
4757
}
4858

4959
if use_64bit_compilation {
50-
base_config
60+
secp_config
5161
.define("USE_FIELD_5X52", "1")
5262
.define("USE_SCALAR_4X64", "1")
5363
.define("HAVE___INT128", "1");
5464
} else {
55-
base_config.define("USE_FIELD_10X26", "1").define("USE_SCALAR_8X32", "1");
65+
secp_config.define("USE_FIELD_10X26", "1").define("USE_SCALAR_8X32", "1");
5666
}
67+
68+
secp_config.compile("libsecp256k1.a");
5769
}
5870

59-
let tool = base_config.get_compiler();
71+
let tool = consensus_config.get_compiler();
6072
if tool.is_like_msvc() {
61-
base_config.flag("/std:c++14").flag("/wd4100");
73+
consensus_config.flag("/std:c++17").flag("/wd4100");
6274
} else if tool.is_like_clang() || tool.is_like_gnu() {
63-
base_config.flag("-std=c++11").flag("-Wno-unused-parameter");
75+
consensus_config.flag("-std=c++17").flag("-Wno-unused-parameter");
6476
}
6577

66-
if target.contains("windows") {
67-
base_config.define("WIN32", "1");
68-
}
69-
base_config
78+
consensus_config
79+
.cpp(true)
80+
.include("depend/bitcoin/src")
81+
.include("depend/bitcoin/src/secp256k1/include")
7082
.file("depend/bitcoin/src/util/strencodings.cpp")
7183
.file("depend/bitcoin/src/uint256.cpp")
7284
.file("depend/bitcoin/src/pubkey.cpp")

contrib/vendor-bitcoin-core.sh

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
function usage() {
5+
echo
6+
echo "Usage: script OPTIONS [bitcoin-core-version]"
7+
echo
8+
echo "OPTIONS:"
9+
echo
10+
echo " -f Vendor even if there are local changes to the rust-bitcoinconsensus git index"
11+
echo " -h Print this help an exit"
12+
echo
13+
echo "Example:"
14+
echo
15+
echo " vendor-bitcoin-core v0.21.2"
16+
echo
17+
18+
exit 0
19+
}
20+
21+
if (($# < 1)) || [ "$1" == '-h' ]; then
22+
usage
23+
fi
24+
25+
# Set default variables
26+
27+
if [ -z "$CORE_VENDOR_GIT_ROOT" ]; then
28+
CORE_VENDOR_GIT_ROOT="$(git rev-parse --show-toplevel)"
29+
else
30+
CORE_VENDOR_GIT_ROOT="$(realpath "$CORE_VENDOR_GIT_ROOT")"
31+
fi
32+
33+
DEFAULT_DEPEND_DIR="depend"
34+
DEFAULT_CORE_REPO=https://github.com/bitcoin/bitcoin.git
35+
36+
: "${CORE_VENDOR_DEPEND_DIR:=$DEFAULT_DEPEND_DIR}"
37+
: "${CORE_VENDOR_REPO:=$DEFAULT_CORE_REPO}"
38+
39+
# CP_NOT_CLONE lets us just copy a directory rather than git cloning.
40+
# This is usually a bad idea, since it will bring in build artifacts or any other
41+
# junk from the source directory, but may be useful during development or CI.
42+
: "${CORE_VENDOR_CP_NOT_CLONE:=no}"
43+
44+
echo "Using depend directory $CORE_VENDOR_DEPEND_DIR. Set CORE_VENDOR_DEPEND_DIR to override."
45+
echo "Using bitcoin repository $CORE_VENDOR_REPO. Set CORE_VENDOR_REPO to override."
46+
47+
# Parse command-line options
48+
CORE_REV=""
49+
FORCE=no
50+
while (( "$#" )); do
51+
case "$1" in
52+
-h)
53+
echo ""
54+
usage
55+
;;
56+
-f)
57+
FORCE=yes
58+
;;
59+
*)
60+
if [ -z "$CORE_REV" ]; then
61+
CORE_REV="$1"
62+
else
63+
echo "WARNING: ignoring unknown command-line argument $1"
64+
fi
65+
;;
66+
esac
67+
shift
68+
done
69+
70+
echo
71+
if [ "$CORE_REV" ]; then
72+
echo "Vendoring Bitcoin Core version: $CORE_REV"
73+
else
74+
echo "WARNING: No Bitcoin Core revision specified. Will use whatever we find at the git repo."
75+
fi
76+
echo
77+
78+
# Check if we will do anything destructive.
79+
80+
if [ "$FORCE" == "no" ]; then
81+
if ! git diff --quiet -- "*.rs"; then
82+
echo "ERROR: There appear to be modified source files. Check these in or pass -f (some source files will be modified to have symbols renamed)."
83+
exit 2
84+
fi
85+
if ! git diff --quiet -- "$CORE_VENDOR_DEPEND_DIR"; then
86+
echo "ERROR: The depend directory appears to be modified. Check it in or pass -f (this directory will be deleted)."
87+
exit 2
88+
fi
89+
fi
90+
91+
DIR=./bitcoin
92+
93+
pushd "$CORE_VENDOR_DEPEND_DIR" > /dev/null
94+
rm -rf "$DIR" || true
95+
96+
# Clone the repo. As a special case, if the repo is a local path and we have
97+
# not specified a revision, just copy the directory rather than using 'git clone'.
98+
# This lets us use non-git repos or dirty source trees as secp sources.
99+
if [ "$CORE_VENDOR_CP_NOT_CLONE" == "yes" ]; then
100+
cp -r "$CORE_VENDOR_REPO" "$DIR"
101+
chmod -R +w "$DIR" # cp preserves write perms, which if missing will cause patch to fail
102+
else
103+
git clone "$CORE_VENDOR_REPO" "$DIR"
104+
fi
105+
106+
# Check out specified revision
107+
pushd "$DIR" > /dev/null
108+
if [ -n "$CORE_REV" ]; then
109+
git checkout "$CORE_REV"
110+
fi
111+
SOURCE_REV=$(git rev-parse HEAD || echo "[unknown revision from $CORE_VENDOR_REPO]")
112+
rm -rf .git/ || true
113+
popd
114+
115+
# Record revision
116+
echo "# This file was automatically created by $(basename "$0")" > ./bitcoin-HEAD-revision.txt
117+
echo "$SOURCE_REV" >> ./bitcoin-HEAD-revision.txt
118+
119+
popd > /dev/null

depend/bitcoin-HEAD-revision.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This file was automatically created by vendor-bitcoin-core.sh
2+
af591f2068d0363c92d9756ca39c43db85e5804c

depend/bitcoin/.appveyor.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,24 @@ clone_depth: 5
77
environment:
88
PATH: 'C:\Python37-x64;C:\Python37-x64\Scripts;%PATH%'
99
PYTHONUTF8: 1
10-
QT_DOWNLOAD_URL: 'https://github.com/sipsorcery/qt_win_binary/releases/download/v1.6/Qt5.9.8_x64_static_vs2019.zip'
11-
QT_DOWNLOAD_HASH: '9a8c6eb20967873785057fdcd329a657c7f922b0af08c5fde105cc597dd37e21'
10+
QT_DOWNLOAD_URL: 'https://github.com/sipsorcery/qt_win_binary/releases/download/qt598x64_vs2019_v1681/qt598_x64_vs2019_1681.zip'
11+
QT_DOWNLOAD_HASH: '00cf7327818c07d74e0b1a4464ffe987c2728b00d49d4bf333065892af0515c3'
1212
QT_LOCAL_PATH: 'C:\Qt5.9.8_x64_static_vs2019'
13-
VCPKG_INSTALL_PATH: 'C:\tools\vcpkg\installed'
14-
VCPKG_COMMIT_ID: 'f3f329a048eaff759c1992c458f2e12351486bc7'
13+
VCPKG_TAG: '75522bb1f2e7d863078bcd06322348f053a9e33f'
1514
install:
1615
# Disable zmq test for now since python zmq library on Windows would cause Access violation sometimes.
1716
# - cmd: pip install zmq
18-
# Powershell block below is to install the c++ dependencies via vcpkg. The pseudo code is:
17+
# The powershell block below is to set up vcpkg to install the c++ dependencies. The pseudo code is:
1918
# a. Checkout the vcpkg source (including port files) for the specific checkout and build the vcpkg binary,
20-
# b. Install the missing packages.
19+
# b. Append a setting to the vcpkg cmake config file to only do release builds of dependencies (skipping deubg builds saves ~5 mins).
20+
# Note originally this block also installed the dependencies using 'vcpkg install'. Dependencies are now installed
21+
# as part of the msbuild command using vcpkg mainfests.
2122
- ps: |
22-
$env:PACKAGES = Get-Content -Path build_msvc\vcpkg-packages.txt
23-
Write-Host "vcpkg installing packages: $env:PACKAGES"
2423
cd c:\tools\vcpkg
2524
$env:GIT_REDIRECT_STDERR = '2>&1' # git is writing non-errors to STDERR when doing git pull. Send to STDOUT instead.
26-
git pull origin master > $null
27-
git -c advice.detachedHead=false checkout $env:VCPKG_COMMIT_ID
25+
git -c advice.detachedHead=false checkout $env:VCPKG_TAG
2826
.\bootstrap-vcpkg.bat > $null
2927
Add-Content "C:\tools\vcpkg\triplets\$env:PLATFORM-windows-static.cmake" "set(VCPKG_BUILD_TYPE release)"
30-
.\vcpkg install --triplet $env:PLATFORM-windows-static $env:PACKAGES.split() > $null
31-
Write-Host "vcpkg packages installed successfully."
32-
.\vcpkg integrate install
3328
cd "$env:APPVEYOR_BUILD_FOLDER"
3429
before_build:
3530
# Powershell block below is to download and extract the Qt static libraries. The pseudo code is:
@@ -55,11 +50,14 @@ after_build:
5550
#- 7z a bitcoin-%APPVEYOR_BUILD_VERSION%.zip %APPVEYOR_BUILD_FOLDER%\build_msvc\%platform%\%configuration%\*.exe
5651
test_script:
5752
- cmd: src\test_bitcoin.exe -l test_suite
58-
- cmd: src\bench_bitcoin.exe -evals=1 -scaling=0 > NUL
53+
- cmd: src\bench_bitcoin.exe > NUL
5954
- ps: python test\util\bitcoin-util-test.py
6055
- cmd: python test\util\rpcauth-test.py
6156
# Fee estimation test failing on appveyor with: WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted.
62-
- cmd: python test\functional\test_runner.py --ci --quiet --combinedlogslen=4000 --failfast --exclude feature_fee_estimation
57+
# functional tests disabled for now. See
58+
# https://github.com/bitcoin/bitcoin/pull/18626#issuecomment-613396202
59+
# https://github.com/bitcoin/bitcoin/issues/18623
60+
# - cmd: python test\functional\test_runner.py --ci --quiet --combinedlogslen=4000 --failfast --exclude feature_fee_estimation
6361
artifacts:
6462
#- path: bitcoin-%APPVEYOR_BUILD_VERSION%.zip
6563
deploy: off

0 commit comments

Comments
 (0)