Skip to content
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
52 changes: 38 additions & 14 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,53 +53,75 @@ 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)
local platform=""

# Convert architecture names
if [ "$architecture" = "arm64" ]; then
architecture="aarch64"
if version_gte "$version" "0.77.0"; then
architecture="arm64"
else
architecture="aarch64"
fi
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/run_test.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
19 changes: 19 additions & 0 deletions barretenberg/bbup/run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -e

cd $(dirname $0)/

VERSION=$1

TEMP_DIR=$(mktemp -d)
trap 'rm -rf $TEMP_DIR' EXIT

BB_PATH=$TEMP_DIR ./bbup -v $VERSION

if ! grep "$VERSION" <<< $($TEMP_DIR/bb --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