-
Notifications
You must be signed in to change notification settings - Fork 600
chore(docs): rewriting bbup script, refactoring bb readme for clarity #9073
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cc70c4e
chore(docs): rewriting bbup script, refactoring bb readme for clarity
signorecello 24e5018
chore(docs): rewriting bbup script, refactoring bb readme for clarity
signorecello aa66695
addressing comments, thanks ludamad
signorecello 2a17443
ignoring .yarn
signorecello b868825
add -nv flag for noir versions, -v kept for barretenberg versions
signorecello 2d99617
Update barretenberg/README.md
signorecello de17c23
Apply suggestions from code review
signorecello 5c8964c
Update barretenberg/bbup/README.md
signorecello 046900f
adding zac's proper banner for bb
signorecello File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||
|
|
||
signorecello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ### 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 | ||
| ``` | ||
signorecello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
signorecello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 hidden or 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(); |
signorecello marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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>", | ||
signorecello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "The Barretenberg version to install" | ||
| ).implies({ noirVersion: null }) | ||
| ) | ||
| .addOption( | ||
| new Option( | ||
| "-nv, --noir-version <version>", | ||
signorecello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "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+)/ | ||
signorecello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| )![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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.