Skip to content

Commit 8705312

Browse files
committed
ci: allow Bitcoin Core ref in SRI test
Allow the SRI scenario to build bitcoin-node from BITCOIN_CORE_REF so CI can run against a custom Bitcoin Core branch. Keep the release-tarball path available, but require version and platform inputs when no source ref is configured. Assisted-by: OpenAI GPT-5-Codex
1 parent 9a3a47e commit 8705312

2 files changed

Lines changed: 69 additions & 16 deletions

File tree

.github/workflows/sri-integration-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Install apt packages
2828
run: |
2929
sudo apt-get update
30-
sudo apt-get install clang mold ccache build-essential cmake ninja-build pkgconf libboost-dev systemtap-sdt-dev capnproto libcapnp-dev -y
30+
sudo apt-get install clang mold ccache build-essential cmake ninja-build pkgconf libboost-dev libevent-dev libsqlite3-dev systemtap-sdt-dev capnproto libcapnp-dev -y
3131
3232
- name: ccache
3333
uses: actions/cache@v4

ci/test/04_run_stratum_v2_scenario.sh

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,39 @@ set -eEuo pipefail
1010

1111
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
1212
readonly 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:-}"
1515
readonly SV2_APPS_REPO="${SV2_APPS_REPO:-https://github.com/stratum-mining/sv2-apps.git}"
1616
readonly SV2_APPS_REF="${SV2_APPS_REF:-main}"
1717
readonly SCENARIO_ROOT="${SCENARIO_ROOT:-${REPO_ROOT}/sri-integration-test}"
1818
readonly 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}}"
2437
else
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:-}"
2641
fi
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-
3243
readonly 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"
3346
readonly SV2_APPS_DIR="${SCENARIO_ROOT}/sv2-apps"
3447
readonly DATADIR="${SCENARIO_ROOT}/datadir"
3548
readonly LOG_DIR="${SCENARIO_ROOT}/logs"
@@ -38,7 +51,11 @@ readonly BITCOIN_CONFIG_SOURCE="${REPO_ROOT}/ci/test/stratum_v2_bitcoin.conf"
3851
readonly SV2_TP_CONFIG_SOURCE="${REPO_ROOT}/ci/test/stratum_v2_sv2-tp.conf"
3952
readonly 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
4259
readonly BITCOIN="${BITCOIN_BINDIR}/bitcoin"
4360
readonly BITCOIN_CLI="${BITCOIN_BINDIR}/bitcoin-cli"
4461
readonly 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+
120173
update_sv2_apps()
121174
{
122175
if [[ ! -d "${SV2_APPS_DIR}/.git" ]]; then
@@ -139,7 +192,7 @@ build_mining_device()
139192
build_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

155208
build_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

161214
build_sv2_tp_phase()

0 commit comments

Comments
 (0)