From 7361302b0b06bc218d287da56cabd7f567cd6aa3 Mon Sep 17 00:00:00 2001 From: josh crites Date: Mon, 11 Sep 2023 09:39:33 -0400 Subject: [PATCH 1/8] fix: Add homepage url to aztec.js package.json (#2196) Add https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/aztec.js as the homepage url for aztec.js. # Checklist: Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge. - [ ] If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag. - [x] I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code. - [x] Every change is related to the PR description. - [ ] I have [linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) this pull request to relevant issues (if any exist). --- yarn-project/aztec.js/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/yarn-project/aztec.js/package.json b/yarn-project/aztec.js/package.json index 956b48c4183f..82c44fe8aaef 100644 --- a/yarn-project/aztec.js/package.json +++ b/yarn-project/aztec.js/package.json @@ -1,5 +1,6 @@ { "name": "@aztec/aztec.js", + "homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/aztec.js", "version": "0.1.0", "type": "module", "exports": { From 55d1674cca9e512c0bc9f6fc09df3cb5a1899772 Mon Sep 17 00:00:00 2001 From: Aztec Bot <49558828+AztecBot@users.noreply.github.com> Date: Mon, 11 Sep 2023 09:55:48 -0400 Subject: [PATCH 2/8] chore(master): Release 0.6.7 (#2174) :robot: I have created a release *beep* *boop* ---
aztec-packages: 0.6.7 ## [0.6.7](https://github.com/AztecProtocol/aztec-packages/compare/aztec-packages-v0.6.6...aztec-packages-v0.6.7) (2023-09-11) ### Bug Fixes * Use Github Bot token for dispatch workflow ([#2171](https://github.com/AztecProtocol/aztec-packages/issues/2171)) ([e6af616](https://github.com/AztecProtocol/aztec-packages/commit/e6af6164095a706109a6f61ef7e1196de67716dc))
barretenberg.js: 0.6.7 ## [0.6.7](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg.js-v0.6.6...barretenberg.js-v0.6.7) (2023-09-11) ### Miscellaneous * **barretenberg.js:** Synchronize aztec-packages versions
barretenberg: 0.6.7 ## [0.6.7](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.6.6...barretenberg-v0.6.7) (2023-09-11) ### Miscellaneous * **barretenberg:** Synchronize aztec-packages versions
--- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- .release-please-manifest.json | 6 +++--- CHANGELOG.md | 14 ++++++++++++++ VERSION | 2 +- circuits/cpp/barretenberg/CHANGELOG.md | 7 +++++++ circuits/cpp/barretenberg/VERSION | 2 +- circuits/cpp/barretenberg/barretenberg-wasm.nix | 2 +- circuits/cpp/barretenberg/barretenberg.nix | 2 +- circuits/cpp/barretenberg/cpp/CMakeLists.txt | 2 +- circuits/cpp/barretenberg/ts/CHANGELOG.md | 7 +++++++ circuits/cpp/barretenberg/ts/package.json | 2 +- 10 files changed, 37 insertions(+), 9 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 51102ba96949..bb18cd9a1d3e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,5 +1,5 @@ { - ".": "0.6.6", - "circuits/cpp/barretenberg": "0.6.6", - "circuits/cpp/barretenberg/ts": "0.6.6" + ".": "0.6.7", + "circuits/cpp/barretenberg": "0.6.7", + "circuits/cpp/barretenberg/ts": "0.6.7" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a1c4a5b52cf..4192d1e02d91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## [0.6.7](https://github.com/AztecProtocol/aztec-packages/compare/aztec-packages-v0.6.6...aztec-packages-v0.6.7) (2023-09-11) + + +### Features + +* Testing commands in CLI docs ([#2119](https://github.com/AztecProtocol/aztec-packages/issues/2119)) ([73328db](https://github.com/AztecProtocol/aztec-packages/commit/73328dbe4e509235329e32ff88f823d849a2b673)) + + +### Bug Fixes + +* Add homepage url to aztec.js package.json ([#2196](https://github.com/AztecProtocol/aztec-packages/issues/2196)) ([7361302](https://github.com/AztecProtocol/aztec-packages/commit/7361302b0b06bc218d287da56cabd7f567cd6aa3)) +* **ci:** Add install backend step in noir rebuild ([#2182](https://github.com/AztecProtocol/aztec-packages/issues/2182)) ([27b8bed](https://github.com/AztecProtocol/aztec-packages/commit/27b8bed05fea4f44f36894739613b07cdb8089ac)) +* Use Github Bot token for dispatch workflow ([#2171](https://github.com/AztecProtocol/aztec-packages/issues/2171)) ([e6af616](https://github.com/AztecProtocol/aztec-packages/commit/e6af6164095a706109a6f61ef7e1196de67716dc)) + ## [0.6.6](https://github.com/AztecProtocol/aztec-packages/compare/aztec-packages-v0.6.5...aztec-packages-v0.6.6) (2023-09-11) diff --git a/VERSION b/VERSION index fe152d6af843..9502cd8069c1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.6.6 x-release-please-version +v0.6.7 x-release-please-version diff --git a/circuits/cpp/barretenberg/CHANGELOG.md b/circuits/cpp/barretenberg/CHANGELOG.md index 412af9b65a96..c982314138c5 100644 --- a/circuits/cpp/barretenberg/CHANGELOG.md +++ b/circuits/cpp/barretenberg/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.6.7](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.6.6...barretenberg-v0.6.7) (2023-09-11) + + +### Miscellaneous + +* **barretenberg:** Synchronize aztec-packages versions + ## [0.6.6](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.6.5...barretenberg-v0.6.6) (2023-09-11) diff --git a/circuits/cpp/barretenberg/VERSION b/circuits/cpp/barretenberg/VERSION index fe152d6af843..9502cd8069c1 100644 --- a/circuits/cpp/barretenberg/VERSION +++ b/circuits/cpp/barretenberg/VERSION @@ -1 +1 @@ -v0.6.6 x-release-please-version +v0.6.7 x-release-please-version diff --git a/circuits/cpp/barretenberg/barretenberg-wasm.nix b/circuits/cpp/barretenberg/barretenberg-wasm.nix index 7ebdaec86e9b..b77203afb968 100644 --- a/circuits/cpp/barretenberg/barretenberg-wasm.nix +++ b/circuits/cpp/barretenberg/barretenberg-wasm.nix @@ -6,7 +6,7 @@ in stdenv.mkDerivation { pname = "barretenberg.wasm"; - version = "0.6.6"; # x-release-please-version + version = "0.6.7"; # x-release-please-version src = ./cpp; diff --git a/circuits/cpp/barretenberg/barretenberg.nix b/circuits/cpp/barretenberg/barretenberg.nix index f82fa08b2068..2f44f94812d3 100644 --- a/circuits/cpp/barretenberg/barretenberg.nix +++ b/circuits/cpp/barretenberg/barretenberg.nix @@ -14,7 +14,7 @@ in buildEnv.mkDerivation { pname = "libbarretenberg"; - version = "0.6.6"; # x-release-please-version + version = "0.6.7"; # x-release-please-version src = ./cpp; diff --git a/circuits/cpp/barretenberg/cpp/CMakeLists.txt b/circuits/cpp/barretenberg/cpp/CMakeLists.txt index f1825eea176a..7d32cfff0964 100644 --- a/circuits/cpp/barretenberg/cpp/CMakeLists.txt +++ b/circuits/cpp/barretenberg/cpp/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.24) project( Barretenberg DESCRIPTION "BN254 elliptic curve library, and PLONK SNARK prover" - VERSION 0.6.6 # x-release-please-version + VERSION 0.6.7 # x-release-please-version LANGUAGES CXX C ) diff --git a/circuits/cpp/barretenberg/ts/CHANGELOG.md b/circuits/cpp/barretenberg/ts/CHANGELOG.md index b224fc4d3534..1dcbdc136f6f 100644 --- a/circuits/cpp/barretenberg/ts/CHANGELOG.md +++ b/circuits/cpp/barretenberg/ts/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.6.7](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg.js-v0.6.6...barretenberg.js-v0.6.7) (2023-09-11) + + +### Miscellaneous + +* **barretenberg.js:** Synchronize aztec-packages versions + ## [0.6.6](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg.js-v0.6.5...barretenberg.js-v0.6.6) (2023-09-11) diff --git a/circuits/cpp/barretenberg/ts/package.json b/circuits/cpp/barretenberg/ts/package.json index 3b10a1613c81..31c190ac4f23 100644 --- a/circuits/cpp/barretenberg/ts/package.json +++ b/circuits/cpp/barretenberg/ts/package.json @@ -1,6 +1,6 @@ { "name": "@aztec/bb.js", - "version": "0.6.6", + "version": "0.6.7", "homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/circuits/cpp/barretenberg/ts", "license": "MIT", "type": "module", From 48e5bc54063595a01f60acf1d556a0b4a2c16dff Mon Sep 17 00:00:00 2001 From: AztecBot Date: Mon, 11 Sep 2023 13:56:41 +0000 Subject: [PATCH 3/8] git subrepo push --branch=master circuits/cpp/barretenberg subrepo: subdir: "circuits/cpp/barretenberg" merged: "1763e4db6" upstream: origin: "https://github.com/AztecProtocol/barretenberg" branch: "master" commit: "1763e4db6" git-subrepo: version: "0.4.6" origin: "???" commit: "???" --- circuits/cpp/barretenberg/.gitrepo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/circuits/cpp/barretenberg/.gitrepo b/circuits/cpp/barretenberg/.gitrepo index 46ee2fd938ea..635cbc895892 100644 --- a/circuits/cpp/barretenberg/.gitrepo +++ b/circuits/cpp/barretenberg/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/AztecProtocol/barretenberg branch = master - commit = 4a9f5cc359b5416861c495a5245e089fcf17b3c4 - parent = 4318b62128b59e867d488a35613b81e5f4e9172c + commit = 1763e4db69817d19da5f82828c55ca71cbf19074 + parent = 55d1674cca9e512c0bc9f6fc09df3cb5a1899772 method = merge cmdver = 0.4.6 From cca55f225f7277cfb44b44e4d1f50d5527afdb8b Mon Sep 17 00:00:00 2001 From: Maddiaa <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 11 Sep 2023 16:13:13 +0200 Subject: [PATCH 4/8] feat(ci): Run nargo test in ci on all packages (#2197) fixes: https://github.com/AztecProtocol/aztec-packages/issues/1982 Runs nargo test on all contracts and libraries in ci --- yarn-project/noir-contracts/Dockerfile.build | 1 + .../scripts/get_all_libraries.sh | 3 + .../noir-contracts/scripts/nargo_test.sh | 78 +++++++++++++++++++ .../noir-contracts/scripts/nargo_test_ci.sh | 7 ++ 4 files changed, 89 insertions(+) create mode 100755 yarn-project/noir-contracts/scripts/get_all_libraries.sh create mode 100755 yarn-project/noir-contracts/scripts/nargo_test.sh create mode 100755 yarn-project/noir-contracts/scripts/nargo_test_ci.sh diff --git a/yarn-project/noir-contracts/Dockerfile.build b/yarn-project/noir-contracts/Dockerfile.build index b946f891009b..d82539127fa5 100644 --- a/yarn-project/noir-contracts/Dockerfile.build +++ b/yarn-project/noir-contracts/Dockerfile.build @@ -21,3 +21,4 @@ ENV PATH="/usr/src/yarn-project/noir-contracts/.nargo/bin:${PATH}" RUN ./scripts/install_noir.sh RUN ./scripts/install_noir_backend.sh RUN ./scripts/compile_ci.sh +RUN ./scripts/nargo_test_ci.sh diff --git a/yarn-project/noir-contracts/scripts/get_all_libraries.sh b/yarn-project/noir-contracts/scripts/get_all_libraries.sh new file mode 100755 index 000000000000..e1aa684e3faf --- /dev/null +++ b/yarn-project/noir-contracts/scripts/get_all_libraries.sh @@ -0,0 +1,3 @@ +#!/bin/bash +# Utility to get the names of all noir libaries located in ../noir-libs +echo $(ls -d ../noir-libs/*/Nargo.toml | sed -r "s/..\\/noir-libs\\/(.+)\\/Nargo.toml/\\1/") \ No newline at end of file diff --git a/yarn-project/noir-contracts/scripts/nargo_test.sh b/yarn-project/noir-contracts/scripts/nargo_test.sh new file mode 100755 index 000000000000..5c90fef4d20f --- /dev/null +++ b/yarn-project/noir-contracts/scripts/nargo_test.sh @@ -0,0 +1,78 @@ +#!/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 ... + +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=() + +# Handler for SIGCHLD, cleanup if child exit with error +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 +} + +# 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 + else + echo "Testing library $PROJECT_NAME..." + cd ../noir-libs/$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 new file mode 100755 index 000000000000..103e92c18b8c --- /dev/null +++ b/yarn-project/noir-contracts/scripts/nargo_test_ci.sh @@ -0,0 +1,7 @@ + +#!/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 From 573dbc20a2b5ebae0e967e320da75febd5361eaf Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Mon, 11 Sep 2023 11:14:12 -0300 Subject: [PATCH 5/8] docs: Dapp tutorial (#2109) Tutorial on building a dapp. I went for the simplest possible options in order to focus on aztec.js usage and avoid the need for other prior knowledge: I used javascript instead of typescript, and set up a console app instead of a web one. Does not include anything on account creation since that is not a dapp concern but a wallet's responsibility. Pending: - [x] Add links to the next section on each page of the tutorial - [x] Add a small page on testing (with a link to the longer testing guide) - [x] Run the code on the CI Fixes #2047 Fixes #2048 Fixes #2049 Fixes #2050 Fixes #2051 --- .circleci/config.yml | 13 ++ .../dapps/tutorials/contract_deployment.md | 110 +++++++++++++- .../dapps/tutorials/contract_interaction.md | 138 +++++++++++++++++- .../dapps/tutorials/creating_accounts.md | 3 - docs/docs/dev_docs/dapps/tutorials/main.md | 27 +++- .../dev_docs/dapps/tutorials/project_setup.md | 31 ++++ .../dev_docs/dapps/tutorials/rpc_server.md | 46 +++++- docs/docs/dev_docs/dapps/tutorials/testing.md | 59 ++++++++ docs/sidebars.js | 3 +- yarn-project/acir-simulator/package.json | 4 +- yarn-project/archiver/package.json | 4 +- yarn-project/aztec-node/package.json | 4 +- yarn-project/aztec-rpc/package.json | 4 +- yarn-project/aztec-sandbox/package.json | 4 +- yarn-project/aztec.js/package.json | 4 +- .../aztec.js/src/contract/contract.ts | 23 +++ yarn-project/aztec.js/src/sandbox/index.ts | 18 ++- yarn-project/aztec.js/src/utils/account.ts | 19 ++- yarn-project/circuits.js/package.json | 4 +- yarn-project/cli/package.json | 4 +- yarn-project/end-to-end/.gitignore | 1 + yarn-project/end-to-end/package.json | 4 +- .../src/guides/dapp_testing.test.ts | 17 +-- .../src/sample-dapp/ci/index.test.mjs | 13 ++ .../end-to-end/src/sample-dapp/connect.mjs | 16 ++ .../end-to-end/src/sample-dapp/contracts.mjs | 19 +++ .../end-to-end/src/sample-dapp/deploy.mjs | 38 +++++ .../end-to-end/src/sample-dapp/index.mjs | 103 +++++++++++++ .../end-to-end/src/sample-dapp/index.test.mjs | 25 ++++ yarn-project/ethereum/package.json | 4 +- yarn-project/foundation/package.json | 4 +- yarn-project/key-store/package.json | 4 +- yarn-project/merkle-tree/package.json | 4 +- yarn-project/noir-compiler/package.json | 4 +- yarn-project/noir-contracts/package.json | 4 +- .../private_token_contract/src/main.nr | 2 + .../public_token_contract/src/main.nr | 4 +- yarn-project/p2p-bootstrap/package.json | 4 +- yarn-project/p2p/package.json | 4 +- yarn-project/package.common.json | 4 +- yarn-project/prover-client/package.json | 4 +- yarn-project/rollup-provider/package.json | 4 +- yarn-project/sequencer-client/package.json | 4 +- yarn-project/types/package.json | 4 +- yarn-project/world-state/package.json | 4 +- 45 files changed, 739 insertions(+), 81 deletions(-) delete mode 100644 docs/docs/dev_docs/dapps/tutorials/creating_accounts.md create mode 100644 docs/docs/dev_docs/dapps/tutorials/project_setup.md create mode 100644 docs/docs/dev_docs/dapps/tutorials/testing.md create mode 100644 yarn-project/end-to-end/.gitignore create mode 100644 yarn-project/end-to-end/src/sample-dapp/ci/index.test.mjs create mode 100644 yarn-project/end-to-end/src/sample-dapp/connect.mjs create mode 100644 yarn-project/end-to-end/src/sample-dapp/contracts.mjs create mode 100644 yarn-project/end-to-end/src/sample-dapp/deploy.mjs create mode 100644 yarn-project/end-to-end/src/sample-dapp/index.mjs create mode 100644 yarn-project/end-to-end/src/sample-dapp/index.test.mjs diff --git a/.circleci/config.yml b/.circleci/config.yml index bd7238dad61d..e4afb837e09d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1002,6 +1002,17 @@ jobs: name: "Test" command: ./scripts/cond_run_script end-to-end $JOB_NAME ./scripts/run_tests_local guides/dapp_testing.test.ts ./scripts/docker-compose-e2e-sandbox.yml working_directory: yarn-project/end-to-end + + guides-sample-dapp: + machine: + image: ubuntu-2004:202010-01 + steps: + - *checkout + - *setup_env + - run: + name: "Test" + command: ./scripts/cond_run_script end-to-end $JOB_NAME ./scripts/run_tests_local sample-dapp ./scripts/docker-compose-e2e-sandbox.yml + working_directory: yarn-project/end-to-end e2e-canary-test: machine: @@ -1443,6 +1454,7 @@ workflows: - cli-docs-sandbox: *e2e_test - guides-writing-an-account-contract: *e2e_test - guides-dapp-testing: *e2e_test + - guides-sample-dapp: *e2e_test - e2e-end: requires: @@ -1476,6 +1488,7 @@ workflows: - cli-docs-sandbox - guides-writing-an-account-contract - guides-dapp-testing + - guides-sample-dapp <<: *defaults - deploy-dockerhub: diff --git a/docs/docs/dev_docs/dapps/tutorials/contract_deployment.md b/docs/docs/dev_docs/dapps/tutorials/contract_deployment.md index a2cc9d4f0441..9bbbbdc3669d 100644 --- a/docs/docs/dev_docs/dapps/tutorials/contract_deployment.md +++ b/docs/docs/dev_docs/dapps/tutorials/contract_deployment.md @@ -1,3 +1,107 @@ ---- -title: Contract Deployment ---- +# Contract Deployment + +To add contracts to your application, we'll start by creating a new `nargo` project. We'll then compile the contracts, and write a simple script to deploy them to our Sandbox. + +:::info +Follow the instructions [here](../../getting_started/noir_contracts.md) to install `nargo` if you haven't done so already. +::: + +## Initialise nargo project + +Create a new `contracts` folder, and from there, initialise a new project called `private_token`: + +```sh +mkdir contracts && cd contracts +nargo new --contract private_token +``` + +Then, open the `contracts/private_token/Nargo.toml` configuration file, and add the `aztec.nr` and `value_note` libraries as dependencies: + +```toml +[dependencies] +aztec = { git="https://github.com/AztecProtocol/aztec-packages", tag="master", directory="yarn-project/noir-libs/noir-aztec" } +value_note = { git="https://github.com/AztecProtocol/aztec-packages", tag="master", directory="yarn-project/noir-libs/value-note" } +``` + +Last, copy-paste the code from the `PrivateToken` contract into `contracts/private_token/main.nr`: + +#include_code all yarn-project/noir-contracts/src/contracts/private_token_contract/src/main.nr rust + +## Compile your contract + +We'll now use the [Aztec CLI](../../cli/main.md) to [compile](../../contracts/compiling.md) our project. If you haven't installed the CLI already, you can install it locally to your project running: + +```sh +yarn add -D @aztec/cli +``` + +Now run the following from your project root: + +```sh +yarn aztec-cli compile contracts/private_token +``` + +:::info +If you are using Typescript, consider including the `--typescript` option to [generate type-safe wrappers](../../contracts/compiling.md#typescript-interfaces) for your contracts. +::: + +This should have created an artifact `contracts/private_token/target/private_token-Main.json` with the interface and bytecode for your contract. + +## Adding a second contract + +For the purposes of this tutorial, we'll set up a second contract: a public token contract. Follow the same steps as above for initialising a new Nargo project, include the dependencies, and copy-paste the following code into `contracts/public_token/main.nr`: + +#include_code all yarn-project/noir-contracts/src/contracts/public_token_contract/src/main.nr rust + +Compile the contract with the CLI: + +```sh +yarn aztec-cli compile contracts/public_token +``` + +With both contracts ready, we'll now proceed to deployment. + +## Deploy your contracts + +Let's now write a script for deploying your contracts to the Sandbox. We'll create an RPC client, and then use the `ContractDeployer` class to deploy our contracts, and store the deployment address to a local JSON file. + +Create a new file `src/deploy.mjs`, importing the contract artifacts we have generated plus the dependencies we'll need, and with a call to a `main` function that we'll populate in a second: + +```js +// src/deploy.mjs +import { writeFileSync } from 'fs'; +import { createAztecRpcClient, ContractDeployer } from '@aztec/aztec.js'; +import PrivateTokenArtifact from '../contracts/private_token/target/PrivateToken.json' assert { type: 'json' }; +import PublicTokenArtifact from '../contracts/public_token/target/PublicToken.json' assert { type: 'json' }; + +async function main() { } + +main().catch(err => { + console.error(`Error in deployment script: ${err}`); + process.exit(1); +}); +``` + +Now we can deploy the contracts by adding the following code to the `src/deploy.mjs` file. Here, we are using the `ContractDeployer` class with the compiled artifact to send a new deployment transaction. The `wait` method will block execution until the transaction is successfully mined, and return a receipt with the deployed contract address. + +#include_code dapp-deploy yarn-project/end-to-end/src/sample-dapp/deploy.mjs javascript + +Note that the private token constructor expects an `owner` address to mint an initial set of tokens to. We are using the first account from the Sandbox for this. + +:::info +If you are using the generated typescript classes, you can drop the generic `ContractDeployer` in favor of using the `deploy` method of the generated class, which will automatically load the artifact for you and type-check the constructor arguments: + +```typescript +await PrivateToken.deploy(client, 100n, owner.address).send().wait(); +``` +::: + +Run the snippet above as `node src/deploy.mjs`, and you should see the following output, along with a new `addresses.json` file in your project root: + +```text +Private token deployed to 0x2950b0f290422ff86b8ee8b91af4417e1464ddfd9dda26de8af52dac9ea4f869 +Public token deployed to 0x2b54f68fd1e18f7dcfa71e3be3c91bb06ecbe727a28d609e964c225a4b5549c8 +``` +## Next steps + +Now that we have our contracts set up, it's time to actually [start writing our application that will be interacting with them](./contract_interaction.md). \ No newline at end of file diff --git a/docs/docs/dev_docs/dapps/tutorials/contract_interaction.md b/docs/docs/dev_docs/dapps/tutorials/contract_interaction.md index ba0febbcfb8b..108bbd69ae00 100644 --- a/docs/docs/dev_docs/dapps/tutorials/contract_interaction.md +++ b/docs/docs/dev_docs/dapps/tutorials/contract_interaction.md @@ -1,3 +1,135 @@ ---- -title: Contract Interactions ---- +# Contract interactions + +In this section, we'll write the logic in our app that will interact with the contract we have previously deployed. We'll be using the accounts already seeded in the Sandbox. + +## Showing user balance + +Let's start by showing our user balance for the private token across their accounts. To do this, we can leverage the `getBalance` [unconstrained](../../contracts/functions.md#unconstrained-functions) view function of the private token contract: + +#include_code getBalance yarn-project/noir-contracts/src/contracts/private_token_contract/src/main.nr rust + +:::info +Note that this function will only return a valid response for accounts registered in the RPC Server, since it requires access to the [user's private state](../../wallets/main.md#private-state). In other words, you cannot query the balance of another user for a private token contract. +::: + +To do this, let's first initialise a new `Contract` instance using `aztec.js` that represents our deployed token contracts. Create a new `src/contracts.mjs` file with the imports for our artifacts and other dependencies: + +```js +// src/contracts.mjs +import { Contract } from '@aztec/aztec.js'; +import { readFileSync } from 'fs'; +import PrivateTokenArtifact from '../contracts/private_token/target/PrivateToken.json' assert { type: 'json' }; +import PublicTokenArtifact from '../contracts/public_token/target/PublicToken.json' assert { type: 'json' }; +``` + +And then add the following code for initialising the `Contract` instances: + +#include_code get-tokens yarn-project/end-to-end/src/sample-dapp/contracts.mjs javascript + +:::info +You can use the typescript autogenerated interface instead of the generic `Contract` class to get type-safe methods. +::: + +We can now get the private token instance in our main code in `src/index.mjs`, and query the private balance for each of the user accounts. To query a function, without sending a transaction, use the `view` function of the method: + +#include_code showPrivateBalances yarn-project/end-to-end/src/sample-dapp/index.mjs javascript + +Run this as `node src/index.mjs` and you should now see the following output: + +``` +Balance of 0x0c8a6673d7676cc80aaebe7fa7504cf51daa90ba906861bfad70a58a98bf5a7d: 100 +Balance of 0x226f8087792beff8d5009eb94e65d2a4a505b70baf4a9f28d33c8d620b0ba972: 0 +Balance of 0x0e1f60e8566e2c6d32378bdcadb7c63696e853281be798c107266b8c3a88ea9b: 0 +``` + +## Transferring private tokens + +Now that we can see the balance for each user, let's transfer tokens from one account to another. To do this, we will first need access to a `Wallet` object. This wraps access to an RPC Server and also provides an interface to craft and sign transactions on behalf of one of the user accounts. + +We can initialise a wallet using one of the `getAccount` methods from `aztec.js``, along with the corresponding signing and encryption keys: + +```js +import { getSchnorrAccount } from '@aztec/aztec.js'; +const wallet = await getSchnorrAccount(client, ENCRYPTION_PRIVATE_KEY, SIGNING_PRIVATE_KEY).getWallet(); +``` + +For ease of use, `aztec.js` also ships with a helper `getSandboxAccountsWallets` method that returns a wallet for each of the pre-initialised accounts in the Sandbox, so you can send transactions as any of them. We'll use one of these wallets to initialise the `Contract` instance that represents our private token contract, so every transaction sent through it will be sent through that wallet. + +#include_code transferPrivateFunds yarn-project/end-to-end/src/sample-dapp/index.mjs javascript + +Let's go step-by-step on this snippet. We first get wallets for two of the Sandbox accounts, and name them `owner` and `recipient`. Then, we initialise the private token `Contract` instance using the `owner` wallet, meaning that any transactions sent through it will have the `owner` as sender. + +Next, we send a transfer transaction, moving 1 unit of balance to the `recipient` account address. This has no immediate effect, since the transaction first needs to be simulated locally and then submitted and mined. Only once this has finished we can query the balances again and see the effect of our transaction. We are using a `showPrivateBalances` helper function here which has the code we wrote in the section above. + +Run this new snippet and you should see the following: + +```text +Sent transfer transaction 16025a7c4f6c44611d7ac884a5c27037d85d9756a4924df6d97fb25f6e83a0c8 + +Balance of 0x0c8a6673d7676cc80aaebe7fa7504cf51daa90ba906861bfad70a58a98bf5a7d: 100 +Balance of 0x226f8087792beff8d5009eb94e65d2a4a505b70baf4a9f28d33c8d620b0ba972: 0 +Balance of 0x0e1f60e8566e2c6d32378bdcadb7c63696e853281be798c107266b8c3a88ea9b: 0 + +Awaiting transaction to be mined +Transaction has been mind on block 4 + +Balance of 0x0c8a6673d7676cc80aaebe7fa7504cf51daa90ba906861bfad70a58a98bf5a7d: 99 +Balance of 0x226f8087792beff8d5009eb94e65d2a4a505b70baf4a9f28d33c8d620b0ba972: 1 +Balance of 0x0e1f60e8566e2c6d32378bdcadb7c63696e853281be798c107266b8c3a88ea9b: 0 +``` + +:::info +At the time of this writing, there are no events emitted when new private notes are received, so the only way to detect of a change in a user's private balance is via polling on every new block processed. This will change in a future release. +::: + +## Working with public state + +While they are [fundamentally differently](../../../concepts/foundation/state_model.md), the API for working with private and public functions and state from `aztec.js` is equivalent. To query the balance in public tokens for our user accounts, we can just call the `publicBalanceOf` view function in the contract: + +#include_code showPublicBalances yarn-project/end-to-end/src/sample-dapp/index.mjs javascript + +:::info +Since this is a public token contract we are working with, we can now query the balance for any address, not just those registered in our local RPC Server. We can also send funds to addresses for which we don't know their [public encryption key](../../../concepts/foundation/accounts/keys.md#encryption-keys). +::: + +Here, since the public token contract does not mint any initial funds upon deployment, the balances for all of our user's accounts will be zero. But we can send a transaction to mint tokens to change this, using very similar code to the one for sending private funds: + +#include_code mintPublicFunds yarn-project/end-to-end/src/sample-dapp/index.mjs javascript + +And get the expected results: + +```text +Sent mint transaction 041d5b4cc68bcb5c6cb45cd4c79f893d94f0df0792f66e6fddd7718c049fe925 +Balance of 0x0c8a6673d7676cc80aaebe7fa7504cf51daa90ba906861bfad70a58a98bf5a7d: 0 +Balance of 0x226f8087792beff8d5009eb94e65d2a4a505b70baf4a9f28d33c8d620b0ba972: 0 +Balance of 0x0e1f60e8566e2c6d32378bdcadb7c63696e853281be798c107266b8c3a88ea9b: 0 + +Awaiting transaction to be mined +Transaction has been mined on block 5 + +Balance of 0x0c8a6673d7676cc80aaebe7fa7504cf51daa90ba906861bfad70a58a98bf5a7d: 100 +Balance of 0x226f8087792beff8d5009eb94e65d2a4a505b70baf4a9f28d33c8d620b0ba972: 0 +Balance of 0x0e1f60e8566e2c6d32378bdcadb7c63696e853281be798c107266b8c3a88ea9b: 0 +``` + +Public functions can emit [unencrypted public logs](../../contracts/events.md#unencrypted-events), which we can query via the RPC Server interface. In particular, the public token contract emits a generic `Coins minted` whenever the `mint` method is called: + +#include_code unencrypted_log yarn-project/noir-contracts/src/contracts/public_token_contract/src/main.nr rust + +We can extend our code by querying the logs emitted on the last block when the minting transaction is mined: + +#include_code showLogs yarn-project/end-to-end/src/sample-dapp/index.mjs javascript + +Running the code again would now show an extra line with: + +```text +Log: Coins minted +``` + +:::info +At the time of this writing, there is no event-based mechanism in the `aztec.js` library to subscribe to events. The only option to consume them is to poll on every new block detected. This will change in a future version. +::: + +## Next steps + +In the next and final section, we'll [set up automated tests for our application](./testing.md). \ No newline at end of file diff --git a/docs/docs/dev_docs/dapps/tutorials/creating_accounts.md b/docs/docs/dev_docs/dapps/tutorials/creating_accounts.md deleted file mode 100644 index 95e19162829c..000000000000 --- a/docs/docs/dev_docs/dapps/tutorials/creating_accounts.md +++ /dev/null @@ -1,3 +0,0 @@ ---- -title: Creating Accounts ---- diff --git a/docs/docs/dev_docs/dapps/tutorials/main.md b/docs/docs/dev_docs/dapps/tutorials/main.md index 957a8f9c10e4..1d5767599929 100644 --- a/docs/docs/dev_docs/dapps/tutorials/main.md +++ b/docs/docs/dev_docs/dapps/tutorials/main.md @@ -1,10 +1,25 @@ --- -title: Dapp Development Tutorials +title: Dapp Development Tutorial --- -Links to specific tutorials +In this tutorial we'll go through the steps for building a simple application that interacts with the Aztec Sandbox. We'll be building a console application using Javascript and NodeJS, but you may reuse the same concepts here for a web-based app. All Aztec libraries are written in Typescript and fully typed, so you can use Typescript instead of Javascript to make the most out of its type checker. -- Connecting to the RPC Server -- Creating Accounts -- Deploying a contract -- Contract Interactions +This tutorial will focus on environment setup, including creating accounts and deployments, as well as interacting with your contracts. It will not cover [how to write contracts in Noir](../../contracts/main.md). + +The full code for this tutorial is [available on the `aztec-packages` repository](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/end-to-end/src/sample-dapp). + +## Dependencies + +- Linux or OSX environment +- [NodeJS](https://nodejs.org/) 18 or higher +- [Aztec Sandbox](../../getting_started/sandbox.md) +- [Aztec CLI](../../getting_started/cli.md) +- [Nargo](../../getting_started/noir_contracts.md) for building contracts + +## Prerequisites + +Basic understanding of NodeJS and Javascript should be enough to follow this tutorial. Along the way, we'll provide links to dig deeper into Aztec concepts as we introduce them. + +## Get started + +Let's get started with [setting up a new javascript project](./project_setup.md). diff --git a/docs/docs/dev_docs/dapps/tutorials/project_setup.md b/docs/docs/dev_docs/dapps/tutorials/project_setup.md new file mode 100644 index 000000000000..51560dd45a55 --- /dev/null +++ b/docs/docs/dev_docs/dapps/tutorials/project_setup.md @@ -0,0 +1,31 @@ +# Setting up your project + +Let's start by setting up a regular Javascript NodeJS project. Feel free to skip this part if you're already familiar with project setup and head directly to connecting to the Sandbox. + +## Create a new project + +We'll use [`yarn`](https://yarnpkg.com/) for managing our project and dependencies, though you can also use `npm` or your Javascript package manager of choice. + +1. Ensure node version is 18 or more by running. + +```sh +node -v +``` + +2. Create a new folder and initialize a new project. + +```sh +mkdir sample-dapp +cd sample-dapp +yarn init -yp +``` + +3. Add the `aztec.js` library as a dependency: + +```sh +yarn add @aztec/aztec.js +``` + +## Next steps + +With your project already set up, let's [connect to the Sandbox RPC Server and grab an account to interact with it](./rpc_server.md). diff --git a/docs/docs/dev_docs/dapps/tutorials/rpc_server.md b/docs/docs/dev_docs/dapps/tutorials/rpc_server.md index 095f49b49ad1..0412ddf5fde4 100644 --- a/docs/docs/dev_docs/dapps/tutorials/rpc_server.md +++ b/docs/docs/dev_docs/dapps/tutorials/rpc_server.md @@ -1,3 +1,43 @@ ---- -title: Connecting to the RPC Server ---- +# Connecting to the RPC Server + +As an app developer, the [Aztec RPC Server interface](../api/aztec_rpc.md) provides you with access to the user's accounts and their private state, as well as a connection to the network for accessing public global state. + +During the Sandbox phase, this role is fulfilled by the [Aztec Sandbox](../../sandbox/main.md), which runs a local RPC Server and an Aztec Node, both connected to a local Ethereum development node like Anvil. The Sandbox also includes a set of pre-initialised accounts that you can use from your app. + +In this section, we'll connect to the Sandbox from our project. + +## Create RPC client + +We'll use the `createAztecRpcClient` function from `aztec.js` to connect to the Sandbox, which by default runs on `localhost:8080`. To test the connection works, we'll request and print the node's chain id. + +Let's create our first file `src/index.mjs` with the following contents: + +#include_code all yarn-project/end-to-end/src/sample-dapp/connect.mjs javascript + +Run this example as `node src/index.mjs` and you should see the following output: +``` +Connected to chain 31337 +``` + +:::info +Should the above fail due to a connection error, make sure the Sandbox is running locally and on port 8080. +::: + +## Load user accounts + +With our connection to the RPC server, let's try loading the accounts that are pre-initialised in the Sandbox: + +#include_code showAccounts yarn-project/end-to-end/src/sample-dapp/index.mjs javascript + +Run again the above, and we should see: + +``` +User accounts: +0x0c8a6673d7676cc80aaebe7fa7504cf51daa90ba906861bfad70a58a98bf5a7d +0x226f8087792beff8d5009eb94e65d2a4a505b70baf4a9f28d33c8d620b0ba972 +0x0e1f60e8566e2c6d32378bdcadb7c63696e853281be798c107266b8c3a88ea9b +``` + +## Next steps + +With a working connection to the RPC Server, let's now setup our application by [compiling and deploying our contracts](./contract_deployment.md). \ No newline at end of file diff --git a/docs/docs/dev_docs/dapps/tutorials/testing.md b/docs/docs/dev_docs/dapps/tutorials/testing.md new file mode 100644 index 000000000000..91eb3c74318b --- /dev/null +++ b/docs/docs/dev_docs/dapps/tutorials/testing.md @@ -0,0 +1,59 @@ +# Testing + +To wrap up this tutorial, we'll set up a simple automated test for our dapp contracts. We will be using [jest](https://jestjs.io/), but any nodejs test runner works fine. + +Here we'll only test the happy path for a `transfer` on our private token contract, but in a real application you should be testing both happy and unhappy paths, as well as both your contracts and application logic. Refer to the full [testing guide](../testing.md) for more info on testing and assertions. + +## Dependencies + +Start by installing our test runner, in this case jest: + +```sh +yarn add -D jest +``` + +We'll also be running our Sandbox within the test suite, to avoid polluting a global instance, so we'll need to install the Sandbox itself as a dependency as well: + +```sh +yarn add -D @aztec/aztec-sandbox +``` + +## Test setup + +Create a new file `src/index.test.mjs` with the imports we'll be using and an empty test suite to begin with: + +```ts +import { createSandbox } from '@aztec/aztec-sandbox'; +import { Contract, createAccount } from '@aztec/aztec.js'; +import PrivateTokenArtifact from '../contracts/private_token/target/PrivateToken.json' assert { type: 'json' }; + +describe('private token', () => { + +}); +``` + +Let's set up our test suite. We'll start [a new Sandbox instance within the test](../testing.md#running-sandbox-in-the-nodejs-process), create two fresh accounts to test with, and deploy an instance of our contract. The `aztec-sandbox` and `aztec.js` provide the helper functions we need to do this: + +#include_code setup yarn-project/end-to-end/src/sample-dapp/index.test.mjs javascript + +Note that, since we are starting a new Sandbox instance, we need to `stop` it in the test suite teardown. Also, even though the Sandbox runs within our tests, we still need a running Ethereum development node. Make sure you are running [Anvil](https://book.getfoundry.sh/anvil/), [Hardhat Network](https://hardhat.org/hardhat-network/docs/overview), or [Ganache](https://trufflesuite.com/ganache/) along with your tests. + +## Writing our test + +Now that we have a working test environment, we can write our first test for exercising the `transfer` function on the private token contract. We will use the same `aztec.js` methods we used when building our dapp: + +#include_code test yarn-project/end-to-end/src/sample-dapp/index.test.mjs javascript + +In this example, we assert that the `recipient`'s balance is increased by the amount transferred. We could also test that the `owner`'s funds are decremented by the same amount, or that a transaction that attempts to send more funds than those available would fail. Check out the [testing guide](../testing.md) for more ideas. + +## Running our tests + +With a local Ethereum development node running in port 8545, we can run our `jest` tests using `yarn`. The quirky syntax is due to [jest limitations in ESM support](https://jestjs.io/docs/ecmascript-modules), as well as not picking up `mjs` file by default: + +```sh +yarn node --experimental-vm-modules $(yarn bin jest) --testRegex '.*\.test\.mjs$' +``` + +## Next steps + +Now that you have finished the tutorial, you can dig deeper on the [APIs for dapp development](../api/main.md), learn more about [writing contracts with Noir](../../contracts/main.md), check out the [Sandbox's architecture](../../sandbox/main.md), or read about the [fundamental concepts behind Aztec Network](../../../concepts/foundation/main.md). \ No newline at end of file diff --git a/docs/sidebars.js b/docs/sidebars.js index 518d6afe2cc9..b45e933b025a 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -185,10 +185,11 @@ const sidebars = { id: "dev_docs/dapps/tutorials/main", }, items: [ + "dev_docs/dapps/tutorials/project_setup", "dev_docs/dapps/tutorials/rpc_server", - "dev_docs/dapps/tutorials/creating_accounts", "dev_docs/dapps/tutorials/contract_deployment", "dev_docs/dapps/tutorials/contract_interaction", + "dev_docs/dapps/tutorials/testing", ], }, ], diff --git a/yarn-project/acir-simulator/package.json b/yarn-project/acir-simulator/package.json index 1dd64c67eed7..8b0b06821c9d 100644 --- a/yarn-project/acir-simulator/package.json +++ b/yarn-project/acir-simulator/package.json @@ -26,9 +26,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "dependencies": { diff --git a/yarn-project/archiver/package.json b/yarn-project/archiver/package.json index e3168c13f1c8..4dbc4a5465eb 100644 --- a/yarn-project/archiver/package.json +++ b/yarn-project/archiver/package.json @@ -30,9 +30,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "dependencies": { diff --git a/yarn-project/aztec-node/package.json b/yarn-project/aztec-node/package.json index c9ebdf72c20c..ec5beb828633 100644 --- a/yarn-project/aztec-node/package.json +++ b/yarn-project/aztec-node/package.json @@ -27,9 +27,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "dependencies": { diff --git a/yarn-project/aztec-rpc/package.json b/yarn-project/aztec-rpc/package.json index 3f3eefc77dec..7ac8adacfc00 100644 --- a/yarn-project/aztec-rpc/package.json +++ b/yarn-project/aztec-rpc/package.json @@ -27,9 +27,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "dependencies": { diff --git a/yarn-project/aztec-sandbox/package.json b/yarn-project/aztec-sandbox/package.json index f565e533ef11..041da41d2965 100644 --- a/yarn-project/aztec-sandbox/package.json +++ b/yarn-project/aztec-sandbox/package.json @@ -64,9 +64,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "engines": { diff --git a/yarn-project/aztec.js/package.json b/yarn-project/aztec.js/package.json index 82c44fe8aaef..0a67c34d5b37 100644 --- a/yarn-project/aztec.js/package.json +++ b/yarn-project/aztec.js/package.json @@ -33,9 +33,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "dependencies": { diff --git a/yarn-project/aztec.js/src/contract/contract.ts b/yarn-project/aztec.js/src/contract/contract.ts index 5f0c0aff12c0..0c58f7d4e5db 100644 --- a/yarn-project/aztec.js/src/contract/contract.ts +++ b/yarn-project/aztec.js/src/contract/contract.ts @@ -1,7 +1,9 @@ import { ContractAbi } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; +import { PublicKey } from '@aztec/types'; import { Wallet } from '../aztec_rpc_client/wallet.js'; +import { DeployMethod, Point } from '../index.js'; import { ContractBase } from './contract_base.js'; /** @@ -26,4 +28,25 @@ export class Contract extends ContractBase { } return new Contract(extendedContractData.getCompleteAddress(), abi, wallet); } + + /** + * Creates a tx to deploy a new instance of a contract. + * @param wallet - The wallet for executing the deployment. + * @param abi - ABI of the contract to deploy. + * @param args - Arguments for the constructor. + */ + public static deploy(wallet: Wallet, abi: ContractAbi, args: any[]) { + return new DeployMethod(Point.ZERO, wallet, abi, args); + } + + /** + * Creates a tx to deploy a new instance of a contract using the specified public key to derive the address. + * @param publicKey - Public key for deriving the address. + * @param wallet - The wallet for executing the deployment. + * @param abi - ABI of the contract to deploy. + * @param args - Arguments for the constructor. + */ + public static deployWithPublicKey(publicKey: PublicKey, wallet: Wallet, abi: ContractAbi, args: any[]) { + return new DeployMethod(publicKey, wallet, abi, args); + } } diff --git a/yarn-project/aztec.js/src/sandbox/index.ts b/yarn-project/aztec.js/src/sandbox/index.ts index 814218c3a12d..3d023d0b485c 100644 --- a/yarn-project/aztec.js/src/sandbox/index.ts +++ b/yarn-project/aztec.js/src/sandbox/index.ts @@ -5,7 +5,14 @@ import { sleep } from '@aztec/foundation/sleep'; import zip from 'lodash.zip'; import SchnorrAccountContractAbi from '../abis/schnorr_account_contract.json' assert { type: 'json' }; -import { AccountWallet, AztecRPC, EntrypointWallet, getAccountWallets, getSchnorrAccount } from '../index.js'; +import { + AccountWallet, + AztecRPC, + EntrypointWallet, + createAztecRpcClient, + getAccountWallets, + getSchnorrAccount, +} from '../index.js'; export const INITIAL_SANDBOX_ENCRYPTION_KEYS = [ GrumpkinScalar.fromString('2153536ff6628eee01cf4024889ff977a18d9fa61d0e414422f7681cf085c281'), @@ -19,6 +26,8 @@ export const INITIAL_SANDBOX_SALTS = [Fr.ZERO, Fr.ZERO, Fr.ZERO]; export const INITIAL_SANDBOX_ACCOUNT_CONTRACT_ABI = SchnorrAccountContractAbi; +export const { SANDBOX_URL = 'http://localhost:8080' } = process.env; + /** * Gets a single wallet that manages all the Aztec accounts that are initially stored in the sandbox. * @param aztecRpc - An instance of the Aztec RPC interface. @@ -84,12 +93,13 @@ export async function deployInitialSandboxAccounts(aztecRpc: AztecRPC) { /** * Function to wait until the sandbox becomes ready for use. - * @param rpcServer - The rpc client connected to the sandbox. + * @param rpc - The rpc client connected to the sandbox. */ -export async function waitForSandbox(rpcServer: AztecRPC) { +export async function waitForSandbox(rpc?: AztecRPC) { + rpc = rpc ?? createAztecRpcClient(SANDBOX_URL); while (true) { try { - await rpcServer.getNodeInfo(); + await rpc.getNodeInfo(); break; } catch (err) { await sleep(1000); diff --git a/yarn-project/aztec.js/src/utils/account.ts b/yarn-project/aztec.js/src/utils/account.ts index baa0b5110f1d..9f070ec8ede7 100644 --- a/yarn-project/aztec.js/src/utils/account.ts +++ b/yarn-project/aztec.js/src/utils/account.ts @@ -5,8 +5,23 @@ import { createDebugLogger } from '@aztec/foundation/log'; import { AztecRPC, TxStatus } from '@aztec/types'; import { SingleKeyAccountEntrypoint } from '../account/entrypoint/single_key_account_entrypoint.js'; -import { EntrypointWallet, Wallet } from '../aztec_rpc_client/wallet.js'; -import { ContractDeployer, EntrypointCollection, StoredKeyAccountEntrypoint, generatePublicKey } from '../index.js'; +import { AccountWallet, EntrypointWallet, Wallet } from '../aztec_rpc_client/wallet.js'; +import { + ContractDeployer, + EntrypointCollection, + StoredKeyAccountEntrypoint, + generatePublicKey, + getSchnorrAccount, +} from '../index.js'; + +/** + * Deploys and registers a new account using random private keys and returns the associated wallet. Useful for testing. + * @param rpc - RPC client. + * @returns - A wallet for a fresh account. + */ +export function createAccount(rpc: AztecRPC): Promise { + return getSchnorrAccount(rpc, GrumpkinScalar.random(), GrumpkinScalar.random()).waitDeploy(); +} /** * Creates an Aztec Account. diff --git a/yarn-project/circuits.js/package.json b/yarn-project/circuits.js/package.json index 2a3dee75f1b9..b2fbac5e846e 100644 --- a/yarn-project/circuits.js/package.json +++ b/yarn-project/circuits.js/package.json @@ -35,9 +35,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "dependencies": { diff --git a/yarn-project/cli/package.json b/yarn-project/cli/package.json index 845b9296eed0..e2541e50de81 100644 --- a/yarn-project/cli/package.json +++ b/yarn-project/cli/package.json @@ -30,9 +30,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "dependencies": { diff --git a/yarn-project/end-to-end/.gitignore b/yarn-project/end-to-end/.gitignore new file mode 100644 index 000000000000..c59c6f13655b --- /dev/null +++ b/yarn-project/end-to-end/.gitignore @@ -0,0 +1 @@ +addresses.json \ No newline at end of file diff --git a/yarn-project/end-to-end/package.json b/yarn-project/end-to-end/package.json index ffcac42a743f..1e7e6a34e013 100644 --- a/yarn-project/end-to-end/package.json +++ b/yarn-project/end-to-end/package.json @@ -18,9 +18,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(ts|mjs)$", "rootDir": "./src" }, "dependencies": { diff --git a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts index 19fdbd27cfcf..f8adaec436ba 100644 --- a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts +++ b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts @@ -4,11 +4,10 @@ import { AztecRPC, CheatCodes, Fr, - GrumpkinScalar, L2BlockL2Logs, + createAccount, createAztecRpcClient, getSandboxAccountsWallets, - getSchnorrAccount, waitForSandbox, } from '@aztec/aztec.js'; import { toBigIntBE } from '@aztec/foundation/bigint-buffer'; @@ -27,8 +26,8 @@ describe('guides/dapp/testing', () => { // docs:start:in-proc-sandbox ({ rpcServer: rpc, stop } = await createSandbox()); // docs:end:in-proc-sandbox - owner = await getSchnorrAccount(rpc, GrumpkinScalar.random(), GrumpkinScalar.random()).waitDeploy(); - recipient = await getSchnorrAccount(rpc, GrumpkinScalar.random(), GrumpkinScalar.random()).waitDeploy(); + owner = await createAccount(rpc); + recipient = await createAccount(rpc); token = await PrivateTokenContract.deploy(owner, 100n, owner.getAddress()).send().deployed(); }, 60_000); @@ -62,8 +61,8 @@ describe('guides/dapp/testing', () => { beforeEach(async () => { rpc = createAztecRpcClient(SANDBOX_URL); - owner = await getSchnorrAccount(rpc, GrumpkinScalar.random(), GrumpkinScalar.random()).waitDeploy(); - recipient = await getSchnorrAccount(rpc, GrumpkinScalar.random(), GrumpkinScalar.random()).waitDeploy(); + owner = await createAccount(rpc); + recipient = await createAccount(rpc); token = await PrivateTokenContract.deploy(owner, 100n, owner.getAddress()).send().deployed(); }, 30_000); @@ -108,7 +107,7 @@ describe('guides/dapp/testing', () => { beforeAll(async () => { rpc = createAztecRpcClient(SANDBOX_URL); - owner = await getSchnorrAccount(rpc, GrumpkinScalar.random(), GrumpkinScalar.random()).waitDeploy(); + owner = await createAccount(rpc); testContract = await TestContract.deploy(owner).send().deployed(); cheats = await CheatCodes.create(ETHEREUM_HOST, rpc); }, 30_000); @@ -135,8 +134,8 @@ describe('guides/dapp/testing', () => { beforeAll(async () => { rpc = createAztecRpcClient(SANDBOX_URL); - owner = await getSchnorrAccount(rpc, GrumpkinScalar.random(), GrumpkinScalar.random()).waitDeploy(); - recipient = await getSchnorrAccount(rpc, GrumpkinScalar.random(), GrumpkinScalar.random()).waitDeploy(); + owner = await createAccount(rpc); + recipient = await createAccount(rpc); token = await PrivateTokenContract.deploy(owner, 100n, owner.getAddress()).send().deployed(); nativeToken = await NativeTokenContract.deploy(owner, 100n, owner.getAddress()).send().deployed(); diff --git a/yarn-project/end-to-end/src/sample-dapp/ci/index.test.mjs b/yarn-project/end-to-end/src/sample-dapp/ci/index.test.mjs new file mode 100644 index 000000000000..4c3312a6d1d0 --- /dev/null +++ b/yarn-project/end-to-end/src/sample-dapp/ci/index.test.mjs @@ -0,0 +1,13 @@ +import { waitForSandbox } from '@aztec/aztec.js'; + +import { deploy } from '../deploy.mjs'; +import { main } from '../index.mjs'; + +// Tests on our CI that all scripts included in the guide work fine +describe('sample-dapp', () => { + it('deploys and runs without errors', async () => { + await waitForSandbox(); + await deploy(); + await main(); + }, 60_000); +}); diff --git a/yarn-project/end-to-end/src/sample-dapp/connect.mjs b/yarn-project/end-to-end/src/sample-dapp/connect.mjs new file mode 100644 index 000000000000..d66fbc3ba024 --- /dev/null +++ b/yarn-project/end-to-end/src/sample-dapp/connect.mjs @@ -0,0 +1,16 @@ +// docs:start:all +import { createAztecRpcClient } from '@aztec/aztec.js'; + +const { SANDBOX_URL = 'http://localhost:8080' } = process.env; + +async function main() { + const client = createAztecRpcClient(SANDBOX_URL); + const { chainId } = await client.getNodeInfo(); + console.log(`Connected to chain ${chainId}`); +} + +main().catch(err => { + console.error(`Error in app: ${err}`); + process.exit(1); +}); +// docs:end:all diff --git a/yarn-project/end-to-end/src/sample-dapp/contracts.mjs b/yarn-project/end-to-end/src/sample-dapp/contracts.mjs new file mode 100644 index 000000000000..d72e4f4bd5fe --- /dev/null +++ b/yarn-project/end-to-end/src/sample-dapp/contracts.mjs @@ -0,0 +1,19 @@ +import { Contract } from '@aztec/aztec.js'; +import { + PrivateTokenContractAbi as PrivateTokenArtifact, + PublicTokenContractAbi as PublicTokenArtifact, +} from '@aztec/noir-contracts/artifacts'; + +import { readFileSync } from 'fs'; + +// docs:start:get-tokens +export async function getPrivateToken(client) { + const addresses = JSON.parse(readFileSync('addresses.json')); + return Contract.at(addresses.privateToken, PrivateTokenArtifact, client); +} + +export async function getPublicToken(client) { + const addresses = JSON.parse(readFileSync('addresses.json')); + return Contract.at(addresses.publicToken, PublicTokenArtifact, client); +} +// docs:end:get-tokens diff --git a/yarn-project/end-to-end/src/sample-dapp/deploy.mjs b/yarn-project/end-to-end/src/sample-dapp/deploy.mjs new file mode 100644 index 000000000000..bcad06487a5b --- /dev/null +++ b/yarn-project/end-to-end/src/sample-dapp/deploy.mjs @@ -0,0 +1,38 @@ +import { ContractDeployer, createAztecRpcClient } from '@aztec/aztec.js'; +import { + PrivateTokenContractAbi as PrivateTokenArtifact, + PublicTokenContractAbi as PublicTokenArtifact, +} from '@aztec/noir-contracts/artifacts'; + +import { writeFileSync } from 'fs'; +import { fileURLToPath } from 'url'; + +// docs:start:dapp-deploy +const { SANDBOX_URL = 'http://localhost:8080' } = process.env; + +async function main() { + const client = createAztecRpcClient(SANDBOX_URL); + const [owner] = await client.getAccounts(); + + const privateTokenDeployer = new ContractDeployer(PrivateTokenArtifact, client); + const { contractAddress: privateTokenAddress } = await privateTokenDeployer.deploy(100n, owner.address).send().wait(); + console.log(`Private token deployed at ${privateTokenAddress.toString()}`); + + const publicTokenDeployer = new ContractDeployer(PublicTokenArtifact, client); + const { contractAddress: publicTokenAddress } = await publicTokenDeployer.deploy().send().wait(); + console.log(`Public token deployed at ${publicTokenAddress.toString()}`); + + const addresses = { privateToken: privateTokenAddress.toString(), publicToken: publicTokenAddress.toString() }; + writeFileSync('addresses.json', JSON.stringify(addresses, null, 2)); +} +// docs:end:dapp-deploy + +// Execute main only if run directly +if (process.argv[1].replace(/\/index\.m?js$/, '') === fileURLToPath(import.meta.url).replace(/\/index\.m?js$/, '')) { + main().catch(err => { + console.error(`Error in deployment script: ${err}`); + process.exit(1); + }); +} + +export { main as deploy }; diff --git a/yarn-project/end-to-end/src/sample-dapp/index.mjs b/yarn-project/end-to-end/src/sample-dapp/index.mjs new file mode 100644 index 000000000000..99bb702ffb37 --- /dev/null +++ b/yarn-project/end-to-end/src/sample-dapp/index.mjs @@ -0,0 +1,103 @@ +import { L2BlockL2Logs, createAztecRpcClient, getSandboxAccountsWallets } from '@aztec/aztec.js'; +import { fileURLToPath } from '@aztec/foundation/url'; + +import { getPrivateToken, getPublicToken } from './contracts.mjs'; + +const { SANDBOX_URL = 'http://localhost:8080' } = process.env; + +async function showAccounts(client) { + // docs:start:showAccounts + const accounts = await client.getAccounts(); + console.log(`User accounts:\n${accounts.map(a => a.address).join('\n')}`); + // docs:end:showAccounts +} + +async function showPrivateBalances(client) { + // docs:start:showPrivateBalances + const accounts = await client.getAccounts(); + const privateToken = await getPrivateToken(client); + + for (const account of accounts) { + // highlight-next-line:showPrivateBalances + const balance = await privateToken.methods.getBalance(account.address).view(); + console.log(`Balance of ${account.address}: ${balance}`); + } + // docs:end:showPrivateBalances +} + +async function transferPrivateFunds(client) { + // docs:start:transferPrivateFunds + const [owner, recipient] = await getSandboxAccountsWallets(client); + const privateToken = await getPrivateToken(owner); + + const tx = privateToken.methods.transfer(1n, recipient.getAddress()).send(); + console.log(`Sent transfer transaction ${await tx.getTxHash()}`); + await showPrivateBalances(client); + + console.log(`Awaiting transaction to be mined`); + const receipt = await tx.wait(); + console.log(`Transaction has been mined on block ${receipt.blockNumber}`); + await showPrivateBalances(client); + // docs:end:transferPrivateFunds +} + +async function showPublicBalances(client) { + // docs:start:showPublicBalances + const accounts = await client.getAccounts(); + const publicToken = await getPublicToken(client); + + for (const account of accounts) { + // highlight-next-line:showPublicBalances + const balance = await publicToken.methods.publicBalanceOf(account.address).view(); + console.log(`Balance of ${account.address}: ${balance}`); + } + // docs:end:showPublicBalances +} + +async function mintPublicFunds(client) { + // docs:start:mintPublicFunds + const [owner] = await getSandboxAccountsWallets(client); + const publicToken = await getPublicToken(owner); + + const tx = publicToken.methods.mint(100n, owner.getAddress()).send(); + console.log(`Sent mint transaction ${await tx.getTxHash()}`); + await showPublicBalances(client); + + console.log(`Awaiting transaction to be mined`); + const receipt = await tx.wait(); + console.log(`Transaction has been mined on block ${receipt.blockNumber}`); + await showPublicBalances(client); + // docs:end:mintPublicFunds + + // docs:start:showLogs + const blockNumber = await client.getBlockNumber(); + const logs = await client.getUnencryptedLogs(blockNumber, 1); + const textLogs = L2BlockL2Logs.unrollLogs(logs).map(log => log.toString('ascii')); + for (const log of textLogs) console.log(`Log emitted: ${log}`); + // docs:end:showLogs +} + +async function main() { + const client = createAztecRpcClient(SANDBOX_URL); + const { chainId } = await client.getNodeInfo(); + console.log(`Connected to chain ${chainId}`); + + await showAccounts(client); + + await transferPrivateFunds(client); + + await mintPublicFunds(client); +} + +// Execute main only if run directly +if (process.argv[1].replace(/\/index\.m?js$/, '') === fileURLToPath(import.meta.url).replace(/\/index\.m?js$/, '')) { + // eslint-disable-next-line @typescript-eslint/no-floating-promises + main() + .then(() => process.exit(0)) + .catch(err => { + console.error(`Error in app: ${err}`); + process.exit(1); + }); +} + +export { main }; diff --git a/yarn-project/end-to-end/src/sample-dapp/index.test.mjs b/yarn-project/end-to-end/src/sample-dapp/index.test.mjs new file mode 100644 index 000000000000..db96a196bf85 --- /dev/null +++ b/yarn-project/end-to-end/src/sample-dapp/index.test.mjs @@ -0,0 +1,25 @@ +import { createSandbox } from '@aztec/aztec-sandbox'; +import { Contract, createAccount } from '@aztec/aztec.js'; +import { PrivateTokenContractAbi as PrivateTokenArtifact } from '@aztec/noir-contracts/artifacts'; + +describe('private token', () => { + // docs:start:setup + let rpc, stop, owner, recipient, token; + beforeAll(async () => { + ({ rpcServer: rpc, stop } = await createSandbox()); + owner = await createAccount(rpc); + recipient = await createAccount(rpc); + token = await Contract.deploy(owner, PrivateTokenArtifact, [100n, owner.getAddress()]).send().deployed(); + }, 30_000); + + afterAll(() => stop()); + // docs:end:setup + + // docs:start:test + it('increases recipient funds on transfer', async () => { + expect(await token.methods.getBalance(recipient.getAddress()).view()).toEqual(0n); + await token.methods.transfer(20n, recipient.getAddress()).send().wait(); + expect(await token.methods.getBalance(recipient.getAddress()).view()).toEqual(20n); + }); + // docs:end:test +}); diff --git a/yarn-project/ethereum/package.json b/yarn-project/ethereum/package.json index 3cf2bd858412..82a2402ad328 100644 --- a/yarn-project/ethereum/package.json +++ b/yarn-project/ethereum/package.json @@ -51,9 +51,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "engines": { diff --git a/yarn-project/foundation/package.json b/yarn-project/foundation/package.json index d1fdfc2f79f6..7441da401864 100644 --- a/yarn-project/foundation/package.json +++ b/yarn-project/foundation/package.json @@ -50,9 +50,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "dependencies": { diff --git a/yarn-project/key-store/package.json b/yarn-project/key-store/package.json index f5f191e81fd3..e9b763702192 100644 --- a/yarn-project/key-store/package.json +++ b/yarn-project/key-store/package.json @@ -26,9 +26,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "dependencies": { diff --git a/yarn-project/merkle-tree/package.json b/yarn-project/merkle-tree/package.json index 2cfa7a4a4bbd..163d6fc8dba4 100644 --- a/yarn-project/merkle-tree/package.json +++ b/yarn-project/merkle-tree/package.json @@ -27,9 +27,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src", "testTimeout": 15000 }, diff --git a/yarn-project/noir-compiler/package.json b/yarn-project/noir-compiler/package.json index c5d9365430f6..067b9a5c6d92 100644 --- a/yarn-project/noir-compiler/package.json +++ b/yarn-project/noir-compiler/package.json @@ -32,9 +32,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "dependencies": { diff --git a/yarn-project/noir-contracts/package.json b/yarn-project/noir-contracts/package.json index fb562f7e2914..35b3dc64ebf0 100644 --- a/yarn-project/noir-contracts/package.json +++ b/yarn-project/noir-contracts/package.json @@ -27,9 +27,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "dependencies": { diff --git a/yarn-project/noir-contracts/src/contracts/private_token_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/private_token_contract/src/main.nr index 8395bbd1ea0c..e03c3fa613cd 100644 --- a/yarn-project/noir-contracts/src/contracts/private_token_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/private_token_contract/src/main.nr @@ -1,3 +1,4 @@ +// docs:start:all contract PrivateToken { use dep::std::option::Option; use dep::value_note::{ @@ -109,3 +110,4 @@ contract PrivateToken { } // docs:end:compute_note_hash_and_nullifier } +// docs:end:all \ No newline at end of file diff --git a/yarn-project/noir-contracts/src/contracts/public_token_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/public_token_contract/src/main.nr index f32f3ec07bf6..2dafe1baff96 100644 --- a/yarn-project/noir-contracts/src/contracts/public_token_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/public_token_contract/src/main.nr @@ -1,3 +1,4 @@ +// docs:start:all contract PublicToken { use dep::std::option::Option; @@ -48,8 +49,8 @@ contract PublicToken { let storage = Storage::init(Context::public(&mut context)); let recipient_balance = storage.balances.at(recipient); let new_amount = recipient_balance.read() + amount; - // docs:start:unencrypted_log // TODO: Remove return value. + // docs:start:unencrypted_log let _hash = emit_unencrypted_log("Coins minted"); // docs:end:unencrypted_log recipient_balance.write(new_amount); @@ -96,3 +97,4 @@ contract PublicToken { storage.balances.at(owner).read() } } +// docs:end:all \ No newline at end of file diff --git a/yarn-project/p2p-bootstrap/package.json b/yarn-project/p2p-bootstrap/package.json index 41a420113212..89fc049dba2e 100644 --- a/yarn-project/p2p-bootstrap/package.json +++ b/yarn-project/p2p-bootstrap/package.json @@ -50,9 +50,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "engines": { diff --git a/yarn-project/p2p/package.json b/yarn-project/p2p/package.json index 98b7276d2977..f32130037027 100644 --- a/yarn-project/p2p/package.json +++ b/yarn-project/p2p/package.json @@ -28,9 +28,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "dependencies": { diff --git a/yarn-project/package.common.json b/yarn-project/package.common.json index feaf0fd5764d..d6231d92f893 100644 --- a/yarn-project/package.common.json +++ b/yarn-project/package.common.json @@ -25,9 +25,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" } } diff --git a/yarn-project/prover-client/package.json b/yarn-project/prover-client/package.json index 19f2aec28b84..fb946ce8d2bc 100644 --- a/yarn-project/prover-client/package.json +++ b/yarn-project/prover-client/package.json @@ -26,9 +26,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "dependencies": { diff --git a/yarn-project/rollup-provider/package.json b/yarn-project/rollup-provider/package.json index 604418c73380..84d68c96dc8e 100644 --- a/yarn-project/rollup-provider/package.json +++ b/yarn-project/rollup-provider/package.json @@ -28,9 +28,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "dependencies": { diff --git a/yarn-project/sequencer-client/package.json b/yarn-project/sequencer-client/package.json index f01cad17e1b2..ab89bd8f455a 100644 --- a/yarn-project/sequencer-client/package.json +++ b/yarn-project/sequencer-client/package.json @@ -28,9 +28,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "dependencies": { diff --git a/yarn-project/types/package.json b/yarn-project/types/package.json index dd636f1278d9..6aaac90d5e81 100644 --- a/yarn-project/types/package.json +++ b/yarn-project/types/package.json @@ -26,9 +26,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "dependencies": { diff --git a/yarn-project/world-state/package.json b/yarn-project/world-state/package.json index 46c1b9df210c..36ae514d0ea8 100644 --- a/yarn-project/world-state/package.json +++ b/yarn-project/world-state/package.json @@ -26,9 +26,9 @@ "jest": { "preset": "ts-jest/presets/default-esm", "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.m?js$": "$1" }, - "testRegex": "./src/.*\\.test\\.ts$", + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" }, "dependencies": { From 6fee803c3ebe511f7c4f37da32052f62ba85846e Mon Sep 17 00:00:00 2001 From: AztecBot Date: Mon, 11 Sep 2023 14:14:44 +0000 Subject: [PATCH 6/8] git subrepo push --branch=main docs subrepo: subdir: "docs" merged: "bef2a920b" upstream: origin: "https://github.com/AztecProtocol/docs" branch: "main" commit: "bef2a920b" git-subrepo: version: "0.4.6" origin: "???" commit: "???" --- docs/.gitrepo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/.gitrepo b/docs/.gitrepo index 586639dbe05f..d4f7496a1af4 100644 --- a/docs/.gitrepo +++ b/docs/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/AztecProtocol/docs branch = main - commit = 76da28406fa55dc0f34dbed9014d68391e6ef18e - parent = 73328dbe4e509235329e32ff88f823d849a2b673 + commit = bef2a920b20e552e5039bdae7ed93eb28822cfda + parent = 573dbc20a2b5ebae0e967e320da75febd5361eaf method = merge cmdver = 0.4.6 From e1e14d2c7fb44d56b9a10a645676d3551830bb10 Mon Sep 17 00:00:00 2001 From: Maddiaa <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 11 Sep 2023 16:28:44 +0200 Subject: [PATCH 7/8] chore(aztec-noir)!: rename noir-aztec to aztec-noir (#2071) Addresses a little nit of mine. In all branding and docs we are referring to the aztec noir library as `Aztec.nr`. It was previously named `noir-aztec` which is inconsistent This pr: - renames the folder from `noir-aztec` to `aztec-noir` - Updates the path anywhere it was mentioned --------- Co-authored-by: Cheethas <47148561+cheethas@users.noreply.github.com> --- .../relations_bench/barycentric.bench.cpp | 6 ++---- .../honk/composer/standard_composer.test.cpp | 4 ++-- .../honk/composer/ultra_composer.test.cpp | 4 ++-- .../src/barretenberg/honk/flavor/goblin_ultra.hpp | 8 ++++---- .../cpp/src/barretenberg/honk/flavor/standard.hpp | 4 ++-- .../honk/flavor/standard_grumpkin.hpp | 8 ++++---- .../cpp/src/barretenberg/honk/flavor/ultra.hpp | 10 +++++----- .../barretenberg/honk/flavor/ultra_grumpkin.hpp | 10 +++++----- .../barretenberg/honk/flavor/ultra_recursive.hpp | 10 +++++----- .../honk/proof_system/grand_product_library.hpp | 2 +- .../honk/proof_system/prover_library.test.cpp | 2 +- .../honk/proof_system/ultra_prover.hpp | 2 +- .../honk/sumcheck/relation_correctness.test.cpp | 3 +-- .../src/barretenberg/honk/sumcheck/sumcheck.hpp | 15 +++++++++------ .../barretenberg/honk/sumcheck/sumcheck.test.cpp | 2 +- .../barretenberg/honk/sumcheck/sumcheck_round.hpp | 15 ++++++++------- .../honk/sumcheck/sumcheck_round.test.cpp | 4 ++-- .../honk/transcript/transcript.test.cpp | 2 +- .../barretenberg/polynomials/barycentric.test.cpp | 2 +- .../cpp/src/barretenberg/polynomials/pow.test.cpp | 6 +++--- .../barretenberg/proof_system/flavor/flavor.hpp | 2 +- .../proof_system/relations/auxiliary_relation.hpp | 2 +- .../relations/permutation_relation.hpp | 2 +- docs/docs/dev_docs/contracts/state_variables.md | 8 ++++---- .../dev_docs/getting_started/noir_contracts.md | 2 +- .../wallets/writing_an_account_contract.md | 4 ++-- .../acir-simulator/src/public/executor.ts | 6 ++---- .../src/account/entrypoint/entrypoint_payload.ts | 2 +- yarn-project/aztec.js/src/utils/cheat_codes.ts | 2 +- .../circuits.js/src/cbind/constants.in.ts | 2 +- yarn-project/noir-contracts/README.md | 2 +- .../src/contracts/card_game_contract/Nargo.toml | 2 +- .../src/contracts/child_contract/Nargo.toml | 2 +- .../contracts/docs_example_contract/Nargo.toml | 2 +- .../easy_private_token_contract/Nargo.toml | 2 +- .../contracts/ecdsa_account_contract/Nargo.toml | 2 +- .../src/contracts/escrow_contract/Nargo.toml | 2 +- .../src/contracts/import_test_contract/Nargo.toml | 2 +- .../src/contracts/lending_contract/Nargo.toml | 2 +- .../contracts/multi_transfer_contract/Nargo.toml | 2 +- .../contracts/native_token_contract/Nargo.toml | 2 +- .../non_native_token_contract/Nargo.toml | 2 +- .../src/contracts/parent_contract/Nargo.toml | 2 +- .../pending_commitments_contract/Nargo.toml | 2 +- .../contracts/pokeable_token_contract/Nargo.toml | 2 +- .../src/contracts/price_feed_contract/Nargo.toml | 2 +- .../private_token_airdrop_contract/Nargo.toml | 2 +- .../contracts/private_token_contract/Nargo.toml | 2 +- .../contracts/public_token_contract/Nargo.toml | 2 +- .../contracts/schnorr_account_contract/Nargo.toml | 2 +- .../Nargo.toml | 2 +- .../schnorr_hardcoded_account_contract/Nargo.toml | 2 +- .../Nargo.toml | 2 +- .../src/contracts/test_contract/Nargo.toml | 2 +- .../src/contracts/uniswap_contract/Nargo.toml | 2 +- .../{noir-aztec => aztec-noir}/Nargo.toml | 0 .../{noir-aztec => aztec-noir}/src/abi.nr | 0 .../{noir-aztec => aztec-noir}/src/auth.nr | 0 .../src/constants_gen.nr | 0 .../{noir-aztec => aztec-noir}/src/context.nr | 0 .../{noir-aztec => aztec-noir}/src/entrypoint.nr | 0 .../{noir-aztec => aztec-noir}/src/lib.nr | 0 .../{noir-aztec => aztec-noir}/src/log.nr | 0 .../{noir-aztec => aztec-noir}/src/messaging.nr | 0 .../src/messaging/get_commitment_getter_data.nr | 0 .../src/messaging/l1_to_l2_message.nr | 0 .../src/messaging/l1_to_l2_message_getter_data.nr | 0 .../{noir-aztec => aztec-noir}/src/note.nr | 0 .../src/note/lifecycle.nr | 0 .../src/note/note_getter.nr | 0 .../src/note/note_getter_options.nr | 0 .../src/note/note_hash.nr | 0 .../src/note/note_header.nr | 0 .../src/note/note_interface.nr | 0 .../src/note/note_viewer_options.nr | 0 .../{noir-aztec => aztec-noir}/src/note/utils.nr | 0 .../{noir-aztec => aztec-noir}/src/oracle.nr | 4 ++++ .../src/oracle/arguments.nr | 0 .../src/oracle/call_private_function.nr | 0 .../src/oracle/compute_selector.nr | 0 .../src/oracle/context.nr | 0 .../src/oracle/create_commitment.nr | 0 .../src/oracle/debug_log.nr | 0 .../src/oracle/enqueue_public_function_call.nr | 0 .../src/oracle/get_commitment.nr | 0 .../src/oracle/get_l1_to_l2_message.nr | 0 .../src/oracle/get_public_key.nr | 0 .../src/oracle/get_secret_key.nr | 0 .../{noir-aztec => aztec-noir}/src/oracle/logs.nr | 0 .../src/oracle/notes.nr | 0 .../src/oracle/public_call.nr | 0 .../{noir-aztec => aztec-noir}/src/oracle/rand.nr | 0 .../src/oracle/storage.nr | 0 .../src/private_call_stack_item.nr | 0 .../src/public_call_stack_item.nr | 0 .../{noir-aztec => aztec-noir}/src/state_vars.nr | 0 .../src/state_vars/immutable_singleton.nr | 0 .../src/state_vars/map.nr | 0 .../src/state_vars/public_state.nr | 0 .../src/state_vars/set.nr | 0 .../src/state_vars/singleton.nr | 0 .../{noir-aztec => aztec-noir}/src/types.nr | 0 .../src/types/grumpkin_scalar.nr | 0 .../{noir-aztec => aztec-noir}/src/types/point.nr | 0 .../src/types/type_serialisation.nr | 0 .../type_serialisation/bool_serialisation.nr | 0 .../type_serialisation/field_serialisation.nr | 0 .../types/type_serialisation/u32_serialisation.nr | 0 .../{noir-aztec => aztec-noir}/src/types/vec.nr | 0 .../{noir-aztec => aztec-noir}/src/utils.nr | 0 .../noir-libs/easy-private-state/Nargo.toml | 2 +- yarn-project/noir-libs/value-note/Nargo.toml | 2 +- 112 files changed, 106 insertions(+), 103 deletions(-) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/Nargo.toml (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/abi.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/auth.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/constants_gen.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/context.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/entrypoint.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/lib.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/log.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/messaging.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/messaging/get_commitment_getter_data.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/messaging/l1_to_l2_message.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/messaging/l1_to_l2_message_getter_data.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/note.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/note/lifecycle.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/note/note_getter.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/note/note_getter_options.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/note/note_hash.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/note/note_header.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/note/note_interface.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/note/note_viewer_options.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/note/utils.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/oracle.nr (78%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/oracle/arguments.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/oracle/call_private_function.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/oracle/compute_selector.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/oracle/context.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/oracle/create_commitment.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/oracle/debug_log.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/oracle/enqueue_public_function_call.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/oracle/get_commitment.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/oracle/get_l1_to_l2_message.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/oracle/get_public_key.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/oracle/get_secret_key.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/oracle/logs.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/oracle/notes.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/oracle/public_call.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/oracle/rand.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/oracle/storage.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/private_call_stack_item.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/public_call_stack_item.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/state_vars.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/state_vars/immutable_singleton.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/state_vars/map.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/state_vars/public_state.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/state_vars/set.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/state_vars/singleton.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/types.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/types/grumpkin_scalar.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/types/point.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/types/type_serialisation.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/types/type_serialisation/bool_serialisation.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/types/type_serialisation/field_serialisation.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/types/type_serialisation/u32_serialisation.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/types/vec.nr (100%) rename yarn-project/noir-libs/{noir-aztec => aztec-noir}/src/utils.nr (100%) diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp index f6d4580fadf9..69425fcd971f 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp @@ -9,9 +9,8 @@ auto& engine = numeric::random::get_debug_engine(); } using FF = barretenberg::fr; -using barretenberg::Univariate; using barretenberg::BarycentricData; - +using barretenberg::Univariate; namespace proof_system::benchmark { @@ -19,8 +18,7 @@ void extend_2_to_6(State& state) noexcept { auto univariate = Univariate::get_random(); BarycentricData barycentric_2_to_6; - for (auto _ : state) - { + for (auto _ : state) { DoNotOptimize(barycentric_2_to_6.extend(univariate)); } } diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/standard_composer.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/standard_composer.test.cpp index 56568cbbf114..bccb233a4f9e 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/standard_composer.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/standard_composer.test.cpp @@ -5,13 +5,13 @@ #include "barretenberg/honk/composer/standard_composer.hpp" #include "barretenberg/honk/proof_system/prover.hpp" -#include "barretenberg/proof_system/relations/permutation_relation.hpp" -#include "barretenberg/proof_system/relations/relation_parameters.hpp" #include "barretenberg/honk/sumcheck/sumcheck_round.hpp" #include "barretenberg/honk/utils/grand_product_delta.hpp" #include "barretenberg/numeric/uint256/uint256.hpp" #include "barretenberg/polynomials/polynomial.hpp" #include "barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp" +#include "barretenberg/proof_system/relations/permutation_relation.hpp" +#include "barretenberg/proof_system/relations/relation_parameters.hpp" using namespace proof_system::honk; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/ultra_composer.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/ultra_composer.test.cpp index 777242c05f20..ec3196186efe 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/ultra_composer.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/ultra_composer.test.cpp @@ -8,13 +8,13 @@ #include "barretenberg/honk/composer/ultra_composer.hpp" #include "barretenberg/honk/proof_system/prover.hpp" #include "barretenberg/honk/proof_system/ultra_prover.hpp" -#include "barretenberg/proof_system/relations/permutation_relation.hpp" -#include "barretenberg/proof_system/relations/relation_parameters.hpp" #include "barretenberg/honk/sumcheck/sumcheck_round.hpp" #include "barretenberg/honk/utils/grand_product_delta.hpp" #include "barretenberg/numeric/uint256/uint256.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/proof_system/plookup_tables/types.hpp" +#include "barretenberg/proof_system/relations/permutation_relation.hpp" +#include "barretenberg/proof_system/relations/relation_parameters.hpp" using namespace proof_system::honk; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/goblin_ultra.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/goblin_ultra.hpp index 894fe54304d3..37049f218665 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/goblin_ultra.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/goblin_ultra.hpp @@ -1,5 +1,9 @@ #pragma once #include "barretenberg/honk/pcs/kzg/kzg.hpp" +#include "barretenberg/honk/transcript/transcript.hpp" +#include "barretenberg/polynomials/univariate.hpp" +#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" +#include "barretenberg/proof_system/flavor/flavor.hpp" #include "barretenberg/proof_system/relations/auxiliary_relation.hpp" #include "barretenberg/proof_system/relations/ecc_op_queue_relation.hpp" #include "barretenberg/proof_system/relations/elliptic_relation.hpp" @@ -7,10 +11,6 @@ #include "barretenberg/proof_system/relations/lookup_relation.hpp" #include "barretenberg/proof_system/relations/permutation_relation.hpp" #include "barretenberg/proof_system/relations/ultra_arithmetic_relation.hpp" -#include "barretenberg/honk/transcript/transcript.hpp" -#include "barretenberg/polynomials/univariate.hpp" -#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" -#include "barretenberg/proof_system/flavor/flavor.hpp" namespace proof_system::honk::flavor { diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/standard.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/standard.hpp index c0a4a53776e5..55006bdfaa90 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/standard.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/standard.hpp @@ -1,8 +1,6 @@ #pragma once #include "barretenberg/ecc/curves/bn254/g1.hpp" #include "barretenberg/honk/pcs/kzg/kzg.hpp" -#include "barretenberg/proof_system/relations/arithmetic_relation.hpp" -#include "barretenberg/proof_system/relations/permutation_relation.hpp" #include "barretenberg/honk/transcript/transcript.hpp" #include "barretenberg/polynomials/barycentric.hpp" #include "barretenberg/polynomials/evaluation_domain.hpp" @@ -10,6 +8,8 @@ #include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp" #include "barretenberg/proof_system/flavor/flavor.hpp" +#include "barretenberg/proof_system/relations/arithmetic_relation.hpp" +#include "barretenberg/proof_system/relations/permutation_relation.hpp" #include "barretenberg/srs/factories/crs_factory.hpp" namespace proof_system::honk::flavor { diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/standard_grumpkin.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/standard_grumpkin.hpp index 957c52aceb4f..dbb013241b0a 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/standard_grumpkin.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/standard_grumpkin.hpp @@ -4,13 +4,13 @@ #include "barretenberg/polynomials/barycentric.hpp" #include "barretenberg/polynomials/univariate.hpp" -#include "barretenberg/proof_system/relations/arithmetic_relation.hpp" -#include "barretenberg/proof_system/relations/permutation_relation.hpp" #include "barretenberg/honk/transcript/transcript.hpp" #include "barretenberg/polynomials/evaluation_domain.hpp" #include "barretenberg/polynomials/polynomial.hpp" #include "barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp" #include "barretenberg/proof_system/flavor/flavor.hpp" +#include "barretenberg/proof_system/relations/arithmetic_relation.hpp" +#include "barretenberg/proof_system/relations/permutation_relation.hpp" #include #include #include @@ -226,8 +226,8 @@ class StandardGrumpkin { * @todo TODO(#390): Simplify this by moving MAX_RELATION_LENGTH? */ template - using ExtendedEdges = - AllEntities, barretenberg::Univariate>; + using ExtendedEdges = AllEntities, + barretenberg::Univariate>; /** * @brief A container for the polynomials evaluations produced during sumcheck, which are purported to be the diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra.hpp index 1323ed988743..df21ba0ce55c 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra.hpp @@ -4,17 +4,17 @@ #include "barretenberg/polynomials/barycentric.hpp" #include "barretenberg/polynomials/univariate.hpp" +#include "barretenberg/honk/transcript/transcript.hpp" +#include "barretenberg/polynomials/evaluation_domain.hpp" +#include "barretenberg/polynomials/polynomial.hpp" +#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" +#include "barretenberg/proof_system/flavor/flavor.hpp" #include "barretenberg/proof_system/relations/auxiliary_relation.hpp" #include "barretenberg/proof_system/relations/elliptic_relation.hpp" #include "barretenberg/proof_system/relations/gen_perm_sort_relation.hpp" #include "barretenberg/proof_system/relations/lookup_relation.hpp" #include "barretenberg/proof_system/relations/permutation_relation.hpp" #include "barretenberg/proof_system/relations/ultra_arithmetic_relation.hpp" -#include "barretenberg/honk/transcript/transcript.hpp" -#include "barretenberg/polynomials/evaluation_domain.hpp" -#include "barretenberg/polynomials/polynomial.hpp" -#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" -#include "barretenberg/proof_system/flavor/flavor.hpp" namespace proof_system::honk::flavor { diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra_grumpkin.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra_grumpkin.hpp index 260b2f44b76f..609421f74c67 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra_grumpkin.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra_grumpkin.hpp @@ -5,17 +5,17 @@ #include "barretenberg/polynomials/barycentric.hpp" #include "barretenberg/polynomials/univariate.hpp" +#include "barretenberg/honk/transcript/transcript.hpp" +#include "barretenberg/polynomials/evaluation_domain.hpp" +#include "barretenberg/polynomials/polynomial.hpp" +#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" +#include "barretenberg/proof_system/flavor/flavor.hpp" #include "barretenberg/proof_system/relations/auxiliary_relation.hpp" #include "barretenberg/proof_system/relations/elliptic_relation.hpp" #include "barretenberg/proof_system/relations/gen_perm_sort_relation.hpp" #include "barretenberg/proof_system/relations/lookup_relation.hpp" #include "barretenberg/proof_system/relations/permutation_relation.hpp" #include "barretenberg/proof_system/relations/ultra_arithmetic_relation.hpp" -#include "barretenberg/honk/transcript/transcript.hpp" -#include "barretenberg/polynomials/evaluation_domain.hpp" -#include "barretenberg/polynomials/polynomial.hpp" -#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" -#include "barretenberg/proof_system/flavor/flavor.hpp" #include #include #include diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra_recursive.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra_recursive.hpp index e050d7b6597d..9d98f4a1c256 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra_recursive.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra_recursive.hpp @@ -5,17 +5,17 @@ #include "barretenberg/polynomials/barycentric.hpp" #include "barretenberg/polynomials/univariate.hpp" +#include "barretenberg/honk/transcript/transcript.hpp" +#include "barretenberg/polynomials/evaluation_domain.hpp" +#include "barretenberg/polynomials/polynomial.hpp" +#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" +#include "barretenberg/proof_system/flavor/flavor.hpp" #include "barretenberg/proof_system/relations/auxiliary_relation.hpp" #include "barretenberg/proof_system/relations/elliptic_relation.hpp" #include "barretenberg/proof_system/relations/gen_perm_sort_relation.hpp" #include "barretenberg/proof_system/relations/lookup_relation.hpp" #include "barretenberg/proof_system/relations/permutation_relation.hpp" #include "barretenberg/proof_system/relations/ultra_arithmetic_relation.hpp" -#include "barretenberg/honk/transcript/transcript.hpp" -#include "barretenberg/polynomials/evaluation_domain.hpp" -#include "barretenberg/polynomials/polynomial.hpp" -#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" -#include "barretenberg/proof_system/flavor/flavor.hpp" #include "barretenberg/srs/factories/crs_factory.hpp" #include #include diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/grand_product_library.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/grand_product_library.hpp index 53405a3aede8..acb530965c64 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/grand_product_library.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/grand_product_library.hpp @@ -1,8 +1,8 @@ #pragma once +#include "barretenberg/common/constexpr_utils.hpp" #include "barretenberg/honk/sumcheck/sumcheck.hpp" #include "barretenberg/plonk/proof_system/proving_key/proving_key.hpp" #include "barretenberg/polynomials/polynomial.hpp" -#include "barretenberg/common/constexpr_utils.hpp" #include namespace proof_system::honk::grand_product_library { diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/prover_library.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/prover_library.test.cpp index af679985ff35..c43a5e699264 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/prover_library.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/prover_library.test.cpp @@ -1,11 +1,11 @@ -#include "prover_library.hpp" #include "barretenberg/ecc/curves/bn254/bn254.hpp" #include "barretenberg/honk/flavor/standard.hpp" #include "barretenberg/honk/flavor/ultra.hpp" #include "barretenberg/honk/proof_system/grand_product_library.hpp" #include "barretenberg/polynomials/polynomial.hpp" #include "prover.hpp" +#include "prover_library.hpp" #include "barretenberg/srs/factories/file_crs_factory.hpp" #include diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/ultra_prover.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/ultra_prover.hpp index 5f4a5460a3f9..9aeea1327fc9 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/ultra_prover.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/ultra_prover.hpp @@ -5,10 +5,10 @@ #include "barretenberg/honk/pcs/gemini/gemini.hpp" #include "barretenberg/honk/pcs/shplonk/shplonk.hpp" #include "barretenberg/honk/proof_system/work_queue.hpp" -#include "barretenberg/proof_system/relations/relation_parameters.hpp" #include "barretenberg/honk/sumcheck/sumcheck_output.hpp" #include "barretenberg/honk/transcript/transcript.hpp" #include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/proof_system/relations/relation_parameters.hpp" namespace proof_system::honk { diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relation_correctness.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relation_correctness.test.cpp index 884bc3e31c48..ea98cc35c461 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relation_correctness.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relation_correctness.test.cpp @@ -271,8 +271,7 @@ TEST_F(RelationCorrectnessTests, StandardRelationCorrectness) grand_product_library::compute_grand_products(prover.key, prover_polynomials, params); // Construct the round for applying sumcheck relations and results for storing computed results - auto relations = - std::tuple(proof_system::ArithmeticRelation(), proof_system::PermutationRelation()); + auto relations = std::tuple(proof_system::ArithmeticRelation(), proof_system::PermutationRelation()); // Check that each relation is satisfied across each row of the prover polynomials check_relation(std::get<0>(relations), circuit_size, prover_polynomials, params); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck.hpp index e3f0ae21409b..e3702752e406 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck.hpp @@ -2,11 +2,11 @@ #include "barretenberg/common/serialize.hpp" #include "barretenberg/common/throw_or_abort.hpp" #include "barretenberg/honk/proof_system/prover.hpp" -#include "barretenberg/proof_system/relations/relation_parameters.hpp" #include "barretenberg/honk/sumcheck/sumcheck_output.hpp" #include "barretenberg/honk/transcript/transcript.hpp" #include "barretenberg/honk/utils/grand_product_delta.hpp" #include "barretenberg/polynomials/univariate.hpp" +#include "barretenberg/proof_system/relations/relation_parameters.hpp" #include "sumcheck_round.hpp" namespace proof_system::honk::sumcheck { @@ -70,8 +70,9 @@ template class SumcheckProver { * * @details */ - SumcheckOutput prove(auto full_polynomials, - const proof_system::RelationParameters& relation_parameters) // pass by value, not by reference + SumcheckOutput prove( + auto full_polynomials, + const proof_system::RelationParameters& relation_parameters) // pass by value, not by reference { auto [alpha, zeta] = transcript.get_challenges("Sumcheck:alpha", "Sumcheck:zeta"); @@ -172,7 +173,8 @@ template class SumcheckVerifier { * @param relation_parameters * @param transcript */ - std::optional> verify(const proof_system::RelationParameters& relation_parameters, auto& transcript) + std::optional> verify(const proof_system::RelationParameters& relation_parameters, + auto& transcript) { bool verified(true); @@ -192,8 +194,9 @@ template class SumcheckVerifier { for (size_t round_idx = 0; round_idx < multivariate_d; round_idx++) { // Obtain the round univariate from the transcript std::string round_univariate_label = "Sumcheck:univariate_" + std::to_string(round_idx); - auto round_univariate = transcript.template receive_from_prover< - barretenberg::Univariate>(round_univariate_label); + auto round_univariate = + transcript.template receive_from_prover>( + round_univariate_label); bool checked = round.check_sum(round_univariate); verified = verified && checked; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck.test.cpp index fba343da1471..1d1b77e21154 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck.test.cpp @@ -1,4 +1,3 @@ -#include "sumcheck.hpp" #include "barretenberg/ecc/curves/bn254/fr.hpp" #include "barretenberg/honk/composer/standard_composer.hpp" #include "barretenberg/honk/composer/ultra_composer.hpp" @@ -11,6 +10,7 @@ #include "barretenberg/proof_system/relations/lookup_relation.hpp" #include "barretenberg/proof_system/relations/permutation_relation.hpp" #include "barretenberg/proof_system/relations/ultra_arithmetic_relation.hpp" +#include "sumcheck.hpp" #include using namespace proof_system::honk; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck_round.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck_round.hpp index 1b72039573a5..42dad0896013 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck_round.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck_round.hpp @@ -121,10 +121,11 @@ template class SumcheckProverRound { * values. Most likely this will end up being S_l(0), ... , S_l(t-1) where t is around 12. At the end, reset all * univariate accumulators to be zero. */ - barretenberg::Univariate compute_univariate(auto& polynomials, - const proof_system::RelationParameters& relation_parameters, - const barretenberg::PowUnivariate& pow_univariate, - const FF alpha) + barretenberg::Univariate compute_univariate( + auto& polynomials, + const proof_system::RelationParameters& relation_parameters, + const barretenberg::PowUnivariate& pow_univariate, + const FF alpha) { // Precompute the vector of required powers of zeta // TODO(luke): Parallelize this @@ -440,12 +441,12 @@ template class SumcheckVerifierRound { * @param round_challenge u_l * @return FF sigma_{l+1} = S^l(u_l) */ - FF compute_next_target_sum(barretenberg::Univariate& univariate, FF& round_challenge) + FF compute_next_target_sum(barretenberg::Univariate& univariate, + FF& round_challenge) { // IMPROVEMENT(Cody): Use barycentric static method, maybe implement evaluation as member // function on Univariate. - auto barycentric = - barretenberg::BarycentricData(); + auto barycentric = barretenberg::BarycentricData(); // Evaluate T^{l}(u_{l}) target_total_sum = barycentric.evaluate(univariate, round_challenge); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck_round.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck_round.test.cpp index e6089f875d14..33cc485cb2f7 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck_round.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck_round.test.cpp @@ -20,9 +20,9 @@ using namespace proof_system::honk; using namespace proof_system::honk::sumcheck; using namespace proof_system; -using barretenberg::Univariate; -using barretenberg::PowUnivariate; using barretenberg::BarycentricData; +using barretenberg::PowUnivariate; +using barretenberg::Univariate; using Flavor = flavor::Standard; using FF = typename Flavor::FF; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/transcript/transcript.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/transcript/transcript.test.cpp index 89b26fa53fda..8865e473fda6 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/transcript/transcript.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/transcript/transcript.test.cpp @@ -2,8 +2,8 @@ #include "barretenberg/honk/composer/standard_composer.hpp" #include "barretenberg/honk/composer/ultra_composer.hpp" #include "barretenberg/honk/flavor/standard.hpp" -#include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/numeric/bitop/get_msb.hpp" +#include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/proof_system/flavor/flavor.hpp" #include "transcript.hpp" #include diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/polynomials/barycentric.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/polynomials/barycentric.test.cpp index 2dcda2c229d9..a166fc5beac6 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/polynomials/barycentric.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/polynomials/barycentric.test.cpp @@ -1,5 +1,5 @@ -#include "barycentric.hpp" #include "barretenberg/ecc/curves/bn254/fr.hpp" +#include "barycentric.hpp" #include namespace barretenberg::test_barycentric { diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/polynomials/pow.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/polynomials/pow.test.cpp index 9c5a725d159b..58355c453c63 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/polynomials/pow.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/polynomials/pow.test.cpp @@ -1,5 +1,5 @@ -#include "pow.hpp" #include "barretenberg/ecc/curves/bn254/fr.hpp" +#include "pow.hpp" #include namespace barretenberg::test_pow { @@ -18,14 +18,14 @@ TEST(SumcheckPow, FullPowConsistency) u_i = FF::random_element(); pow_univariate.partially_evaluate(u_i); } - + FF zeta_power = zeta; FF expected_eval = 1; for (auto& u_i : variables) { expected_eval *= FF(1) - u_i + u_i * zeta_power; zeta_power *= zeta_power; } - + EXPECT_EQ(pow_univariate.partial_evaluation_constant, expected_eval); } } // namespace barretenberg::test_pow diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/flavor/flavor.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/flavor/flavor.hpp index af934fe7069e..7f6baf00b4cd 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/flavor/flavor.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/flavor/flavor.hpp @@ -65,8 +65,8 @@ #pragma once #include "barretenberg/polynomials/barycentric.hpp" -#include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/polynomials/evaluation_domain.hpp" +#include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/proof_system/types/circuit_type.hpp" #include #include diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/relations/auxiliary_relation.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/relations/auxiliary_relation.hpp index 91997903d8ce..05078bf638fd 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/relations/auxiliary_relation.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/relations/auxiliary_relation.hpp @@ -8,7 +8,7 @@ namespace proof_system { template class AuxiliaryRelationImpl { public: using FF = FF_; - + // 1 + polynomial degree of this relation static constexpr size_t RELATION_LENGTH = 6; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/relations/permutation_relation.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/relations/permutation_relation.hpp index 972f98e6ed45..a267e6735522 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/relations/permutation_relation.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/relations/permutation_relation.hpp @@ -14,7 +14,7 @@ template class PermutationRelationImpl { static constexpr size_t LEN_1 = 5; // grand product construction sub-relation static constexpr size_t LEN_2 = 3; // left-shiftable polynomial sub-relation - static constexpr std::tuple SUBRELATION_LENGTHS = {LEN_1, LEN_2}; + static constexpr std::tuple SUBRELATION_LENGTHS = { LEN_1, LEN_2 }; template