Skip to content

Commit

Permalink
Merge pull request #101 from AztecProtocol/jc/update-with-foundry
Browse files Browse the repository at this point in the history
Jc/update with foundry
  • Loading branch information
critesjosh authored Jan 2, 2025
2 parents 89577f0 + 8f455af commit 388be0b
Show file tree
Hide file tree
Showing 66 changed files with 49 additions and 12,275 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/with_foundry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Install libc++
run: |
sudo apt-get update
sudo apt-get install -y libc++-dev libc++abi-dev
- name: Get latest version
id: versions_step
Expand All @@ -39,8 +46,7 @@ jobs:

- name: Use bbup
run: |
bbup -v 0.41.0
bb --version # or any other bbup command you want to run
bbup -v 0.63.1
shell: bash

- name: Generate verifier contract
Expand All @@ -56,4 +62,4 @@ jobs:

- name: Test with Foundry
run: |
forge test --optimize --optimizer-runs 5000 --evm-version london
forge test --optimize --optimizer-runs 5000 --evm-version cancun
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "with-foundry/lib/foundry-noir-helper"]
path = with-foundry/lib/foundry-noir-helper
url = https://github.com/0xnonso/foundry-noir-helper
5 changes: 4 additions & 1 deletion with-foundry/.gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
branch = v1.4.0

[submodule "with-foundry/lib/foundry-noir-helper"]
path = with-foundry/lib/foundry-noir-helper
url = https://github.com/0xnonso/foundry-noir-helper
29 changes: 5 additions & 24 deletions with-foundry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,12 @@ Install [noirup](https://noir-lang.org/docs/getting_started/installation/#instal
curl -L https://foundry.paradigm.xyz | bash
```

4. Install the correct version of the
[Barretenberg](https://github.com/AztecProtocol/aztec-packages/tree/master/barretenberg/cpp/src/barretenberg/bb#version-compatibility-with-noir)
proving backend for Noir (bb).
4. Install foundry dependencies by running `forge install 0xnonso/foundry-noir-helper --no-commit`.

```bash
curl -L https://raw.githubusercontent.com/AztecProtocol/aztec-packages/master/barretenberg/cpp/installation/install | bash
```

then
5. Install `bbup`, the tool for managing Barretenberg versions, by following the instructions
[here](https://github.com/AztecProtocol/aztec-packages/blob/master/barretenberg/bbup/README.md#installation).

```bash
bbup -v 0.41.0 # compatible with nargo 0.31.0
```
6. Then run `bbup`.

## Generate verifier contract and proof

Expand All @@ -60,18 +53,6 @@ bb contract

A file named `contract.sol` should appear in the `circuits/target` folder.

#### Proof

You also need a proof, as this template currently doesn't employ `ffi` to call `nargo execute` (to
generate the witness) and `bb prove` by itself. For this, ensure your prover parameters are correct
in `Prover.toml` and run:

```bash
bb prove -b ./target/with_foundry.json -w ./target/witness.gz -o ./target/with_foundry.proof
```

A file named `with_foundry.proof` should appear in the `./circuits/target` folder.

### Test with Foundry

We're ready to test with Foundry. There's a basic test inside the `test` folder that deploys the
Expand All @@ -84,7 +65,7 @@ deep" error on the solc compiler**. Then it will run the test, expecting it to p
inputs, and fail with wrong inputs:

```bash
forge test --optimize --optimizer-runs 5000 --evm-version london
forge test --optimize --optimizer-runs 5000 --evm-version cancun
```

#### Testing On-chain
Expand Down
1 change: 1 addition & 0 deletions with-foundry/circuits/Prover.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
return = 3
x = 3
y = 3
2 changes: 1 addition & 1 deletion with-foundry/circuits/Verifier.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
return = "0x0000000000000000000000000000000000000000000000000000000000000003"
y = "0x0000000000000000000000000000000000000000000000000000000000000003"
y = "0x0000000000000000000000000000000000000000000000000000000000000003"
5 changes: 0 additions & 5 deletions with-foundry/circuits/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,3 @@ fn main(x: Field, y: pub Field) -> pub Field {
assert(x == y);
y
}

#[export]
fn exported() -> Field {
3
}
5 changes: 5 additions & 0 deletions with-foundry/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ libs = ["lib"]
fs_permissions = [{ access = "read-write", path = "./"},{ access = "read-write", path = "/tmp/"}]
ffi = true

[profile.remappings]
# ds-test = "lib/forge-std/lib/ds-test/src/"
forge-std = "lib/foundry-noir-helper/lib/forge-std/src/"
# foundry-noir-helper = "lib/foundry-noir-helper/src/"

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
92 changes: 0 additions & 92 deletions with-foundry/lib/forge-std/.github/workflows/ci.yml

This file was deleted.

29 changes: 0 additions & 29 deletions with-foundry/lib/forge-std/.github/workflows/sync.yml

This file was deleted.

4 changes: 0 additions & 4 deletions with-foundry/lib/forge-std/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions with-foundry/lib/forge-std/.gitmodules

This file was deleted.

Loading

0 comments on commit 388be0b

Please sign in to comment.