Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix bbup and add CI #12541

Merged
merged 12 commits into from
Mar 6, 2025
2 changes: 2 additions & 0 deletions barretenberg/bbup/.rebuild_patterns
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
^barretenberg/bbup/bbup
^barretenberg/bbup/install
46 changes: 33 additions & 13 deletions barretenberg/bbup/bbup
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ NC='\033[0m'
SUCCESS="✓"
ERROR="✗"

BB_PATH=${BB_PATH:-"$HOME/.bb"}

# Utility functions
print_spinner() {
local pid=$1
Expand Down Expand Up @@ -51,6 +53,10 @@ get_bb_version_for_noir() {
echo "$bb_version"
}

version_gte() {
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ]
}

install_bb() {
local version=$1
local architecture=$(uname -m)
Expand All @@ -60,44 +66,58 @@ install_bb() {
if [ "$architecture" = "arm64" ]; then
architecture="aarch64"
elif [ "$architecture" = "x86_64" ]; then
architecture="amd64"
if version_gte "$version" "0.77.0"; then
architecture="amd64"
else
architecture="x86_64"
fi
else
printf "${RED}${ERROR} Unsupported architecture: ${architecture}${NC}\n"
exit 1
fi

# Determine platform
if [ "$(uname)" = "Darwin" ]; then
platform="darwin"
if version_gte "$version" "0.77.0"; then
platform="darwin"
else
platform="apple-darwin"
fi
elif [ "$(uname)" = "Linux" ]; then
platform="linux"
if version_gte "$version" "0.77.0"; then
platform="linux"
else
platform="linux-gnu"
fi

else
printf "${RED}${ERROR} Unsupported platform: $(uname)${NC}\n"
exit 1
fi

local home_dir=$HOME
local bb_path="${home_dir}/.bb"

printf "${BLUE}Installing to ${bb_path}${NC}\n"
printf "${BLUE}Installing to ${BB_PATH}${NC}\n"

# Create temporary directory
local temp_dir=$(mktemp -d)
local temp_tar="${temp_dir}/temp.tar.gz"

# Download and extract
local release_url="https://github.com/AztecProtocol/aztec-packages/releases/download/v${version}"
local binary_url="${release_url}/barretenberg-${architecture}-${platform}.tar.gz"
local release_url_base="https://github.com/AztecProtocol/aztec-packages/releases/download"
local release_tag="v${version}"
if ! version_gte "$version" "0.77.0"; then
release_tag="aztec-packages-v${version}"
fi
local binary_url="${release_url_base}/${release_tag}/barretenberg-${architecture}-${platform}.tar.gz"

curl -L "$binary_url" -o "$temp_tar"
mkdir -p "$bb_path"
tar xzf "$temp_tar" -C "$bb_path"
mkdir -p "$BB_PATH"
tar xzf "$temp_tar" -C "$BB_PATH"
rm -rf "$temp_dir"

# Update shell configuration
update_shell_config "$bb_path"
update_shell_config "$BB_PATH"

printf "${GREEN}${SUCCESS} Installed barretenberg to ${bb_path}${NC}\n"
printf "${GREEN}${SUCCESS} Installed barretenberg to ${BB_PATH}${NC}\n"
}

update_shell_config() {
Expand Down
44 changes: 44 additions & 0 deletions barretenberg/bbup/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
source $(git rev-parse --show-toplevel)/ci3/source_bootstrap

cmd=${1:-}
[ -n "$cmd" ] && shift

export hash=$(cache_content_hash .rebuild_patterns)

# Print every individual test command. Can be fed into gnu parallel.
# Paths are relative to repo root.
# We append the hash as a comment. This ensures the test harness and cache and skip future runs.
function test_cmds {
local test_versions=("0.72.1" "0.77.1")

for version in ${test_versions[@]}; do
echo -e "$hash barretenberg/bbup/test_install.sh $version"
done
}

# This is not called in ci. It is just for a developer to run the tests.
function test {
echo_header "bbup test"
test_cmds | filter_test_cmds | parallelise
}

case "$cmd" in
"clean")
git clean -fdx
;;
""|"fast"|"full")
;;
"ci")
test
;;
"hash")
echo $hash
;;
test|test_cmds)
$cmd "$@"
;;
*)
echo "Unknown command: $cmd"
exit 1
esac
33 changes: 33 additions & 0 deletions barretenberg/bbup/test_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

set -e

cd $(dirname $0)/

VERSION=$1

TEMP_DIR=$(mktemp -d)

BB_PATH=$TEMP_DIR ./bbup -v $VERSION

# omg why did we remove bb --version?
version_gte() {
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ]
}

SEEN_VERSION=""
if version_gte "$VERSION" "0.77.0"; then
Copy link
Collaborator

@ludamad ludamad Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do now have in ci3 folder a 'semver' tool that can do this by if [ $(ci3/semver sort $1 $2 | tail -1) == $1 ]. It's the official perl semver regex with an AI-generated shell (that generated tests :D) with the modification that it supports 'v' prefix

SEEN_VERSION=$($TEMP_DIR/bb version)
else
SEEN_VERSION=$($TEMP_DIR/bb --version)
fi

rm -rf $TEMP_DIR

if ! grep "$VERSION" <<< $SEEN_VERSION > /dev/null; then
echo "Did not find expected version of bb"
echo "Expected: $VERSION"
echo "Found: $SEEN_VERSION"
exit 1
fi

3 changes: 2 additions & 1 deletion barretenberg/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ source $(git rev-parse --show-toplevel)/ci3/source
# Download ignition up front to ensure no race conditions at runtime.
[ -n "${SKIP_BB_CRS:-}" ] || ./scripts/download_bb_crs.sh

./bbup/bootstrap.sh $@
./cpp/bootstrap.sh $@
./ts/bootstrap.sh $@
./acir_tests/bootstrap.sh $@
Expand All @@ -24,4 +25,4 @@ if [ "$cmd" == "bench" ]; then
> ./bench-out/bb-bench.json

cache_upload barretenberg-bench-results-$COMMIT_HASH.tar.gz ./bench-out/bb-bench.json
fi
fi