Skip to content

Commit

Permalink
chore!: deprecate circuits/cpp (#3421)
Browse files Browse the repository at this point in the history
Stop building circuits.wasm. It's not used anywhere and is no longer
exported from 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.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] 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).
  • Loading branch information
LeilaWang authored Nov 27, 2023
1 parent 63173c4 commit 4973cfb
Show file tree
Hide file tree
Showing 98 changed files with 419 additions and 7,573 deletions.
48 changes: 0 additions & 48 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,39 +302,6 @@ jobs:
name: "Build and test"
command: cond_spot_run_build barretenberg-acir-tests-bb.js 32

circuits-wasm-linux-clang:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- run:
name: "Build"
command: cond_spot_run_build circuits-wasm-linux-clang 32

circuits-x86_64-linux-clang-assert:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- run:
name: "Build"
command: cond_spot_run_build circuits-x86_64-linux-clang-assert 32

circuits-x86_64-tests:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- run:
name: "Test"
command: cond_spot_run_test circuits-x86_64-linux-clang-assert 32 ./scripts/run_tests 1 x86_64 scripts/a3-tests -*.skip*

l1-contracts:
machine:
image: ubuntu-2204:2023.07.2
Expand Down Expand Up @@ -1057,28 +1024,13 @@ workflows:
- bb-js
<<: *defaults

# Circuits
- circuits-wasm-linux-clang:
requires:
- barretenberg-wasm-linux-clang
<<: *defaults
- circuits-x86_64-linux-clang-assert:
requires:
- barretenberg-x86_64-linux-clang
<<: *defaults
- circuits-x86_64-tests:
requires:
- circuits-x86_64-linux-clang-assert
<<: *defaults

- l1-contracts: *defaults

- mainnet-fork: *defaults

# Yarn Project
- yarn-project-base:
requires:
- circuits-wasm-linux-clang
- l1-contracts
- bb-js
- noir-ecr-manifest
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

