@@ -10,26 +10,39 @@ set -eEuo pipefail
1010
1111REPO_ROOT=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) /../.." && pwd) "
1212readonly REPO_ROOT
13- readonly BITCOIN_CORE_VERSION =" ${BITCOIN_CORE_VERSION :- 31.0rc1 } "
14- readonly BITCOIN_CORE_PLATFORM =" ${BITCOIN_CORE_PLATFORM :- x86_64-linux-gnu } "
13+ readonly BITCOIN_CORE_REPO =" ${BITCOIN_CORE_REPO :- https :// github.com / bitcoin / bitcoin.git } "
14+ readonly BITCOIN_CORE_REF =" ${BITCOIN_CORE_REF :- } "
1515readonly SV2_APPS_REPO=" ${SV2_APPS_REPO:- https:// github.com/ stratum-mining/ sv2-apps.git} "
1616readonly SV2_APPS_REF=" ${SV2_APPS_REF:- main} "
1717readonly SCENARIO_ROOT=" ${SCENARIO_ROOT:- ${REPO_ROOT} / sri-integration-test} "
1818readonly MODE=" ${1:- all} "
1919
20- if [[ " ${BITCOIN_CORE_VERSION} " == * rc* ]]; then
21- bitcoin_core_series=" ${BITCOIN_CORE_VERSION%% rc* } "
22- bitcoin_core_rc=" ${BITCOIN_CORE_VERSION##* rc} "
23- bitcoin_core_url_default=" https://bitcoincore.org/bin/bitcoin-core-${bitcoin_core_series} /test.rc${bitcoin_core_rc} "
20+ if [[ -z " ${BITCOIN_CORE_REF} " ]]; then
21+ : " ${BITCOIN_CORE_VERSION:? BITCOIN_CORE_VERSION must be set when BITCOIN_CORE_REF is empty} "
22+ : " ${BITCOIN_CORE_PLATFORM:? BITCOIN_CORE_PLATFORM must be set when BITCOIN_CORE_REF is empty} "
23+ readonly BITCOIN_CORE_VERSION
24+ readonly BITCOIN_CORE_PLATFORM
25+
26+ if [[ " ${BITCOIN_CORE_VERSION} " == * rc* ]]; then
27+ bitcoin_core_series=" ${BITCOIN_CORE_VERSION%% rc* } "
28+ bitcoin_core_rc=" ${BITCOIN_CORE_VERSION##* rc} "
29+ bitcoin_core_url_default=" https://bitcoincore.org/bin/bitcoin-core-${bitcoin_core_series} /test.rc${bitcoin_core_rc} "
30+ else
31+ bitcoin_core_url_default=" https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_CORE_VERSION} "
32+ fi
33+
34+ readonly BITCOIN_CORE_URL=" ${BITCOIN_CORE_URL:- ${bitcoin_core_url_default} } "
35+ readonly BITCOIN_CORE_TARBALL=" ${BITCOIN_CORE_TARBALL:- bitcoin-${BITCOIN_CORE_VERSION} -${BITCOIN_CORE_PLATFORM} .tar.gz} "
36+ readonly BITCOIN_CORE_DIR=" ${BITCOIN_CORE_DIR:- bitcoin-${BITCOIN_CORE_VERSION} } "
2437else
25- bitcoin_core_url_default=" https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_CORE_VERSION} "
38+ readonly BITCOIN_CORE_URL=" ${BITCOIN_CORE_URL:- } "
39+ readonly BITCOIN_CORE_TARBALL=" ${BITCOIN_CORE_TARBALL:- } "
40+ readonly BITCOIN_CORE_DIR=" ${BITCOIN_CORE_DIR:- } "
2641fi
2742
28- readonly BITCOIN_CORE_URL=" ${BITCOIN_CORE_URL:- ${bitcoin_core_url_default} } "
29- readonly BITCOIN_CORE_TARBALL=" ${BITCOIN_CORE_TARBALL:- bitcoin-${BITCOIN_CORE_VERSION} -${BITCOIN_CORE_PLATFORM} .tar.gz} "
30- readonly BITCOIN_CORE_DIR=" ${BITCOIN_CORE_DIR:- bitcoin-${BITCOIN_CORE_VERSION} } "
31-
3243readonly DOWNLOADS_DIR=" ${SCENARIO_ROOT} /downloads"
44+ readonly BITCOIN_CORE_SOURCE_DIR=" ${SCENARIO_ROOT} /bitcoin-core-source"
45+ readonly BITCOIN_CORE_BUILD_DIR=" ${SCENARIO_ROOT} /bitcoin-core-build"
3346readonly SV2_APPS_DIR=" ${SCENARIO_ROOT} /sv2-apps"
3447readonly DATADIR=" ${SCENARIO_ROOT} /datadir"
3548readonly LOG_DIR=" ${SCENARIO_ROOT} /logs"
@@ -38,7 +51,11 @@ readonly BITCOIN_CONFIG_SOURCE="${REPO_ROOT}/ci/test/stratum_v2_bitcoin.conf"
3851readonly SV2_TP_CONFIG_SOURCE=" ${REPO_ROOT} /ci/test/stratum_v2_sv2-tp.conf"
3952readonly POOL_CONFIG_TEMPLATE=" ${REPO_ROOT} /ci/test/stratum_v2_pool-regtest.toml.in"
4053
41- readonly BITCOIN_BINDIR=" ${DOWNLOADS_DIR} /${BITCOIN_CORE_DIR} /bin"
54+ if [[ -n " ${BITCOIN_CORE_REF} " ]]; then
55+ readonly BITCOIN_BINDIR=" ${BITCOIN_CORE_BUILD_DIR} /bin"
56+ else
57+ readonly BITCOIN_BINDIR=" ${DOWNLOADS_DIR} /${BITCOIN_CORE_DIR} /bin"
58+ fi
4259readonly BITCOIN=" ${BITCOIN_BINDIR} /bitcoin"
4360readonly BITCOIN_CLI=" ${BITCOIN_BINDIR} /bitcoin-cli"
4461readonly SV2_TP=" ${REPO_ROOT} /build/bin/sv2-tp"
@@ -117,6 +134,42 @@ download_bitcoin_core()
117134 fi
118135}
119136
137+ update_bitcoin_core_source ()
138+ {
139+ if [[ ! -d " ${BITCOIN_CORE_SOURCE_DIR} /.git" ]]; then
140+ rm -rf " ${BITCOIN_CORE_SOURCE_DIR} "
141+ echo " Cloning Bitcoin Core (${BITCOIN_CORE_REPO} )"
142+ git init " ${BITCOIN_CORE_SOURCE_DIR} "
143+ git -C " ${BITCOIN_CORE_SOURCE_DIR} " remote add origin " ${BITCOIN_CORE_REPO} "
144+ fi
145+
146+ echo " Updating Bitcoin Core to ${BITCOIN_CORE_REF} "
147+ git -C " ${BITCOIN_CORE_SOURCE_DIR} " fetch --depth=1 --filter=blob:none origin " ${BITCOIN_CORE_REF} "
148+ git -C " ${BITCOIN_CORE_SOURCE_DIR} " checkout --force FETCH_HEAD
149+ }
150+
151+ build_bitcoin_core_from_source ()
152+ {
153+ echo " Building Bitcoin Core from ${BITCOIN_CORE_REF} "
154+ update_bitcoin_core_source
155+ cmake -B " ${BITCOIN_CORE_BUILD_DIR} " -G Ninja \
156+ -DBUILD_BENCH=OFF \
157+ -DBUILD_FUZZ_BINARY=OFF \
158+ -DBUILD_GUI=OFF \
159+ -DBUILD_TESTS=OFF \
160+ " ${BITCOIN_CORE_SOURCE_DIR} "
161+ cmake --build " ${BITCOIN_CORE_BUILD_DIR} " --target bitcoin bitcoin-node bitcoin-cli -j" $( nproc) "
162+ }
163+
164+ prepare_bitcoin_core ()
165+ {
166+ if [[ -n " ${BITCOIN_CORE_REF} " ]]; then
167+ build_bitcoin_core_from_source
168+ else
169+ download_bitcoin_core
170+ fi
171+ }
172+
120173update_sv2_apps ()
121174{
122175 if [[ ! -d " ${SV2_APPS_DIR} /.git" ]]; then
@@ -139,7 +192,7 @@ build_mining_device()
139192build_phase ()
140193{
141194 echo " Preparing SRI integration test build artifacts"
142- download_bitcoin_core
195+ prepare_bitcoin_core
143196 update_sv2_apps
144197
145198 echo " Building sv2-tp"
@@ -154,8 +207,8 @@ build_phase()
154207
155208build_bitcoin_core_phase ()
156209{
157- echo " Preparing Bitcoin Core binary artifacts"
158- download_bitcoin_core
210+ echo " Preparing Bitcoin Core artifacts"
211+ prepare_bitcoin_core
159212}
160213
161214build_sv2_tp_phase ()
0 commit comments