diff --git a/barretenberg/bbup/.rebuild_patterns b/barretenberg/bbup/.rebuild_patterns new file mode 100644 index 000000000000..1c4d6ab92e5d --- /dev/null +++ b/barretenberg/bbup/.rebuild_patterns @@ -0,0 +1,2 @@ +^barretenberg/bbup/bbup +^barretenberg/bbup/install diff --git a/barretenberg/bbup/bbup b/barretenberg/bbup/bbup index 716b4c054434..d92c82e64f2b 100755 --- a/barretenberg/bbup/bbup +++ b/barretenberg/bbup/bbup @@ -10,6 +10,8 @@ NC='\033[0m' SUCCESS="✓" ERROR="✗" +BB_PATH=${BB_PATH:-"$HOME/.bb"} + # Utility functions print_spinner() { local pid=$1 @@ -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) @@ -58,9 +64,17 @@ install_bb() { # 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 @@ -68,36 +82,46 @@ install_bb() { # 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() { diff --git a/barretenberg/bbup/bootstrap.sh b/barretenberg/bbup/bootstrap.sh new file mode 100755 index 000000000000..fa7349c46108 --- /dev/null +++ b/barretenberg/bbup/bootstrap.sh @@ -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 diff --git a/barretenberg/bbup/run_test.sh b/barretenberg/bbup/run_test.sh new file mode 100755 index 000000000000..3ce9f610ba14 --- /dev/null +++ b/barretenberg/bbup/run_test.sh @@ -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 diff --git a/barretenberg/bootstrap.sh b/barretenberg/bootstrap.sh index d8024a6bd9d8..93aedc96cb33 100755 --- a/barretenberg/bootstrap.sh +++ b/barretenberg/bootstrap.sh @@ -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 $@ @@ -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