Skip to content

Commit a4fe9db

Browse files
authored
chore: Accumulated backports to v4-next (#22075)
BEGIN_COMMIT_OVERRIDE fix(aztec-up): always reinstall noirup and foundryup bootstrappers (#21826) fix(aztec-up): show installed version after install (#21822) feat(aztec-up): default install version to latest instead of nightly (backport #21883) (#22076) feat(aztec-up): auto-update before install with staleness check (#21866) cherry-pick: feat(aztec-up): add versioned aliases for multi-major version support (#21817) feat(aztec-up): add versioned aliases for multi-major version support (backport #21817) (#22080) feat(aztec-up): decouple infra assets from toolchain VERSION (backport #22078) (#22079) feat: backport hardcode version into install scripts at release time (#22082) fix(aztec-up): pass VERSION to per-version installer and fix release sed (#22083) END_COMMIT_OVERRIDE
2 parents a4701a6 + 03a9107 commit a4fe9db

10 files changed

Lines changed: 447 additions & 119 deletions

File tree

.github/workflows/ci3.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ jobs:
8181
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
8282
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
8383
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
84+
AZTEC_TOOLCHAIN_DEFAULT_MAJOR_VERSION: ${{ vars.AZTEC_TOOLCHAIN_DEFAULT_MAJOR_VERSION }}
8485
# For automatic documentation updates via Claude Code
8586
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
8687
# Nightly test env vars.

aztec-up/bin/0.0.1/aztec-banner

Lines changed: 28 additions & 0 deletions
Large diffs are not rendered by default.

aztec-up/bin/0.0.1/aztec-banner-truecolor

Lines changed: 28 additions & 0 deletions
Large diffs are not rendered by default.

aztec-up/bin/0.0.1/aztec-install

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
{
99
set -euo pipefail
1010

11-
# Colors
12-
g="\033[32m" # Green
13-
y="\033[33m" # Yellow
14-
b="\033[34m" # Blue
15-
p="\033[35m" # Purple
11+
# Colors (truecolor with 256-color fallback)
1612
r="\033[0m" # Reset
1713
bold="\033[1m"
14+
g="\033[38;5;114m" # green
15+
y="\033[38;5;222m" # yellow
16+
b="\033[38;5;111m" # blue
17+
p="\033[38;5;176m" # purple
18+
red="\033[38;5;203m" # red
19+
o="\033[38;5;214m" # orange
1820

1921
if [ ! -t 0 ]; then
2022
NON_INTERACTIVE=1
@@ -26,10 +28,14 @@ fi
2628
AZTEC_HOME="${AZTEC_HOME:-$HOME/.aztec}"
2729
shared_bin_path="$AZTEC_HOME/bin"
2830

29-
VERSION="${VERSION:-nightly}"
31+
# Toolchain version to install (alias or semver). Replaced at release time.
32+
VERSION=${VERSION:-0.0.1}
33+
# Infrastructure version: controls where to fetch installer assets (banner, aztec-up).
34+
# When empty, assets are fetched directly from INSTALL_URI.
35+
INFRA_VERSION=${INFRA_VERSION:-}
3036

31-
# Install URI (root, not version-specific)
3237
INSTALL_URI="${INSTALL_URI:-https://install.aztec-labs.com}"
38+
INFRA_BASE_URI="$INSTALL_URI${INFRA_VERSION:+/$INFRA_VERSION}"
3339

3440
# Check if version string is valid semver
3541
function is_semver {
@@ -57,35 +63,43 @@ function resolve_version {
5763

5864
VERSION=$(resolve_version "$VERSION")
5965

60-
# Add color to the AZTEC ascii art.
61-
function print_colored() {
62-
local b=$'\033[34m' # Blue
63-
local y=$'\033[33m' # Yellow
64-
local r=$'\033[0m' # Reset
65-
echo "$1" | sed -E "s/(█+)/${b}\1${y}/g"
66+
function typewriter {
67+
trap 'printf "${r}\n"; exit 1' INT
68+
local text="$1"
69+
local color="${2:-}"
70+
local delay="${3:-0.02}"
71+
local width=80
72+
local pad=$(( (width - ${#text}) / 2 ))
73+
printf "\r\033[2K%${pad}s${color}" ""
74+
for (( i=0; i<${#text}; i++ )); do printf '%s' "${text:$i:1}"; sleep "$delay"; done
75+
trap - INT
6676
}
6777

6878
function title {
6979
clear
80+
if [ "${COLORTERM:-}" = "truecolor" ] || [ "${COLORTERM:-}" = "24bit" ]; then
81+
curl -fsSL "$INFRA_BASE_URI/aztec-banner-truecolor" 2>/dev/null || true
82+
else
83+
curl -fsSL "$INFRA_BASE_URI/aztec-banner" 2>/dev/null || true
84+
fi
85+
typewriter "initializing stealth protocols..." "${p}"
86+
sleep 1
87+
typewriter "zk loaded." "${y}"
88+
sleep 1
89+
typewriter "privacy restored." "${g}${bold}"
90+
sleep 1
91+
printf "${r}\r"
92+
echo -e "Welcome to ${bold}${b}Aztec${r}! Your journey into blockchain privacy begins... ${bold}${p}now${r}."
7093
echo
71-
print_colored " █████╗ ███████╗████████╗███████╗ ██████╗"
72-
print_colored "██╔══██╗╚══███╔╝╚══██╔══╝██╔════╝██╔════╝"
73-
print_colored "███████║ ███╔╝ ██║ █████╗ ██║"
74-
print_colored "██╔══██║ ███╔╝ ██║ ██╔══╝ ██║"
75-
print_colored "██║ ██║███████╗ ██║ ███████╗╚██████╗"
76-
print_colored "╚═╝ ╚═╝╚══════╝ ╚═╝ ╚══════╝ ╚═════╝"
77-
echo -e "${r}"
78-
echo -e "Welcome to the ${bold}${b}Aztec${r} installer! Your journey into blockchain privacy begins... ${bold}${p}now${r}."
79-
echo
80-
echo -e "Installing version: ${bold}${g}$VERSION${r}"
94+
echo -e "Installing version: ${bold}${o}$VERSION${r}"
8195
echo
82-
echo -e "This install script will install the following and update your PATH if necessary:"
83-
echo -e " ${bold}${g}nargo${r} - the version of the noir programming language compatible with this version of aztec."
84-
echo -e " ${bold}${g}noir-profiler${r} - a sampling profiler for analyzing and visualizing Noir programs."
85-
echo -e " ${bold}${g}bb${r} - the version of the barretenberg proving backend compatible with this version of aztec."
86-
echo -e " ${bold}${g}aztec${r} - a collection of tools to compile and test contracts, to launch subsystems and interact with the aztec network."
87-
echo -e " ${bold}${g}aztec-up${r} - a tool to install and manage aztec toolchain versions."
88-
echo -e " ${bold}${g}aztec-wallet${r} - our minimalistic CLI wallet"
96+
echo -e "This script installs the following and updates your PATH if necessary:"
97+
echo -e " ${bold}${g}nargo${r} - the noir programming language compiler and simulator."
98+
echo -e " ${bold}${g}noir-profiler${r} - a profiler for analyzing and visualizing noir programs."
99+
echo -e " ${bold}${g}bb${r} - the barretenberg proving backend."
100+
echo -e " ${bold}${g}aztec${r} - compiles and tests contracts, interacts with the network."
101+
echo -e " ${bold}${g}aztec-up${r} - installs and manages aztec toolchain versions."
102+
echo -e " ${bold}${g}aztec-wallet${r} - a minimalistic wallet cli."
89103
echo
90104
read -p "Do you wish to continue? (Y/n) " -n 1 -r
91105
echo
@@ -161,12 +175,10 @@ function install_jq {
161175
}
162176

163177
function install_aztec_up {
164-
# If there's a version of aztec-up at the VERSION location, use that, else fallback to root installer.
165-
if ! curl -fsSL "$INSTALL_URI/$VERSION/aztec-up" -o "$shared_bin_path/aztec-up"; then
166-
# Download aztec-up from root.
167-
curl -fsSL "$INSTALL_URI/aztec-up" -o "$shared_bin_path/aztec-up"
168-
fi
178+
curl -fsSL "$INFRA_BASE_URI/aztec-up" -o "$shared_bin_path/aztec-up"
169179
chmod +x "$shared_bin_path/aztec-up"
180+
# Seed the auto-update staleness clock (see auto_update() in aztec-up).
181+
date +%s > "$AZTEC_HOME/.last_update_check"
170182
}
171183

172184
# Updates appropriate shell script to ensure the paths are in PATH.
@@ -212,9 +224,11 @@ function main {
212224
mkdir -p "$shared_bin_path"
213225

214226
# Install jq
215-
echo -n "Installing jq... "
216-
install_jq
217-
echo_green "done."
227+
if ! command -v jq >/dev/null 2>&1; then
228+
echo -n "Installing jq... "
229+
install_jq
230+
echo_green "done."
231+
fi
218232

219233
# Install aztec-up (version manager)
220234
echo -n "Installing aztec-up... "

aztec-up/bin/0.0.1/aztec-up

Lines changed: 152 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ r="\033[0m" # Reset
1414

1515
AZTEC_HOME="${AZTEC_HOME:-$HOME/.aztec}"
1616
INSTALL_URI="${INSTALL_URI:-https://install.aztec-labs.com}"
17+
AZTEC_NO_AUTO_UPDATE="${AZTEC_NO_AUTO_UPDATE:-}"
18+
AUTO_UPDATE_INTERVAL_SECS=86400 # 24 hours
19+
LAST_UPDATE_CHECK_FILE="$AZTEC_HOME/.last_update_check"
20+
readonly SELF_UPDATE_UPDATED=0
21+
readonly SELF_UPDATE_FAILED=1
22+
readonly SELF_UPDATE_UP_TO_DATE=2
1723

1824
function echo_green {
1925
echo -e "${g}$1${r}"
@@ -37,6 +43,7 @@ function help {
3743
echo " use [<version>] Switch to an installed version (or read from .aztecrc)"
3844
echo " list List installed versions"
3945
echo " uninstall <version> Remove an installed version"
46+
echo " prune Remove all versions except the current one"
4047
echo " self-update Update aztec-up itself to the latest version"
4148
echo " env Output PATH for .aztecrc version (for eval)"
4249
echo
@@ -117,6 +124,72 @@ function resolve_version {
117124
fi
118125
}
119126

127+
# Download latest aztec-up and replace if changed.
128+
function download_latest_self {
129+
local self_path="$AZTEC_HOME/bin/aztec-up"
130+
local tmp_path
131+
tmp_path=$(mktemp)
132+
133+
if ! curl -fsSL "$INSTALL_URI/aztec-up" -o "$tmp_path"; then
134+
rm -f "$tmp_path"
135+
return "$SELF_UPDATE_FAILED"
136+
fi
137+
138+
# Ensure we didn't get an empty or truncated response
139+
if [ ! -s "$tmp_path" ]; then
140+
rm -f "$tmp_path"
141+
return "$SELF_UPDATE_FAILED"
142+
fi
143+
144+
# Skip replacement if the downloaded script is identical to the current one
145+
if cmp -s "$tmp_path" "$self_path"; then
146+
rm -f "$tmp_path"
147+
date +%s > "$LAST_UPDATE_CHECK_FILE"
148+
return "$SELF_UPDATE_UP_TO_DATE"
149+
fi
150+
151+
# Replace the current aztec-up binary with the downloaded one
152+
chmod +x "$tmp_path"
153+
if ! mv "$tmp_path" "$self_path"; then
154+
rm -f "$tmp_path"
155+
return "$SELF_UPDATE_FAILED"
156+
fi
157+
158+
date +%s > "$LAST_UPDATE_CHECK_FILE"
159+
return "$SELF_UPDATE_UPDATED"
160+
}
161+
162+
# Auto-update aztec-up itself if stale
163+
function auto_update {
164+
# Allow users to opt out of auto-update (e.g. in CI or offline environments)
165+
if [ -n "$AZTEC_NO_AUTO_UPDATE" ]; then
166+
return 0
167+
fi
168+
169+
# Skip if we already checked recently (within 24 hours)
170+
local last_check
171+
last_check=$(cat "$LAST_UPDATE_CHECK_FILE" 2>/dev/null || echo 0)
172+
[[ "$last_check" =~ ^[0-9]+$ ]] || last_check=0
173+
local now
174+
now=$(date +%s)
175+
if [ $((now - last_check)) -lt "$AUTO_UPDATE_INTERVAL_SECS" ]; then
176+
return 0
177+
fi
178+
179+
# Suppress curl output -- auto-update is best-effort
180+
local result=0
181+
download_latest_self 2>/dev/null || result=$?
182+
183+
if [ "$result" -eq "$SELF_UPDATE_UPDATED" ]; then
184+
# The updated script takes effect on the next invocation.
185+
# Current invocation continues with already-parsed old code
186+
# (safe due to the { ... exit } wrapper at the top of the file).
187+
echo_green "aztec-up has been updated. Changes take effect on next run." >&2
188+
elif [ "$result" -eq "$SELF_UPDATE_FAILED" ]; then
189+
echo_yellow "Warning: Failed to check for aztec-up updates" >&2
190+
fi
191+
}
192+
120193
# Install a version by downloading and running the version-specific installer
121194
function cmd_install {
122195
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
@@ -145,6 +218,8 @@ function cmd_install {
145218
exit 1
146219
fi
147220

221+
auto_update
222+
148223
# Resolve alias to actual version
149224
local resolved_version
150225
if ! resolved_version=$(resolve_version "$version"); then
@@ -165,6 +240,12 @@ function cmd_install {
165240

166241
# Update the current symlink
167242
ln -sfn "$AZTEC_HOME/versions/$resolved_version" "$AZTEC_HOME/current"
243+
244+
if [ "$version" != "$resolved_version" ]; then
245+
echo_green "Installed and activated $version ($resolved_version)"
246+
else
247+
echo_green "Installed and activated version $resolved_version"
248+
fi
168249
}
169250

170251
# Switch to a version
@@ -335,6 +416,68 @@ function cmd_uninstall {
335416
echo_green "Uninstalled version $version"
336417
}
337418

419+
# Remove all versions except the current one
420+
function cmd_prune {
421+
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
422+
echo "Remove all installed versions except the currently active one"
423+
echo
424+
echo "Usage: aztec-up prune"
425+
echo
426+
echo "Options:"
427+
echo " -h, --help Print help"
428+
echo
429+
echo "Examples:"
430+
echo " aztec-up prune # Remove all versions except current"
431+
return 0
432+
fi
433+
434+
local current_version
435+
current_version=$(get_current_version)
436+
437+
if [ -z "$current_version" ]; then
438+
echo "Error: No version is currently active. Use 'aztec-up use <version>' first."
439+
exit 1
440+
fi
441+
442+
# Collect versions to remove
443+
local to_remove=()
444+
for dir in "$AZTEC_HOME/versions"/*/; do
445+
[ -d "$dir" ] || continue
446+
local version
447+
version=$(basename "$dir")
448+
if [ "$version" != "$current_version" ]; then
449+
to_remove+=("$version")
450+
fi
451+
done
452+
453+
if [ ${#to_remove[@]} -eq 0 ]; then
454+
echo "Nothing to prune. Only the current version ($current_version) is installed."
455+
return 0
456+
fi
457+
458+
echo "Current version: $current_version"
459+
echo
460+
echo "The following versions will be removed:"
461+
for version in "${to_remove[@]}"; do
462+
echo " $version"
463+
done
464+
echo
465+
466+
read -p "Continue? (y/N) " -n 1 -r
467+
echo
468+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
469+
echo "Aborted."
470+
return 0
471+
fi
472+
473+
for version in "${to_remove[@]}"; do
474+
rm -rf "$AZTEC_HOME/versions/$version"
475+
echo "Removed $version"
476+
done
477+
478+
echo_green "Pruned all versions except $current_version"
479+
}
480+
338481
# Update aztec-up itself
339482
function cmd_self-update {
340483
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
@@ -352,22 +495,17 @@ function cmd_self-update {
352495

353496
echo "Updating aztec-up..."
354497

355-
local self_path="$AZTEC_HOME/bin/aztec-up"
356-
local tmp_path=$(mktemp)
357-
358-
# Download latest aztec-up from root
359-
if ! curl -fsSL "$INSTALL_URI/aztec-up" -o "$tmp_path"; then
498+
local result=0
499+
download_latest_self || result=$?
500+
if [ "$result" -eq "$SELF_UPDATE_FAILED" ]; then
360501
echo "Error: Failed to download latest aztec-up"
361-
rm -f "$tmp_path"
362502
exit 1
503+
elif [ "$result" -eq "$SELF_UPDATE_UP_TO_DATE" ]; then
504+
echo_green "aztec-up is already up to date."
505+
else
506+
echo_green "aztec-up updated successfully."
507+
echo "Run 'aztec-up --help' to see available commands."
363508
fi
364-
365-
# Replace self
366-
chmod +x "$tmp_path"
367-
mv "$tmp_path" "$self_path"
368-
369-
echo_green "aztec-up updated successfully."
370-
echo "Run 'aztec-up --help' to see available commands."
371509
}
372510

373511
# Output PATH for .aztecrc version (for eval in shell scripts)
@@ -424,7 +562,7 @@ function main {
424562
""|-h|--help)
425563
help
426564
;;
427-
install|use|list|uninstall|self-update|env)
565+
install|use|list|uninstall|prune|self-update|env)
428566
cmd_$cmd "$@"
429567
;;
430568
*)

0 commit comments

Comments
 (0)