Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jc/update with foundry #101

Merged
merged 23 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confused why we need this file again? This was used by Nargo before...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah you're right. I will delete it

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
Loading