Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/actions/setup-boost-186/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Setup Boost 1.86
description: Restores or builds the Boost 1.86 toolchain required by libbitcoin-system.
runs:
using: composite
steps:
- name: Restore Boost 1.86 cache
id: boost-cache
uses: actions/cache/restore@v4
with:
path: ${{ runner.tool_cache }}/bitcoinfuzz/boost-1.86.0
key: boost-1.86.0-${{ runner.os }}-clang-${{ hashFiles('.github/actions/setup-boost-186/**') }}

- name: Build Boost 1.86
shell: bash
env:
BOOST_PREFIX: ${{ runner.tool_cache }}/bitcoinfuzz/boost-1.86.0
BOOST_VERSION: 1.86.0
BOOST_URL: https://github.com/boostorg/boost/releases/download/boost-1.86.0/boost-1.86.0-cmake.tar.gz
BOOST_LIBRARIES: iostreams;locale;program_options;thread;url;test;regex;filesystem;system;date_time;chrono;atomic;random;container;charconv;json
CC: /usr/bin/clang
CXX: /usr/bin/clang++
run: bash "${{ github.action_path }}/install-boost.sh"

- name: Save Boost 1.86 cache
if: ${{ steps.boost-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
path: ${{ runner.tool_cache }}/bitcoinfuzz/boost-1.86.0
key: boost-1.86.0-${{ runner.os }}-clang-${{ hashFiles('.github/actions/setup-boost-186/**') }}

- name: Export BOOST_ROOT
shell: bash
run: echo "BOOST_ROOT=${{ runner.tool_cache }}/bitcoinfuzz/boost-1.86.0" >> "$GITHUB_ENV"
50 changes: 50 additions & 0 deletions .github/actions/setup-boost-186/install-boost.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
set -euo pipefail

boost_config="${BOOST_PREFIX}/lib/cmake/Boost-${BOOST_VERSION}/BoostConfig.cmake"
if [[ -f "${boost_config}" ]]; then
exit 0
fi

mkdir -p "$(dirname "${BOOST_PREFIX}")"

workdir="$(mktemp -d "${RUNNER_TEMP:-/tmp}/boost-${BOOST_VERSION}.XXXXXX")"
archive="${workdir}/boost.tar.gz"
srcdir="${workdir}/boost-${BOOST_VERSION}"
stage_prefix="${BOOST_PREFIX}.new"

cleanup() {
rm -rf "${workdir}" "${stage_prefix}"
}

trap cleanup EXIT

rm -rf "${BOOST_PREFIX}" "${stage_prefix}"

curl --fail --show-error --location \
--retry 5 \
--retry-all-errors \
--retry-delay 2 \
--output "${archive}" \
"${BOOST_URL}"

tar -tzf "${archive}" >/dev/null
tar -xzf "${archive}" -C "${workdir}"

if [[ ! -d "${srcdir}" ]]; then
echo "Expected Boost source directory ${srcdir} was not created" >&2
exit 1
fi

cmake -S "${srcdir}" -B "${srcdir}/build" \
-DCMAKE_C_COMPILER="${CC}" \
-DCMAKE_CXX_COMPILER="${CXX}" \
-DCMAKE_INSTALL_PREFIX="${stage_prefix}" \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DBOOST_INCLUDE_LIBRARIES="${BOOST_LIBRARIES}"

cmake --build "${srcdir}/build" --parallel "$(nproc)"
cmake --install "${srcdir}/build"

mv "${stage_prefix}" "${BOOST_PREFIX}"
55 changes: 19 additions & 36 deletions .github/actions/setup-test-env/action.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,33 @@
name: Setup Test Environment
description: Sets up the environment for a test job, including repo checkout, cache restore, and macOS-specific setup.
description: Checks out bitcoinfuzz at the commit the build job used, downloads the build artifacts and installs the runtime deps.
inputs:
os:
description: Operating system
required: true
github-sha:
description: GitHub SHA
required: true
github-run-id:
description: GitHub Run ID
bitcoinfuzz-ref:
description: bitcoinfuzz commit SHA the build job compiled
required: true
runs:
using: "composite"
steps:
- name: Restore build artifacts
uses: actions/cache/restore@v4
- name: Checkout bitcoinfuzz repo
uses: actions/checkout@v4
with:
repository: bitcoinfuzz/bitcoinfuzz
ref: ${{ inputs.bitcoinfuzz-ref }}
path: bitcoinfuzz

- name: Download build artifacts
uses: actions/download-artifact@v8
with:
path: |
bitcoinfuzz
build.env
key: bitcoinfuzz-build-${{ inputs.os }}-${{ inputs.github-sha }}-${{ inputs.github-run-id }}
name: bitcoinfuzz-build
path: bitcoinfuzz

- name: Setup environment
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y lowdown libsodium-dev
# libbitcoin-system requires CMake >= 3.30; Ubuntu 24.04 ships 3.28.3.
# pip provides a binary cmake that takes precedence on PATH.
python3 -m pip install --upgrade --break-system-packages 'cmake>=3.30'

- name: Install Boost 1.86 (required for libbitcoin-system targets)
shell: bash
run: |
# Cache hit short-circuits this; Boost is installed to /opt/boost-1.86
# so the bitcoinfuzz link step can resolve libbitcoin-system's Boost refs.
if [ ! -f /opt/boost-1.86/lib/cmake/Boost-1.86.0/BoostConfig.cmake ]; then
python3 -m pip install --upgrade --break-system-packages 'cmake>=3.30'
curl -sSL -o /tmp/boost.tar.gz \
https://github.com/boostorg/boost/releases/download/boost-1.86.0/boost-1.86.0-cmake.tar.gz
tar -xzf /tmp/boost.tar.gz -C /tmp
cd /tmp/boost-1.86.0
cmake -B build \
-DCMAKE_C_COMPILER=/usr/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
-DCMAKE_INSTALL_PREFIX=/opt/boost-1.86 \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DBOOST_INCLUDE_LIBRARIES="iostreams;locale;program_options;thread;url;test;regex;filesystem;system;date_time;chrono;atomic;random;container;charconv"
cmake --build build --parallel "$(nproc)"
sudo cmake --install build
fi
echo "BOOST_ROOT=/opt/boost-1.86" >> $GITHUB_ENV
uses: ./.github/actions/setup-boost-186
6 changes: 5 additions & 1 deletion .github/scripts/run-fuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ CXXFLAGS="$3"
ASAN_OPTIONS="${4:-}"
CXX="${5}"

# Remove the fixed arguments in order to forward
# any extra arguments to libFuzzer
shift 5

if [ -d "./${CORPUS_DIR}" ]; then
echo "Using corpora for ${TARGET}"
cd bitcoinfuzz
export CXXFLAGS="${CXXFLAGS}"
export CXX="${CXX}"
[[ -n "${ASAN_OPTIONS}" ]] && export ASAN_OPTIONS="${ASAN_OPTIONS}"
make
FUZZ="${TARGET}" ./bitcoinfuzz -runs=1 "../${CORPUS_DIR}"
FUZZ="${TARGET}" ./bitcoinfuzz -runs=1 "$@" "../${CORPUS_DIR}"
else
echo "Corpus ./${CORPUS_DIR} does not exist. Skipping."
fi
Loading
Loading