All the packages that make up [Aztec](https://docs.aztec.network).

- [**`circuits`**](/circuits): C++ code for circuits and cryptographic functions
- [**`l1-contracts`**](/l1-contracts): Solidity code for the Ethereum contracts that process rollups
- [**`yarn-project`**](/yarn-project): Typescript code for client and backend
- [**`docs`**](/docs): Documentation source for the docs site
Expand All @@ -22,15 +21,14 @@ All issues being worked on are tracked on the [Aztec Github Project](https://git

## Development Setup

Run `bootstrap.sh` in the project root to set up your environment. This will update git submodules, download ignition transcripts, build all C++ circuits code, install Foundry, compile Solidity contracts, install the current node version via nvm, and build all typescript packages.

To build the C++ code, follow the [instructions in the circuits subdirectory](./circuits/README.md), which contains all of the ZK circuit logic for Aztec. Note that "barretenberg", Aztec's underlying cryptographic library, can be found inside the circuits subdirectory as well and is automatically built as a side effect of building the circuits.
Run `bootstrap.sh` in the project root to set up your environment. This will update git submodules, download ignition transcripts, install Foundry, compile Solidity contracts, install the current node version via nvm, and build all typescript packages.

To build Typescript code, make sure to have [`nvm`](https://github.com/nvm-sh/nvm) (node version manager) installed.

To build noir code, make sure that you are using the version from `yarn-project/noir-compiler/src/noir-version.json`.

Install nargo by running
Install nargo by running

```
noirup -v TAG_FROM_THE_FILE
```
Expand All @@ -41,18 +39,20 @@ This repository uses CircleCI for continuous integration. Build steps are manage

All packages need to be included in the [build manifest](`build_manifest.json`), which declares what paths belong to each package, as well as dependencies between packages. When the CI runs, if none of the rebuild patterns or dependencies were changed, then the build step is skipped and the last successful image is re-tagged with the current commit. Read more on the [`build-system`](https://github.com/AztecProtocol/build-system) repository README.

It is faster to debug CI failures within a persistent ssh session compared to pushing and waiting. You can create a session with "Rerun step with SSH" on CircleCI which will generate an ssh command for debugging on a worker. Run that command locally and then do
It is faster to debug CI failures within a persistent ssh session compared to pushing and waiting. You can create a session with "Rerun step with SSH" on CircleCI which will generate an ssh command for debugging on a worker. Run that command locally and then do

```bash
cd project
./build-system/scripts/setup_env "$(git rev-parse HEAD)" "" "" ""
source /tmp/.bash_env*
{start testing your CI commands here}
```

This provide an interactive environment for debugging the CI test.

## Debugging

Logging goes through the [`info` and `debug`](barretenberg/cpp/src/barretenberg/common/log.hpp) functions in C++, and through the [DebugLogger](yarn-project/foundation/src/log/debug.ts) module in Typescript. To see the log output, set a `DEBUG` environment variable to the name of the module you want to debug, to `aztec:*`, or to `*` to see all logs.
Logging goes through the [DebugLogger](yarn-project/foundation/src/log/debug.ts) module in Typescript. To see the log output, set a `DEBUG` environment variable to the name of the module you want to debug, to `aztec:*`, or to `*` to see all logs.

## Releases

Expand Down
4 changes: 1 addition & 3 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,13 @@ fi
# Install pre-commit git hooks.
HOOKS_DIR=$(git rev-parse --git-path hooks)
echo "(cd barretenberg/cpp && ./format.sh staged)" > $HOOKS_DIR/pre-commit
echo "(cd circuits/cpp && ./format.sh staged)" >> $HOOKS_DIR/pre-commit
chmod +x $HOOKS_DIR/pre-commit

git submodule update --init --recursive

PROJECTS=(
barretenberg
noir
circuits/cpp
l1-contracts
yarn-project
)
Expand All @@ -67,4 +65,4 @@ for P in "${PROJECTS[@]}"; do
$P/bootstrap.sh
echo
echo
done
done
15 changes: 0 additions & 15 deletions build_manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,6 @@ barretenberg-acir-tests-bb.js:
dependencies:
- bb.js

circuits-wasm-linux-clang:
buildDir: circuits/cpp
dockerfile: dockerfiles/Dockerfile.wasm-linux-clang
rebuildPatterns: .rebuild_patterns
dependencies:
- barretenberg-wasm-linux-clang

circuits-x86_64-linux-clang-assert:
buildDir: circuits/cpp
dockerfile: dockerfiles/Dockerfile.x86_64-linux-clang-assert
rebuildPatterns: .rebuild_patterns
dependencies:
- barretenberg-x86_64-linux-clang

l1-contracts:
buildDir: l1-contracts

Expand All @@ -76,7 +62,6 @@ yarn-project-base:
- ^yarn-project/yarn-project-base/
- ^yarn-project/yarn.lock
dependencies:
- circuits-wasm-linux-clang
- l1-contracts
- bb.js
- noir
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/dev_docs/debugging/sandbox-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This section contains a list of errors you may encounter when using Aztec Sandbo

## Circuit Errors

**To prevent bloating this doc, here is a list of some of the common errors. Feel free to have a look at [circuit_errors.hpp](https://github.com/AztecProtocol/aztec-packages/blob/master/circuits/cpp/src/aztec3/utils/circuit_errors.hpp) for a list of all possible circuit errors.**
**To prevent bloating this doc, here is a list of some of the common errors.**

### Kernel Circuits

Expand Down Expand Up @@ -160,7 +160,7 @@ Circuits work by having a fixed size array. As such, we have limits on how many
- too many transient read requests in one tx
- too many transient read request membership witnesses in one tx

You can have a look at our current constants/limitations in [constants.hpp](https://github.com/AztecProtocol/aztec-packages/blob/master/circuits/cpp/src/aztec3/constants.hpp)
You can have a look at our current constants/limitations in [constants.nr](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/aztec/src/constants_gen.nr)

#### 7008 - MEMBERSHIP_CHECK_FAILED

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/dev_docs/limitations/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Due to the rigidity of zk-SNARK circuits, there are upper bounds on the amount o
Here are the current constants:

#include_code constants circuits/cpp/src/aztec3/constants.hpp cpp
#include_code constants /yarn-project/aztec-nr/aztec/src/constants_gen.nr rust

#### What are the consequences?

Expand Down
12 changes: 0 additions & 12 deletions yarn-project/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,6 @@ RUN cd /usr/src/yarn-project/aztec.js && yarn build:web
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/yarn-project-base
COPY --from=builder /usr/src/yarn-project /usr/src/yarn-project

# Download minimal CRS requirements
COPY --from=builder /usr/src/barretenberg/cpp/srs_db/download_ignition.sh /usr/src/yarn-project/circuits.js/resources/download_ignition.sh
WORKDIR /usr/src/yarn-project/circuits.js/resources
RUN ./download_ignition.sh 0 28 3200027
RUN ./download_ignition.sh 0 322560092 322560219 true

# Ensure wasm symlink is removed
RUN rm /usr/src/yarn-project/circuits.js/resources/aztec3-circuits.wasm

# Copy real wasm into yarn-project
RUN cp /usr/src/circuits/cpp/build-wasm/bin/aztec3-circuits.wasm /usr/src/yarn-project/circuits.js/resources/aztec3-circuits.wasm

WORKDIR /usr/src/yarn-project

ENTRYPOINT ["yarn"]
1 change: 0 additions & 1 deletion yarn-project/acir-simulator/src/public/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export function isPublicExecutionResult(
/**
* Collect all public storage reads across all nested executions
* and convert them to PublicDataReads (to match kernel output).
* @param wasm - A module providing low-level wasm access.
* @param execResult - The topmost execution result.
* @returns All public data reads (in execution order).
*/
Expand Down
1 change: 0 additions & 1 deletion yarn-project/acir-simulator/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export type NoirPoint = {
* Computes the resulting storage slot for an entry in a mapping.
* @param mappingSlot - The slot of the mapping within state.
* @param owner - The key of the mapping.
* @param bbWasm - Wasm module for computing.
* @returns The slot in the contract storage where the value is stored.
*/
export function computeSlotForMapping(mappingSlot: Fr, owner: NoirPoint | Fr) {
Expand Down
80 changes: 67 additions & 13 deletions yarn-project/aztec-nr/aztec/src/constants_gen.nr
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in circuits.js
global ARGS_LENGTH: Field = 16;
global RETURN_VALUES_LENGTH: Field = 4;

/**
* Convention for constant array lengths are mainly divided in 2 classes:
* - FUNCTION CALL
* - TRANSACTION
*
* Agreed convention is to use MAX_XXX_PER_CALL resp. MAX_XXX_PER_TX, where XXX denotes a type of element such as
* commitment, or nullifier, e.g.,:
* - MAX_NEW_NULLIFIERS_PER_CALL
* - MAX_NEW_COMMITMENTS_PER_TX
*
* In the kernel circuits, we accumulate elements such as commitments and the nullifiers from all functions calls in a
* transaction. Therefore, we always must have:
* MAX_XXX_PER_TX ≥ MAX_XXX_PER_CALL
*
* For instance:
* MAX_NEW_COMMITMENTS_PER_TX ≥ MAX_NEW_COMMITMENTS_PER_CALL
* MAX_NEW_NULLIFIERS_PER_TX ≥ MAX_NEW_NULLIFIERS_PER_CALL
*
*/

// docs:start:constants
// "PER CALL" CONSTANTS
global MAX_NEW_COMMITMENTS_PER_CALL: Field = 16;
global MAX_NEW_NULLIFIERS_PER_CALL: Field = 16;
global MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL: Field = 4;
Expand All @@ -10,6 +32,8 @@ global MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL: Field = 16;
global MAX_PUBLIC_DATA_READS_PER_CALL: Field = 16;
global MAX_READ_REQUESTS_PER_CALL: Field = 32;
global MAX_PENDING_READ_REQUESTS_PER_CALL: Field = 32;

// "PER TRANSACTION" CONSTANTS
global MAX_NEW_COMMITMENTS_PER_TX: Field = 64;
global MAX_NEW_NULLIFIERS_PER_TX: Field = 64;
global MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX: Field = 8;
Expand All @@ -23,11 +47,17 @@ global MAX_READ_REQUESTS_PER_TX: Field = 128;
global MAX_PENDING_READ_REQUESTS_PER_TX: Field = 128;
global NUM_ENCRYPTED_LOGS_HASHES_PER_TX: Field = 1;
global NUM_UNENCRYPTED_LOGS_HASHES_PER_TX: Field = 1;
// docs:end:constants

// ROLLUP CONTRACT CONSTANTS - constants used only in l1-contracts
global NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP: Field = 16;
// TODO(961): Use this constant everywhere instead of hard-coded "2".
global KERNELS_PER_BASE_ROLLUP: Field = 2;
global MAX_NEW_NULLIFIERS_PER_BASE_ROLLUP: Field = 128;
global MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_BASE_ROLLUP: Field = 32;
global MAX_PUBLIC_DATA_READS_PER_BASE_ROLLUP: Field = 32;

// TREES RELATED CONSTANTS
global VK_TREE_HEIGHT: Field = 3;
global FUNCTION_TREE_HEIGHT: Field = 4;
global CONTRACT_TREE_HEIGHT: Field = 16;
Expand All @@ -36,6 +66,8 @@ global PUBLIC_DATA_TREE_HEIGHT: Field = 254;
global NULLIFIER_TREE_HEIGHT: Field = 20;
global L1_TO_L2_MSG_TREE_HEIGHT: Field = 16;
global ROLLUP_VK_TREE_HEIGHT: Field = 8;

// SUB-TREES RELATED CONSTANTS
global CONTRACT_SUBTREE_HEIGHT: Field = 1;
global CONTRACT_SUBTREE_SIBLING_PATH_LENGTH: Field = 15;
global NOTE_HASH_SUBTREE_HEIGHT: Field = 7;
Expand All @@ -45,22 +77,37 @@ global HISTORIC_BLOCKS_TREE_HEIGHT: Field = 16;
global NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH: Field = 13;
global L1_TO_L2_MSG_SUBTREE_HEIGHT: Field = 4;
global L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH: Field = 12;

// MISC CONSTANTS
global FUNCTION_SELECTOR_NUM_BYTES: Field = 4;
global MAPPING_SLOT_PEDERSEN_SEPARATOR: Field = 4;
global NUM_FIELDS_PER_SHA256: Field = 2;

// NOIR CONSTANTS - constants used only in yarn-packages/noir-contracts
// Some are defined here because Noir doesn't yet support globals referencing other globals yet.
// Move these constants to a noir file once the issue bellow is resolved:
// https://github.com/noir-lang/noir/issues/1734
global L1_TO_L2_MESSAGE_LENGTH: Field = 8;
global L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH: Field = 26;
global MAX_NOTE_FIELDS_LENGTH: Field = 20;
// GET_NOTE_ORACLE_RETURN_LENGT = MAX_NOTE_FIELDS_LENGTH + 1 + 2
// The plus 1 is 1 extra field for nonce.
// + 2 for EXTRA_DATA: [number_of_return_notes, contract_address]
global GET_NOTE_ORACLE_RETURN_LENGTH: Field = 23;
global MAX_NOTES_PER_PAGE: Field = 10;
// VIEW_NOTE_ORACLE_RETURN_LENGTH = MAX_NOTES_PER_PAGE * (MAX_NOTE_FIELDS_LENGTH + 1) + 2;
global VIEW_NOTE_ORACLE_RETURN_LENGTH: Field = 212;
global CALL_CONTEXT_LENGTH: Field = 7;
global HISTORIC_BLOCK_DATA_LENGTH: Field = 7;
global FUNCTION_DATA_LENGTH: Field = 4;
global CONTRACT_DEPLOYMENT_DATA_LENGTH: Field = 6;
// Change this ONLY if you have changed the PrivateCircuitPublicInputs structure.
// In other words, if the structure/size of the public inputs of a function call changes then we
// should change this constant as well as the offsets in private_call_stack_item.nr
global PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH: Field = 155;
global CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH: Field = 3;
global CONTRACT_STORAGE_READ_LENGTH: Field = 2;
// Change this ONLY if you have changed the PublicCircuitPublicInputs structure.
global PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH: Field = 142;
global GET_NOTES_ORACLE_RETURN_LENGTH: Field = 674;
global EMPTY_NULLIFIED_COMMITMENT: Field = 1000000;
Expand All @@ -75,6 +122,23 @@ global CONTRACT_DATA_NUM_BYTES_PER_BASE_ROLLUP: Field = 128;
global CONTRACT_DATA_NUM_BYTES_PER_BASE_ROLLUP_UNPADDED: Field = 104;
global L2_TO_L1_MSGS_NUM_BYTES_PER_BASE_ROLLUP: Field = 128;
global LOGS_HASHES_NUM_BYTES_PER_BASE_ROLLUP: Field = 128;

/**
* Enumerate the hash_indices which are used for pedersen hashing.
* We start from 1 to avoid the default generators. The generator indices are listed
* based on the number of elements each index hashes. The following conditions must be met:
*
* +-----------+-------------------------------+----------------------+
* | Hash size | Number of elements hashed (n) | Condition to use |
* |-----------+-------------------------------+----------------------|
* | LOW | n ≤ 8 | 0 < hash_index ≤ 32 |
* | MID | 8 < n ≤ 16 | 32 < hash_index ≤ 40 |
* | HIGH | 16 < n ≤ 48 | 40 < hash_index ≤ 48 |
* +-----------+-------------------------------+----------------------+
*
* Note: When modifying, modify `GeneratorIndexPacker` in packer.hpp accordingly.
*/
// Indices with size ≤ 8
global GENERATOR_INDEX__COMMITMENT = 1;
global GENERATOR_INDEX__COMMITMENT_NONCE = 2;
global GENERATOR_INDEX__UNIQUE_COMMITMENT = 3;
Expand Down Expand Up @@ -103,21 +167,11 @@ global GENERATOR_INDEX__SIGNED_TX_REQUEST = 25;
global GENERATOR_INDEX__GLOBAL_VARIABLES = 26;
global GENERATOR_INDEX__PARTIAL_ADDRESS = 27;
global GENERATOR_INDEX__BLOCK_HASH = 28;
// Indices with size ≤ 16
global GENERATOR_INDEX__TX_REQUEST = 33;
global GENERATOR_INDEX__SIGNATURE_PAYLOAD = 34;
// Indices with size ≤ 44
global GENERATOR_INDEX__VK = 41;
global GENERATOR_INDEX__PRIVATE_CIRCUIT_PUBLIC_INPUTS = 42;
global GENERATOR_INDEX__PUBLIC_CIRCUIT_PUBLIC_INPUTS = 43;
global GENERATOR_INDEX__FUNCTION_ARGS = 44;
global STORAGE_SLOT_GENERATOR_INDEX__BASE_SLOT = 0;
global STORAGE_SLOT_GENERATOR_INDEX__MAPPING_SLOT = 1;
global STORAGE_SLOT_GENERATOR_INDEX__MAPPING_SLOT_PLACEHOLDER = 2;
global PRIVATE_STATE_NOTE_GENERATOR_INDEX__VALUE = 1;
global PRIVATE_STATE_NOTE_GENERATOR_INDEX__OWNER = 2;
global PRIVATE_STATE_NOTE_GENERATOR_INDEX__CREATOR = 3;
global PRIVATE_STATE_NOTE_GENERATOR_INDEX__SALT = 4;
global PRIVATE_STATE_NOTE_GENERATOR_INDEX__NONCE = 5;
global PRIVATE_STATE_NOTE_GENERATOR_INDEX__MEMO = 6;
global PRIVATE_STATE_NOTE_GENERATOR_INDEX__IS_DUMMY = 7;
global PRIVATE_STATE_TYPE__PARTITIONED = 1;
global PRIVATE_STATE_TYPE__WHOLE = 2;
2 changes: 0 additions & 2 deletions yarn-project/aztec-sandbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ yarn start

It will look for a local Ethereum RPC to talk to but you can change this with the `ETHEREUM_HOST` environment variable.

You'll also need to run `./bootstrap.sh` in the `circuits/cpp` directory in order to build the WASM binaries.

## Examples

The package also includes 2 examples. There are some system prerequisites that you will need to run these locally:
Expand Down
Loading

0 comments on commit 4973cfb

Please sign in to comment.