From cc25b0ffa853b885357f11d1ff335e8895f990f3 Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Wed, 1 Nov 2023 18:04:41 +0000 Subject: [PATCH] chore: remove noir-version.json --- README.md | 3 +- build_manifest.yml | 1 - docs/README.md | 55 ++++++++-------- docs/docusaurus.config.js | 16 +++-- docs/src/preprocess/include_version.js | 16 +++-- yarn-project/cli/src/unbox.ts | 20 +++--- yarn-project/noir-contracts/bootstrap.sh | 16 +---- yarn-project/noir-contracts/scripts/catch.sh | 19 ------ .../noir-contracts/scripts/install_noir.sh | 8 --- .../noir-contracts/scripts/install_noirup.sh | 22 ------- .../noir-contracts/scripts/nargo_check.sh | 20 ------ .../noir-contracts/scripts/nargo_test.sh | 62 ------------------- .../noir-contracts/scripts/nargo_test_ci.sh | 5 -- 13 files changed, 62 insertions(+), 201 deletions(-) delete mode 100644 yarn-project/noir-contracts/scripts/catch.sh delete mode 100755 yarn-project/noir-contracts/scripts/install_noir.sh delete mode 100755 yarn-project/noir-contracts/scripts/install_noirup.sh delete mode 100644 yarn-project/noir-contracts/scripts/nargo_check.sh delete mode 100755 yarn-project/noir-contracts/scripts/nargo_test.sh delete mode 100755 yarn-project/noir-contracts/scripts/nargo_test_ci.sh diff --git a/README.md b/README.md index bf141bfea78a..76476b4685ce 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,7 @@ To build the C++ code, follow the [instructions in the circuits subdirectory](./ To build Typescript code, make sure to have [`nvm`](https://github.com/nvm-sh/nvm) (node version manager) installed. -To build noir code, make sure that you are using the version from `yarn-project/noir-compiler/src/noir-version.json`. -Install nargo by running `noirup -v TAG_FROM_THE_FILE`. +To build noir code, use `yarn-project/noir-compiler`. ## Continuous Integration diff --git a/build_manifest.yml b/build_manifest.yml index 4c2bb8e7e225..34ef1dd68ec1 100644 --- a/build_manifest.yml +++ b/build_manifest.yml @@ -188,7 +188,6 @@ docs: - ^.*.cpp$ - ^.*.ts$ - ^.release-please-manifest.json$ - - ^.*/noir-version.json$ - ^.*.nr$ dependencies: - yarn-project diff --git a/docs/README.md b/docs/README.md index d07cc7f39814..555ecfd15435 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,4 +1,3 @@ - # Aztec Network Documentation Documentation for the Aztec Network, built with docusaurus @@ -58,37 +57,37 @@ $ yarn build This command generates static content into the `build` directory and can be served using any static contents hosting service. When run on Netlify, it will also build the typescript projects needed for extracting type information via typedoc. - ## Macros ### `#include_code` You can embed code snippets into a `.md`/`.mdx` file from code which lives elsewhere in the repo. + - In your markdown file: - - `#include_code identifier path/from/repo/root/to/file.ts language` - - E.g. `#include_code hello path/from/repo/root/to/file.ts typescript` - - See [here](docusaurus.config.js) for supported languages and the exact name to use for that language. + - `#include_code identifier path/from/repo/root/to/file.ts language` + - E.g. `#include_code hello path/from/repo/root/to/file.ts typescript` + - See [here](docusaurus.config.js) for supported languages and the exact name to use for that language. - In the corresponding code delineate the code snippet with comments: - - ```typescript - some code - some code - // docs:start:hello - more code - more code - // this-will-error <-- you can use docusaurus highlighting comments. - this code will be highlighted red - more code - // highlight-next-line - this line will be highlighted - more code - // highlight-start - this line will be highlighted - this line will be highlighted - // highlight-end - more code - // docs:end:hello - more code - ``` + - ```typescript + some code + some code + // docs:start:hello + more code + more code + // this-will-error <-- you can use docusaurus highlighting comments. + this code will be highlighted red + more code + // highlight-next-line + this line will be highlighted + more code + // highlight-start + this line will be highlighted + this line will be highlighted + // highlight-end + more code + // docs:end:hello + more code + ``` - You can even include chunks of the same piece of code (with different highlighting preferences) into different parts of the docs: - ```typescript some code @@ -112,7 +111,7 @@ You can embed code snippets into a `.md`/`.mdx` file from code which lives elsew // docs:end:hello some code some code - ``` + ``` - Somewhere in your markdown, you can then write: - `#include_code hello path/from/repo/root/to/file.ts typescript` - And somewhere else, you can write: @@ -134,9 +133,9 @@ import { AztecPackagesVersion } from "@site/src/components/Version"; <>{AztecPackagesVersion()} ``` - ### `#include_noir_version` +### `#include_noir_version` -This macros will be replaced inline with the required nargo version, which is `0.11.1-aztec.0` at the time of these writing. This value is sourced from `yarn-project/noir-compiler/src/noir-version.json`. +This macros will be replaced inline with the required nargo version, which is `0.18.0-a098541.aztec` at the time of these writing. This value is sourced from `yarn-project/noir-compiler/package.json`. Alternatively, you can also use the `NoirVersion()` js function, which you need to import explicitly: diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index 945bcc5ccf5d..23b99fdea8c5 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -82,13 +82,17 @@ const config = { name: "load-versions", async loadContent() { try { - const noirVersionPath = path.resolve( - __dirname, - "../yarn-project/noir-compiler/src/noir-version.json" + const noirCompilerPackage = JSON.parse( + fs.readFileSync( + path.resolve( + __dirname, + "../yarn-project/noir-compiler/package.json" + ), + "utf-8" + ) ); - const noirVersion = JSON.parse( - fs.readFileSync(noirVersionPath).toString() - ).tag; + const noirVersion = + noirCompilerPackage.dependencies["@noir-lang/noir_wasm"]; const aztecVersionPath = path.resolve( __dirname, "../.release-please-manifest.json" diff --git a/docs/src/preprocess/include_version.js b/docs/src/preprocess/include_version.js index afa372e0a047..601a62903a52 100644 --- a/docs/src/preprocess/include_version.js +++ b/docs/src/preprocess/include_version.js @@ -7,13 +7,17 @@ let versions; async function getVersions() { if (!versions) { try { - const noirVersionPath = path.resolve( - __dirname, - "../../../yarn-project/noir-compiler/src/noir-version.json" + const noirCompilerPackage = JSON.parse( + fs.readFileSync( + path.resolve( + __dirname, + "../../../yarn-project/noir-compiler/package.json" + ), + "utf-8" + ) ); - const noirVersion = JSON.parse( - fs.readFileSync(noirVersionPath).toString() - ).tag; + const noirVersion = + noirCompilerPackage.dependencies["@noir-lang/noir_wasm"]; const aztecVersionPath = path.resolve( __dirname, "../../../.release-please-manifest.json" diff --git a/yarn-project/cli/src/unbox.ts b/yarn-project/cli/src/unbox.ts index 07fcdd21983c..b8f33e788da3 100644 --- a/yarn-project/cli/src/unbox.ts +++ b/yarn-project/cli/src/unbox.ts @@ -13,6 +13,7 @@ import { promises as fs } from 'fs'; import JSZip from 'jszip'; import fetch from 'node-fetch'; import * as path from 'path'; +import { coerce } from 'semver'; const GITHUB_OWNER = 'AztecProtocol'; const GITHUB_REPO = 'aztec-packages'; @@ -68,7 +69,7 @@ async function copyFolderFromGithub(data: JSZip, repositoryFolderPath: string, l * @param repositoryFile - path of the file to copy from github repo * @param localOutputPath - local path to copy the file to */ -async function copyFileFromGithub(data: JSZip, repositoryFile: string, localOutputPath: string, log: LogFn) { +async function readFileFromGithub(data: JSZip, repositoryFile: string, log: LogFn): Promise { log(`Downloading file from github: ${repositoryFile}`); const file = data.files[repositoryFile]; @@ -77,11 +78,7 @@ async function copyFileFromGithub(data: JSZip, repositoryFile: string, localOutp throw new Error(`File not found or it's a directory: ${repositoryFile}`); } - const filename = path.basename(repositoryFile); - const targetPath = `${localOutputPath}/${filename}`; - - const content = await file.async('nodebuffer'); - await fs.writeFile(targetPath, content); + return await file.async('nodebuffer'); } /** @@ -120,10 +117,17 @@ async function downloadContractAndBoxFromGithub( await copyFolderFromGithub(data, boxPath, outputPath, log); // the expected noir version is contained in - // aztec-packages/yarn-project/noir-compiler/src/noir-version.json + // aztec-packages/yarn-project/noir-compiler/package.json // copy it in and use to update the package.json script to install that version of noir const noirVersionPath = `${repoDirectoryPrefix}/yarn-project/noir-compiler/src/noir-version.json`; - await copyFileFromGithub(data, noirVersionPath, outputPath, log); + const pkg = await readFileFromGithub(data, noirVersionPath, log); + const noirWasmVersion = coerce(JSON.parse(pkg.toString()).dependencies['@noir-lang/noir_wasm']); + await fs.writeFile( + path.join(outputPath, 'noir-version.json'), + JSON.stringify({ + tag: `v${noirWasmVersion?.major}.${noirWasmVersion?.minor}.${noirWasmVersion?.patch}-aztec.0`, + }), + ); const contractTargetDirectory = path.join(outputPath, 'src', 'contracts'); const boxContainsNoirSource = await isDirectoryNonEmpty(contractTargetDirectory); diff --git a/yarn-project/noir-contracts/bootstrap.sh b/yarn-project/noir-contracts/bootstrap.sh index 1077490d138c..43284ba2a798 100755 --- a/yarn-project/noir-contracts/bootstrap.sh +++ b/yarn-project/noir-contracts/bootstrap.sh @@ -1,15 +1,3 @@ -#!/bin/bash +#!/usr/bin/env bash -# Install noir if it is not installed already -if ! command -v noirup &> /dev/null -then - echo "Installing noir" - source ./scripts/install_noirup.sh -fi - -# Update noir -./scripts/install_noir.sh - -# Use yarn script to compile and create types -yarn -yarn noir:build:all \ No newline at end of file +yarn noir:build:all diff --git a/yarn-project/noir-contracts/scripts/catch.sh b/yarn-project/noir-contracts/scripts/catch.sh deleted file mode 100644 index 8a0a894b93ff..000000000000 --- a/yarn-project/noir-contracts/scripts/catch.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# Handler for SIGCHLD, cleanup if child exit with error, used by nargo_test.sh and compile.sh -handle_sigchld() { - for pid in "${pids[@]}"; do - # If process is no longer running - if ! kill -0 "$pid" 2>/dev/null; then - # Wait for the process and get exit status - wait "$pid" - status=$? - - # If exit status is error - if [ $status -ne 0 ]; then - # Create error file - touch "$error_file" - fi - fi - done -} \ No newline at end of file diff --git a/yarn-project/noir-contracts/scripts/install_noir.sh b/yarn-project/noir-contracts/scripts/install_noir.sh deleted file mode 100755 index 325e9a56620d..000000000000 --- a/yarn-project/noir-contracts/scripts/install_noir.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# Script to install noirup and the latest aztec nargo -set -eu - -VERSION="${VERSION:-$(jq -r '.tag' ../noir-compiler/src/noir-version.json)}" - -# Install nargo -noirup -v $VERSION diff --git a/yarn-project/noir-contracts/scripts/install_noirup.sh b/yarn-project/noir-contracts/scripts/install_noirup.sh deleted file mode 100755 index 11ba9b15d312..000000000000 --- a/yarn-project/noir-contracts/scripts/install_noirup.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# Script to install noirup and the latest nargo -set -eu - -SPECIFIED_HOME=${1:-$HOME} - -export NARGO_HOME="$SPECIFIED_HOME/.nargo" -NARGO_BIN_DIR="$NARGO_HOME/bin" -BIN_URL="https://raw.githubusercontent.com/noir-lang/noirup/master/noirup" -BIN_PATH="$NARGO_BIN_DIR/noirup" -NARGO_MAN_DIR="$NARGO_HOME/share/man/man1" - -# Clean -rm -rf $NARGO_HOME - -# Install noirup. -mkdir -p $NARGO_BIN_DIR -mkdir -p $NARGO_MAN_DIR - -curl -# -Ls $BIN_URL -o $BIN_PATH -chmod +x $BIN_PATH -export PATH=$NARGO_BIN_DIR:$PATH diff --git a/yarn-project/noir-contracts/scripts/nargo_check.sh b/yarn-project/noir-contracts/scripts/nargo_check.sh deleted file mode 100644 index 10d9d14c2c1b..000000000000 --- a/yarn-project/noir-contracts/scripts/nargo_check.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -# Check nargo version matches the expected one -nargo_check() { - echo "Using $(nargo --version)" - EXPECTED_VERSION=$(jq -r '.commit' ../noir-compiler/src/noir-version.json) - FOUND_VERSION=$(nargo --version | grep -o 'git version hash: [0-9a-f]*' | cut -d' ' -f4) - if [ "$EXPECTED_VERSION" != "$FOUND_VERSION" ]; then - echo "Expected nargo version $EXPECTED_VERSION but found version $FOUND_VERSION. Aborting." - - # Get the directory of the script and the parent directory, where its meant to be run - SCRIPT_DIR="$(dirname "$(realpath "$0")")" - PARENT_DIR="$(dirname "$SCRIPT_DIR")" - - # bootstrap.sh calls this non-interactively, so we can't just ask for confirmation to autorun this script. - echo "To fix the version issue, you can run the following command:" - echo "cd $PARENT_DIR && scripts/install_noir.sh" - exit 1 - fi -} diff --git a/yarn-project/noir-contracts/scripts/nargo_test.sh b/yarn-project/noir-contracts/scripts/nargo_test.sh deleted file mode 100755 index 8468c19f4928..000000000000 --- a/yarn-project/noir-contracts/scripts/nargo_test.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -# Tests noir contracts, if multiple are provided, then they are testing in parallel, bubbling any testing errors -# -# Usage: -# If testing a single contract: -# ./scripts/test.sh CONTRACT -# If testing multiple contracts: -# ./scripts/test.sh CONTRACT ... -# If testing a library: -# ./scripts/test.sh LIB -# If testing multiple libraries: -# ./scripts/test.sh LIB ... - -source ./scripts/catch.sh - -ROOT=$(pwd) - -# Get the project type from the first argument -PROJECT_TYPE=$1 -shift - -# Error flag file -error_file="/tmp/error.$$" -# Array of child PIDs -pids=() - -# Set SIGCHLD handler -trap handle_sigchld SIGCHLD # Trap any ERR signal and call the custom error handler - -test() { - PROJECT_NAME=$1 - - if [ "$PROJECT_TYPE" == "CONTRACT" ]; then - CONTRACT_FOLDER="${PROJECT_NAME}_contract" - echo "Testing contract $PROJECT_NAME..." - cd src/contracts/$CONTRACT_FOLDER - nargo test --package ${PROJECT_NAME}_contract - else - echo "Testing library $PROJECT_NAME..." - cd ../aztec-nr/$PROJECT_NAME - nargo test - fi -} - -echo "Using $(nargo --version)" - -# Build contracts -for PROJECT_NAME in "$@"; do - test $PROJECT_NAME & - pids+=($!) -done - -# Wait for all background processes to finish -wait - -# If error file exists, exit with error -if [ -f "$error_file" ]; then - rm "$error_file" - echo "Error occurred in one or more child processes. Exiting..." - exit 1 -fi diff --git a/yarn-project/noir-contracts/scripts/nargo_test_ci.sh b/yarn-project/noir-contracts/scripts/nargo_test_ci.sh deleted file mode 100755 index 5a4458d4da50..000000000000 --- a/yarn-project/noir-contracts/scripts/nargo_test_ci.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# Runs tests scripts for all contracts, then for all libraries. -./scripts/nargo_test.sh CONTRACT $(./scripts/get_all_contracts.sh) -./scripts/nargo_test.sh LIB $(./scripts/get_all_libraries.sh) \ No newline at end of file