From 255a8f6ce909087b42b848a40e532f342355f4e9 Mon Sep 17 00:00:00 2001 From: Saleel Date: Tue, 24 Dec 2024 01:29:08 +0400 Subject: [PATCH 1/3] feat: improve bb env config in aztec-wallet script --- aztec-up/bin/aztec-wallet | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/aztec-up/bin/aztec-wallet b/aztec-up/bin/aztec-wallet index 998e51157c1..d7de4cfa7ca 100755 --- a/aztec-up/bin/aztec-wallet +++ b/aztec-up/bin/aztec-wallet @@ -4,7 +4,16 @@ set -euo pipefail export SKIP_PORT_ASSIGNMENT=1 export WALLET_DATA_DIRECTORY=$(dirname $0)/wallet-data export BB_WORKING_DIRECTORY=$(dirname $0)/bb-workdir -export BB_BINARY_PATH=$(which bb) + +if [ -z "${BB_BINARY_PATH:-}" ]; then + export BB_BINARY_PATH=$HOME/.bb/bb +fi + +if [ ! -f $BB_BINARY_PATH ]; then + echo "bb binary does not exist at $BB_BINARY_PATH. Set BB_BINARY_PATH environment variable to the path of the bb binary." + exit 1 +fi + export ENV_VARS_TO_INJECT="WALLET_DATA_DIRECTORY SSH_AUTH_SOCK PXE_PROVER_ENABLED BB_BINARY_PATH BB_WORKING_DIRECTORY" mkdir -p $BB_WORKING_DIRECTORY From 8e6cab00316d83acb8d5672b5d2f610ce2e063e9 Mon Sep 17 00:00:00 2001 From: Saleel Date: Tue, 24 Dec 2024 01:29:54 +0400 Subject: [PATCH 2/3] feat: update docs for local proving --- .../local_env/sandbox_proving.md | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/docs/docs/guides/developer_guides/local_env/sandbox_proving.md b/docs/docs/guides/developer_guides/local_env/sandbox_proving.md index 528d94561d8..c6fd869a971 100644 --- a/docs/docs/guides/developer_guides/local_env/sandbox_proving.md +++ b/docs/docs/guides/developer_guides/local_env/sandbox_proving.md @@ -40,31 +40,18 @@ The sandbox will also deploy 3 Schnorr account contracts on startup. The sandbox Once everything has been set up, you will see that the PXE is listening on `localhost:8080` as you would see with the sandbox running in the default mode. At this point you can use the sandbox as you would without client-side proving enabled. ## Proving with `aztec-wallet` -You can enable proving on a per-transaction basis using the `aztec-wallet` CLI. - -### Config -Open `~/.aztec/bin/aztec-wallet` and update the `ENV_VARS_TO_INJECT` variable to: - -```bash -# ~/.aztec/bin/aztec-wallet -export ENV_VARS_TO_INJECT="WALLET_DATA_DIRECTORY SSH_AUTH_SOCK BB_BINARY_PATH PXE_PROVER_ENABLED BB_WORKING_DIRECTORY" -``` - -Export the following envnironment variables in the terminal where you will run `aztec-wallet` commands: +You can enable proving on a per-transaction basis using the `aztec-wallet` CLI by setting the `PXE_PROVER_ENABLED` environment variable to `1`. This will use your local `bb` binary to prove the transaction. ```bash -export BB_BINARY_PATH=/usr/src/barretenberg/cpp/build/bin/bb -export PXE_PROVER_ENABLED=1 -export BB_WORKING_DIRECTORY=~/bb-temp +PXE_PROVER_ENABLED=1 aztec-wallet create-account -a test ``` -### Usage -Now send transactions from `aztec-wallet`, and proving will be enabled. Check the [Quickstart](../../getting_started.md) for a refresher on how to send transactions using `aztec-wallet` or check the [reference here](../../../reference/developer_references/cli_wallet_reference.md) +Check the [Quickstart](../../getting_started.md) for a refresher on how to send transactions using `aztec-wallet` or check the [reference here](../../../reference/developer_references/cli_wallet_reference.md) -Note that you do not need to restart the sandbox in order to start sending proven transactions. You can optionally set this for 1 off transactions. +Note that you do not need to restart the sandbox in order to start sending proven transactions. You can optionally set this for one-off transactions. -If this is the first time you are sending transactions with proving enabled, you will have to download the CRS (which is several GBs). +If this is the first time you are sending transactions with proving enabled, it will take a while to download a CRS file (which is several MBs) that is required for proving. -::: note -You can also profile your transactions to get gate count, if you don't want to prove your transactions but check how many constraints it is. Follow [reference here](../../../reference/developer_references/cli_wallet_reference.md#profile) +:::note +You can also profile your transactions to get gate count, if you don't want to prove your transactions but check how many constraints it is. Follow the [guide here](../../developer_guides/smart_contracts/profiling_transactions.md) ::: From f19100a91eae910d0c98df587de702f9b7541d80 Mon Sep 17 00:00:00 2001 From: Saleel Date: Tue, 24 Dec 2024 01:46:35 +0400 Subject: [PATCH 3/3] docs: update profiler docs --- .../smart_contracts/profiling_transactions.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/docs/guides/developer_guides/smart_contracts/profiling_transactions.md b/docs/docs/guides/developer_guides/smart_contracts/profiling_transactions.md index 40aa27888fa..1f755a8b09c 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/profiling_transactions.md +++ b/docs/docs/guides/developer_guides/smart_contracts/profiling_transactions.md @@ -18,7 +18,6 @@ In this guide, we will look at how to profile the private execution of a transac - `aztec-nargo` installed (go to [Sandbox section](../../../reference/developer_references/sandbox_reference/sandbox-reference.md) for installation instructions) - `aztec-wallet` installed (installed as part of the Sandbox) -- Aztec Sandbox running with **proving enabled** (go to [Sandbox PXE Proving](../local_env/sandbox_proving.md) for instructions) ## Profiling using aztec-wallet @@ -35,6 +34,7 @@ aztec-wallet create-account -a owner aztec-wallet create-account -a user # Deploy a token contract and mint 100 tokens to the user +# Run this from noir-projects/noir-contracts to determine the path to the token_contract aztec-wallet deploy token_contract@Token --args accounts:owner Test TST 18 -f owner -a token aztec-wallet send mint_to_private -ca token --args accounts:owner accounts:user 100 -f owner ``` @@ -56,14 +56,14 @@ This will print the following results after some time: ```bash Gate count per circuit: - SchnorrAccount:entrypoint Gates: 26,363 Acc: 26,363 - private_kernel_init Gates: 34,887 Acc: 61,250 - Token:transfer Gates: 28,229 Acc: 89,479 - private_kernel_inner Gates: 57,530 Acc: 147,009 - private_kernel_reset Gates: 86,600 Acc: 233,609 - private_kernel_tail Gates: 13,045 Acc: 246,654 - -Total gates: 246,654 + SchnorrAccount:entrypoint Gates: 26,487 Acc: 26,487 + private_kernel_init Gates: 48,562 Acc: 75,049 + Token:transfer Gates: 32,869 Acc: 107,918 + private_kernel_inner Gates: 89,062 Acc: 196,980 + private_kernel_reset Gates: 105,077 Acc: 302,057 + private_kernel_tail Gates: 27,501 Acc: 329,558 + +Total gates: 329,558 ``` Here you can see the gate count of each private function call in the transaction along with the kernel circuits needed in between, and the total gate count.