Skip to content

Commit

Permalink
chore!: move noir out of yarn-project (#4479)
Browse files Browse the repository at this point in the history
Fixes #4107
  • Loading branch information
spypsy committed Feb 12, 2024
1 parent ca4dd60 commit 1fe674b
Show file tree
Hide file tree
Showing 555 changed files with 3,998 additions and 1,105 deletions.
19 changes: 18 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,17 @@ jobs:
name: "Build and test"
command: build l1-contracts

noir-projects:
machine:
image: ubuntu-2204:2023.07.2
resource_class: large
steps:
- *checkout
- *setup_env
- run:
name: "Build and test"
command: build noir-projects

boxes-files:
machine:
image: ubuntu-2204:2023.07.2
Expand Down Expand Up @@ -1207,14 +1218,20 @@ workflows:

- boxes-files: *defaults

- noir-projects:
requires:
- avm-transpiler
- noir-ecr-manifest
<<: *defaults

# Yarn Project
- yarn-project-base:
requires:
- avm-transpiler
- l1-contracts
- bb-js
- noir-ecr-manifest
- noir-packages
- noir-projects
- boxes-files
<<: *defaults
- yarn-project:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/mirror_repos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,22 @@ jobs:
token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
- name: Push to aztec-nr repo
run: |
SUBREPO_PATH=yarn-project/aztec-nr
SUBREPO_PATH=aztec-nr
git config --global user.name AztecBot
git config --global user.email tech@aztecprotocol.com
monorepo_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
# list all aztec-packages tags, take the "highest" version
monorepo_tag="$(git tag --list aztec-packages-v* | sort --version-sort | tail -1)"
monorepo_protocol_circuits_path="yarn-project/noir-protocol-circuits"
monorepo_protocol_circuits_path="noir-packages/noir-protocol-circuits"
# take all Nargo.toml files that reference noir-protocol-circuits
nargo_files="$(find $SUBREPO_PATH -name 'Nargo.toml' | xargs grep --files-with-matches 'noir-protocol-circuits')"
# match lines like this:
# protocol_types = { path = "../../noir-protocol-circuits/src/crates/types" }
# and replace with
# protocol_types = { git="https://github.com/aztecprotocol/aztec-packages", tag="aztec-packages-v0.16.9", directory="yarn-project/noir-protocol-circuits/src/crates/types" }
# protocol_types = { git="https://github.com/aztecprotocol/aztec-packages", tag="aztec-packages-v0.16.9", directory="noir-projects/noir-protocol-circuits/src/crates/types" }
for nargo_file in $nargo_files; do
sed --regexp-extended --in-place \
"s;path\s*=\s*\".*noir-protocol-circuits(.*)\";git=\"$monorepo_url\", tag=\"$monorepo_tag\", directory=\"$monorepo_protocol_circuits_path\1\";" \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/protocol-circuits-gate-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
run: nargo --version

- name: Generate gates report
working-directory: ./yarn-project/noir-protocol-circuits/src
working-directory: ./noir-projects/noir-protocol-circuits/src
run: |
nargo info --json > protocol_circuits_report.json
mv protocol_circuits_report.json ../../../protocol_circuits_report.json
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ cmake-build-debug
# Local Netlify folder
.netlify

.graphite*
.graphite*

noir-protocol-circuits/src/target/*.json
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ All the packages that make up [Aztec](https://docs.aztec.network).

## Popular packages

- [Aztec.nr](./yarn-project/aztec-nr/): A [Noir](https://noir-lang.org) framework for smart contracts on Aztec.
- [Aztec.nr](./aztec-nr/): A [Noir](https://noir-lang.org) framework for smart contracts on Aztec.
- [Aztec](./yarn-project/aztec/): A package for starting up local dev net modules, including a local 'sandbox' devnet, an Ethereum network, deployed rollup contracts and Aztec execution environment.
- [Aztec.js](./yarn-project/aztec.js/): A tool for interacting with the Aztec network. It communicates via the [Private Execution Environment (PXE)](./yarn-project/pxe/).
- [Example contracts](./yarn-project/noir-contracts/): Example contracts for the Aztec network, written in Noir.
- [Example contracts](./noir-contracts/): Example contracts for the Aztec network, written in Noir.
- [End to end tests](./yarn-project/end-to-end/): Integration tests written in Typescript--a good reference for how to use the packages for specific tasks.
- [Aztec Boxes](./boxes/): Example starter projects.

Expand Down Expand Up @@ -71,7 +71,8 @@ We currently use [git-subrepo](https://github.com/ingydotnet/git-subrepo) to man
There is an automatic mirror pushing noir to a PR on noir side. If the mirror is not working, generally we need to do a "git subrepo pull noir".

Recovering if the sync is not happening with basic pull commands:
- manually editing the commit variable in noir/.gitrepo:
this needs to exist in the branch we push to, and have the same content as our base. This is similar to submodules, except instead of pointing to the final state of the module, it points to the last commit we have sync'd from, for purposes of commit replay. This can be fixed to match the commit in master after merges.
- manually editing the parent variable in noir/.gitrepo: this is the parent of the last sync commit on aztec side. If you get errors with a commit not being found in the upstream repo, and the commit mentioned is not the commit variable above, it might indicate this is somehow incorrect. This can happen when commit content is ported without its history, e.g. squashes
- use pull --force ONLY where you would use git reset. That is, if you really want to match some upstream noir for a purpose its fine, but you'll lose local changes (if any)

- manually editing the commit variable in noir/.gitrepo:
this needs to exist in the branch we push to, and have the same content as our base. This is similar to submodules, except instead of pointing to the final state of the module, it points to the last commit we have sync'd from, for purposes of commit replay. This can be fixed to match the commit in master after merges.
- manually editing the parent variable in noir/.gitrepo: this is the parent of the last sync commit on aztec side. If you get errors with a commit not being found in the upstream repo, and the commit mentioned is not the commit variable above, it might indicate this is somehow incorrect. This can happen when commit content is ported without its history, e.g. squashes
- use pull --force ONLY where you would use git reset. That is, if you really want to match some upstream noir for a purpose its fine, but you'll lose local changes (if any)
5 changes: 3 additions & 2 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ 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 barretenberg/cpp && ./format.sh staged)" >$HOOKS_DIR/pre-commit
chmod +x $HOOKS_DIR/pre-commit

git submodule update --init --recursive
Expand All @@ -55,6 +55,7 @@ PROJECTS=(
noir
l1-contracts
avm-transpiler
noir-projects
yarn-project
)

Expand All @@ -66,7 +67,7 @@ for P in "${PROJECTS[@]}"; do
echo "**************************************"
echo
$P/bootstrap_cache.sh
else
else
echo "**************************************"
echo -e "\033[1mBootstrapping $P...\033[0m"
echo "**************************************"
Expand Down
2 changes: 2 additions & 0 deletions boxes/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
# Produces a container that can be run to test a specific box. See docker-compose.yml.
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/aztec AS aztec
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/noir as noir
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/noir-projects as noir-projects

# We need yarn. Start fresh container.
FROM node:18.19.0
COPY --from=aztec /usr/src /usr/src
COPY --from=noir /usr/src/noir/target/release/nargo /usr/src/noir/target/release/nargo
COPY --from=noir-projects /usr/src/noir-projects/aztec-nr /usr/src/noir-projects/aztec-nr
WORKDIR /usr/src/boxes
ENV AZTEC_NARGO=/usr/src/noir/target/release/nargo
ENV AZTEC_CLI=/usr/src/yarn-project/cli/aztec-cli-dest
Expand Down
2 changes: 1 addition & 1 deletion boxes/blank-react/src/contracts/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
aztec = { path = "../../../../yarn-project/aztec-nr/aztec" }
aztec = { path = "../../../../noir-projects/aztec-nr/aztec" }
2 changes: 1 addition & 1 deletion boxes/blank/src/contracts/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
aztec = { path = "../../../../yarn-project/aztec-nr/aztec" }
aztec = { path = "../../../../noir-projects/aztec-nr/aztec" }
8 changes: 4 additions & 4 deletions boxes/token/src/contracts/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
aztec = { path = "../../../../yarn-project/aztec-nr/aztec" }
safe_math = { path = "../../../../yarn-project/aztec-nr/safe-math" }
compressed_string = {path = "../../../../yarn-project/aztec-nr/compressed-string"}
authwit = { path = "../../../../yarn-project/aztec-nr/authwit" }
aztec = { path = "../../../../noir-projects/aztec-nr/aztec" }
safe_math = { path = "../../../../noir-projects/aztec-nr/safe-math" }
compressed_string = { path = "../../../../noir-projects/aztec-nr/compressed-string" }
authwit = { path = "../../../../noir-projects/aztec-nr/authwit" }
9 changes: 9 additions & 0 deletions build_manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ noir-packages:
- ^noir/tooling/noirc_abi
- ^noir/tooling/noirc_abi_wasm

noir-projects:
buildDir: noir-projects
dependencies:
- noir
- avm-transpiler

noir-compile-acir-tests:
buildDir: noir/test_programs
# Awkward. Maybe change dockerfile paths to be absolute.
Expand Down Expand Up @@ -135,6 +141,7 @@ yarn-project-base:
- noir-packages
- boxes-files
- avm-transpiler
- noir-projects

yarn-project:
buildDir: yarn-project
Expand Down Expand Up @@ -179,6 +186,7 @@ boxes:
dependencies:
- aztec
- noir
- noir-projects
runDependencies:
- aztec

Expand Down Expand Up @@ -206,6 +214,7 @@ docs:
- ^.*.nr$
dependencies:
- yarn-project
- noir-projects

yellow-paper:
buildDir: yellow-paper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ To generate them, include a `--ts` option in the `codegen` command with a path t
aztec-cli codegen ./aztec-nargo/output/target/path -o src/artifacts --ts
```

Below is typescript code generated from the [Token](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/noir-contracts/contracts/token_contract/src/main.nr) contract:
Below is typescript code generated from the [Token](https://github.com/AztecProtocol/aztec-packages/blob/master/noir-projects/noir-contracts/contracts/token_contract/src/main.nr) contract:

```ts showLineNumbers
export class TokenContract extends ContractBase {
Expand Down Expand Up @@ -127,7 +127,7 @@ To generate them, include a `--nr` option in the `codegen` command with a path t
aztec-cli codegen ./aztec-nargo/output/target/path -o ./path/to/output/folder --nr
```

Below is an example interface, also generated from the [Token](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/noir-contracts/contracts/token_contract/src/main.nr) contract:
Below is an example interface, also generated from the [Token](https://github.com/AztecProtocol/aztec-packages/blob/master/noir-projects/noir-contracts/contracts/token_contract/src/main.nr) contract:

```rust
impl TokenPrivateContextInterface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ There are several optional arguments that can be passed:
<Tabs groupId="deployment-methods">
<TabItem value="cli" label="Aztec CLI">

`aztec-cli deploy` takes 1 mandatory argument which is the path to the contract artifact file in a JSON format (e.g. `contracts/target/PrivateToken.json`). Alternatively you can pass the name of an example contract as exported by `@aztec/noir-contracts` (run `aztec-cli example-contracts` to see the full list of contracts available).
`aztec-cli deploy` takes 1 mandatory argument which is the path to the contract artifact file in a JSON format (e.g. `contracts/target/PrivateToken.json`). Alternatively you can pass the name of an example contract as exported by `@aztec/noir-contracts.js` (run `aztec-cli example-contracts` to see the full list of contracts available).

The command also takes the following optional arguments:

Expand Down Expand Up @@ -105,7 +105,7 @@ const tx = ExampleContract.deploy(pxe).send({

### Deploying token contract

To give you a more complete example we will deploy a `Token` contract whose artifacts are included in the `@aztec/noir-contracts` package.
To give you a more complete example we will deploy a `Token` contract whose artifacts are included in the `@aztec/noir-contracts.js` package.

The contract has `admin` as a constructor argument.
We will deploy the contract with the `aztec-cli` and pass the `admin` address as an argument.
Expand Down
24 changes: 16 additions & 8 deletions docs/docs/developers/contracts/references/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,57 @@ description: Documentation of Aztec's Global Variables in the Public and Private
---

# Global Variables
For developers coming from solidity, this concept will be similar to how the global `block` variable exposes a series of block values. The idea is the same in Aztec. Developers can access a namespace of values made available in each function.

`Aztec` has two execution environments, Private and Public. Each execution environment contains a different global variables object.
For developers coming from solidity, this concept will be similar to how the global `block` variable exposes a series of block values. The idea is the same in Aztec. Developers can access a namespace of values made available in each function.

## Private Global Variables
#include_code private-global-variables /yarn-project/aztec-nr/aztec/src/context/globals/private_global_variables.nr rust
`Aztec` has two execution environments, Private and Public. Each execution environment contains a different global variables object.

## Private Global Variables

#include_code private-global-variables /noir-projects/aztec-nr/aztec/src/context/globals/private_global_variables.nr rust

The private global variables contain:

### Chain Id

The chain id differs depending on which Aztec instance you are on ( NOT the Ethereum hardfork that the rollup is settling to ). On original deployment of the network, this value will be 1.

```rust
context.chain_id();
```

### Version

The version number indicates which Aztec hardfork you are on. The Genesis block of the network will have the version number 1.

```rust
context.version();
```


## Public Global Variables
#include_code global-variables /yarn-project/noir-protocol-circuits/src/crates/types/src/abis/global_variables.nr rust

#include_code global-variables /noir-projects/noir-protocol-circuits/src/crates/types/src/abis/global_variables.nr rust

The public global variables contain the values present in the `private global variables` described above, with the addition of:

### Timestamp

The timestamp is the unix timestamp in which the block has been executed. The value is provided by the block's proposer (therefore can have variance). This value will always increase.

```rust
context.timestamp();
```

### Block Number

The block number is a sequential identifier that labels each individual block of the network. This value will be the block number of the block the accessing transaction is included in.
The block number of the genesis block will be 1, with the number increasing by 1 for every block after.

```rust
context.block_number();
```

:::info *Why do the available global variables differ per execution environment?*
The global variables are constrained by the proving environment. In the case of public functions, they are executed on a sequencer that will know the timestamp and number of the next block ( as they are the block producer ).
:::info _Why do the available global variables differ per execution environment?_
The global variables are constrained by the proving environment. In the case of public functions, they are executed on a sequencer that will know the timestamp and number of the next block ( as they are the block producer ).
In the case of private functions, we cannot be sure which block our transaction will be included in, hence we can not guarantee values for the timestamp or block number.
:::
Loading

0 comments on commit 1fe674b

Please sign in to comment.