-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docs): rewriting bbup script, refactoring bb readme for clarity (…
…#9073) ## Description Closes #8530 Closes #7511 #7525 as no longer useful / relevant This PR updates the Barretenberg README with more information about the project, its installation, usage, and development. It also refactors `bbup` with `commander` to match the rest of the repository's CLI tooling. ## Changes ### bb readme - Added a project banner and reorganized the README structure - Expanded usage instructions for UltraHonk and MegaHonk ### bbup - Refactored bbup installation script and related files - Included detailed installation instructions in its README ## Testing `bbup` won't change much so it is deployed manually on `npm`. You can try it immediately with: ```bash curl -L bbup.dev | bash bbup ``` --------- Co-authored-by: Savio <[email protected]>
- Loading branch information
1 parent
09c3b28
commit 662b61e
Showing
22 changed files
with
1,734 additions
and
435 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,4 @@ terraform.tfstate* | |
|
||
# tmux | ||
tmux-client-*.log | ||
.supermavenignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
yarn.lock | ||
*.js | ||
.yarn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
yarn.lock | ||
*.ts | ||
.yarn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# BBup | ||
|
||
BBup is a CLI tool that makes it easy to install the [Barretenberg](https://github.com/AztecProtocol/aztec-packages/blob/master/barretenberg/README.md) proving backend. | ||
|
||
It assumes you are using [Noir](https://noir-lang.org) as the frontend language. | ||
|
||
## Installation | ||
|
||
### Dependencies | ||
|
||
TODO | ||
|
||
### Installation script | ||
|
||
BBup is an installer for whatever version of BB you may want. Install BBup with: | ||
|
||
```bash | ||
curl -L bbup.dev | bash | ||
``` | ||
|
||
> [!IMPORTANT] | ||
> *Always* check what scripts do. The above one redirects to [the install script](https://github.com/AztecProtocol/aztec-packages/blob/master/barretenberg/bbup/install) which checks if you have `npm`, installing it with `nvm` otherwise. It then installs [bbup](https://github.com/AztecProtocol/aztec-packages/blob/master/barretenberg/bbup/bbup.ts) globally. | ||
## Usage | ||
|
||
To install the Barretenberg version compatible with the current installed Noir version (ex. installed with [noirup](https://github.com/noir-lang/noirup)), run: | ||
|
||
```bash | ||
bbup | ||
``` | ||
|
||
Check if the installation was successful: | ||
|
||
```bash | ||
bb --version | ||
``` | ||
|
||
If installation was successful, the command would print the version of `bb` installed. | ||
|
||
### Options | ||
|
||
You can install any specific version of `bb` with the `-v` flag. Example: | ||
|
||
```bash | ||
bbup -v 0.56.0 | ||
``` | ||
|
||
You can also can pass [any Noir version](https://github.com/noir-lang/noir/tags) with the `-nv` flag, or specify `nightly` for the nightly version. Examples: | ||
|
||
```bash | ||
bbup # installs the barretenberg version matching your current nargo version | ||
bbup -nv 0.34.0 # installs the barretenberg version compatible with Noir 0.34.0 release | ||
bbup -nv nightly # installs the barretenberg version compatible with Noir nightly release | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env node | ||
import { Command } from "commander"; | ||
const program = new Command(); | ||
import { installBB } from "./shell.js"; | ||
import ora from "ora"; | ||
import logSymbols from "log-symbols"; | ||
import { getBbVersionForNoir } from "./versions.js"; | ||
import { execSync } from "child_process"; | ||
const spinner = ora({ color: "blue", discardStdin: false }); | ||
const bbup = program | ||
.command("install", { isDefault: true }) | ||
.description("Installs Barretenberg.") | ||
.option("-f, --frontend", "Match the version of a specific frontend language", "noir"); | ||
const options = bbup.opts(); | ||
if (options.frontend === "noir") { | ||
bbup | ||
.requiredOption("-v, --version <version>", "The Noir version to match", "current") | ||
.action(async ({ version }) => { | ||
let resolvedVersion = version; | ||
if (version === "current") { | ||
spinner.start(`Querying noir version from nargo`); | ||
try { | ||
const output = execSync("nargo --version", { encoding: "utf-8" }); | ||
resolvedVersion = output.match(/nargo version = (\d+\.\d+\.\d+)/)[1]; | ||
spinner.stopAndPersist({ | ||
text: `Resolved noir version ${resolvedVersion} from nargo`, | ||
symbol: logSymbols.success, | ||
}); | ||
} | ||
catch (e) { | ||
spinner.stopAndPersist({ | ||
text: `Could not get noir version from nargo --version. Please specify a version.`, | ||
symbol: logSymbols.error, | ||
}); | ||
process.exit(1); | ||
} | ||
} | ||
spinner.start(`Getting compatible barretenberg version for noir version ${resolvedVersion}`); | ||
const compatibleVersion = await getBbVersionForNoir(resolvedVersion, spinner); | ||
spinner.stopAndPersist({ | ||
text: `Resolved to barretenberg version ${compatibleVersion}`, | ||
symbol: logSymbols.success, | ||
}); | ||
spinner.start(`Installing barretenberg`); | ||
await installBB(compatibleVersion, spinner); | ||
}); | ||
} | ||
bbup.parse(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env node | ||
import { Command, Option } from "commander"; | ||
const program = new Command(); | ||
import { installBB } from "./shell.js"; | ||
import ora from "ora"; | ||
import logSymbols from "log-symbols"; | ||
import { getBbVersionForNoir } from "./versions.js"; | ||
import { execSync } from "child_process"; | ||
|
||
const spinner = ora({ color: "blue", discardStdin: false }); | ||
|
||
const bbup = program | ||
.command("install", { isDefault: true }) | ||
.description("Installs Barretenberg.") | ||
.addOption( | ||
new Option( | ||
"-v, --version <version>", | ||
"The Barretenberg version to install" | ||
).implies({ noirVersion: null }) | ||
) | ||
.addOption( | ||
new Option( | ||
"-nv, --noir-version <version>", | ||
"The Noir version to match" | ||
).default("current") | ||
) | ||
.action(async ({ version, noirVersion }) => { | ||
let resolvedBBVersion = ""; | ||
if (noirVersion) { | ||
let resolvedNoirVersion = noirVersion; | ||
if (noirVersion === "current") { | ||
spinner.start(`Querying noir version from nargo`); | ||
try { | ||
const output = execSync("nargo --version", { encoding: "utf-8" }); | ||
resolvedNoirVersion = output.match( | ||
/nargo version = (\d+\.\d+\.\d+)/ | ||
)![1]; | ||
spinner.stopAndPersist({ | ||
text: `Resolved noir version ${resolvedNoirVersion} from nargo`, | ||
symbol: logSymbols.success, | ||
}); | ||
} catch (e) { | ||
spinner.stopAndPersist({ | ||
text: `Could not get noir version from nargo --version. Please specify a version.`, | ||
symbol: logSymbols.error, | ||
}); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
spinner.start( | ||
`Getting compatible barretenberg version for noir version ${resolvedNoirVersion}` | ||
); | ||
resolvedBBVersion = await getBbVersionForNoir( | ||
resolvedNoirVersion, | ||
spinner | ||
); | ||
spinner.stopAndPersist({ | ||
text: `Resolved to barretenberg version ${resolvedBBVersion}`, | ||
symbol: logSymbols.success, | ||
}); | ||
} else if (version) { | ||
resolvedBBVersion = version; | ||
} | ||
|
||
spinner.start(`Installing barretenberg`); | ||
|
||
await installBB(resolvedBBVersion, spinner); | ||
}); | ||
|
||
bbup.parse(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Function to check if a command exists | ||
command_exists() { | ||
command -v "$1" >/dev/null 2>&1 | ||
} | ||
|
||
# Function to install NVM and Node.js | ||
install_nvm_and_node() { | ||
echo "Installing NVM..." | ||
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash | ||
|
||
# Load NVM | ||
export NVM_DIR="$HOME/.nvm" | ||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | ||
|
||
# Install the latest LTS version of Node.js | ||
echo "Installing the latest LTS version of Node.js..." | ||
nvm install --lts | ||
|
||
# Use the installed version | ||
nvm use --lts | ||
|
||
# Verify installation | ||
node --version | ||
npm --version | ||
} | ||
|
||
# Check if NPM is installed | ||
if ! command_exists npm; then | ||
install_nvm_and_node | ||
fi | ||
|
||
|
||
# Install bbup globally | ||
echo "Installing bbup..." | ||
npm install -g bbup | ||
|
||
echo "Installation complete. You can now use the 'bbup' command." | ||
echo "Please restart your terminal or run 'source ~/.bashrc' (or your shell's equivalent) to start using bbup." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "bbup", | ||
"type": "module", | ||
"description": "Barretenberg installation script", | ||
"bin": "bbup.js", | ||
"version": "0.0.7", | ||
"license": "ISC", | ||
"scripts": { | ||
"start": "npx tsx bbup.ts", | ||
"compile": "tsc bbup.ts --esModuleInterop true --module nodenext && chmod +x bbup.js", | ||
"publish": "yarn compile && yarn npm publish --access public" | ||
}, | ||
"dependencies": { | ||
"@inquirer/input": "^1.2.16", | ||
"@inquirer/select": "^1.3.3", | ||
"axios": "^1.7.7", | ||
"commander": "^11.1.0", | ||
"log-symbols": "^7.0.0", | ||
"ora": "^8.1.0", | ||
"tar-fs": "^3.0.6", | ||
"tiged": "^2.12.6" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { execSync } from "child_process"; | ||
import logSymbols from "log-symbols"; | ||
import os from "os"; | ||
import axios from "axios"; | ||
import fs from "fs"; | ||
import { createGunzip } from "zlib"; | ||
import tar from "tar-fs"; | ||
import { promisify } from "util"; | ||
import { pipeline } from "stream"; | ||
import path from "path"; | ||
export function sourceShellConfig() { | ||
const shell = execSync("echo $SHELL", { encoding: "utf-8" }).trim(); | ||
if (shell.includes("bash")) { | ||
process.env.PATH = execSync("echo $PATH", { encoding: "utf-8" }).trim(); | ||
} | ||
else if (shell.includes("zsh")) { | ||
process.env.PATH = execSync('zsh -c "echo $PATH"', { | ||
encoding: "utf-8", | ||
}).trim(); | ||
} | ||
else if (shell.includes("fish")) { | ||
process.env.PATH = execSync('fish -c "echo $PATH"', { | ||
encoding: "utf-8", | ||
}).trim(); | ||
} | ||
} | ||
export function exec(cmd, options = {}) { | ||
return execSync(cmd, { | ||
encoding: "utf-8", | ||
stdio: "pipe", | ||
...options, | ||
}); | ||
} | ||
export async function installBB(version, spinner) { | ||
let architecture = os.arch(); | ||
if (architecture === "arm64") { | ||
architecture = "aarch64"; | ||
} | ||
else if (architecture === "x64") { | ||
architecture = "x86_64"; | ||
} | ||
let platform = os.platform(); | ||
if (platform === "darwin") { | ||
platform = "apple-darwin"; | ||
} | ||
else if (platform === "linux") { | ||
platform = "linux-gnu"; | ||
} | ||
const home = os.homedir(); | ||
const bbPath = path.join(home, ".bb"); | ||
spinner.start(`Installing to ${bbPath}`); | ||
const tempTarPath = path.join(fs.mkdtempSync("bb-"), "temp.tar.gz"); | ||
if (!["x86_64", "aarch64"].includes(architecture) || | ||
!["linux-gnu", "apple-darwin"].includes(platform)) { | ||
throw new Error(`Unsupported architecture ${architecture} and platform ${platform}`); | ||
} | ||
const releaseUrl = `https://github.com/AztecProtocol/aztec-packages/releases/download/aztec-packages-v${version}`; | ||
const binaryUrl = `${releaseUrl}/barretenberg-${architecture}-${platform}.tar.gz`; | ||
const response = await axios.get(binaryUrl, { responseType: "stream" }); | ||
const pipelineAsync = promisify(pipeline); | ||
await pipelineAsync(response.data, fs.createWriteStream(tempTarPath)); | ||
await pipelineAsync(fs.createReadStream(tempTarPath), createGunzip(), tar.extract(bbPath)); | ||
fs.rmSync(path.dirname(tempTarPath), { recursive: true }); | ||
spinner.stopAndPersist({ | ||
text: `Installed barretenberg to ${bbPath}`, | ||
symbol: logSymbols.success, | ||
}); | ||
} |
Oops, something went wrong.