From 9de0268423d6ac4ce76dac3bbb6978bd50885b8a Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 14:36:50 +0000 Subject: [PATCH 001/108] Add solidity verifier workflow --- .github/workflows/test-solidity-verifier.yml | 37 ++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/test-solidity-verifier.yml diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml new file mode 100644 index 00000000000..fc46f2b36f8 --- /dev/null +++ b/.github/workflows/test-solidity-verifier.yml @@ -0,0 +1,37 @@ +name: Test Solidity Verifier + +on: + push: + branches: + - jb-test-solidity-verifier + +jobs: + build-apple-darwin: + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.tag || env.GITHUB_REF }} + + - name: Install Foundry + uses: onbjerg/foundry-toolchain@v1 + with: + version: nightly + + - name: Download nargo binary + uses: actions/download-artifact@v3 + with: + name: nargo + path: ./nargo + + - name: Test nargo + run: | + nargo_binary=${{ github.workspace }}/nargo/nargo + chmod +x $nargo_binary + $nargo_binary -V + + - name: Run Anvil + run: | + anvil > /dev/null 2>&1 & + sleep 10 From bd694b3f92af6983069228307816034c495f9028 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 14:40:23 +0000 Subject: [PATCH 002/108] Fix install nargo step --- .github/workflows/test-solidity-verifier.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index fc46f2b36f8..181b41a71b6 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -19,11 +19,10 @@ jobs: with: version: nightly - - name: Download nargo binary - uses: actions/download-artifact@v3 - with: - name: nargo - path: ./nargo + - name: Install nargo + run: | + curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash + noirup - name: Test nargo run: | From 02a6babb9426652c3d106ed0260876d95c3a3417 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 14:43:10 +0000 Subject: [PATCH 003/108] Fix noirup --- .github/workflows/test-solidity-verifier.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index 181b41a71b6..27caf87ffd4 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -22,6 +22,7 @@ jobs: - name: Install nargo run: | curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash + source /Users/runner/.bashrc noirup - name: Test nargo From f0d93d0c9e68a00348d74c4087c4aeb17cf426aa Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 14:46:01 +0000 Subject: [PATCH 004/108] Run nargo -v --- .github/workflows/test-solidity-verifier.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index 27caf87ffd4..8264f68db61 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -25,11 +25,8 @@ jobs: source /Users/runner/.bashrc noirup - - name: Test nargo - run: | - nargo_binary=${{ github.workspace }}/nargo/nargo - chmod +x $nargo_binary - $nargo_binary -V + - name: Test nargo version + run: nargo -V - name: Run Anvil run: | From 9de8e887b362fda4258ec5f382cdb6222c043488 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 14:54:56 +0000 Subject: [PATCH 005/108] Fix nargo binary path --- .github/workflows/test-solidity-verifier.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index 8264f68db61..58ce5a4d5c7 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -25,8 +25,11 @@ jobs: source /Users/runner/.bashrc noirup - - name: Test nargo version - run: nargo -V + - name: Test nargo + run: | + nargo_binary="/Users/runner/.nargo/bin/nargo" + chmod +x $nargo_binary + $nargo_binary -V - name: Run Anvil run: | From 5ba830b5ada27eb3923f4c3013491c146d1ad74a Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 14:59:34 +0000 Subject: [PATCH 006/108] codegen-verifier for contracts --- .github/workflows/test-solidity-verifier.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index 58ce5a4d5c7..dfd83b6bb0c 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -19,6 +19,11 @@ jobs: with: version: nightly + - name: Run Anvil + run: | + anvil > /dev/null 2>&1 & + sleep 10 + - name: Install nargo run: | curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash @@ -31,7 +36,11 @@ jobs: chmod +x $nargo_binary $nargo_binary -V - - name: Run Anvil - run: | - anvil > /dev/null 2>&1 & - sleep 10 + - name: Run codegen-verifier for 1_mul + working-directory: ./tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul + run: $nargo_binary codegen-verifier + + - name: Run codegen-verifier for double_verify_proof + working-directory: ./tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof + run: $nargo_binary codegen-verifier + From 489fe64921a18cac8a616accf6545a85c9147897 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 15:01:28 +0000 Subject: [PATCH 007/108] Fix path --- .github/workflows/test-solidity-verifier.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index dfd83b6bb0c..a0d6ad75d68 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -36,11 +36,14 @@ jobs: chmod +x $nargo_binary $nargo_binary -V + - name: Dirs + run: ls -R + - name: Run codegen-verifier for 1_mul - working-directory: ./tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul + working-directory: tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul run: $nargo_binary codegen-verifier - name: Run codegen-verifier for double_verify_proof - working-directory: ./tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof + working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof run: $nargo_binary codegen-verifier From 2b8b84bb73da289d9c4c3e0da4e06cc30c99fd62 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 15:03:39 +0000 Subject: [PATCH 008/108] Fix path --- .github/workflows/test-solidity-verifier.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index a0d6ad75d68..ac75496245f 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -40,10 +40,10 @@ jobs: run: ls -R - name: Run codegen-verifier for 1_mul - working-directory: tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul + working-directory: tooling/nargo_cli/tests/execution_success/1_mul run: $nargo_binary codegen-verifier - name: Run codegen-verifier for double_verify_proof - working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof + working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof run: $nargo_binary codegen-verifier From 865a8db90aafa8b9aecddf5ac16067eceff37afd Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 15:07:03 +0000 Subject: [PATCH 009/108] Try fix --- .github/workflows/test-solidity-verifier.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index ac75496245f..e4b655a2b9f 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -35,6 +35,8 @@ jobs: nargo_binary="/Users/runner/.nargo/bin/nargo" chmod +x $nargo_binary $nargo_binary -V + cd ./tooling/nargo_cli/tests/execution_success/1_mul + $nargo_binary codegen-verifier - name: Dirs run: ls -R From 239efc74538c7fb415d5eb552491a6fa2af18f48 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 15:13:14 +0000 Subject: [PATCH 010/108] Fix nargo --- .github/workflows/test-solidity-verifier.yml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index e4b655a2b9f..53a6e638656 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -29,23 +29,14 @@ jobs: curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash source /Users/runner/.bashrc noirup - - - name: Test nargo - run: | - nargo_binary="/Users/runner/.nargo/bin/nargo" - chmod +x $nargo_binary - $nargo_binary -V - cd ./tooling/nargo_cli/tests/execution_success/1_mul - $nargo_binary codegen-verifier - - - name: Dirs - run: ls -R + echo "/Users/runner/.nargo/bin" >> $GITHUB_PATH + nargo -V - name: Run codegen-verifier for 1_mul working-directory: tooling/nargo_cli/tests/execution_success/1_mul - run: $nargo_binary codegen-verifier + run: nargo codegen-verifier - name: Run codegen-verifier for double_verify_proof working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof - run: $nargo_binary codegen-verifier + run: nargo codegen-verifier From 32aaed77545f07395b6f775140feae4e14107647 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 15:19:35 +0000 Subject: [PATCH 011/108] Fix codegen-verifier --- .github/workflows/test-solidity-verifier.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index 53a6e638656..fdb01178352 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -34,9 +34,13 @@ jobs: - name: Run codegen-verifier for 1_mul working-directory: tooling/nargo_cli/tests/execution_success/1_mul - run: nargo codegen-verifier + run: | + nargo codegen-verifier + ls -R + + # - name: Run codegen-verifier for double_verify_proof + # working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof + # run: nargo codegen-verifier - - name: Run codegen-verifier for double_verify_proof - working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof - run: nargo codegen-verifier - + - name: Create new Foundry project + run: forge new foundry-project \ No newline at end of file From c60af0c6256ea6fc45df793763542b64051e92cc Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 15:26:17 +0000 Subject: [PATCH 012/108] Fix forge init --- .github/workflows/test-solidity-verifier.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index fdb01178352..c075ad8118a 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -43,4 +43,4 @@ jobs: # run: nargo codegen-verifier - name: Create new Foundry project - run: forge new foundry-project \ No newline at end of file + run: forge init foundry-project \ No newline at end of file From 13f76c959a466b6d556e911d2adf45f6c2319b69 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 15:52:56 +0000 Subject: [PATCH 013/108] Fix init forge --- .github/workflows/test-solidity-verifier.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index c075ad8118a..db607695da1 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -31,6 +31,9 @@ jobs: noirup echo "/Users/runner/.nargo/bin" >> $GITHUB_PATH nargo -V + + - name: Create new Foundry project + run: forge init foundry-project - name: Run codegen-verifier for 1_mul working-directory: tooling/nargo_cli/tests/execution_success/1_mul @@ -40,7 +43,4 @@ jobs: # - name: Run codegen-verifier for double_verify_proof # working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof - # run: nargo codegen-verifier - - - name: Create new Foundry project - run: forge init foundry-project \ No newline at end of file + # run: nargo codegen-verifier \ No newline at end of file From b6593c3cfa78668514e942da3c00200b304443e1 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 16:01:24 +0000 Subject: [PATCH 014/108] Forge build --- .github/workflows/test-solidity-verifier.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index db607695da1..ab28930a291 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -37,10 +37,20 @@ jobs: - name: Run codegen-verifier for 1_mul working-directory: tooling/nargo_cli/tests/execution_success/1_mul - run: | - nargo codegen-verifier - ls -R + run: nargo codegen-verifier # - name: Run codegen-verifier for double_verify_proof # working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof - # run: nargo codegen-verifier \ No newline at end of file + # run: nargo codegen-verifier + + - name: Copy compiled 1_mul + working-directory: foundry-project + run: cp tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol src/1_mul.sol + + # - name: Copy compiled double_verify_proof + # working-directory: foundry-project + # run: cp tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof/plonk_vk.sol src/double_verify_proof.sol + + - name: Forge build + working-directory: foundry-project + run: forge build \ No newline at end of file From 3ae69aea6604dce60b5316e115c8ffcf5d7261c5 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 16:02:41 +0000 Subject: [PATCH 015/108] Replace macos for ubuntu --- .github/workflows/test-solidity-verifier.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index ab28930a291..b46b76c53fb 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -6,8 +6,8 @@ on: - jb-test-solidity-verifier jobs: - build-apple-darwin: - runs-on: macos-latest + test-solidity-verifier: + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 From bcce07743205d6d0911cf404ed376bab0cd6c5e5 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 16:04:21 +0000 Subject: [PATCH 016/108] Fix for ubuntu --- .github/workflows/test-solidity-verifier.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index b46b76c53fb..e576aa17d5f 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -27,7 +27,7 @@ jobs: - name: Install nargo run: | curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash - source /Users/runner/.bashrc + source /home/runner/.bashrc noirup echo "/Users/runner/.nargo/bin" >> $GITHUB_PATH nargo -V From fe069ac91b16a758b2ef1ebdec05571523e4f905 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 17:10:13 +0000 Subject: [PATCH 017/108] Move .bashrc --- .github/workflows/test-solidity-verifier.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index e576aa17d5f..1de824a3e5e 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -27,8 +27,8 @@ jobs: - name: Install nargo run: | curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash - source /home/runner/.bashrc noirup + source /home/runner/.bashrc echo "/Users/runner/.nargo/bin" >> $GITHUB_PATH nargo -V From a40625da7989edbbe419eeda062497d6f28c2719 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 17:11:50 +0000 Subject: [PATCH 018/108] Try fixes --- .github/workflows/test-solidity-verifier.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index 1de824a3e5e..c045976e900 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -27,8 +27,16 @@ jobs: - name: Install nargo run: | curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash + + export PATH="/home/runner/.nargo/bin:$PATH" + + echo $PATH + + ls -la /home/runner/.nargo/bin + + /home/runner/.nargo/bin/noirup + noirup - source /home/runner/.bashrc echo "/Users/runner/.nargo/bin" >> $GITHUB_PATH nargo -V From 7e7688017f2396cd3bd09ccd7d57a5caa43271e1 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 17:13:30 +0000 Subject: [PATCH 019/108] Add git config --- .github/workflows/test-solidity-verifier.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index c045976e900..b2e842de6ec 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -24,18 +24,17 @@ jobs: anvil > /dev/null 2>&1 & sleep 10 + + - name: Configure git + run: | + git config user.name kevaundray + git config user.email kevtheappdev@gmail.com + - name: Install nargo run: | curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash - export PATH="/home/runner/.nargo/bin:$PATH" - echo $PATH - - ls -la /home/runner/.nargo/bin - - /home/runner/.nargo/bin/noirup - noirup echo "/Users/runner/.nargo/bin" >> $GITHUB_PATH nargo -V From 6317c388625499f3d86af39b578db7c676b30dd1 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 17:16:14 +0000 Subject: [PATCH 020/108] Fix nargo --- .github/workflows/test-solidity-verifier.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index b2e842de6ec..5cf5dbaabf8 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -34,9 +34,8 @@ jobs: run: | curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash export PATH="/home/runner/.nargo/bin:$PATH" - noirup - echo "/Users/runner/.nargo/bin" >> $GITHUB_PATH + echo "/home/runner/.nargo/bin" >> $GITHUB_PATH nargo -V - name: Create new Foundry project From 2f95c2abc0d43e390897dbdb99de234bf94f9ccc Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 17:18:25 +0000 Subject: [PATCH 021/108] Fixes --- .github/workflows/test-solidity-verifier.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index 5cf5dbaabf8..d4175d80278 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -49,9 +49,12 @@ jobs: # working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof # run: nargo codegen-verifier + - name: Output folder content + run: ls -R + - name: Copy compiled 1_mul working-directory: foundry-project - run: cp tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol src/1_mul.sol + run: cp noir/tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol noir/src/1_mul.sol # - name: Copy compiled double_verify_proof # working-directory: foundry-project From 93cdb97f31950a6cb7582cdb877e684c9891fb50 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 17:21:31 +0000 Subject: [PATCH 022/108] Fix copy --- .github/workflows/test-solidity-verifier.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index d4175d80278..32236dcf96c 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -49,12 +49,12 @@ jobs: # working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof # run: nargo codegen-verifier - - name: Output folder content - run: ls -R + - name: Output foundry-project + working-directory: foundry-project + run: ls -R - name: Copy compiled 1_mul - working-directory: foundry-project - run: cp noir/tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol noir/src/1_mul.sol + run: cp tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol foundry-project/src/1_mul.sol # - name: Copy compiled double_verify_proof # working-directory: foundry-project From ac0c6c2840fa4303cbc6fe2334b855bb2a6087f4 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 17:24:35 +0000 Subject: [PATCH 023/108] Add deploy --- .github/workflows/test-solidity-verifier.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index 32236dcf96c..ed06006ce92 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -49,10 +49,6 @@ jobs: # working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof # run: nargo codegen-verifier - - name: Output foundry-project - working-directory: foundry-project - run: ls -R - - name: Copy compiled 1_mul run: cp tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol foundry-project/src/1_mul.sol @@ -60,6 +56,14 @@ jobs: # working-directory: foundry-project # run: cp tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof/plonk_vk.sol src/double_verify_proof.sol + - name: Output foundry-project/src + working-directory: foundry-project/src + run: ls -R + - name: Forge build working-directory: foundry-project - run: forge build \ No newline at end of file + run: forge build + + - name: Forge deploy + working-directory: foundry-project + run: forge create --rpc-url http://127.0.0.1:8545 src/1_mul.sol:UltraVerifier \ No newline at end of file From 1e192fcd6cf8c6418ad2a52df9d172e07e016aef Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 17:27:13 +0000 Subject: [PATCH 024/108] Enable double_verify_proof --- .github/workflows/test-solidity-verifier.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index ed06006ce92..2233310a1c9 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -24,7 +24,6 @@ jobs: anvil > /dev/null 2>&1 & sleep 10 - - name: Configure git run: | git config user.name kevaundray @@ -45,16 +44,16 @@ jobs: working-directory: tooling/nargo_cli/tests/execution_success/1_mul run: nargo codegen-verifier - # - name: Run codegen-verifier for double_verify_proof - # working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof - # run: nargo codegen-verifier + - name: Run codegen-verifier for double_verify_proof + working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof + run: nargo codegen-verifier - name: Copy compiled 1_mul run: cp tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol foundry-project/src/1_mul.sol - # - name: Copy compiled double_verify_proof - # working-directory: foundry-project - # run: cp tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof/plonk_vk.sol src/double_verify_proof.sol + - name: Copy compiled double_verify_proof + working-directory: foundry-project + run: cp tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof/plonk_vk.sol src/double_verify_proof.sol - name: Output foundry-project/src working-directory: foundry-project/src From 0f680a287253b79d2387e9b56d9a6dffe8c33449 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 17:32:25 +0000 Subject: [PATCH 025/108] Add mnemonic --- .github/workflows/test-solidity-verifier.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index 2233310a1c9..c7356be30d5 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -44,16 +44,16 @@ jobs: working-directory: tooling/nargo_cli/tests/execution_success/1_mul run: nargo codegen-verifier - - name: Run codegen-verifier for double_verify_proof - working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof - run: nargo codegen-verifier + # - name: Run codegen-verifier for double_verify_proof + # working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof + # run: nargo codegen-verifier - name: Copy compiled 1_mul run: cp tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol foundry-project/src/1_mul.sol - - name: Copy compiled double_verify_proof - working-directory: foundry-project - run: cp tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof/plonk_vk.sol src/double_verify_proof.sol + # - name: Copy compiled double_verify_proof + # working-directory: foundry-project + # run: cp tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof/plonk_vk.sol src/double_verify_proof.sol - name: Output foundry-project/src working-directory: foundry-project/src @@ -65,4 +65,4 @@ jobs: - name: Forge deploy working-directory: foundry-project - run: forge create --rpc-url http://127.0.0.1:8545 src/1_mul.sol:UltraVerifier \ No newline at end of file + run: forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/1_mul.sol:UltraVerifier \ No newline at end of file From ba247ed85dce4319088d46ba354be15d18fc9241 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 19 Sep 2023 17:34:40 +0000 Subject: [PATCH 026/108] Remove output --- .github/workflows/test-solidity-verifier.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml index c7356be30d5..2ed3cd1d91c 100644 --- a/.github/workflows/test-solidity-verifier.yml +++ b/.github/workflows/test-solidity-verifier.yml @@ -55,10 +55,6 @@ jobs: # working-directory: foundry-project # run: cp tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof/plonk_vk.sol src/double_verify_proof.sol - - name: Output foundry-project/src - working-directory: foundry-project/src - run: ls -R - - name: Forge build working-directory: foundry-project run: forge build From 62b072530e853bdcfc5fbb548a4ee080132d94fe Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 17:28:01 +0100 Subject: [PATCH 027/108] Add test for solidity verifier --- .github/workflows/test-integration.yml | 74 ++++++++++++++++--- .github/workflows/test-solidity-verifier.yml | 64 ---------------- compiler/integration-tests/package.json | 1 + .../browser/compile_prove_verify.test.ts | 45 +++++++++++ yarn.lock | 73 ++++++++++++++++++ 5 files changed, 184 insertions(+), 73 deletions(-) delete mode 100644 .github/workflows/test-solidity-verifier.yml diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index e72e7d81498..9c28ad5870b 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -1,22 +1,29 @@ -name: test-integration +name: Test Solidity Verifier on: - workflow_dispatch: - pull_request: - paths: - - ./compiler/integration-tests - schedule: - - cron: "0 2 * * *" # Run nightly at 2 AM UTC + push: + branches: + - jb-test-solidity-verifier + +# on: +# workflow_dispatch: +# pull_request: +# paths: +# - ./compiler/integration-tests +# schedule: +# - cron: "0 2 * * *" # Run nightly at 2 AM UTC jobs: - wasm-packages-build-test: + test-solidity-verifier: runs-on: ubuntu-latest env: CACHED_PATH: /tmp/nix-cache steps: - - name: Checkout noir sources + - name: Checkout uses: actions/checkout@v4 + with: + ref: ${{ inputs.tag || env.GITHUB_REF }} - name: Checkout acvm sources uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution @@ -83,6 +90,55 @@ jobs: - name: Install Yarn dependencies uses: ./.github/actions/setup + - name: Install Foundry + uses: onbjerg/foundry-toolchain@v1 + with: + version: nightly + + - name: Run Anvil + run: | + anvil > /dev/null 2>&1 & + sleep 10 + + - name: Configure git + run: | + git config user.name kevaundray + git config user.email kevtheappdev@gmail.com + + - name: Install nargo + run: | + curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash + export PATH="/home/runner/.nargo/bin:$PATH" + noirup + echo "/home/runner/.nargo/bin" >> $GITHUB_PATH + nargo -V + + - name: Create new Foundry project + run: forge init --no-git --no-commit --force foundry-project + + - name: Run codegen-verifier for 1_mul + working-directory: tooling/nargo_cli/tests/execution_success/1_mul + run: nargo codegen-verifier + + # - name: Run codegen-verifier for double_verify_proof + # working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof + # run: nargo codegen-verifier + + - name: Copy compiled contracts + run: | + cp tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol foundry-project/src/1_mul.sol + cp tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof/plonk_vk.sol foundry-project/src/double_verify_proof.sol + + - name: Forge build + working-directory: foundry-project + run: forge build + + - name: Forge deploy + working-directory: foundry-project + run: | + forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/1_mul.sol:UltraVerifier + forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/double_verify_proof.sol:UltraVerifier + - name: Setup `integration-tests` run: | yarn workspace @noir-lang/source-resolver build diff --git a/.github/workflows/test-solidity-verifier.yml b/.github/workflows/test-solidity-verifier.yml deleted file mode 100644 index 2ed3cd1d91c..00000000000 --- a/.github/workflows/test-solidity-verifier.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Test Solidity Verifier - -on: - push: - branches: - - jb-test-solidity-verifier - -jobs: - test-solidity-verifier: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ inputs.tag || env.GITHUB_REF }} - - - name: Install Foundry - uses: onbjerg/foundry-toolchain@v1 - with: - version: nightly - - - name: Run Anvil - run: | - anvil > /dev/null 2>&1 & - sleep 10 - - - name: Configure git - run: | - git config user.name kevaundray - git config user.email kevtheappdev@gmail.com - - - name: Install nargo - run: | - curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash - export PATH="/home/runner/.nargo/bin:$PATH" - noirup - echo "/home/runner/.nargo/bin" >> $GITHUB_PATH - nargo -V - - - name: Create new Foundry project - run: forge init foundry-project - - - name: Run codegen-verifier for 1_mul - working-directory: tooling/nargo_cli/tests/execution_success/1_mul - run: nargo codegen-verifier - - # - name: Run codegen-verifier for double_verify_proof - # working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof - # run: nargo codegen-verifier - - - name: Copy compiled 1_mul - run: cp tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol foundry-project/src/1_mul.sol - - # - name: Copy compiled double_verify_proof - # working-directory: foundry-project - # run: cp tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof/plonk_vk.sol src/double_verify_proof.sol - - - name: Forge build - working-directory: foundry-project - run: forge build - - - name: Forge deploy - working-directory: foundry-project - run: forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/1_mul.sol:UltraVerifier \ No newline at end of file diff --git a/compiler/integration-tests/package.json b/compiler/integration-tests/package.json index a3727026f62..910cedc91e3 100644 --- a/compiler/integration-tests/package.json +++ b/compiler/integration-tests/package.json @@ -20,6 +20,7 @@ "@web/dev-server-esbuild": "^0.3.6", "@web/test-runner": "^0.15.3", "@web/test-runner-webdriver": "^0.7.0", + "ethers": "^6.7.1", "fflate": "^0.8.0", "smol-toml": "^1.1.2" } diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 1388923506c..bfd6eb55c3f 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -5,6 +5,7 @@ import newCompiler, { init_log_level as compilerLogLevel, } from "@noir-lang/noir_wasm"; import { decompressSync as gunzip } from "fflate"; +import { ethers } from "ethers"; import newABICoder, { abiEncode } from "@noir-lang/noirc_abi"; import initACVM, { executeCircuit, @@ -16,10 +17,28 @@ import { Barretenberg, RawBuffer, Crs } from "@aztec/bb.js"; import * as TOML from "smol-toml"; +import compiled1Mul from "../../../../../foundry-project/out/1_mul.sol/UltraVerifier.json" + +const mnemonic = "test test test test test test test test test test test junk"; +const contractAddress = "0x5fbdb2315678afecb367f032d93f642f64180aa3"; + +const provider = new ethers.JsonRpcProvider('http://localhost:8545'); +const walletPath = ethers.utils.defaultPath; +const walletMnemonic = ethers.Wallet.fromPhrase(mnemonic, walletPath); +const wallet = walletMnemonic.connect(provider); + +// Assuming your contract ABI is named `contractAbi` +const contractAbi = compiled1Mul.abi; + +// Create a contract instance +const contract = new ethers.Contract(contractAddress, contractAbi, wallet); + + await newCompiler(); await newABICoder(); await initACVM(); + compilerLogLevel("DEBUG"); async function getFile(url: URL): Promise { @@ -152,6 +171,32 @@ test_cases.forEach((testInfo) => { ); expect(verified).to.be.true; + + try { + const tx = await contract.verifyProof(proof); // replace `verifyProof` with the correct method name if it's different + console.log("Transaction hash:", tx.hash); + + await tx.wait(); + + // Retrieve the result from the contract event/logs or however you're setup to get the verification result + // You might want to listen for a specific event emitted by your contract upon verification + + const logs = await provider.getLogs({ + fromBlock: tx.blockNumber, + toBlock: tx.blockNumber, + address: contractAddress + }); + + // Decode the logs using your contract's interface to get the verification result + const parsedLogs = logs.map(log => contract.interface.parseLog(log)); + console.log(parsedLogs); + + // Now you can extract data from parsedLogs or perform other tasks as required. + + } catch (error) { + console.error("Error while submitting the proof:", error); + } + } catch (e) { expect(e, "Proving and Verifying").to.not.be.an("error"); throw e; diff --git a/yarn.lock b/yarn.lock index d3f2274737e..201d52e3974 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,6 +22,13 @@ __metadata: languageName: node linkType: hard +"@adraffy/ens-normalize@npm:1.9.2": + version: 1.9.2 + resolution: "@adraffy/ens-normalize@npm:1.9.2" + checksum: a9fdeb9e080774c19e4b7f9f60aa5b37cf23fe0e8fe80284bf8221f7396e9f78642bfd39a09a94a4dc3fb8e70f2ac81545204bdcaf222d93f4c4c2ae1f0dca0b + languageName: node + linkType: hard + "@aztec/bb.js@npm:^0.6.7": version: 0.6.7 resolution: "@aztec/bb.js@npm:0.6.7" @@ -358,6 +365,20 @@ __metadata: languageName: node linkType: hard +"@noble/hashes@npm:1.1.2": + version: 1.1.2 + resolution: "@noble/hashes@npm:1.1.2" + checksum: 3c2a8cb7c2e053811032f242155d870c5eb98844d924d69702244d48804cb03b42d4a666c49c2b71164420d8229cb9a6f242b972d50d5bb2f1d673b98b041de2 + languageName: node + linkType: hard + +"@noble/secp256k1@npm:1.7.1": + version: 1.7.1 + resolution: "@noble/secp256k1@npm:1.7.1" + checksum: d2301f1f7690368d8409a3152450458f27e54df47e3f917292de3de82c298770890c2de7c967d237eff9c95b70af485389a9695f73eb05a43e2bd562d18b18cb + languageName: node + linkType: hard + "@nodelib/fs.scandir@npm:2.1.5": version: 2.1.5 resolution: "@nodelib/fs.scandir@npm:2.1.5" @@ -874,6 +895,13 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:18.15.13": + version: 18.15.13 + resolution: "@types/node@npm:18.15.13" + checksum: 79cc5a2b5f98e8973061a4260a781425efd39161a0e117a69cd089603964816c1a14025e1387b4590c8e82d05133b7b4154fa53a7dffb3877890a66145e76515 + languageName: node + linkType: hard + "@types/node@npm:^18.7.20": version: 18.17.16 resolution: "@types/node@npm:18.17.16" @@ -1548,6 +1576,13 @@ __metadata: languageName: node linkType: hard +"aes-js@npm:4.0.0-beta.5": + version: 4.0.0-beta.5 + resolution: "aes-js@npm:4.0.0-beta.5" + checksum: cc2ea969d77df939c32057f7e361b6530aa6cb93cb10617a17a45cd164e6d761002f031ff6330af3e67e58b1f0a3a8fd0b63a720afd591a653b02f649470e15b + languageName: node + linkType: hard + "agent-base@npm:6, agent-base@npm:^6.0.2": version: 6.0.2 resolution: "agent-base@npm:6.0.2" @@ -3348,6 +3383,21 @@ __metadata: languageName: node linkType: hard +"ethers@npm:^6.7.1": + version: 6.7.1 + resolution: "ethers@npm:6.7.1" + dependencies: + "@adraffy/ens-normalize": 1.9.2 + "@noble/hashes": 1.1.2 + "@noble/secp256k1": 1.7.1 + "@types/node": 18.15.13 + aes-js: 4.0.0-beta.5 + tslib: 2.4.0 + ws: 8.5.0 + checksum: 07833692e3f53b18e28c4cba9f53f3d5ebff8360de02ad57b2584c00c52b88f5b790373f9b9f6b4f6b52ffa2074530a6101192b30c3260f7cdeff929d34bb88b + languageName: node + linkType: hard + "event-stream@npm:=3.3.4": version: 3.3.4 resolution: "event-stream@npm:3.3.4" @@ -4289,6 +4339,7 @@ __metadata: "@web/dev-server-esbuild": ^0.3.6 "@web/test-runner": ^0.15.3 "@web/test-runner-webdriver": ^0.7.0 + ethers: ^6.7.1 fflate: ^0.8.0 smol-toml: ^1.1.2 languageName: unknown @@ -7001,6 +7052,13 @@ __metadata: languageName: node linkType: hard +"tslib@npm:2.4.0": + version: 2.4.0 + resolution: "tslib@npm:2.4.0" + checksum: 8c4aa6a3c5a754bf76aefc38026134180c053b7bd2f81338cb5e5ebf96fefa0f417bff221592bf801077f5bf990562f6264fecbc42cd3309b33872cb6fc3b113 + languageName: node + linkType: hard + "tslib@npm:^1.8.1": version: 1.14.1 resolution: "tslib@npm:1.14.1" @@ -7535,6 +7593,21 @@ __metadata: languageName: node linkType: hard +"ws@npm:8.5.0": + version: 8.5.0 + resolution: "ws@npm:8.5.0" + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + checksum: 76f2f90e40344bf18fd544194e7067812fb1372b2a37865678d8f12afe4b478ff2ebc0c7c0aff82cd5e6b66fc43d889eec0f1865c2365d8f7a66d92da7744a77 + languageName: node + linkType: hard + "ws@npm:^7.4.2": version: 7.5.9 resolution: "ws@npm:7.5.9" From e21327a9c5a56e75a1f27052cfaf7411ee1a1ac4 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 18:08:09 +0100 Subject: [PATCH 028/108] Comment unused code --- .github/workflows/test-integration.yml | 146 ++++++++++++------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 9c28ad5870b..34227845d90 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -25,67 +25,67 @@ jobs: with: ref: ${{ inputs.tag || env.GITHUB_REF }} - - name: Checkout acvm sources - uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution - with: - repository: noir-lang/acvm - path: acvm - - - name: Setup Nix - uses: cachix/install-nix-action@v22 - with: - nix_path: nixpkgs=channel:nixos-23.05 - github_access_token: ${{ secrets.GITHUB_TOKEN }} - - - uses: cachix/cachix-action@v12 - with: - name: barretenberg - authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - - - name: Restore nix store cache - uses: actions/cache/restore@v3 - id: cache - with: - path: ${{ env.CACHED_PATH }} - key: ${{ runner.os }}-flake-wasm-${{ hashFiles('*.lock') }} - - # Based on https://github.com/marigold-dev/deku/blob/b5016f0cf4bf6ac48db9111b70dd7fb49b969dfd/.github/workflows/build.yml#L26 - - name: Copy cache into nix store - if: steps.cache.outputs.cache-hit == 'true' - # We don't check the signature because we're the one that created the cache - run: | - for narinfo in ${{ env.CACHED_PATH }}/*.narinfo; do - path=$(head -n 1 "$narinfo" | awk '{print $2}') - nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path" - done - - - name: Build noir_wasm package - run: | - nix build -L .#noir_wasm - echo "UPLOAD_PATH=$(readlink -f ./result/noir_wasm)" >> $GITHUB_ENV - cp -r ./result/noir_wasm/nodejs ./compiler/wasm - cp -r ./result/noir_wasm/web ./compiler/wasm - - - name: Upload `noir_wasm` artifact - uses: actions/upload-artifact@v3 - with: - name: noir_wasm - path: ${{ env.UPLOAD_PATH }} - retention-days: 3 - - - name: Build noirc_abi_wasm package - run: | - nix build -L .#noirc_abi_wasm - echo "UPLOAD_PATH=$(readlink -f ./result/noirc_abi_wasm)" >> $GITHUB_ENV - cp -r ./result/noirc_abi_wasm/nodejs ./tooling/noirc_abi_wasm - cp -r ./result/noirc_abi_wasm/web ./tooling/noirc_abi_wasm - - - name: Upload `noirc_abi_wasm` artifact - uses: actions/upload-artifact@v3 - with: - name: noirc_abi_wasm - path: ${{ env.UPLOAD_PATH }} - retention-days: 3 + # - name: Checkout acvm sources + # uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution + # with: + # repository: noir-lang/acvm + # path: acvm + + # - name: Setup Nix + # uses: cachix/install-nix-action@v22 + # with: + # nix_path: nixpkgs=channel:nixos-23.05 + # github_access_token: ${{ secrets.GITHUB_TOKEN }} + + # - uses: cachix/cachix-action@v12 + # with: + # name: barretenberg + # authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + + # - name: Restore nix store cache + # uses: actions/cache/restore@v3 + # id: cache + # with: + # path: ${{ env.CACHED_PATH }} + # key: ${{ runner.os }}-flake-wasm-${{ hashFiles('*.lock') }} + + # # Based on https://github.com/marigold-dev/deku/blob/b5016f0cf4bf6ac48db9111b70dd7fb49b969dfd/.github/workflows/build.yml#L26 + # - name: Copy cache into nix store + # if: steps.cache.outputs.cache-hit == 'true' + # # We don't check the signature because we're the one that created the cache + # run: | + # for narinfo in ${{ env.CACHED_PATH }}/*.narinfo; do + # path=$(head -n 1 "$narinfo" | awk '{print $2}') + # nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path" + # done + + # - name: Build noir_wasm package + # run: | + # nix build -L .#noir_wasm + # echo "UPLOAD_PATH=$(readlink -f ./result/noir_wasm)" >> $GITHUB_ENV + # cp -r ./result/noir_wasm/nodejs ./compiler/wasm + # cp -r ./result/noir_wasm/web ./compiler/wasm + + # - name: Upload `noir_wasm` artifact + # uses: actions/upload-artifact@v3 + # with: + # name: noir_wasm + # path: ${{ env.UPLOAD_PATH }} + # retention-days: 3 + + # - name: Build noirc_abi_wasm package + # run: | + # nix build -L .#noirc_abi_wasm + # echo "UPLOAD_PATH=$(readlink -f ./result/noirc_abi_wasm)" >> $GITHUB_ENV + # cp -r ./result/noirc_abi_wasm/nodejs ./tooling/noirc_abi_wasm + # cp -r ./result/noirc_abi_wasm/web ./tooling/noirc_abi_wasm + + # - name: Upload `noirc_abi_wasm` artifact + # uses: actions/upload-artifact@v3 + # with: + # name: noirc_abi_wasm + # path: ${{ env.UPLOAD_PATH }} + # retention-days: 3 - name: Install Yarn dependencies uses: ./.github/actions/setup @@ -127,7 +127,7 @@ jobs: - name: Copy compiled contracts run: | cp tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol foundry-project/src/1_mul.sol - cp tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof/plonk_vk.sol foundry-project/src/double_verify_proof.sol + # cp tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof/plonk_vk.sol foundry-project/src/double_verify_proof.sol - name: Forge build working-directory: foundry-project @@ -137,7 +137,7 @@ jobs: working-directory: foundry-project run: | forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/1_mul.sol:UltraVerifier - forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/double_verify_proof.sol:UltraVerifier + # forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/double_verify_proof.sol:UltraVerifier - name: Setup `integration-tests` run: | @@ -147,13 +147,13 @@ jobs: run: | yarn test:integration - - name: Alert on nightly test failure - uses: JasonEtco/create-an-issue@v2 - if: ${{ failure() && github.event_name == 'schedule' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - WORKFLOW_NAME: ${{ github.workflow }} - WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - with: - update_existing: true - filename: .github/NIGHTLY_TEST_FAILURE.md + # - name: Alert on nightly test failure + # uses: JasonEtco/create-an-issue@v2 + # if: ${{ failure() && github.event_name == 'schedule' }} + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # WORKFLOW_NAME: ${{ github.workflow }} + # WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + # with: + # update_existing: true + # filename: .github/NIGHTLY_TEST_FAILURE.md From 2e6940b12f6f0741c442bf7b474282cad1078dfc Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 18:16:09 +0100 Subject: [PATCH 029/108] Log out address --- .github/workflows/test-integration.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 34227845d90..ee0574a7e6f 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -136,9 +136,16 @@ jobs: - name: Forge deploy working-directory: foundry-project run: | - forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/1_mul.sol:UltraVerifier + result=$(forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/1_mul.sol:UltraVerifier) + echo "$result" + address=$(echo "$result" | grep "Deployed to:" | awk '{print $3}') + echo "CONTRACT_ADDRESS=$address" >> $GITHUB_ENV # forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/double_verify_proof.sol:UltraVerifier + - name: Log Address + run: | + echo "Deployed contract address is $CONTRACT_ADDRESS" + - name: Setup `integration-tests` run: | yarn workspace @noir-lang/source-resolver build From ead7b4cb11306a51d7d4195eb9f0c13c4c906f19 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 18:22:29 +0100 Subject: [PATCH 030/108] Run full test --- .github/workflows/test-integration.yml | 118 +++++++++--------- .../browser/compile_prove_verify.test.ts | 4 +- 2 files changed, 63 insertions(+), 59 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index ee0574a7e6f..8b032a93118 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -25,67 +25,67 @@ jobs: with: ref: ${{ inputs.tag || env.GITHUB_REF }} - # - name: Checkout acvm sources - # uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution - # with: - # repository: noir-lang/acvm - # path: acvm + - name: Checkout acvm sources + uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution + with: + repository: noir-lang/acvm + path: acvm - # - name: Setup Nix - # uses: cachix/install-nix-action@v22 - # with: - # nix_path: nixpkgs=channel:nixos-23.05 - # github_access_token: ${{ secrets.GITHUB_TOKEN }} + - name: Setup Nix + uses: cachix/install-nix-action@v22 + with: + nix_path: nixpkgs=channel:nixos-23.05 + github_access_token: ${{ secrets.GITHUB_TOKEN }} - # - uses: cachix/cachix-action@v12 - # with: - # name: barretenberg - # authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + - uses: cachix/cachix-action@v12 + with: + name: barretenberg + authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - # - name: Restore nix store cache - # uses: actions/cache/restore@v3 - # id: cache - # with: - # path: ${{ env.CACHED_PATH }} - # key: ${{ runner.os }}-flake-wasm-${{ hashFiles('*.lock') }} - - # # Based on https://github.com/marigold-dev/deku/blob/b5016f0cf4bf6ac48db9111b70dd7fb49b969dfd/.github/workflows/build.yml#L26 - # - name: Copy cache into nix store - # if: steps.cache.outputs.cache-hit == 'true' - # # We don't check the signature because we're the one that created the cache - # run: | - # for narinfo in ${{ env.CACHED_PATH }}/*.narinfo; do - # path=$(head -n 1 "$narinfo" | awk '{print $2}') - # nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path" - # done - - # - name: Build noir_wasm package - # run: | - # nix build -L .#noir_wasm - # echo "UPLOAD_PATH=$(readlink -f ./result/noir_wasm)" >> $GITHUB_ENV - # cp -r ./result/noir_wasm/nodejs ./compiler/wasm - # cp -r ./result/noir_wasm/web ./compiler/wasm - - # - name: Upload `noir_wasm` artifact - # uses: actions/upload-artifact@v3 - # with: - # name: noir_wasm - # path: ${{ env.UPLOAD_PATH }} - # retention-days: 3 - - # - name: Build noirc_abi_wasm package - # run: | - # nix build -L .#noirc_abi_wasm - # echo "UPLOAD_PATH=$(readlink -f ./result/noirc_abi_wasm)" >> $GITHUB_ENV - # cp -r ./result/noirc_abi_wasm/nodejs ./tooling/noirc_abi_wasm - # cp -r ./result/noirc_abi_wasm/web ./tooling/noirc_abi_wasm - - # - name: Upload `noirc_abi_wasm` artifact - # uses: actions/upload-artifact@v3 - # with: - # name: noirc_abi_wasm - # path: ${{ env.UPLOAD_PATH }} - # retention-days: 3 + - name: Restore nix store cache + uses: actions/cache/restore@v3 + id: cache + with: + path: ${{ env.CACHED_PATH }} + key: ${{ runner.os }}-flake-wasm-${{ hashFiles('*.lock') }} + + # Based on https://github.com/marigold-dev/deku/blob/b5016f0cf4bf6ac48db9111b70dd7fb49b969dfd/.github/workflows/build.yml#L26 + - name: Copy cache into nix store + if: steps.cache.outputs.cache-hit == 'true' + # We don't check the signature because we're the one that created the cache + run: | + for narinfo in ${{ env.CACHED_PATH }}/*.narinfo; do + path=$(head -n 1 "$narinfo" | awk '{print $2}') + nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path" + done + + - name: Build noir_wasm package + run: | + nix build -L .#noir_wasm + echo "UPLOAD_PATH=$(readlink -f ./result/noir_wasm)" >> $GITHUB_ENV + cp -r ./result/noir_wasm/nodejs ./compiler/wasm + cp -r ./result/noir_wasm/web ./compiler/wasm + + - name: Upload `noir_wasm` artifact + uses: actions/upload-artifact@v3 + with: + name: noir_wasm + path: ${{ env.UPLOAD_PATH }} + retention-days: 3 + + - name: Build noirc_abi_wasm package + run: | + nix build -L .#noirc_abi_wasm + echo "UPLOAD_PATH=$(readlink -f ./result/noirc_abi_wasm)" >> $GITHUB_ENV + cp -r ./result/noirc_abi_wasm/nodejs ./tooling/noirc_abi_wasm + cp -r ./result/noirc_abi_wasm/web ./tooling/noirc_abi_wasm + + - name: Upload `noirc_abi_wasm` artifact + uses: actions/upload-artifact@v3 + with: + name: noirc_abi_wasm + path: ${{ env.UPLOAD_PATH }} + retention-days: 3 - name: Install Yarn dependencies uses: ./.github/actions/setup @@ -153,6 +153,8 @@ jobs: - name: Run `integration-tests` run: | yarn test:integration + env: + CONTRACT_ADDRESS: ${{ env.CONTRACT_ADDRESS }} # - name: Alert on nightly test failure # uses: JasonEtco/create-an-issue@v2 diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index bfd6eb55c3f..e06cc2a620a 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -20,7 +20,9 @@ import * as TOML from "smol-toml"; import compiled1Mul from "../../../../../foundry-project/out/1_mul.sol/UltraVerifier.json" const mnemonic = "test test test test test test test test test test test junk"; -const contractAddress = "0x5fbdb2315678afecb367f032d93f642f64180aa3"; +const contractAddress = process.env.CONTRACT_ADDRESS || ""; + +console.log({ contractAddress }) const provider = new ethers.JsonRpcProvider('http://localhost:8545'); const walletPath = ethers.utils.defaultPath; From 5f186c50a8d5bbe0439c95190e475ea6a3f8b896 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 19:16:19 +0100 Subject: [PATCH 031/108] Fix test run --- .github/workflows/test-integration.yml | 8 ++------ compiler/integration-tests/package.json | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 8b032a93118..76cb39787d4 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -146,13 +146,9 @@ jobs: run: | echo "Deployed contract address is $CONTRACT_ADDRESS" - - name: Setup `integration-tests` - run: | - yarn workspace @noir-lang/source-resolver build - - name: Run `integration-tests` - run: | - yarn test:integration + working-directory: compiler/integration-tests + run: yarn workspace integration-tests test env: CONTRACT_ADDRESS: ${{ env.CONTRACT_ADDRESS }} diff --git a/compiler/integration-tests/package.json b/compiler/integration-tests/package.json index 910cedc91e3..b2f467afbdb 100644 --- a/compiler/integration-tests/package.json +++ b/compiler/integration-tests/package.json @@ -7,7 +7,7 @@ "build": "echo Integration Test build step", "test": "yarn test:browser", "test:browser": "web-test-runner", - "test:integration:browser": "web-test-runner test//integration/browser/**/*.test.ts", + "test:integration:browser": "web-test-runner test/integration/browser/**/*.test.ts", "test:integration:browser:watch": "web-test-runner test/integration/browser/**/*.test.ts --watch", "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0" }, From 25b8c1eac690478f4bdc21546fe6fcbd7a36fd30 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 20:01:50 +0100 Subject: [PATCH 032/108] Fix integration test run --- .github/workflows/test-integration.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 76cb39787d4..57be5fbc575 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -146,9 +146,11 @@ jobs: run: | echo "Deployed contract address is $CONTRACT_ADDRESS" + - name: Setup `integration-tests` + run: yarn build + - name: Run `integration-tests` - working-directory: compiler/integration-tests - run: yarn workspace integration-tests test + run: yarn test:integration env: CONTRACT_ADDRESS: ${{ env.CONTRACT_ADDRESS }} From 00d2461dbfa5aa657739e724b9ab97311624271b Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 20:59:41 +0100 Subject: [PATCH 033/108] Fix bad import --- .../test/integration/browser/compile_prove_verify.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index c62f7373550..84763fd17a6 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -13,7 +13,7 @@ import { decompressSync as gunzip } from "fflate"; import * as TOML from "smol-toml"; -import compiled1Mul from "../../../../../foundry-project/out/1_mul.sol/UltraVerifier.json" +// import compiled1Mul from "../../../../../foundry-project/out/1_mul.sol/UltraVerifier.json" const mnemonic = "test test test test test test test test test test test junk"; const contractAddress = process.env.CONTRACT_ADDRESS || ""; @@ -26,7 +26,7 @@ const walletMnemonic = ethers.Wallet.fromPhrase(mnemonic, walletPath); const wallet = walletMnemonic.connect(provider); // Assuming your contract ABI is named `contractAbi` -const contractAbi = compiled1Mul.abi; +const contractAbi = "";//compiled1Mul.abi; // Create a contract instance const contract = new ethers.Contract(contractAddress, contractAbi, wallet); From b3492c011706436842d9e013557dc1b527bb54f1 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 21:11:26 +0100 Subject: [PATCH 034/108] Fix lint --- .../browser/compile_prove_verify.test.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 84763fd17a6..30d1d6d3d09 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -18,15 +18,15 @@ import * as TOML from "smol-toml"; const mnemonic = "test test test test test test test test test test test junk"; const contractAddress = process.env.CONTRACT_ADDRESS || ""; -console.log({ contractAddress }) +console.log({ contractAddress }); -const provider = new ethers.JsonRpcProvider('http://localhost:8545'); +const provider = new ethers.JsonRpcProvider("http://localhost:8545"); const walletPath = ethers.utils.defaultPath; const walletMnemonic = ethers.Wallet.fromPhrase(mnemonic, walletPath); const wallet = walletMnemonic.connect(provider); // Assuming your contract ABI is named `contractAbi` -const contractAbi = "";//compiled1Mul.abi; +const contractAbi = ""; //compiled1Mul.abi; // Create a contract instance const contract = new ethers.Contract(contractAddress, contractAbi, wallet); @@ -40,7 +40,6 @@ await newCompiler(); await newABICoder(); await initACVM(); - compilerLogLevel("DEBUG"); async function getFile(url: URL): Promise { @@ -186,19 +185,19 @@ test_cases.forEach((testInfo) => { const logs = await provider.getLogs({ fromBlock: tx.blockNumber, toBlock: tx.blockNumber, - address: contractAddress + address: contractAddress, }); // Decode the logs using your contract's interface to get the verification result - const parsedLogs = logs.map(log => contract.interface.parseLog(log)); + const parsedLogs = logs.map((log) => + contract.interface.parseLog(log) + ); console.log(parsedLogs); // Now you can extract data from parsedLogs or perform other tasks as required. - } catch (error) { console.error("Error while submitting the proof:", error); } - } catch (e) { expect(e, "Proving and Verifying").to.not.be.an("error"); throw e; From 5a276166ccf52d08d6bac7d993557526113463e0 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 21:24:41 +0100 Subject: [PATCH 035/108] Import contract correctly --- .../browser/compile_prove_verify.test.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 30d1d6d3d09..0788bc45914 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -13,8 +13,6 @@ import { decompressSync as gunzip } from "fflate"; import * as TOML from "smol-toml"; -// import compiled1Mul from "../../../../../foundry-project/out/1_mul.sol/UltraVerifier.json" - const mnemonic = "test test test test test test test test test test test junk"; const contractAddress = process.env.CONTRACT_ADDRESS || ""; @@ -26,10 +24,8 @@ const walletMnemonic = ethers.Wallet.fromPhrase(mnemonic, walletPath); const wallet = walletMnemonic.connect(provider); // Assuming your contract ABI is named `contractAbi` -const contractAbi = ""; //compiled1Mul.abi; // Create a contract instance -const contract = new ethers.Contract(contractAddress, contractAbi, wallet); const { default: initACVM, executeCircuit, compressWitness } = acvm; const { default: newABICoder, abiEncode } = noirc; @@ -55,9 +51,11 @@ const CIRCUIT_SIZE = 2 ** 19; const test_cases = [ { case: "tooling/nargo_cli/tests/execution_success/1_mul", + compiled: "foundry-project/out/1_mul.sol/UltraVerifier.json", }, { case: "tooling/nargo_cli/tests/execution_success/double_verify_proof", + compiled: "foundry-project/out/double_verify.sol/UltraVerifier.json", }, ]; @@ -68,6 +66,7 @@ const suite = Mocha.Suite.create(mocha.suite, "Noir end to end test"); suite.timeout(60 * 20e3); //20mins test_cases.forEach((testInfo) => { + const test_name = testInfo.case.split("/").pop(); const mochaTest = new Mocha.Test( `${test_name} (Compile, Execute, Prove, Verify)`, @@ -83,9 +82,16 @@ test_cases.forEach((testInfo) => { `${base_relative_path}/${test_case}/Prover.toml`, import.meta.url ); + const compiled_contract_url = new URL( + `${base_relative_path}/${testInfo.compiled}`, + import.meta.url + ); const noir_source = await getFile(noir_source_url); const prover_toml = await getFile(prover_toml_url); + const compiled_contract = await getFile(compiled_contract_url); + + const contract = new ethers.Contract(contractAddress, JSON.parse(compiled_contract).abi, wallet); expect(noir_source).to.be.a.string; From b8888a1997a77d5ed49dbe8a86477a15ddad1f5c Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 21:47:35 +0100 Subject: [PATCH 036/108] Inject contract address --- .github/workflows/test-integration.yml | 129 +++++++++--------- .../browser/compile_prove_verify.test.ts | 5 +- 2 files changed, 68 insertions(+), 66 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 51e9875de6f..a29985b269c 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -25,67 +25,67 @@ jobs: with: ref: ${{ inputs.tag || env.GITHUB_REF }} - - name: Checkout acvm sources - uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution - with: - repository: noir-lang/acvm - path: acvm - - - name: Setup Nix - uses: cachix/install-nix-action@v22 - with: - nix_path: nixpkgs=channel:nixos-23.05 - github_access_token: ${{ secrets.GITHUB_TOKEN }} - - - uses: cachix/cachix-action@v12 - with: - name: barretenberg - authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - - - name: Restore nix store cache - uses: actions/cache/restore@v3 - id: cache - with: - path: ${{ env.CACHED_PATH }} - key: ${{ runner.os }}-flake-wasm-${{ hashFiles('*.lock') }} - - # Based on https://github.com/marigold-dev/deku/blob/b5016f0cf4bf6ac48db9111b70dd7fb49b969dfd/.github/workflows/build.yml#L26 - - name: Copy cache into nix store - if: steps.cache.outputs.cache-hit == 'true' - # We don't check the signature because we're the one that created the cache - run: | - for narinfo in ${{ env.CACHED_PATH }}/*.narinfo; do - path=$(head -n 1 "$narinfo" | awk '{print $2}') - nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path" - done - - - name: Build noir_wasm package - run: | - nix build -L .#noir_wasm - echo "UPLOAD_PATH=$(readlink -f ./result/noir_wasm)" >> $GITHUB_ENV - cp -r ./result/noir_wasm/nodejs ./compiler/wasm - cp -r ./result/noir_wasm/web ./compiler/wasm + # - name: Checkout acvm sources + # uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution + # with: + # repository: noir-lang/acvm + # path: acvm - - name: Upload `noir_wasm` artifact - uses: actions/upload-artifact@v3 - with: - name: noir_wasm - path: ${{ env.UPLOAD_PATH }} - retention-days: 3 + # - name: Setup Nix + # uses: cachix/install-nix-action@v22 + # with: + # nix_path: nixpkgs=channel:nixos-23.05 + # github_access_token: ${{ secrets.GITHUB_TOKEN }} - - name: Build noirc_abi_wasm package - run: | - nix build -L .#noirc_abi_wasm - echo "UPLOAD_PATH=$(readlink -f ./result/noirc_abi_wasm)" >> $GITHUB_ENV - cp -r ./result/noirc_abi_wasm/nodejs ./tooling/noirc_abi_wasm - cp -r ./result/noirc_abi_wasm/web ./tooling/noirc_abi_wasm + # - uses: cachix/cachix-action@v12 + # with: + # name: barretenberg + # authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - - name: Upload `noirc_abi_wasm` artifact - uses: actions/upload-artifact@v3 - with: - name: noirc_abi_wasm - path: ${{ env.UPLOAD_PATH }} - retention-days: 3 + # - name: Restore nix store cache + # uses: actions/cache/restore@v3 + # id: cache + # with: + # path: ${{ env.CACHED_PATH }} + # key: ${{ runner.os }}-flake-wasm-${{ hashFiles('*.lock') }} + + # # Based on https://github.com/marigold-dev/deku/blob/b5016f0cf4bf6ac48db9111b70dd7fb49b969dfd/.github/workflows/build.yml#L26 + # - name: Copy cache into nix store + # if: steps.cache.outputs.cache-hit == 'true' + # # We don't check the signature because we're the one that created the cache + # run: | + # for narinfo in ${{ env.CACHED_PATH }}/*.narinfo; do + # path=$(head -n 1 "$narinfo" | awk '{print $2}') + # nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path" + # done + + # - name: Build noir_wasm package + # run: | + # nix build -L .#noir_wasm + # echo "UPLOAD_PATH=$(readlink -f ./result/noir_wasm)" >> $GITHUB_ENV + # cp -r ./result/noir_wasm/nodejs ./compiler/wasm + # cp -r ./result/noir_wasm/web ./compiler/wasm + + # - name: Upload `noir_wasm` artifact + # uses: actions/upload-artifact@v3 + # with: + # name: noir_wasm + # path: ${{ env.UPLOAD_PATH }} + # retention-days: 3 + + # - name: Build noirc_abi_wasm package + # run: | + # nix build -L .#noirc_abi_wasm + # echo "UPLOAD_PATH=$(readlink -f ./result/noirc_abi_wasm)" >> $GITHUB_ENV + # cp -r ./result/noirc_abi_wasm/nodejs ./tooling/noirc_abi_wasm + # cp -r ./result/noirc_abi_wasm/web ./tooling/noirc_abi_wasm + + # - name: Upload `noirc_abi_wasm` artifact + # uses: actions/upload-artifact@v3 + # with: + # name: noirc_abi_wasm + # path: ${{ env.UPLOAD_PATH }} + # retention-days: 3 - name: Install Yarn dependencies uses: ./.github/actions/setup @@ -139,12 +139,17 @@ jobs: result=$(forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/1_mul.sol:UltraVerifier) echo "$result" address=$(echo "$result" | grep "Deployed to:" | awk '{print $3}') - echo "CONTRACT_ADDRESS=$address" >> $GITHUB_ENV + echo "1_MUL_CONTRACT_ADDRESS=$address" >> $GITHUB_ENV # forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/double_verify_proof.sol:UltraVerifier - - name: Log Address + - name: Replace 1_MUL_CONTRACT_ADDRESS in the file + working-directory: compiler/integration-tests/test/integration/browser run: | - echo "Deployed contract address is $CONTRACT_ADDRESS" + sed -i 's|address: "1_MUL_CONTRACT_ADDRESS"|address: "'"$1_MUL_CONTRACT_ADDRESS"'"|g' compile_prove_verify.test.ts + + - name: Check injection + working-directory: compiler/integration-tests/test/integration/browser + run: cat compile_prove_verify.test.ts - name: Setup `integration-tests` run: | @@ -153,8 +158,6 @@ jobs: - name: Run `integration-tests` run: yarn test:integration - env: - CONTRACT_ADDRESS: ${{ env.CONTRACT_ADDRESS }} # - name: Alert on nightly test failure # uses: JasonEtco/create-an-issue@v2 diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 0788bc45914..029c0ca08cd 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -14,9 +14,6 @@ import { decompressSync as gunzip } from "fflate"; import * as TOML from "smol-toml"; const mnemonic = "test test test test test test test test test test test junk"; -const contractAddress = process.env.CONTRACT_ADDRESS || ""; - -console.log({ contractAddress }); const provider = new ethers.JsonRpcProvider("http://localhost:8545"); const walletPath = ethers.utils.defaultPath; @@ -52,10 +49,12 @@ const test_cases = [ { case: "tooling/nargo_cli/tests/execution_success/1_mul", compiled: "foundry-project/out/1_mul.sol/UltraVerifier.json", + address: "1_MUL_CONTRACT_ADDRESS" }, { case: "tooling/nargo_cli/tests/execution_success/double_verify_proof", compiled: "foundry-project/out/double_verify.sol/UltraVerifier.json", + address: "DOUBLE_VERIFY_CONTRACT_ADDRESS" }, ]; From 74d8008af02be524f446a385ebc8a0742a832ab5 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 21:52:06 +0100 Subject: [PATCH 037/108] Fix injection --- .github/workflows/test-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index a29985b269c..4113806a1d2 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -145,7 +145,7 @@ jobs: - name: Replace 1_MUL_CONTRACT_ADDRESS in the file working-directory: compiler/integration-tests/test/integration/browser run: | - sed -i 's|address: "1_MUL_CONTRACT_ADDRESS"|address: "'"$1_MUL_CONTRACT_ADDRESS"'"|g' compile_prove_verify.test.ts + sed -i 's|address: "1_MUL_CONTRACT_ADDRESS"|address: "'"${1_MUL_CONTRACT_ADDRESS}"'"|g' compile_prove_verify.test.ts - name: Check injection working-directory: compiler/integration-tests/test/integration/browser From ff9c2927f9f1499b93d8339c2d55580e6c748221 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 22:08:44 +0100 Subject: [PATCH 038/108] Fix var name --- .github/workflows/test-integration.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 4113806a1d2..806d300e995 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -139,13 +139,13 @@ jobs: result=$(forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/1_mul.sol:UltraVerifier) echo "$result" address=$(echo "$result" | grep "Deployed to:" | awk '{print $3}') - echo "1_MUL_CONTRACT_ADDRESS=$address" >> $GITHUB_ENV + echo "MUL_CONTRACT_ADDRESS=$address" >> $GITHUB_ENV # forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/double_verify_proof.sol:UltraVerifier - - name: Replace 1_MUL_CONTRACT_ADDRESS in the file + - name: Replace MUL_CONTRACT_ADDRESS in the file working-directory: compiler/integration-tests/test/integration/browser run: | - sed -i 's|address: "1_MUL_CONTRACT_ADDRESS"|address: "'"${1_MUL_CONTRACT_ADDRESS}"'"|g' compile_prove_verify.test.ts + sed -i 's|address: "MUL_CONTRACT_ADDRESS"|address: "'"$MUL_CONTRACT_ADDRESS"'"|g' compile_prove_verify.test.ts - name: Check injection working-directory: compiler/integration-tests/test/integration/browser From d4244e9645b55ae008342893ddb6a4074451cfa5 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 22:12:22 +0100 Subject: [PATCH 039/108] Fix var name test side --- .../test/integration/browser/compile_prove_verify.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 029c0ca08cd..8e9d66b276c 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -49,7 +49,7 @@ const test_cases = [ { case: "tooling/nargo_cli/tests/execution_success/1_mul", compiled: "foundry-project/out/1_mul.sol/UltraVerifier.json", - address: "1_MUL_CONTRACT_ADDRESS" + address: "MUL_CONTRACT_ADDRESS" }, { case: "tooling/nargo_cli/tests/execution_success/double_verify_proof", From 040c9919a3c0fd0d16fa476ff67f180d809483cf Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 22:16:11 +0100 Subject: [PATCH 040/108] Uncomment setup, comment double_verify --- .github/workflows/test-integration.yml | 116 +++++++++--------- .../browser/compile_prove_verify.test.ts | 10 +- 2 files changed, 63 insertions(+), 63 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 806d300e995..f099037dead 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -25,67 +25,67 @@ jobs: with: ref: ${{ inputs.tag || env.GITHUB_REF }} - # - name: Checkout acvm sources - # uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution - # with: - # repository: noir-lang/acvm - # path: acvm + - name: Checkout acvm sources + uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution + with: + repository: noir-lang/acvm + path: acvm - # - name: Setup Nix - # uses: cachix/install-nix-action@v22 - # with: - # nix_path: nixpkgs=channel:nixos-23.05 - # github_access_token: ${{ secrets.GITHUB_TOKEN }} + - name: Setup Nix + uses: cachix/install-nix-action@v22 + with: + nix_path: nixpkgs=channel:nixos-23.05 + github_access_token: ${{ secrets.GITHUB_TOKEN }} - # - uses: cachix/cachix-action@v12 - # with: - # name: barretenberg - # authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + - uses: cachix/cachix-action@v12 + with: + name: barretenberg + authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - # - name: Restore nix store cache - # uses: actions/cache/restore@v3 - # id: cache - # with: - # path: ${{ env.CACHED_PATH }} - # key: ${{ runner.os }}-flake-wasm-${{ hashFiles('*.lock') }} - - # # Based on https://github.com/marigold-dev/deku/blob/b5016f0cf4bf6ac48db9111b70dd7fb49b969dfd/.github/workflows/build.yml#L26 - # - name: Copy cache into nix store - # if: steps.cache.outputs.cache-hit == 'true' - # # We don't check the signature because we're the one that created the cache - # run: | - # for narinfo in ${{ env.CACHED_PATH }}/*.narinfo; do - # path=$(head -n 1 "$narinfo" | awk '{print $2}') - # nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path" - # done - - # - name: Build noir_wasm package - # run: | - # nix build -L .#noir_wasm - # echo "UPLOAD_PATH=$(readlink -f ./result/noir_wasm)" >> $GITHUB_ENV - # cp -r ./result/noir_wasm/nodejs ./compiler/wasm - # cp -r ./result/noir_wasm/web ./compiler/wasm - - # - name: Upload `noir_wasm` artifact - # uses: actions/upload-artifact@v3 - # with: - # name: noir_wasm - # path: ${{ env.UPLOAD_PATH }} - # retention-days: 3 - - # - name: Build noirc_abi_wasm package - # run: | - # nix build -L .#noirc_abi_wasm - # echo "UPLOAD_PATH=$(readlink -f ./result/noirc_abi_wasm)" >> $GITHUB_ENV - # cp -r ./result/noirc_abi_wasm/nodejs ./tooling/noirc_abi_wasm - # cp -r ./result/noirc_abi_wasm/web ./tooling/noirc_abi_wasm - - # - name: Upload `noirc_abi_wasm` artifact - # uses: actions/upload-artifact@v3 - # with: - # name: noirc_abi_wasm - # path: ${{ env.UPLOAD_PATH }} - # retention-days: 3 + - name: Restore nix store cache + uses: actions/cache/restore@v3 + id: cache + with: + path: ${{ env.CACHED_PATH }} + key: ${{ runner.os }}-flake-wasm-${{ hashFiles('*.lock') }} + + # Based on https://github.com/marigold-dev/deku/blob/b5016f0cf4bf6ac48db9111b70dd7fb49b969dfd/.github/workflows/build.yml#L26 + - name: Copy cache into nix store + if: steps.cache.outputs.cache-hit == 'true' + # We don't check the signature because we're the one that created the cache + run: | + for narinfo in ${{ env.CACHED_PATH }}/*.narinfo; do + path=$(head -n 1 "$narinfo" | awk '{print $2}') + nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path" + done + + - name: Build noir_wasm package + run: | + nix build -L .#noir_wasm + echo "UPLOAD_PATH=$(readlink -f ./result/noir_wasm)" >> $GITHUB_ENV + cp -r ./result/noir_wasm/nodejs ./compiler/wasm + cp -r ./result/noir_wasm/web ./compiler/wasm + + - name: Upload `noir_wasm` artifact + uses: actions/upload-artifact@v3 + with: + name: noir_wasm + path: ${{ env.UPLOAD_PATH }} + retention-days: 3 + + - name: Build noirc_abi_wasm package + run: | + nix build -L .#noirc_abi_wasm + echo "UPLOAD_PATH=$(readlink -f ./result/noirc_abi_wasm)" >> $GITHUB_ENV + cp -r ./result/noirc_abi_wasm/nodejs ./tooling/noirc_abi_wasm + cp -r ./result/noirc_abi_wasm/web ./tooling/noirc_abi_wasm + + - name: Upload `noirc_abi_wasm` artifact + uses: actions/upload-artifact@v3 + with: + name: noirc_abi_wasm + path: ${{ env.UPLOAD_PATH }} + retention-days: 3 - name: Install Yarn dependencies uses: ./.github/actions/setup diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 8e9d66b276c..95b0ddf6c72 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -51,11 +51,11 @@ const test_cases = [ compiled: "foundry-project/out/1_mul.sol/UltraVerifier.json", address: "MUL_CONTRACT_ADDRESS" }, - { - case: "tooling/nargo_cli/tests/execution_success/double_verify_proof", - compiled: "foundry-project/out/double_verify.sol/UltraVerifier.json", - address: "DOUBLE_VERIFY_CONTRACT_ADDRESS" - }, + // { + // case: "tooling/nargo_cli/tests/execution_success/double_verify_proof", + // compiled: "foundry-project/out/double_verify.sol/UltraVerifier.json", + // address: "DOUBLE_VERIFY_CONTRACT_ADDRESS" + // }, ]; const numberOfThreads = navigator.hardwareConcurrency || 1; From 6ebf880897e987c28ff1f5b5eb6d7a602293af60 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 22:33:31 +0100 Subject: [PATCH 041/108] Remove walletPath --- .../test/integration/browser/compile_prove_verify.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 95b0ddf6c72..9c063586c2f 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -16,8 +16,7 @@ import * as TOML from "smol-toml"; const mnemonic = "test test test test test test test test test test test junk"; const provider = new ethers.JsonRpcProvider("http://localhost:8545"); -const walletPath = ethers.utils.defaultPath; -const walletMnemonic = ethers.Wallet.fromPhrase(mnemonic, walletPath); +const walletMnemonic = ethers.Wallet.fromPhrase(mnemonic); const wallet = walletMnemonic.connect(provider); // Assuming your contract ABI is named `contractAbi` From 3b8fd4592f4b20ee71169004212c9baacc4882d2 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 22:34:39 +0100 Subject: [PATCH 042/108] Fix import --- .../integration/browser/compile_prove_verify.test.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 9c063586c2f..561b5d43c75 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -4,17 +4,13 @@ import newCompiler, { compile, init_log_level as compilerLogLevel, } from "@noir-lang/noir_wasm"; -import { decompressSync as gunzip } from "fflate"; -import { ethers } from "ethers"; - -import { Barretenberg, RawBuffer, Crs } from "@aztec/bb.js"; import { acvm, noirc } from "@noir-lang/noir_js"; +import { Barretenberg, RawBuffer, Crs } from "@aztec/bb.js"; import { decompressSync as gunzip } from "fflate"; - +import { ethers } from "ethers"; import * as TOML from "smol-toml"; const mnemonic = "test test test test test test test test test test test junk"; - const provider = new ethers.JsonRpcProvider("http://localhost:8545"); const walletMnemonic = ethers.Wallet.fromPhrase(mnemonic); const wallet = walletMnemonic.connect(provider); @@ -89,7 +85,7 @@ test_cases.forEach((testInfo) => { const prover_toml = await getFile(prover_toml_url); const compiled_contract = await getFile(compiled_contract_url); - const contract = new ethers.Contract(contractAddress, JSON.parse(compiled_contract).abi, wallet); + const contract = new ethers.Contract(testInfo.address, JSON.parse(compiled_contract).abi, wallet); expect(noir_source).to.be.a.string; @@ -189,7 +185,7 @@ test_cases.forEach((testInfo) => { const logs = await provider.getLogs({ fromBlock: tx.blockNumber, toBlock: tx.blockNumber, - address: contractAddress, + address: testInfo.address, }); // Decode the logs using your contract's interface to get the verification result From 71d94c3d5c07482ff0f45fc48c4bbaefc6144ca1 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 22:58:44 +0100 Subject: [PATCH 043/108] Rename function --- .../test/integration/browser/compile_prove_verify.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 561b5d43c75..41807efa7ea 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -174,7 +174,7 @@ test_cases.forEach((testInfo) => { expect(verified).to.be.true; try { - const tx = await contract.verifyProof(proof); // replace `verifyProof` with the correct method name if it's different + const tx = await contract.verify(proof); console.log("Transaction hash:", tx.hash); await tx.wait(); From 825cb8d1a7800e96edac03133441d6855bcd4a7a Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 23:17:42 +0100 Subject: [PATCH 044/108] ABI debug --- .../integration/browser/compile_prove_verify.test.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 41807efa7ea..2d91cdb634c 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -15,9 +15,6 @@ const provider = new ethers.JsonRpcProvider("http://localhost:8545"); const walletMnemonic = ethers.Wallet.fromPhrase(mnemonic); const wallet = walletMnemonic.connect(provider); -// Assuming your contract ABI is named `contractAbi` - -// Create a contract instance const { default: initACVM, executeCircuit, compressWitness } = acvm; const { default: newABICoder, abiEncode } = noirc; @@ -85,7 +82,14 @@ test_cases.forEach((testInfo) => { const prover_toml = await getFile(prover_toml_url); const compiled_contract = await getFile(compiled_contract_url); - const contract = new ethers.Contract(testInfo.address, JSON.parse(compiled_contract).abi, wallet); + console.log({ compiled_contract }) + + const { abi } = JSON.parse(compiled_contract); + const contract = new ethers.Contract(testInfo.address, abi, wallet); + + const callable_functions = abi.filter(item => item.type === 'function' && item.stateMutability !== 'view' && item.stateMutability !== 'pure'); + + console.log({ callable_functions }) expect(noir_source).to.be.a.string; From 530fa8fe73e82c27b378b2b81fde7b2db2c0fa00 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 23:33:34 +0100 Subject: [PATCH 045/108] Debug --- .github/workflows/test-integration.yml | 4 ---- .../test/integration/browser/compile_prove_verify.test.ts | 4 +++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index f099037dead..241e50436c7 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -147,10 +147,6 @@ jobs: run: | sed -i 's|address: "MUL_CONTRACT_ADDRESS"|address: "'"$MUL_CONTRACT_ADDRESS"'"|g' compile_prove_verify.test.ts - - name: Check injection - working-directory: compiler/integration-tests/test/integration/browser - run: cat compile_prove_verify.test.ts - - name: Setup `integration-tests` run: | yarn workspace @noir-lang/source-resolver build diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 2d91cdb634c..98e9b4064cf 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -82,9 +82,11 @@ test_cases.forEach((testInfo) => { const prover_toml = await getFile(prover_toml_url); const compiled_contract = await getFile(compiled_contract_url); - console.log({ compiled_contract }) const { abi } = JSON.parse(compiled_contract); + + console.log({ abi }) + const contract = new ethers.Contract(testInfo.address, abi, wallet); const callable_functions = abi.filter(item => item.type === 'function' && item.stateMutability !== 'view' && item.stateMutability !== 'pure'); From fb40df110b3ffa866e04e896fc273379a12cb655 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 20 Sep 2023 23:51:38 +0100 Subject: [PATCH 046/108] Fix verify --- .../browser/compile_prove_verify.test.ts | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 98e9b4064cf..81887594db2 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -180,27 +180,9 @@ test_cases.forEach((testInfo) => { expect(verified).to.be.true; try { - const tx = await contract.verify(proof); - console.log("Transaction hash:", tx.hash); - - await tx.wait(); - - // Retrieve the result from the contract event/logs or however you're setup to get the verification result - // You might want to listen for a specific event emitted by your contract upon verification - - const logs = await provider.getLogs({ - fromBlock: tx.blockNumber, - toBlock: tx.blockNumber, - address: testInfo.address, - }); - - // Decode the logs using your contract's interface to get the verification result - const parsedLogs = logs.map((log) => - contract.interface.parseLog(log) - ); - console.log(parsedLogs); - - // Now you can extract data from parsedLogs or perform other tasks as required. + const result = await contract.verify(proof, []); + console.log(result); + expect(result).to.be.true; } catch (error) { console.error("Error while submitting the proof:", error); } From 99c06688782c21f38afdb27c89a78d2621064cc5 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 00:10:20 +0100 Subject: [PATCH 047/108] Slice for verify --- .../integration/browser/compile_prove_verify.test.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 81887594db2..1b1a0dfc940 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -82,17 +82,10 @@ test_cases.forEach((testInfo) => { const prover_toml = await getFile(prover_toml_url); const compiled_contract = await getFile(compiled_contract_url); - const { abi } = JSON.parse(compiled_contract); - console.log({ abi }) - const contract = new ethers.Contract(testInfo.address, abi, wallet); - const callable_functions = abi.filter(item => item.type === 'function' && item.stateMutability !== 'view' && item.stateMutability !== 'pure'); - - console.log({ callable_functions }) - expect(noir_source).to.be.a.string; initializeResolver((id: string) => { @@ -180,7 +173,10 @@ test_cases.forEach((testInfo) => { expect(verified).to.be.true; try { - const result = await contract.verify(proof, []); + const publicInputs = proof.slice(0, 32); + const slicedProof = proof.slice(32); + + const result = await contract.verify(slicedProof, [publicInputs]); console.log(result); expect(result).to.be.true; } catch (error) { From 3147b7263c0b213e6d0c51141c13348bc0667a4e Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 00:39:26 +0100 Subject: [PATCH 048/108] Pass no public input --- .../test/integration/browser/compile_prove_verify.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 1b1a0dfc940..d94731f8a7e 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -173,10 +173,11 @@ test_cases.forEach((testInfo) => { expect(verified).to.be.true; try { + // https://github.com/AztecProtocol/aztec-packages/issues/1315 const publicInputs = proof.slice(0, 32); const slicedProof = proof.slice(32); - const result = await contract.verify(slicedProof, [publicInputs]); + const result = await contract.verify(slicedProof, []); console.log(result); expect(result).to.be.true; } catch (error) { From 25eaca83a9ac9b0e5164f3d86bcce3a5c6bfda8d Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 11:39:00 +0100 Subject: [PATCH 049/108] Fix nargo --- .github/workflows/test-integration.yml | 39 +++++++++++++++++--------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 241e50436c7..f1ddf01049c 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -42,6 +42,23 @@ jobs: name: barretenberg authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + - name: Build Nargo + run: cargo build --package nargo_cli --release + + - name: Package artifacts + run: | + mkdir dist + cp ./target/release/nargo ./dist/nargo + 7z a -ttar -so -an ./dist/* | 7z a -si ./nargo-x86_64-unknown-linux-gnu.tar.gz + + - name: Compile test program with Nargo CLI + working-directory: ./compiler/wasm/noir-script + run: | + nargo_binary=${{ github.workspace }}/nargo/nargo + chmod +x $nargo_binary + $nargo_binary compile + nargo -V + - name: Restore nix store cache uses: actions/cache/restore@v3 id: cache @@ -105,14 +122,6 @@ jobs: git config user.name kevaundray git config user.email kevtheappdev@gmail.com - - name: Install nargo - run: | - curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash - export PATH="/home/runner/.nargo/bin:$PATH" - noirup - echo "/home/runner/.nargo/bin" >> $GITHUB_PATH - nargo -V - - name: Create new Foundry project run: forge init --no-git --no-commit --force foundry-project @@ -120,14 +129,14 @@ jobs: working-directory: tooling/nargo_cli/tests/execution_success/1_mul run: nargo codegen-verifier - # - name: Run codegen-verifier for double_verify_proof - # working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof - # run: nargo codegen-verifier + - name: Run codegen-verifier for double_verify_proof + working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof + run: nargo codegen-verifier - name: Copy compiled contracts run: | cp tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol foundry-project/src/1_mul.sol - # cp tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof/plonk_vk.sol foundry-project/src/double_verify_proof.sol + cp tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof/plonk_vk.sol foundry-project/src/double_verify_proof.sol - name: Forge build working-directory: foundry-project @@ -140,7 +149,11 @@ jobs: echo "$result" address=$(echo "$result" | grep "Deployed to:" | awk '{print $3}') echo "MUL_CONTRACT_ADDRESS=$address" >> $GITHUB_ENV - # forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/double_verify_proof.sol:UltraVerifier + + # result=$(forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/double_verify_proof.sol:UltraVerifier) + # echo "$result" + # address=$(echo "$result" | grep "Deployed to:" | awk '{print $3}') + # echo "MUL_CONTRACT_ADDRESS=$address" >> $GITHUB_ENV - name: Replace MUL_CONTRACT_ADDRESS in the file working-directory: compiler/integration-tests/test/integration/browser From 0c26bb81b961afa273f2255fe239ad89bcd51980 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 11:50:35 +0100 Subject: [PATCH 050/108] Add nargo to PATH --- .github/workflows/test-integration.yml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index f1ddf01049c..e5ccbf1dc52 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -42,23 +42,12 @@ jobs: name: barretenberg authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - - name: Build Nargo - run: cargo build --package nargo_cli --release - - name: Package artifacts run: | mkdir dist cp ./target/release/nargo ./dist/nargo 7z a -ttar -so -an ./dist/* | 7z a -si ./nargo-x86_64-unknown-linux-gnu.tar.gz - - name: Compile test program with Nargo CLI - working-directory: ./compiler/wasm/noir-script - run: | - nargo_binary=${{ github.workspace }}/nargo/nargo - chmod +x $nargo_binary - $nargo_binary compile - nargo -V - - name: Restore nix store cache uses: actions/cache/restore@v3 id: cache @@ -76,6 +65,14 @@ jobs: nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path" done + - name: Build Nargo + run: | + cargo build --package nargo_cli --release + nargo_binary=${{ github.workspace }}/nargo/nargo + chmod +x $nargo_binary + echo "$(dirname $nargo_binary)" >> $GITHUB_PATH + nargo -V + - name: Build noir_wasm package run: | nix build -L .#noir_wasm From ff9b7fecdd2f388eaaefb556b76cb883e8c8801a Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 11:54:36 +0100 Subject: [PATCH 051/108] Separate build-nargo step --- .github/workflows/test-integration.yml | 54 +++++++++++++++++++++----- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index e5ccbf1dc52..a89912ed224 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -14,8 +14,44 @@ on: # - cron: "0 2 * * *" # Run nightly at 2 AM UTC jobs: + build-nargo: + runs-on: ubuntu-22.04 + strategy: + matrix: + target: [x86_64-unknown-linux-gnu] + + steps: + - name: Checkout Noir repo + uses: actions/checkout@v4 + + - name: Setup toolchain + uses: dtolnay/rust-toolchain@1.66.0 + + - uses: Swatinem/rust-cache@v2 + with: + key: ${{ matrix.target }} + cache-on-failure: true + save-if: ${{ github.event_name != 'merge_group' }} + + - name: Build Nargo + run: cargo build --package nargo_cli --release + + - name: Package artifacts + run: | + mkdir dist + cp ./target/release/nargo ./dist/nargo + 7z a -ttar -so -an ./dist/* | 7z a -si ./nargo-x86_64-unknown-linux-gnu.tar.gz + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: nargo + path: ./dist/* + retention-days: 3 + test-solidity-verifier: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 + needs: [build-nargo] env: CACHED_PATH: /tmp/nix-cache @@ -42,12 +78,6 @@ jobs: name: barretenberg authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - - name: Package artifacts - run: | - mkdir dist - cp ./target/release/nargo ./dist/nargo - 7z a -ttar -so -an ./dist/* | 7z a -si ./nargo-x86_64-unknown-linux-gnu.tar.gz - - name: Restore nix store cache uses: actions/cache/restore@v3 id: cache @@ -65,9 +95,15 @@ jobs: nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path" done - - name: Build Nargo + - name: Download nargo binary + uses: actions/download-artifact@v3 + with: + name: nargo + path: ./nargo + + - name: Set nargo on PATH + working-directory: ./compiler/wasm/noir-script run: | - cargo build --package nargo_cli --release nargo_binary=${{ github.workspace }}/nargo/nargo chmod +x $nargo_binary echo "$(dirname $nargo_binary)" >> $GITHUB_PATH From 837d93e4dec1c0ac073e9309c128eb1a806f368b Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 12:02:01 +0100 Subject: [PATCH 052/108] Test nargo_binary --- .github/workflows/test-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index a89912ed224..7643007e923 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -107,7 +107,7 @@ jobs: nargo_binary=${{ github.workspace }}/nargo/nargo chmod +x $nargo_binary echo "$(dirname $nargo_binary)" >> $GITHUB_PATH - nargo -V + $nargo_binary -V - name: Build noir_wasm package run: | From 96c55423c6c2ea44c1ff50f608b6a971025e6001 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 12:10:18 +0100 Subject: [PATCH 053/108] Use nargo by name --- .github/workflows/test-integration.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 7643007e923..51b750d0919 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -104,10 +104,16 @@ jobs: - name: Set nargo on PATH working-directory: ./compiler/wasm/noir-script run: | - nargo_binary=${{ github.workspace }}/nargo/nargo + # nargo_binary=${{ github.workspace }}/nargo/nargo + # chmod +x $nargo_binary + # $nargo_binary -V + # echo "$(dirname $nargo_binary)" >> $GITHUB_PATH + # nargo -V + nargo_binary="${{ github.workspace }}/nargo/nargo" chmod +x $nargo_binary echo "$(dirname $nargo_binary)" >> $GITHUB_PATH - $nargo_binary -V + export PATH="$PATH:$(dirname $nargo_binary)" + nargo -V - name: Build noir_wasm package run: | From d0797c6815547e8cf2b8e13e2efa9e5910f89cd7 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 12:30:14 +0100 Subject: [PATCH 054/108] Enable double_verify --- .github/workflows/test-integration.yml | 17 +++++++++-------- .../browser/compile_prove_verify.test.ts | 16 ++++++++-------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 51b750d0919..57aeafd17ec 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -184,20 +184,21 @@ jobs: - name: Forge deploy working-directory: foundry-project run: | - result=$(forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/1_mul.sol:UltraVerifier) - echo "$result" - address=$(echo "$result" | grep "Deployed to:" | awk '{print $3}') + mul_result=$(forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/1_mul.sol:UltraVerifier) + echo "$mul_result" + address=$(echo "$mul_result" | grep "Deployed to:" | awk '{print $3}') echo "MUL_CONTRACT_ADDRESS=$address" >> $GITHUB_ENV - # result=$(forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/double_verify_proof.sol:UltraVerifier) - # echo "$result" - # address=$(echo "$result" | grep "Deployed to:" | awk '{print $3}') - # echo "MUL_CONTRACT_ADDRESS=$address" >> $GITHUB_ENV + dv_result=$(forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/double_verify_proof.sol:UltraVerifier) + echo "$dv_result" + address=$(echo "$dv_result" | grep "Deployed to:" | awk '{print $3}') + echo "DV_CONTRACT_ADDRESS=$address" >> $GITHUB_ENV - - name: Replace MUL_CONTRACT_ADDRESS in the file + - name: Replace addresses in the file working-directory: compiler/integration-tests/test/integration/browser run: | sed -i 's|address: "MUL_CONTRACT_ADDRESS"|address: "'"$MUL_CONTRACT_ADDRESS"'"|g' compile_prove_verify.test.ts + sed -i 's|address: "DV_CONTRACT_ADDRESS"|address: "'"$DV_CONTRACT_ADDRESS"'"|g' compile_prove_verify.test.ts - name: Setup `integration-tests` run: | diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index d94731f8a7e..d904fab10d6 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -43,11 +43,11 @@ const test_cases = [ compiled: "foundry-project/out/1_mul.sol/UltraVerifier.json", address: "MUL_CONTRACT_ADDRESS" }, - // { - // case: "tooling/nargo_cli/tests/execution_success/double_verify_proof", - // compiled: "foundry-project/out/double_verify.sol/UltraVerifier.json", - // address: "DOUBLE_VERIFY_CONTRACT_ADDRESS" - // }, + { + case: "tooling/nargo_cli/tests/execution_success/double_verify_proof", + compiled: "foundry-project/out/double_verify.sol/UltraVerifier.json", + address: "DV_CONTRACT_ADDRESS" + }, ]; const numberOfThreads = navigator.hardwareConcurrency || 1; @@ -174,10 +174,10 @@ test_cases.forEach((testInfo) => { try { // https://github.com/AztecProtocol/aztec-packages/issues/1315 - const publicInputs = proof.slice(0, 32); - const slicedProof = proof.slice(32); + // const publicInputs = proof.slice(0, 32); + // const slicedProof = proof.slice(32); - const result = await contract.verify(slicedProof, []); + const result = await contract.verify(proof, []); console.log(result); expect(result).to.be.true; } catch (error) { From d3689699ce1bdd42ec5ab149a5b6223c228b0f3f Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 12:41:34 +0100 Subject: [PATCH 055/108] Separate build stages --- .github/workflows/test-integration.yml | 160 +++++++++++++----- .../browser/compile_prove_verify.test.ts | 5 - 2 files changed, 114 insertions(+), 51 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 57aeafd17ec..8604f2041d9 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -49,35 +49,21 @@ jobs: path: ./dist/* retention-days: 3 - test-solidity-verifier: - runs-on: ubuntu-22.04 - needs: [build-nargo] + build-wasm: + runs-on: ubuntu-latest env: CACHED_PATH: /tmp/nix-cache steps: - - name: Checkout + - name: Checkout sources uses: actions/checkout@v4 - with: - ref: ${{ inputs.tag || env.GITHUB_REF }} - - - name: Checkout acvm sources - uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution - with: - repository: noir-lang/acvm - path: acvm - name: Setup Nix uses: cachix/install-nix-action@v22 with: - nix_path: nixpkgs=channel:nixos-23.05 + nix_path: nixpkgs=channel:nixos-22.11 github_access_token: ${{ secrets.GITHUB_TOKEN }} - - uses: cachix/cachix-action@v12 - with: - name: barretenberg - authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - - name: Restore nix store cache uses: actions/cache/restore@v3 id: cache @@ -95,53 +81,135 @@ jobs: nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path" done - - name: Download nargo binary - uses: actions/download-artifact@v3 - with: - name: nargo - path: ./nargo - - - name: Set nargo on PATH - working-directory: ./compiler/wasm/noir-script + - name: Build wasm package run: | - # nargo_binary=${{ github.workspace }}/nargo/nargo - # chmod +x $nargo_binary - # $nargo_binary -V - # echo "$(dirname $nargo_binary)" >> $GITHUB_PATH - # nargo -V - nargo_binary="${{ github.workspace }}/nargo/nargo" - chmod +x $nargo_binary - echo "$(dirname $nargo_binary)" >> $GITHUB_PATH - export PATH="$PATH:$(dirname $nargo_binary)" - nargo -V + nix build -L .#noir_wasm - - name: Build noir_wasm package + - name: Export cache from nix store + if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} run: | - nix build -L .#noir_wasm - echo "UPLOAD_PATH=$(readlink -f ./result/noir_wasm)" >> $GITHUB_ENV - cp -r ./result/noir_wasm/nodejs ./compiler/wasm - cp -r ./result/noir_wasm/web ./compiler/wasm + nix copy --to "file://${{ env.CACHED_PATH }}?compression=zstd¶llel-compression=true" .#noir-wasm-cargo-artifacts - - name: Upload `noir_wasm` artifact + - uses: actions/cache/save@v3 + # Don't create cache entries for the merge queue. + if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} + with: + path: ${{ env.CACHED_PATH }} + key: ${{ steps.cache.outputs.cache-primary-key }} + + - name: Dereference symlink + run: echo "UPLOAD_PATH=$(readlink -f ./result/noir_wasm)" >> $GITHUB_ENV + + - name: Upload artifact uses: actions/upload-artifact@v3 with: name: noir_wasm path: ${{ env.UPLOAD_PATH }} retention-days: 3 - - name: Build noirc_abi_wasm package + build-noirc: + runs-on: ubuntu-latest + env: + CACHED_PATH: /tmp/nix-cache + + steps: + - name: Checkout sources + uses: actions/checkout@v3 + + - uses: cachix/install-nix-action@v20 + with: + nix_path: nixpkgs=channel:nixos-23.05 + github_access_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Restore nix store cache + uses: actions/cache/restore@v3 + id: cache + with: + path: ${{ env.CACHED_PATH }} + key: ${{ runner.os }}-flake-abi-wasm-${{ hashFiles('*.lock') }} + + # Based on https://github.com/marigold-dev/deku/blob/b5016f0cf4bf6ac48db9111b70dd7fb49b969dfd/.github/workflows/build.yml#L26 + - name: Copy cache into nix store + if: steps.cache.outputs.cache-hit == 'true' + # We don't check the signature because we're the one that created the cache + run: | + for narinfo in ${{ env.CACHED_PATH }}/*.narinfo; do + path=$(head -n 1 "$narinfo" | awk '{print $2}') + nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path" + done + + - name: Build noirc_abi_wasm run: | nix build -L .#noirc_abi_wasm - echo "UPLOAD_PATH=$(readlink -f ./result/noirc_abi_wasm)" >> $GITHUB_ENV cp -r ./result/noirc_abi_wasm/nodejs ./tooling/noirc_abi_wasm cp -r ./result/noirc_abi_wasm/web ./tooling/noirc_abi_wasm - - name: Upload `noirc_abi_wasm` artifact + - name: Export cache from nix store + if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} + run: | + nix copy --to "file://${{ env.CACHED_PATH }}?compression=zstd¶llel-compression=true" .#noirc-abi-wasm-cargo-artifacts + + - uses: actions/cache/save@v3 + # Don't create cache entries for the merge queue. + if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} + with: + path: ${{ env.CACHED_PATH }} + key: ${{ steps.cache.outputs.cache-primary-key }} + + - name: Dereference symlink + run: echo "UPLOAD_PATH=$(readlink -f ./result/noirc_abi_wasm)" >> $GITHUB_ENV + + - name: Upload artifact uses: actions/upload-artifact@v3 with: name: noirc_abi_wasm path: ${{ env.UPLOAD_PATH }} - retention-days: 3 + retention-days: 10 + + test-solidity-verifier: + runs-on: ubuntu-22.04 + needs: [build-wasm, build-nargo, build-noirc] + env: + CACHED_PATH: /tmp/nix-cache + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.tag || env.GITHUB_REF }} + + - name: Checkout acvm sources + uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution + with: + repository: noir-lang/acvm + path: acvm + + - name: Download nargo binary + uses: actions/download-artifact@v3 + with: + name: nargo + path: ./nargo + + - name: Download wasm package artifact + uses: actions/download-artifact@v3 + with: + name: noir_wasm + path: ./compiler/wasm/downloaded + + - name: Download noirc package artifact + uses: actions/download-artifact@v3 + with: + name: noirc_abi_wasm + path: ./tooling/noirc_abi_wasm + + - name: Set nargo on PATH + working-directory: ./compiler/wasm/noir-script + run: | + nargo_binary="${{ github.workspace }}/nargo/nargo" + chmod +x $nargo_binary + echo "$(dirname $nargo_binary)" >> $GITHUB_PATH + export PATH="$PATH:$(dirname $nargo_binary)" + nargo -V - name: Install Yarn dependencies uses: ./.github/actions/setup diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index d904fab10d6..4c84e80fd92 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -173,12 +173,7 @@ test_cases.forEach((testInfo) => { expect(verified).to.be.true; try { - // https://github.com/AztecProtocol/aztec-packages/issues/1315 - // const publicInputs = proof.slice(0, 32); - // const slicedProof = proof.slice(32); - const result = await contract.verify(proof, []); - console.log(result); expect(result).to.be.true; } catch (error) { console.error("Error while submitting the proof:", error); From 1471d0194697f598861e8e31d78639a9443d4be0 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 12:54:04 +0100 Subject: [PATCH 056/108] Fix dv verify --- .github/workflows/test-integration.yml | 2 +- .../browser/compile_prove_verify.test.ts | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 8604f2041d9..fc1ee7381b6 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -15,7 +15,7 @@ on: jobs: build-nargo: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: matrix: target: [x86_64-unknown-linux-gnu] diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 4c84e80fd92..5e5d3ec676c 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -41,12 +41,14 @@ const test_cases = [ { case: "tooling/nargo_cli/tests/execution_success/1_mul", compiled: "foundry-project/out/1_mul.sol/UltraVerifier.json", - address: "MUL_CONTRACT_ADDRESS" + address: "MUL_CONTRACT_ADDRESS", + publicInputsLength: 0 }, { case: "tooling/nargo_cli/tests/execution_success/double_verify_proof", compiled: "foundry-project/out/double_verify.sol/UltraVerifier.json", - address: "DV_CONTRACT_ADDRESS" + address: "DV_CONTRACT_ADDRESS", + publicInputsLength: 16 * 32 }, ]; @@ -173,10 +175,19 @@ test_cases.forEach((testInfo) => { expect(verified).to.be.true; try { - const result = await contract.verify(proof, []); + let result; + if (testInfo.publicInputsLength === 0) { + result = await contract.verify(proof, []); + } else { + const publicInputs = proof.slice(0, testInfo.publicInputsLength); + const slicedProof = proof.slice(testInfo.publicInputsLength); + result = await contract.verify(slicedProof, [publicInputs]); + } + expect(result).to.be.true; } catch (error) { console.error("Error while submitting the proof:", error); + throw error; } } catch (e) { expect(e, "Proving and Verifying").to.not.be.an("error"); From af5bd010935f9a0f754638829326efdce537a8ae Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 13:10:13 +0100 Subject: [PATCH 057/108] Fix lint --- .github/workflows/test-integration.yml | 2 +- .../test/integration/browser/compile_prove_verify.test.ts | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index fc1ee7381b6..8604f2041d9 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -15,7 +15,7 @@ on: jobs: build-nargo: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: matrix: target: [x86_64-unknown-linux-gnu] diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 5e5d3ec676c..223298e6194 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -15,7 +15,6 @@ const provider = new ethers.JsonRpcProvider("http://localhost:8545"); const walletMnemonic = ethers.Wallet.fromPhrase(mnemonic); const wallet = walletMnemonic.connect(provider); - const { default: initACVM, executeCircuit, compressWitness } = acvm; const { default: newABICoder, abiEncode } = noirc; @@ -42,13 +41,13 @@ const test_cases = [ case: "tooling/nargo_cli/tests/execution_success/1_mul", compiled: "foundry-project/out/1_mul.sol/UltraVerifier.json", address: "MUL_CONTRACT_ADDRESS", - publicInputsLength: 0 + publicInputsLength: 0, }, { case: "tooling/nargo_cli/tests/execution_success/double_verify_proof", compiled: "foundry-project/out/double_verify.sol/UltraVerifier.json", address: "DV_CONTRACT_ADDRESS", - publicInputsLength: 16 * 32 + publicInputsLength: 16 * 32, }, ]; @@ -59,7 +58,6 @@ const suite = Mocha.Suite.create(mocha.suite, "Noir end to end test"); suite.timeout(60 * 20e3); //20mins test_cases.forEach((testInfo) => { - const test_name = testInfo.case.split("/").pop(); const mochaTest = new Mocha.Test( `${test_name} (Compile, Execute, Prove, Verify)`, From f9f7e32dab3d12bc0a57505b6bd9cfc29842c002 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 13:20:10 +0100 Subject: [PATCH 058/108] Fix download path for noir_wasm --- .github/workflows/test-integration.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 8604f2041d9..93a1bc16fdc 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -194,7 +194,11 @@ jobs: uses: actions/download-artifact@v3 with: name: noir_wasm - path: ./compiler/wasm/downloaded + path: ./compiler/wasm + + - name: Output wasm + working-directory: ./compiler/wasm + run: ls -R - name: Download noirc package artifact uses: actions/download-artifact@v3 From 0ee3cc6181bf9598cf8fba71e755bc7bd00eb75f Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 14:19:33 +0100 Subject: [PATCH 059/108] Output error --- .github/workflows/test-integration.yml | 4 ---- .../test/integration/browser/compile_prove_verify.test.ts | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 93a1bc16fdc..220c2042d58 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -196,10 +196,6 @@ jobs: name: noir_wasm path: ./compiler/wasm - - name: Output wasm - working-directory: ./compiler/wasm - run: ls -R - - name: Download noirc package artifact uses: actions/download-artifact@v3 with: diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 223298e6194..fe599a311ad 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -175,10 +175,12 @@ test_cases.forEach((testInfo) => { try { let result; if (testInfo.publicInputsLength === 0) { + console.log("Running ", testInfo.case, " with no publicInput") result = await contract.verify(proof, []); } else { const publicInputs = proof.slice(0, testInfo.publicInputsLength); const slicedProof = proof.slice(testInfo.publicInputsLength); + console.log("Running ", testInfo.case, " slicing by ", testInfo.publicInputsLength) result = await contract.verify(slicedProof, [publicInputs]); } From a977886f2856ec74f66967af74e50e1e28217db0 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 14:25:44 +0100 Subject: [PATCH 060/108] Revert split build stages --- .github/workflows/test-integration.yml | 154 +++++++------------------ 1 file changed, 40 insertions(+), 114 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 220c2042d58..cb8a6d9f78e 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -49,21 +49,35 @@ jobs: path: ./dist/* retention-days: 3 - build-wasm: - runs-on: ubuntu-latest + test-solidity-verifier: + runs-on: ubuntu-22.04 + needs: [build-nargo] env: CACHED_PATH: /tmp/nix-cache steps: - - name: Checkout sources + - name: Checkout uses: actions/checkout@v4 + with: + ref: ${{ inputs.tag || env.GITHUB_REF }} + + - name: Checkout acvm sources + uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution + with: + repository: noir-lang/acvm + path: acvm - name: Setup Nix uses: cachix/install-nix-action@v22 with: - nix_path: nixpkgs=channel:nixos-22.11 + nix_path: nixpkgs=channel:nixos-23.05 github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: cachix/cachix-action@v12 + with: + name: barretenberg + authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + - name: Restore nix store cache uses: actions/cache/restore@v3 id: cache @@ -81,135 +95,47 @@ jobs: nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path" done - - name: Build wasm package - run: | - nix build -L .#noir_wasm + - name: Download nargo binary + uses: actions/download-artifact@v3 + with: + name: nargo + path: ./nargo - - name: Export cache from nix store - if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} + - name: Set nargo on PATH + working-directory: ./compiler/wasm/noir-script run: | - nix copy --to "file://${{ env.CACHED_PATH }}?compression=zstd¶llel-compression=true" .#noir-wasm-cargo-artifacts - - - uses: actions/cache/save@v3 - # Don't create cache entries for the merge queue. - if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} - with: - path: ${{ env.CACHED_PATH }} - key: ${{ steps.cache.outputs.cache-primary-key }} + nargo_binary=${{ github.workspace }}/nargo/nargo + chmod +x $nargo_binary + echo "$(dirname $nargo_binary)" >> $GITHUB_PATH + nargo -V - - name: Dereference symlink - run: echo "UPLOAD_PATH=$(readlink -f ./result/noir_wasm)" >> $GITHUB_ENV + - name: Build noir_wasm package + run: | + nix build -L .#noir_wasm + echo "UPLOAD_PATH=$(readlink -f ./result/noir_wasm)" >> $GITHUB_ENV + cp -r ./result/noir_wasm/nodejs ./compiler/wasm + cp -r ./result/noir_wasm/web ./compiler/wasm - - name: Upload artifact + - name: Upload `noir_wasm` artifact uses: actions/upload-artifact@v3 with: name: noir_wasm path: ${{ env.UPLOAD_PATH }} retention-days: 3 - build-noirc: - runs-on: ubuntu-latest - env: - CACHED_PATH: /tmp/nix-cache - - steps: - - name: Checkout sources - uses: actions/checkout@v3 - - - uses: cachix/install-nix-action@v20 - with: - nix_path: nixpkgs=channel:nixos-23.05 - github_access_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Restore nix store cache - uses: actions/cache/restore@v3 - id: cache - with: - path: ${{ env.CACHED_PATH }} - key: ${{ runner.os }}-flake-abi-wasm-${{ hashFiles('*.lock') }} - - # Based on https://github.com/marigold-dev/deku/blob/b5016f0cf4bf6ac48db9111b70dd7fb49b969dfd/.github/workflows/build.yml#L26 - - name: Copy cache into nix store - if: steps.cache.outputs.cache-hit == 'true' - # We don't check the signature because we're the one that created the cache - run: | - for narinfo in ${{ env.CACHED_PATH }}/*.narinfo; do - path=$(head -n 1 "$narinfo" | awk '{print $2}') - nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path" - done - - - name: Build noirc_abi_wasm + - name: Build noirc_abi_wasm package run: | nix build -L .#noirc_abi_wasm + echo "UPLOAD_PATH=$(readlink -f ./result/noirc_abi_wasm)" >> $GITHUB_ENV cp -r ./result/noirc_abi_wasm/nodejs ./tooling/noirc_abi_wasm cp -r ./result/noirc_abi_wasm/web ./tooling/noirc_abi_wasm - - name: Export cache from nix store - if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} - run: | - nix copy --to "file://${{ env.CACHED_PATH }}?compression=zstd¶llel-compression=true" .#noirc-abi-wasm-cargo-artifacts - - - uses: actions/cache/save@v3 - # Don't create cache entries for the merge queue. - if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} - with: - path: ${{ env.CACHED_PATH }} - key: ${{ steps.cache.outputs.cache-primary-key }} - - - name: Dereference symlink - run: echo "UPLOAD_PATH=$(readlink -f ./result/noirc_abi_wasm)" >> $GITHUB_ENV - - - name: Upload artifact + - name: Upload `noirc_abi_wasm` artifact uses: actions/upload-artifact@v3 with: name: noirc_abi_wasm path: ${{ env.UPLOAD_PATH }} - retention-days: 10 - - test-solidity-verifier: - runs-on: ubuntu-22.04 - needs: [build-wasm, build-nargo, build-noirc] - env: - CACHED_PATH: /tmp/nix-cache - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ inputs.tag || env.GITHUB_REF }} - - - name: Checkout acvm sources - uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution - with: - repository: noir-lang/acvm - path: acvm - - - name: Download nargo binary - uses: actions/download-artifact@v3 - with: - name: nargo - path: ./nargo - - - name: Download wasm package artifact - uses: actions/download-artifact@v3 - with: - name: noir_wasm - path: ./compiler/wasm - - - name: Download noirc package artifact - uses: actions/download-artifact@v3 - with: - name: noirc_abi_wasm - path: ./tooling/noirc_abi_wasm - - - name: Set nargo on PATH - working-directory: ./compiler/wasm/noir-script - run: | - nargo_binary="${{ github.workspace }}/nargo/nargo" - chmod +x $nargo_binary - echo "$(dirname $nargo_binary)" >> $GITHUB_PATH - export PATH="$PATH:$(dirname $nargo_binary)" - nargo -V + retention-days: 3 - name: Install Yarn dependencies uses: ./.github/actions/setup From 13dfbdcd060d2a1eb17518924ac8ac5491832d76 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 14:49:29 +0100 Subject: [PATCH 061/108] Fix nargo --- .github/workflows/test-integration.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index cb8a6d9f78e..de9f59b57d9 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -104,9 +104,10 @@ jobs: - name: Set nargo on PATH working-directory: ./compiler/wasm/noir-script run: | - nargo_binary=${{ github.workspace }}/nargo/nargo + nargo_binary="${{ github.workspace }}/nargo/nargo" chmod +x $nargo_binary echo "$(dirname $nargo_binary)" >> $GITHUB_PATH + export PATH="$PATH:$(dirname $nargo_binary)" nargo -V - name: Build noir_wasm package From e2e18e64b7426d8416c110611589f1029c2cc9d2 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 15:17:47 +0100 Subject: [PATCH 062/108] Revert --- .github/workflows/test-integration.yml | 155 +++++++++++++----- .../browser/compile_prove_verify.test.ts | 3 +- 2 files changed, 115 insertions(+), 43 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index de9f59b57d9..220c2042d58 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -49,35 +49,21 @@ jobs: path: ./dist/* retention-days: 3 - test-solidity-verifier: - runs-on: ubuntu-22.04 - needs: [build-nargo] + build-wasm: + runs-on: ubuntu-latest env: CACHED_PATH: /tmp/nix-cache steps: - - name: Checkout + - name: Checkout sources uses: actions/checkout@v4 - with: - ref: ${{ inputs.tag || env.GITHUB_REF }} - - - name: Checkout acvm sources - uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution - with: - repository: noir-lang/acvm - path: acvm - name: Setup Nix uses: cachix/install-nix-action@v22 with: - nix_path: nixpkgs=channel:nixos-23.05 + nix_path: nixpkgs=channel:nixos-22.11 github_access_token: ${{ secrets.GITHUB_TOKEN }} - - uses: cachix/cachix-action@v12 - with: - name: barretenberg - authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - - name: Restore nix store cache uses: actions/cache/restore@v3 id: cache @@ -95,48 +81,135 @@ jobs: nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path" done - - name: Download nargo binary - uses: actions/download-artifact@v3 - with: - name: nargo - path: ./nargo - - - name: Set nargo on PATH - working-directory: ./compiler/wasm/noir-script + - name: Build wasm package run: | - nargo_binary="${{ github.workspace }}/nargo/nargo" - chmod +x $nargo_binary - echo "$(dirname $nargo_binary)" >> $GITHUB_PATH - export PATH="$PATH:$(dirname $nargo_binary)" - nargo -V + nix build -L .#noir_wasm - - name: Build noir_wasm package + - name: Export cache from nix store + if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} run: | - nix build -L .#noir_wasm - echo "UPLOAD_PATH=$(readlink -f ./result/noir_wasm)" >> $GITHUB_ENV - cp -r ./result/noir_wasm/nodejs ./compiler/wasm - cp -r ./result/noir_wasm/web ./compiler/wasm + nix copy --to "file://${{ env.CACHED_PATH }}?compression=zstd¶llel-compression=true" .#noir-wasm-cargo-artifacts - - name: Upload `noir_wasm` artifact + - uses: actions/cache/save@v3 + # Don't create cache entries for the merge queue. + if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} + with: + path: ${{ env.CACHED_PATH }} + key: ${{ steps.cache.outputs.cache-primary-key }} + + - name: Dereference symlink + run: echo "UPLOAD_PATH=$(readlink -f ./result/noir_wasm)" >> $GITHUB_ENV + + - name: Upload artifact uses: actions/upload-artifact@v3 with: name: noir_wasm path: ${{ env.UPLOAD_PATH }} retention-days: 3 - - name: Build noirc_abi_wasm package + build-noirc: + runs-on: ubuntu-latest + env: + CACHED_PATH: /tmp/nix-cache + + steps: + - name: Checkout sources + uses: actions/checkout@v3 + + - uses: cachix/install-nix-action@v20 + with: + nix_path: nixpkgs=channel:nixos-23.05 + github_access_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Restore nix store cache + uses: actions/cache/restore@v3 + id: cache + with: + path: ${{ env.CACHED_PATH }} + key: ${{ runner.os }}-flake-abi-wasm-${{ hashFiles('*.lock') }} + + # Based on https://github.com/marigold-dev/deku/blob/b5016f0cf4bf6ac48db9111b70dd7fb49b969dfd/.github/workflows/build.yml#L26 + - name: Copy cache into nix store + if: steps.cache.outputs.cache-hit == 'true' + # We don't check the signature because we're the one that created the cache + run: | + for narinfo in ${{ env.CACHED_PATH }}/*.narinfo; do + path=$(head -n 1 "$narinfo" | awk '{print $2}') + nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path" + done + + - name: Build noirc_abi_wasm run: | nix build -L .#noirc_abi_wasm - echo "UPLOAD_PATH=$(readlink -f ./result/noirc_abi_wasm)" >> $GITHUB_ENV cp -r ./result/noirc_abi_wasm/nodejs ./tooling/noirc_abi_wasm cp -r ./result/noirc_abi_wasm/web ./tooling/noirc_abi_wasm - - name: Upload `noirc_abi_wasm` artifact + - name: Export cache from nix store + if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} + run: | + nix copy --to "file://${{ env.CACHED_PATH }}?compression=zstd¶llel-compression=true" .#noirc-abi-wasm-cargo-artifacts + + - uses: actions/cache/save@v3 + # Don't create cache entries for the merge queue. + if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} + with: + path: ${{ env.CACHED_PATH }} + key: ${{ steps.cache.outputs.cache-primary-key }} + + - name: Dereference symlink + run: echo "UPLOAD_PATH=$(readlink -f ./result/noirc_abi_wasm)" >> $GITHUB_ENV + + - name: Upload artifact uses: actions/upload-artifact@v3 with: name: noirc_abi_wasm path: ${{ env.UPLOAD_PATH }} - retention-days: 3 + retention-days: 10 + + test-solidity-verifier: + runs-on: ubuntu-22.04 + needs: [build-wasm, build-nargo, build-noirc] + env: + CACHED_PATH: /tmp/nix-cache + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.tag || env.GITHUB_REF }} + + - name: Checkout acvm sources + uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution + with: + repository: noir-lang/acvm + path: acvm + + - name: Download nargo binary + uses: actions/download-artifact@v3 + with: + name: nargo + path: ./nargo + + - name: Download wasm package artifact + uses: actions/download-artifact@v3 + with: + name: noir_wasm + path: ./compiler/wasm + + - name: Download noirc package artifact + uses: actions/download-artifact@v3 + with: + name: noirc_abi_wasm + path: ./tooling/noirc_abi_wasm + + - name: Set nargo on PATH + working-directory: ./compiler/wasm/noir-script + run: | + nargo_binary="${{ github.workspace }}/nargo/nargo" + chmod +x $nargo_binary + echo "$(dirname $nargo_binary)" >> $GITHUB_PATH + export PATH="$PATH:$(dirname $nargo_binary)" + nargo -V - name: Install Yarn dependencies uses: ./.github/actions/setup diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index fe599a311ad..89a8a03eb07 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -175,12 +175,11 @@ test_cases.forEach((testInfo) => { try { let result; if (testInfo.publicInputsLength === 0) { - console.log("Running ", testInfo.case, " with no publicInput") + console.log({ proof }) result = await contract.verify(proof, []); } else { const publicInputs = proof.slice(0, testInfo.publicInputsLength); const slicedProof = proof.slice(testInfo.publicInputsLength); - console.log("Running ", testInfo.case, " slicing by ", testInfo.publicInputsLength) result = await contract.verify(slicedProof, [publicInputs]); } From b1f22864bfc613b20d8e80a2eaf8ce55122177bc Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 15:20:32 +0100 Subject: [PATCH 063/108] Update yarn lock --- yarn.lock | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/yarn.lock b/yarn.lock index ff2a682135b..d26bdba4127 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,6 +22,13 @@ __metadata: languageName: node linkType: hard +"@adraffy/ens-normalize@npm:1.9.2": + version: 1.9.2 + resolution: "@adraffy/ens-normalize@npm:1.9.2" + checksum: a9fdeb9e080774c19e4b7f9f60aa5b37cf23fe0e8fe80284bf8221f7396e9f78642bfd39a09a94a4dc3fb8e70f2ac81545204bdcaf222d93f4c4c2ae1f0dca0b + languageName: node + linkType: hard + "@aztec/bb.js@npm:0.7.2": version: 0.7.2 resolution: "@aztec/bb.js@npm:0.7.2" From 524d89b136a8b3715929139bf0ed32f0157c4c9b Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 15:58:22 +0100 Subject: [PATCH 064/108] Name action --- .github/workflows/test-integration.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index fcc99a4e868..7bc49d7a7c8 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -116,7 +116,8 @@ jobs: - name: Checkout sources uses: actions/checkout@v3 - - uses: cachix/install-nix-action@v20 + - name: Setup Nix + uses: cachix/install-nix-action@v20 with: nix_path: nixpkgs=channel:nixos-23.05 github_access_token: ${{ secrets.GITHUB_TOKEN }} From 387091ce20b82f46fb4683a1ab5696a5e982f8c2 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 16:26:11 +0100 Subject: [PATCH 065/108] Fix --- .../test/integration/browser/compile_prove_verify.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index f286e47a4ff..4537141398d 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -4,7 +4,7 @@ import newCompiler, { compile, init_log_level as compilerLogLevel, } from "@noir-lang/noir_wasm"; -import { acvm, noirc } from "@noir-lang/noir_js"; +import { acvm, abi } from "@noir-lang/noir_js"; import { Barretenberg, RawBuffer, Crs } from "@aztec/bb.js"; import { decompressSync as gunzip } from "fflate"; import { ethers } from "ethers"; @@ -16,7 +16,7 @@ const walletMnemonic = ethers.Wallet.fromPhrase(mnemonic); const wallet = walletMnemonic.connect(provider); const { default: initACVM, executeCircuit, compressWitness } = acvm; -const { default: newABICoder, abiEncode } = noirc; +const { default: newABICoder, abiEncode } = abi; type WitnessMap = acvm.WitnessMap; From 89abeb8229dcde64615888ba286af1ea7d0e3d97 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 16:27:34 +0100 Subject: [PATCH 066/108] Prettier --- .../test/integration/browser/compile_prove_verify.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 4537141398d..f171cde8d58 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -75,7 +75,7 @@ test_cases.forEach((testInfo) => { ); const compiled_contract_url = new URL( `${base_relative_path}/${testInfo.compiled}`, - import.meta.url + import.meta.url, ); const noir_source = await getFile(noir_source_url); @@ -175,7 +175,7 @@ test_cases.forEach((testInfo) => { try { let result; if (testInfo.publicInputsLength === 0) { - console.log({ proof }) + console.log({ proof }); result = await contract.verify(proof, []); } else { const publicInputs = proof.slice(0, testInfo.publicInputsLength); From 1f039a9fad5f0829cb40c3619583bcc906e5012f Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 16:57:14 +0100 Subject: [PATCH 067/108] Comment test case --- .../browser/compile_prove_verify.test.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index f171cde8d58..3eec3aefbb7 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -37,12 +37,12 @@ async function getFile(url: URL): Promise { const CIRCUIT_SIZE = 2 ** 19; const test_cases = [ - { - case: "tooling/nargo_cli/tests/execution_success/1_mul", - compiled: "foundry-project/out/1_mul.sol/UltraVerifier.json", - address: "MUL_CONTRACT_ADDRESS", - publicInputsLength: 0, - }, + // { + // case: "tooling/nargo_cli/tests/execution_success/1_mul", + // compiled: "foundry-project/out/1_mul.sol/UltraVerifier.json", + // address: "MUL_CONTRACT_ADDRESS", + // publicInputsLength: 0, + // }, { case: "tooling/nargo_cli/tests/execution_success/double_verify_proof", compiled: "foundry-project/out/double_verify.sol/UltraVerifier.json", @@ -175,7 +175,6 @@ test_cases.forEach((testInfo) => { try { let result; if (testInfo.publicInputsLength === 0) { - console.log({ proof }); result = await contract.verify(proof, []); } else { const publicInputs = proof.slice(0, testInfo.publicInputsLength); From 70e1c609c2746973c55657eca9b0fa2d6abb750a Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 17:10:03 +0100 Subject: [PATCH 068/108] Uncomment test --- .../integration/browser/compile_prove_verify.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 3eec3aefbb7..efa22b05712 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -37,12 +37,12 @@ async function getFile(url: URL): Promise { const CIRCUIT_SIZE = 2 ** 19; const test_cases = [ - // { - // case: "tooling/nargo_cli/tests/execution_success/1_mul", - // compiled: "foundry-project/out/1_mul.sol/UltraVerifier.json", - // address: "MUL_CONTRACT_ADDRESS", - // publicInputsLength: 0, - // }, + { + case: "tooling/nargo_cli/tests/execution_success/1_mul", + compiled: "foundry-project/out/1_mul.sol/UltraVerifier.json", + address: "MUL_CONTRACT_ADDRESS", + publicInputsLength: 0, + }, { case: "tooling/nargo_cli/tests/execution_success/double_verify_proof", compiled: "foundry-project/out/double_verify.sol/UltraVerifier.json", From e14b15c48e72bac68d611d53b036424d5d2c7c84 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 21 Sep 2023 17:31:46 +0100 Subject: [PATCH 069/108] Bump bb.js --- compiler/integration-tests/package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/integration-tests/package.json b/compiler/integration-tests/package.json index 71e629029a4..527d9027490 100644 --- a/compiler/integration-tests/package.json +++ b/compiler/integration-tests/package.json @@ -12,7 +12,7 @@ "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0" }, "dependencies": { - "@aztec/bb.js": "^0.6.7", + "@aztec/bb.js": "^0.7.2", "@noir-lang/noir_js": "workspace:*", "@noir-lang/noir_wasm": "workspace:*", "@noir-lang/source-resolver": "workspace:*", diff --git a/yarn.lock b/yarn.lock index d26bdba4127..301e77cb51e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -43,9 +43,9 @@ __metadata: languageName: node linkType: hard -"@aztec/bb.js@npm:^0.6.7": - version: 0.6.7 - resolution: "@aztec/bb.js@npm:0.6.7" +"@aztec/bb.js@npm:^0.7.2": + version: 0.7.10 + resolution: "@aztec/bb.js@npm:0.7.10" dependencies: comlink: ^4.4.1 commander: ^10.0.1 @@ -53,7 +53,7 @@ __metadata: tslib: ^2.4.0 bin: bb.js: dest/node/main.js - checksum: 9067e9c4c5e51de173261bb5feebe6c4f6fc2be0381e2b30301fd5ed6794c5a20f5242427b7701384bc6285cd65e04e2fa914010923d1671cf59c8674b6545eb + checksum: 0410278e6ec2a6ecdcbaa58633b181ec1d91e1c267c76e7e587fb69c8f2fd394e79f65bd96cfcdb2a2b20fe5abeb86ababd45bd6364ba07555fc0643bf0e4307 languageName: node linkType: hard @@ -4487,7 +4487,7 @@ __metadata: version: 0.0.0-use.local resolution: "integration-tests@workspace:compiler/integration-tests" dependencies: - "@aztec/bb.js": ^0.6.7 + "@aztec/bb.js": ^0.7.2 "@noir-lang/noir_js": "workspace:*" "@noir-lang/noir_wasm": "workspace:*" "@noir-lang/source-resolver": "workspace:*" From 9ab73cbcddd9b59ed7a3bb7621aeed74e24619e9 Mon Sep 17 00:00:00 2001 From: Tom French Date: Thu, 21 Sep 2023 17:48:02 +0100 Subject: [PATCH 070/108] fix: make proof non-recursive --- .../browser/compile_prove_verify.test.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index efa22b05712..9f7814a6da2 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -67,15 +67,15 @@ test_cases.forEach((testInfo) => { const noir_source_url = new URL( `${base_relative_path}/${test_case}/src/main.nr`, - import.meta.url, + import.meta.url ); const prover_toml_url = new URL( `${base_relative_path}/${test_case}/Prover.toml`, - import.meta.url, + import.meta.url ); const compiled_contract_url = new URL( `${base_relative_path}/${testInfo.compiled}`, - import.meta.url, + import.meta.url ); const noir_source = await getFile(noir_source_url); @@ -121,7 +121,7 @@ test_cases.forEach((testInfo) => { try { compressedByteCode = Uint8Array.from( atob(compile_output.circuit), - (c) => c.charCodeAt(0), + (c) => c.charCodeAt(0) ); solvedWitness = await executeCircuit( @@ -129,7 +129,7 @@ test_cases.forEach((testInfo) => { witnessMap, () => { throw Error("unexpected oracle"); - }, + } ); } catch (e) { expect(e, "Abi Encoding Step").to.not.be.an("error"); @@ -141,7 +141,7 @@ test_cases.forEach((testInfo) => { const acirUint8Array = gunzip(compressedByteCode); const witnessUint8Array = gunzip(compressedWitness); - const isRecursive = true; + const isRecursive = false; const api = await Barretenberg.new(numberOfThreads); await api.commonInitSlabAllocator(CIRCUIT_SIZE); @@ -150,7 +150,7 @@ test_cases.forEach((testInfo) => { await api.srsInitSrs( new RawBuffer(crs.getG1Data()), crs.numPoints, - new RawBuffer(crs.getG2Data()), + new RawBuffer(crs.getG2Data()) ); const acirComposer = await api.acirNewAcirComposer(CIRCUIT_SIZE); @@ -160,14 +160,14 @@ test_cases.forEach((testInfo) => { acirComposer, acirUint8Array, witnessUint8Array, - isRecursive, + isRecursive ); // And this took ~5 minutes! const verified = await api.acirVerifyProof( acirComposer, proof, - isRecursive, + isRecursive ); expect(verified).to.be.true; @@ -191,7 +191,7 @@ test_cases.forEach((testInfo) => { expect(e, "Proving and Verifying").to.not.be.an("error"); throw e; } - }, + } ); suite.addTest(mochaTest); From 00ffd6d600e8dcb37ede7607396f50fbbad3c40b Mon Sep 17 00:00:00 2001 From: Tom French Date: Thu, 21 Sep 2023 18:27:32 +0100 Subject: [PATCH 071/108] chore: remove wrapping layer around public inputs --- .github/workflows/test-integration.yml | 3 ++- .../test/integration/browser/compile_prove_verify.test.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 7bc49d7a7c8..f8b10463390 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -15,7 +15,8 @@ on: jobs: build-nargo: - runs-on: ubuntu-22.04 + + runs-on: ubuntu-latest-16-cores strategy: matrix: target: [x86_64-unknown-linux-gnu] diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 9f7814a6da2..9541081e98b 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -179,7 +179,7 @@ test_cases.forEach((testInfo) => { } else { const publicInputs = proof.slice(0, testInfo.publicInputsLength); const slicedProof = proof.slice(testInfo.publicInputsLength); - result = await contract.verify(slicedProof, [publicInputs]); + result = await contract.verify(slicedProof, publicInputs); } expect(result).to.be.true; From bdcdb8289e1d7e7201193f2dc54b2e8b8c23e868 Mon Sep 17 00:00:00 2001 From: Tom French Date: Thu, 21 Sep 2023 18:38:14 +0100 Subject: [PATCH 072/108] chore: update runners --- .github/workflows/test-integration.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index f8b10463390..70579af85e5 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -16,7 +16,7 @@ on: jobs: build-nargo: - runs-on: ubuntu-latest-16-cores + runs-on: ubuntu-large strategy: matrix: target: [x86_64-unknown-linux-gnu] @@ -51,7 +51,7 @@ jobs: retention-days: 3 build-wasm: - runs-on: ubuntu-latest + runs-on: ubuntu-large env: CACHED_PATH: /tmp/nix-cache @@ -109,7 +109,7 @@ jobs: retention-days: 3 build-noirc: - runs-on: ubuntu-latest + runs-on: ubuntu-large env: CACHED_PATH: /tmp/nix-cache @@ -169,7 +169,7 @@ jobs: retention-days: 10 test-solidity-verifier: - runs-on: ubuntu-22.04 + runs-on: ubuntu-large needs: [build-wasm, build-nargo, build-noirc] env: CACHED_PATH: /tmp/nix-cache From 46e242b5d937f6a21874e509fc104a127d6998c7 Mon Sep 17 00:00:00 2001 From: Tom French Date: Thu, 21 Sep 2023 18:55:11 +0100 Subject: [PATCH 073/108] chore: add better error message for failing proof --- .../test/integration/browser/compile_prove_verify.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 9541081e98b..8fc3c0df838 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -170,7 +170,7 @@ test_cases.forEach((testInfo) => { isRecursive ); - expect(verified).to.be.true; + expect(verified, "Proof fails verification in JS").to.be.true; try { let result; From 84881215a6365a8c7b0210aa354852d2839b8455 Mon Sep 17 00:00:00 2001 From: Tom French Date: Thu, 21 Sep 2023 19:57:15 +0100 Subject: [PATCH 074/108] chore: go back down to small runners --- .github/workflows/test-integration.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 70579af85e5..ea9859cc859 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -16,7 +16,7 @@ on: jobs: build-nargo: - runs-on: ubuntu-large + runs-on: ubuntu-latest strategy: matrix: target: [x86_64-unknown-linux-gnu] @@ -51,7 +51,7 @@ jobs: retention-days: 3 build-wasm: - runs-on: ubuntu-large + runs-on: ubuntu-latest env: CACHED_PATH: /tmp/nix-cache @@ -109,7 +109,7 @@ jobs: retention-days: 3 build-noirc: - runs-on: ubuntu-large + runs-on: ubuntu-latest env: CACHED_PATH: /tmp/nix-cache @@ -169,7 +169,7 @@ jobs: retention-days: 10 test-solidity-verifier: - runs-on: ubuntu-large + runs-on: ubuntu-latest needs: [build-wasm, build-nargo, build-noirc] env: CACHED_PATH: /tmp/nix-cache From 6e992caa0ba1292a4070ba5a32c564b1d8ae5595 Mon Sep 17 00:00:00 2001 From: Tom French Date: Thu, 21 Sep 2023 19:57:29 +0100 Subject: [PATCH 075/108] chore: turn off `double_verify_proof` testcase --- .../integration/browser/compile_prove_verify.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 8fc3c0df838..ef67df3aa8f 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -43,12 +43,12 @@ const test_cases = [ address: "MUL_CONTRACT_ADDRESS", publicInputsLength: 0, }, - { - case: "tooling/nargo_cli/tests/execution_success/double_verify_proof", - compiled: "foundry-project/out/double_verify.sol/UltraVerifier.json", - address: "DV_CONTRACT_ADDRESS", - publicInputsLength: 16 * 32, - }, + // { + // case: "tooling/nargo_cli/tests/execution_success/double_verify_proof", + // compiled: "foundry-project/out/double_verify.sol/UltraVerifier.json", + // address: "DV_CONTRACT_ADDRESS", + // publicInputsLength: 16 * 32, + // }, ]; const numberOfThreads = navigator.hardwareConcurrency || 1; From 2e2607ce891c9cec6c0a848645dbd1acec2ce691 Mon Sep 17 00:00:00 2001 From: Tom French Date: Thu, 21 Sep 2023 20:09:37 +0100 Subject: [PATCH 076/108] chore: linter --- compiler/source-resolver/src/index.ts | 10 +++++----- compiler/source-resolver/types/index.d.ts | 2 +- compiler/wasm/test/node/index.test.ts | 2 +- tooling/noirc_abi_wasm/test/browser/abi_encode.test.ts | 4 ++-- tooling/noirc_abi_wasm/test/node/abi_encode.test.ts | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/compiler/source-resolver/src/index.ts b/compiler/source-resolver/src/index.ts index 66ff1e947aa..e7e1db64b75 100644 --- a/compiler/source-resolver/src/index.ts +++ b/compiler/source-resolver/src/index.ts @@ -8,30 +8,30 @@ export const read_file = function (source_id: string): string { return result; } else { throw new Error( - "Noir source resolver function MUST return String synchronously. Are you trying to return anything else, eg. `Promise`?", + "Noir source resolver function MUST return String synchronously. Are you trying to return anything else, eg. `Promise`?" ); } } else { throw new Error( - "Not yet initialized. Use initializeResolver(() => string)", + "Not yet initialized. Use initializeResolver(() => string)" ); } }; function initialize( - noir_resolver: (source_id: string) => string, + noir_resolver: (source_id: string) => string ): (source_id: string) => string { if (typeof noir_resolver === "function") { return noir_resolver; } else { throw new Error( - "Provided Noir Resolver is not a function, hint: use function(module_id) => NoirSource as second parameter", + "Provided Noir Resolver is not a function, hint: use function(module_id) => NoirSource as second parameter" ); } } export function initializeResolver( - resolver: (source_id: string) => string, + resolver: (source_id: string) => string ): void { resolveFunction = initialize(resolver); } diff --git a/compiler/source-resolver/types/index.d.ts b/compiler/source-resolver/types/index.d.ts index bf144c3928f..ef4e98c87e1 100644 --- a/compiler/source-resolver/types/index.d.ts +++ b/compiler/source-resolver/types/index.d.ts @@ -1,4 +1,4 @@ export declare const read_file: (source_id: string) => string; export declare function initializeResolver( - resolver: (source_id: string) => string, + resolver: (source_id: string) => string ): void; diff --git a/compiler/wasm/test/node/index.test.ts b/compiler/wasm/test/node/index.test.ts index f823db35944..c180fd6db39 100644 --- a/compiler/wasm/test/node/index.test.ts +++ b/compiler/wasm/test/node/index.test.ts @@ -34,7 +34,7 @@ describe("noir wasm compilation", () => { console.log( "Compilation is a match? ", - wasmCircuitBase64 === cliCircuitBase64, + wasmCircuitBase64 === cliCircuitBase64 ); expect(wasmCircuitBase64).to.equal(cliCircuitBase64); diff --git a/tooling/noirc_abi_wasm/test/browser/abi_encode.test.ts b/tooling/noirc_abi_wasm/test/browser/abi_encode.test.ts index 8cdf19c43a7..2ca45d78f5c 100644 --- a/tooling/noirc_abi_wasm/test/browser/abi_encode.test.ts +++ b/tooling/noirc_abi_wasm/test/browser/abi_encode.test.ts @@ -18,10 +18,10 @@ it("recovers original inputs when abi encoding and decoding", async () => { expect(BigInt(decoded_inputs.inputs.foo)).to.be.equal(BigInt(inputs.foo)); expect(BigInt(decoded_inputs.inputs.bar[0])).to.be.equal( - BigInt(inputs.bar[0]), + BigInt(inputs.bar[0]) ); expect(BigInt(decoded_inputs.inputs.bar[1])).to.be.equal( - BigInt(inputs.bar[1]), + BigInt(inputs.bar[1]) ); expect(decoded_inputs.return_value).to.be.null; }); diff --git a/tooling/noirc_abi_wasm/test/node/abi_encode.test.ts b/tooling/noirc_abi_wasm/test/node/abi_encode.test.ts index b84d84fdd77..8a3b6fe9ffc 100644 --- a/tooling/noirc_abi_wasm/test/node/abi_encode.test.ts +++ b/tooling/noirc_abi_wasm/test/node/abi_encode.test.ts @@ -10,10 +10,10 @@ it("recovers original inputs when abi encoding and decoding", async () => { expect(BigInt(decoded_inputs.inputs.foo)).to.be.equal(BigInt(inputs.foo)); expect(BigInt(decoded_inputs.inputs.bar[0])).to.be.equal( - BigInt(inputs.bar[0]), + BigInt(inputs.bar[0]) ); expect(BigInt(decoded_inputs.inputs.bar[1])).to.be.equal( - BigInt(inputs.bar[1]), + BigInt(inputs.bar[1]) ); expect(decoded_inputs.return_value).to.be.null; }); From 813af9e97e38109d468a0e074c99eaf671089dce Mon Sep 17 00:00:00 2001 From: Tom French Date: Thu, 21 Sep 2023 20:32:18 +0100 Subject: [PATCH 077/108] chore: linter fix --- .../browser/compile_prove_verify.test.ts | 18 +++++++++--------- compiler/source-resolver/src/index.ts | 10 +++++----- compiler/source-resolver/types/index.d.ts | 2 +- compiler/wasm/test/node/index.test.ts | 2 +- .../test/browser/abi_encode.test.ts | 4 ++-- .../test/node/abi_encode.test.ts | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index ef67df3aa8f..dfe9f0fdd3f 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -67,15 +67,15 @@ test_cases.forEach((testInfo) => { const noir_source_url = new URL( `${base_relative_path}/${test_case}/src/main.nr`, - import.meta.url + import.meta.url, ); const prover_toml_url = new URL( `${base_relative_path}/${test_case}/Prover.toml`, - import.meta.url + import.meta.url, ); const compiled_contract_url = new URL( `${base_relative_path}/${testInfo.compiled}`, - import.meta.url + import.meta.url, ); const noir_source = await getFile(noir_source_url); @@ -121,7 +121,7 @@ test_cases.forEach((testInfo) => { try { compressedByteCode = Uint8Array.from( atob(compile_output.circuit), - (c) => c.charCodeAt(0) + (c) => c.charCodeAt(0), ); solvedWitness = await executeCircuit( @@ -129,7 +129,7 @@ test_cases.forEach((testInfo) => { witnessMap, () => { throw Error("unexpected oracle"); - } + }, ); } catch (e) { expect(e, "Abi Encoding Step").to.not.be.an("error"); @@ -150,7 +150,7 @@ test_cases.forEach((testInfo) => { await api.srsInitSrs( new RawBuffer(crs.getG1Data()), crs.numPoints, - new RawBuffer(crs.getG2Data()) + new RawBuffer(crs.getG2Data()), ); const acirComposer = await api.acirNewAcirComposer(CIRCUIT_SIZE); @@ -160,14 +160,14 @@ test_cases.forEach((testInfo) => { acirComposer, acirUint8Array, witnessUint8Array, - isRecursive + isRecursive, ); // And this took ~5 minutes! const verified = await api.acirVerifyProof( acirComposer, proof, - isRecursive + isRecursive, ); expect(verified, "Proof fails verification in JS").to.be.true; @@ -191,7 +191,7 @@ test_cases.forEach((testInfo) => { expect(e, "Proving and Verifying").to.not.be.an("error"); throw e; } - } + }, ); suite.addTest(mochaTest); diff --git a/compiler/source-resolver/src/index.ts b/compiler/source-resolver/src/index.ts index e7e1db64b75..66ff1e947aa 100644 --- a/compiler/source-resolver/src/index.ts +++ b/compiler/source-resolver/src/index.ts @@ -8,30 +8,30 @@ export const read_file = function (source_id: string): string { return result; } else { throw new Error( - "Noir source resolver function MUST return String synchronously. Are you trying to return anything else, eg. `Promise`?" + "Noir source resolver function MUST return String synchronously. Are you trying to return anything else, eg. `Promise`?", ); } } else { throw new Error( - "Not yet initialized. Use initializeResolver(() => string)" + "Not yet initialized. Use initializeResolver(() => string)", ); } }; function initialize( - noir_resolver: (source_id: string) => string + noir_resolver: (source_id: string) => string, ): (source_id: string) => string { if (typeof noir_resolver === "function") { return noir_resolver; } else { throw new Error( - "Provided Noir Resolver is not a function, hint: use function(module_id) => NoirSource as second parameter" + "Provided Noir Resolver is not a function, hint: use function(module_id) => NoirSource as second parameter", ); } } export function initializeResolver( - resolver: (source_id: string) => string + resolver: (source_id: string) => string, ): void { resolveFunction = initialize(resolver); } diff --git a/compiler/source-resolver/types/index.d.ts b/compiler/source-resolver/types/index.d.ts index ef4e98c87e1..bf144c3928f 100644 --- a/compiler/source-resolver/types/index.d.ts +++ b/compiler/source-resolver/types/index.d.ts @@ -1,4 +1,4 @@ export declare const read_file: (source_id: string) => string; export declare function initializeResolver( - resolver: (source_id: string) => string + resolver: (source_id: string) => string, ): void; diff --git a/compiler/wasm/test/node/index.test.ts b/compiler/wasm/test/node/index.test.ts index c180fd6db39..f823db35944 100644 --- a/compiler/wasm/test/node/index.test.ts +++ b/compiler/wasm/test/node/index.test.ts @@ -34,7 +34,7 @@ describe("noir wasm compilation", () => { console.log( "Compilation is a match? ", - wasmCircuitBase64 === cliCircuitBase64 + wasmCircuitBase64 === cliCircuitBase64, ); expect(wasmCircuitBase64).to.equal(cliCircuitBase64); diff --git a/tooling/noirc_abi_wasm/test/browser/abi_encode.test.ts b/tooling/noirc_abi_wasm/test/browser/abi_encode.test.ts index 2ca45d78f5c..8cdf19c43a7 100644 --- a/tooling/noirc_abi_wasm/test/browser/abi_encode.test.ts +++ b/tooling/noirc_abi_wasm/test/browser/abi_encode.test.ts @@ -18,10 +18,10 @@ it("recovers original inputs when abi encoding and decoding", async () => { expect(BigInt(decoded_inputs.inputs.foo)).to.be.equal(BigInt(inputs.foo)); expect(BigInt(decoded_inputs.inputs.bar[0])).to.be.equal( - BigInt(inputs.bar[0]) + BigInt(inputs.bar[0]), ); expect(BigInt(decoded_inputs.inputs.bar[1])).to.be.equal( - BigInt(inputs.bar[1]) + BigInt(inputs.bar[1]), ); expect(decoded_inputs.return_value).to.be.null; }); diff --git a/tooling/noirc_abi_wasm/test/node/abi_encode.test.ts b/tooling/noirc_abi_wasm/test/node/abi_encode.test.ts index 8a3b6fe9ffc..b84d84fdd77 100644 --- a/tooling/noirc_abi_wasm/test/node/abi_encode.test.ts +++ b/tooling/noirc_abi_wasm/test/node/abi_encode.test.ts @@ -10,10 +10,10 @@ it("recovers original inputs when abi encoding and decoding", async () => { expect(BigInt(decoded_inputs.inputs.foo)).to.be.equal(BigInt(inputs.foo)); expect(BigInt(decoded_inputs.inputs.bar[0])).to.be.equal( - BigInt(inputs.bar[0]) + BigInt(inputs.bar[0]), ); expect(BigInt(decoded_inputs.inputs.bar[1])).to.be.equal( - BigInt(inputs.bar[1]) + BigInt(inputs.bar[1]), ); expect(decoded_inputs.return_value).to.be.null; }); From 536e0f1b0c7a8fcbc2f8cd14a661b5bdaff66212 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:21:45 +0100 Subject: [PATCH 078/108] Update .github/workflows/test-integration.yml --- .github/workflows/test-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index ea9859cc859..68afe2d3bc1 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -1,4 +1,4 @@ -name: Test Solidity Verifier +name: test-integration on: push: From 1449f9f428f5749f4faf00c8b452305080b0fd9c Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:21:57 +0100 Subject: [PATCH 079/108] Update .github/workflows/test-integration.yml --- .github/workflows/test-integration.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 68afe2d3bc1..205609c8d12 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -226,10 +226,6 @@ jobs: anvil > /dev/null 2>&1 & sleep 10 - - name: Configure git - run: | - git config user.name kevaundray - git config user.email kevtheappdev@gmail.com - name: Create new Foundry project run: forge init --no-git --no-commit --force foundry-project From 6a8c31e34a66ebfb8e30ca48246b65690d2d97d6 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:23:48 +0100 Subject: [PATCH 080/108] Update .github/workflows/test-integration.yml --- .github/workflows/test-integration.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 205609c8d12..1e416dd8634 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -274,13 +274,13 @@ jobs: - name: Run `integration-tests` run: yarn test:integration - # - name: Alert on nightly test failure - # uses: JasonEtco/create-an-issue@v2 - # if: ${{ failure() && github.event_name == 'schedule' }} - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # WORKFLOW_NAME: ${{ github.workflow }} - # WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - # with: - # update_existing: true - # filename: .github/NIGHTLY_TEST_FAILURE.md + - name: Alert on nightly test failure + uses: JasonEtco/create-an-issue@v2 + if: ${{ failure() && github.event_name == 'schedule' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WORKFLOW_NAME: ${{ github.workflow }} + WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + update_existing: true + filename: .github/NIGHTLY_TEST_FAILURE.md From 7b037a486bb6c518b43665ea46843a3917a5582f Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:24:12 +0100 Subject: [PATCH 081/108] Update .github/workflows/test-integration.yml --- .github/workflows/test-integration.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 1e416dd8634..fe98318f707 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -278,9 +278,9 @@ jobs: uses: JasonEtco/create-an-issue@v2 if: ${{ failure() && github.event_name == 'schedule' }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - WORKFLOW_NAME: ${{ github.workflow }} - WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - with: - update_existing: true - filename: .github/NIGHTLY_TEST_FAILURE.md + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WORKFLOW_NAME: ${{ github.workflow }} + WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + update_existing: true + filename: .github/NIGHTLY_TEST_FAILURE.md From 386b1386cad5f4d3d0dfa7274d52dce9ae8e6edc Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:24:56 +0100 Subject: [PATCH 082/108] Update .github/workflows/test-integration.yml --- .github/workflows/test-integration.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index fe98318f707..967df8cccef 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -272,7 +272,8 @@ jobs: yarn workspace @noir-lang/noir_js build - name: Run `integration-tests` - run: yarn test:integration + run: | + yarn test:integration - name: Alert on nightly test failure uses: JasonEtco/create-an-issue@v2 From 44d5c6824ac2a10ec286affb25cb993e1102bf46 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:25:42 +0100 Subject: [PATCH 083/108] Update .github/workflows/test-integration.yml --- .github/workflows/test-integration.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 967df8cccef..d07bb9fe6ff 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -205,7 +205,6 @@ jobs: path: ./tooling/noirc_abi_wasm - name: Set nargo on PATH - working-directory: ./compiler/wasm/noir-script run: | nargo_binary="${{ github.workspace }}/nargo/nargo" chmod +x $nargo_binary From 24bdc761a370cc94c920e1418ef23fe8c18751ed Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 13:50:08 -0400 Subject: [PATCH 084/108] Clean up workflow --- .github/workflows/test-integration.yml | 32 +++++++++++++++----------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index d07bb9fe6ff..c91a83fa157 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -4,18 +4,15 @@ on: push: branches: - jb-test-solidity-verifier - -# on: -# workflow_dispatch: -# pull_request: -# paths: -# - ./compiler/integration-tests/** -# schedule: -# - cron: "0 2 * * *" # Run nightly at 2 AM UTC + # workflow_dispatch: + # pull_request: + # paths: + # - ./compiler/integration-tests/** + # schedule: + # - cron: "0 2 * * *" # Run nightly at 2 AM UTC jobs: build-nargo: - runs-on: ubuntu-latest strategy: matrix: @@ -62,9 +59,14 @@ jobs: - name: Setup Nix uses: cachix/install-nix-action@v22 with: - nix_path: nixpkgs=channel:nixos-22.11 + nix_path: nixpkgs=channel:nixos-23.05 github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: cachix/cachix-action@v12 + with: + name: barretenberg + authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + - name: Restore nix store cache uses: actions/cache/restore@v3 id: cache @@ -118,11 +120,16 @@ jobs: uses: actions/checkout@v3 - name: Setup Nix - uses: cachix/install-nix-action@v20 + uses: cachix/install-nix-action@v22 with: nix_path: nixpkgs=channel:nixos-23.05 github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: cachix/cachix-action@v12 + with: + name: barretenberg + authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + - name: Restore nix store cache uses: actions/cache/restore@v3 id: cache @@ -177,8 +184,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - ref: ${{ inputs.tag || env.GITHUB_REF }} - name: Checkout acvm sources uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution @@ -225,7 +230,6 @@ jobs: anvil > /dev/null 2>&1 & sleep 10 - - name: Create new Foundry project run: forge init --no-git --no-commit --force foundry-project From dd59f714577699ba2fce65a10e2e322abfc088ba Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 14:15:40 -0400 Subject: [PATCH 085/108] Set up addresses in external file --- .github/workflows/test-integration.yml | 6 +++--- compiler/integration-tests/test/environment.js | 2 ++ .../test/integration/browser/compile_prove_verify.test.ts | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 641cf0e9e9c..a9e4108f8fb 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -247,10 +247,10 @@ jobs: echo "DV_CONTRACT_ADDRESS=$address" >> $GITHUB_ENV - name: Replace addresses in the file - working-directory: compiler/integration-tests/test/integration/browser + working-directory: compiler/integration-tests/test run: | - sed -i 's|address: "MUL_CONTRACT_ADDRESS"|address: "'"$MUL_CONTRACT_ADDRESS"'"|g' compile_prove_verify.test.ts - sed -i 's|address: "DV_CONTRACT_ADDRESS"|address: "'"$DV_CONTRACT_ADDRESS"'"|g' compile_prove_verify.test.ts + sed -i 's|MUL_CONTRACT_ADDRESS = ""|MUL_CONTRACT_ADDRESS = "'"$MUL_CONTRACT_ADDRESS"'"|g' environment.js + sed -i 's|DV_CONTRACT_ADDRESS = ""|DV_CONTRACT_ADDRESS = "'"$DV_CONTRACT_ADDRESS"'"|g' environment.js - name: Setup `integration-tests` run: | diff --git a/compiler/integration-tests/test/environment.js b/compiler/integration-tests/test/environment.js index 6b5f522aff6..aa0f7a82c66 100644 --- a/compiler/integration-tests/test/environment.js +++ b/compiler/integration-tests/test/environment.js @@ -1 +1,3 @@ export const TEST_LOG_LEVEL = 5; // 0: silly, 1: trace, 2: debug, 3: info, 4: warn, 5: error, 6: fatal +export const MUL_CONTRACT_ADDRESS = ""; +export const DV_CONTRACT_ADDRESS = ""; diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 7028ab36248..8a77d331ef0 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -1,5 +1,5 @@ import { expect } from "@esm-bundle/chai"; -import { TEST_LOG_LEVEL } from "../../environment.js"; +import { TEST_LOG_LEVEL, MUL_CONTRACT_ADDRESS } from "../../environment.js"; import { Logger } from "tslog"; import { initializeResolver } from "@noir-lang/source-resolver"; import newCompiler, { @@ -43,13 +43,13 @@ const test_cases = [ { case: "tooling/nargo_cli/tests/execution_success/1_mul", compiled: "foundry-project/out/1_mul.sol/UltraVerifier.json", - address: "MUL_CONTRACT_ADDRESS", + address: MUL_CONTRACT_ADDRESS, publicInputsLength: 0, }, // { // case: "tooling/nargo_cli/tests/execution_success/double_verify_proof", // compiled: "foundry-project/out/double_verify.sol/UltraVerifier.json", - // address: "DV_CONTRACT_ADDRESS", + // address: DV_CONTRACT_ADDRESS, // publicInputsLength: 16 * 32, // }, ]; From f68967784d76dbd420dd3ff1c18909abcaf45309 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 14:48:51 -0400 Subject: [PATCH 086/108] Log out address --- .../test/integration/browser/compile_prove_verify.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 8a77d331ef0..6ed2bf9b637 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -39,6 +39,8 @@ async function getFile(url: URL): Promise { const CIRCUIT_SIZE = 2 ** 19; +console.log({ MUL_CONTRACT_ADDRESS }) + const test_cases = [ { case: "tooling/nargo_cli/tests/execution_success/1_mul", From 4a6a82a6d1896e173e29925c1ed48b24731a980d Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 14:53:26 -0400 Subject: [PATCH 087/108] Lint test --- .../test/integration/browser/compile_prove_verify.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 6ed2bf9b637..68366b7e00a 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -39,7 +39,7 @@ async function getFile(url: URL): Promise { const CIRCUIT_SIZE = 2 ** 19; -console.log({ MUL_CONTRACT_ADDRESS }) +console.log({ MUL_CONTRACT_ADDRESS }); const test_cases = [ { From bbcf3910416c7b68c7c91cbacb832a9f3eb9d95e Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 15:07:18 -0400 Subject: [PATCH 088/108] Remove log --- .../test/integration/browser/compile_prove_verify.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 68366b7e00a..8a77d331ef0 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -39,8 +39,6 @@ async function getFile(url: URL): Promise { const CIRCUIT_SIZE = 2 ** 19; -console.log({ MUL_CONTRACT_ADDRESS }); - const test_cases = [ { case: "tooling/nargo_cli/tests/execution_success/1_mul", From 1c8e3db4b33ac381dd7c21473a269b4147c1a8e5 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 15:07:56 -0400 Subject: [PATCH 089/108] Update .github/workflows/test-integration.yml Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com> --- .github/workflows/test-integration.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index a9e4108f8fb..11f07aaa737 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -168,11 +168,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Checkout acvm sources - uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution - with: - repository: noir-lang/acvm - path: acvm - name: Download nargo binary uses: actions/download-artifact@v3 From f9fa8396cd901b7d010824d428b5a1c5ecdb8063 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 15:31:02 -0400 Subject: [PATCH 090/108] Replace dv with main circuit --- .github/workflows/test-integration.yml | 12 ++++++------ compiler/integration-tests/test/environment.js | 2 +- .../browser/compile_prove_verify.test.ts | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index a9e4108f8fb..23241fd7238 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -220,14 +220,14 @@ jobs: working-directory: tooling/nargo_cli/tests/execution_success/1_mul run: nargo codegen-verifier - - name: Run codegen-verifier for double_verify_proof - working-directory: tooling/nargo_cli/tests/execution_success/double_verify_proof + - name: Run codegen-verifier for main + working-directory: compiler/integration-tests/test/circuits/main run: nargo codegen-verifier - name: Copy compiled contracts run: | cp tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol foundry-project/src/1_mul.sol - cp tooling/nargo_cli/tests/execution_success/double_verify_proof/contract/double_verify_proof/plonk_vk.sol foundry-project/src/double_verify_proof.sol + cp compiler/integration-tests/test/circuits/main/contract/main/plonk_vk.sol foundry-project/src/main.sol - name: Forge build working-directory: foundry-project @@ -241,16 +241,16 @@ jobs: address=$(echo "$mul_result" | grep "Deployed to:" | awk '{print $3}') echo "MUL_CONTRACT_ADDRESS=$address" >> $GITHUB_ENV - dv_result=$(forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/double_verify_proof.sol:UltraVerifier) + dv_result=$(forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/main.sol:UltraVerifier) echo "$dv_result" address=$(echo "$dv_result" | grep "Deployed to:" | awk '{print $3}') - echo "DV_CONTRACT_ADDRESS=$address" >> $GITHUB_ENV + echo "MAIN_ADDRESS=$address" >> $GITHUB_ENV - name: Replace addresses in the file working-directory: compiler/integration-tests/test run: | sed -i 's|MUL_CONTRACT_ADDRESS = ""|MUL_CONTRACT_ADDRESS = "'"$MUL_CONTRACT_ADDRESS"'"|g' environment.js - sed -i 's|DV_CONTRACT_ADDRESS = ""|DV_CONTRACT_ADDRESS = "'"$DV_CONTRACT_ADDRESS"'"|g' environment.js + sed -i 's|MAIN_ADDRESS = ""|MAIN_ADDRESS = "'"$MAIN_ADDRESS"'"|g' environment.js - name: Setup `integration-tests` run: | diff --git a/compiler/integration-tests/test/environment.js b/compiler/integration-tests/test/environment.js index aa0f7a82c66..5d0084fe55b 100644 --- a/compiler/integration-tests/test/environment.js +++ b/compiler/integration-tests/test/environment.js @@ -1,3 +1,3 @@ export const TEST_LOG_LEVEL = 5; // 0: silly, 1: trace, 2: debug, 3: info, 4: warn, 5: error, 6: fatal export const MUL_CONTRACT_ADDRESS = ""; -export const DV_CONTRACT_ADDRESS = ""; +export const MAIN_ADDRESS = ""; diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 8a77d331ef0..feb16610b37 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -1,5 +1,5 @@ import { expect } from "@esm-bundle/chai"; -import { TEST_LOG_LEVEL, MUL_CONTRACT_ADDRESS } from "../../environment.js"; +import { TEST_LOG_LEVEL, MUL_CONTRACT_ADDRESS, MAIN_ADDRESS } from "../../environment.js"; import { Logger } from "tslog"; import { initializeResolver } from "@noir-lang/source-resolver"; import newCompiler, { @@ -46,12 +46,12 @@ const test_cases = [ address: MUL_CONTRACT_ADDRESS, publicInputsLength: 0, }, - // { - // case: "tooling/nargo_cli/tests/execution_success/double_verify_proof", - // compiled: "foundry-project/out/double_verify.sol/UltraVerifier.json", - // address: DV_CONTRACT_ADDRESS, - // publicInputsLength: 16 * 32, - // }, + { + case: "compiler/integration-tests/test/circuits/main", + compiled: "foundry-project/out/main.sol/UltraVerifier.json", + address: MAIN_ADDRESS, + publicInputsLength: 16 * 32, + }, ]; const numberOfThreads = navigator.hardwareConcurrency || 1; From d01f8b09e0cbd9f22de44741bcee729aa61c32e6 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 15:42:41 -0400 Subject: [PATCH 091/108] Lint test --- .../test/integration/browser/compile_prove_verify.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index feb16610b37..fa1cf8f7058 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -1,5 +1,9 @@ import { expect } from "@esm-bundle/chai"; -import { TEST_LOG_LEVEL, MUL_CONTRACT_ADDRESS, MAIN_ADDRESS } from "../../environment.js"; +import { + TEST_LOG_LEVEL, + MUL_CONTRACT_ADDRESS, + MAIN_ADDRESS, +} from "../../environment.js"; import { Logger } from "tslog"; import { initializeResolver } from "@noir-lang/source-resolver"; import newCompiler, { From 35e308446c08e294e689a35f6b9985fab0beaac6 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 16:05:48 -0400 Subject: [PATCH 092/108] Use json output for addresses --- .github/workflows/test-integration.yml | 18 ++---------------- compiler/integration-tests/test/environment.js | 2 -- .../browser/compile_prove_verify.test.ts | 16 ++++++++++------ 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index e39853800a3..aeae33f88f5 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -168,7 +168,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Download nargo binary uses: actions/download-artifact@v3 with: @@ -231,21 +230,8 @@ jobs: - name: Forge deploy working-directory: foundry-project run: | - mul_result=$(forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/1_mul.sol:UltraVerifier) - echo "$mul_result" - address=$(echo "$mul_result" | grep "Deployed to:" | awk '{print $3}') - echo "MUL_CONTRACT_ADDRESS=$address" >> $GITHUB_ENV - - dv_result=$(forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/main.sol:UltraVerifier) - echo "$dv_result" - address=$(echo "$dv_result" | grep "Deployed to:" | awk '{print $3}') - echo "MAIN_ADDRESS=$address" >> $GITHUB_ENV - - - name: Replace addresses in the file - working-directory: compiler/integration-tests/test - run: | - sed -i 's|MUL_CONTRACT_ADDRESS = ""|MUL_CONTRACT_ADDRESS = "'"$MUL_CONTRACT_ADDRESS"'"|g' environment.js - sed -i 's|MAIN_ADDRESS = ""|MAIN_ADDRESS = "'"$MAIN_ADDRESS"'"|g' environment.js + forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/1_mul.sol:UltraVerifier --json > mul_output.json + forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/main.sol:UltraVerifier --json > main_output.json - name: Setup `integration-tests` run: | diff --git a/compiler/integration-tests/test/environment.js b/compiler/integration-tests/test/environment.js index 5d0084fe55b..6b5f522aff6 100644 --- a/compiler/integration-tests/test/environment.js +++ b/compiler/integration-tests/test/environment.js @@ -1,3 +1 @@ export const TEST_LOG_LEVEL = 5; // 0: silly, 1: trace, 2: debug, 3: info, 4: warn, 5: error, 6: fatal -export const MUL_CONTRACT_ADDRESS = ""; -export const MAIN_ADDRESS = ""; diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index fa1cf8f7058..ac04e415627 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -1,8 +1,6 @@ import { expect } from "@esm-bundle/chai"; import { - TEST_LOG_LEVEL, - MUL_CONTRACT_ADDRESS, - MAIN_ADDRESS, + TEST_LOG_LEVEL } from "../../environment.js"; import { Logger } from "tslog"; import { initializeResolver } from "@noir-lang/source-resolver"; @@ -47,13 +45,13 @@ const test_cases = [ { case: "tooling/nargo_cli/tests/execution_success/1_mul", compiled: "foundry-project/out/1_mul.sol/UltraVerifier.json", - address: MUL_CONTRACT_ADDRESS, + deployInformation: "foundry-project/mul_output.json", publicInputsLength: 0, }, { case: "compiler/integration-tests/test/circuits/main", compiled: "foundry-project/out/main.sol/UltraVerifier.json", - address: MAIN_ADDRESS, + deployInformation: "foundry-project/main_output.json", publicInputsLength: 16 * 32, }, ]; @@ -87,14 +85,20 @@ test_cases.forEach((testInfo) => { `${base_relative_path}/${testInfo.compiled}`, import.meta.url, ); + const deploy_information_url = new URL( + `${base_relative_path}/${testInfo.compiled}`, + import.meta.url, + ); const noir_source = await getFile(noir_source_url); const prover_toml = await getFile(prover_toml_url); const compiled_contract = await getFile(compiled_contract_url); + const deploy_information = await getFile(deploy_information_url); const { abi } = JSON.parse(compiled_contract); + const { deployedTo } = JSON.parse(deploy_information); - const contract = new ethers.Contract(testInfo.address, abi, wallet); + const contract = new ethers.Contract(deployedTo, abi, wallet); expect(noir_source).to.be.a.string; From 77b4fcedd3a968e99a776172017bb1c64cd38dd4 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 16:09:54 -0400 Subject: [PATCH 093/108] Lint fix --- .../test/integration/browser/compile_prove_verify.test.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index ac04e415627..a07fb58fd1b 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -1,7 +1,5 @@ import { expect } from "@esm-bundle/chai"; -import { - TEST_LOG_LEVEL -} from "../../environment.js"; +import { TEST_LOG_LEVEL } from "../../environment.js"; import { Logger } from "tslog"; import { initializeResolver } from "@noir-lang/source-resolver"; import newCompiler, { From ff928916da1d027109b9bd2d817cc9a1249e4910 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 16:13:54 -0400 Subject: [PATCH 094/108] Fix public inputs length --- .../test/integration/browser/compile_prove_verify.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index a07fb58fd1b..e7ca6e8c32e 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -50,7 +50,7 @@ const test_cases = [ case: "compiler/integration-tests/test/circuits/main", compiled: "foundry-project/out/main.sol/UltraVerifier.json", deployInformation: "foundry-project/main_output.json", - publicInputsLength: 16 * 32, + publicInputsLength: 32, }, ]; From c4827fc880d3d295b50c08368e3e421ea2a6ad2d Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 16:31:17 -0400 Subject: [PATCH 095/108] Output debug values --- .../test/integration/browser/compile_prove_verify.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index e7ca6e8c32e..147e54aac3a 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -95,6 +95,7 @@ test_cases.forEach((testInfo) => { const { abi } = JSON.parse(compiled_contract); const { deployedTo } = JSON.parse(deploy_information); + console.log({ deployedTo, deploy_information }) const contract = new ethers.Contract(deployedTo, abi, wallet); From 5fc1dc14937c0739f477850d7ece83348a924a04 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 16:46:19 -0400 Subject: [PATCH 096/108] Fix path --- .../test/integration/browser/compile_prove_verify.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 147e54aac3a..9903157ca5f 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -84,7 +84,7 @@ test_cases.forEach((testInfo) => { import.meta.url, ); const deploy_information_url = new URL( - `${base_relative_path}/${testInfo.compiled}`, + `${base_relative_path}/${testInfo.deployInformation}`, import.meta.url, ); @@ -95,7 +95,6 @@ test_cases.forEach((testInfo) => { const { abi } = JSON.parse(compiled_contract); const { deployedTo } = JSON.parse(deploy_information); - console.log({ deployedTo, deploy_information }) const contract = new ethers.Contract(deployedTo, abi, wallet); From 72ace483b7a1f5c7a0add200636eb9ddf968bfa8 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 16:58:56 -0400 Subject: [PATCH 097/108] Disable second test --- .../integration/browser/compile_prove_verify.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 9903157ca5f..0149274330c 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -46,12 +46,12 @@ const test_cases = [ deployInformation: "foundry-project/mul_output.json", publicInputsLength: 0, }, - { - case: "compiler/integration-tests/test/circuits/main", - compiled: "foundry-project/out/main.sol/UltraVerifier.json", - deployInformation: "foundry-project/main_output.json", - publicInputsLength: 32, - }, + // { + // case: "compiler/integration-tests/test/circuits/main", + // compiled: "foundry-project/out/main.sol/UltraVerifier.json", + // deployInformation: "foundry-project/main_output.json", + // publicInputsLength: 32, + // }, ]; const numberOfThreads = navigator.hardwareConcurrency || 1; From fe3eb79c5278bbb0f9e95967d82ab45898911c8b Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 17:00:41 -0400 Subject: [PATCH 098/108] Set up workflow running condition --- .github/workflows/test-integration.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index aeae33f88f5..711fff8885d 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -1,15 +1,12 @@ name: test-integration on: - push: - branches: - - jb-test-solidity-verifier - # workflow_dispatch: - # pull_request: - # paths: - # - ./compiler/integration-tests/** - # schedule: - # - cron: "0 2 * * *" # Run nightly at 2 AM UTC + workflow_dispatch: + pull_request: + paths: + - ./compiler/integration-tests/** + schedule: + - cron: "0 2 * * *" # Run nightly at 2 AM UTC jobs: build-nargo: From 33857ca4b4972714421157e673745bd00e02e28d Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 17:05:20 -0400 Subject: [PATCH 099/108] Readd second test --- .github/workflows/test-integration.yml | 15 +++++++++------ .../browser/compile_prove_verify.test.ts | 14 +++++++------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 711fff8885d..aeae33f88f5 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -1,12 +1,15 @@ name: test-integration on: - workflow_dispatch: - pull_request: - paths: - - ./compiler/integration-tests/** - schedule: - - cron: "0 2 * * *" # Run nightly at 2 AM UTC + push: + branches: + - jb-test-solidity-verifier + # workflow_dispatch: + # pull_request: + # paths: + # - ./compiler/integration-tests/** + # schedule: + # - cron: "0 2 * * *" # Run nightly at 2 AM UTC jobs: build-nargo: diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 0149274330c..c1a75fa438d 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -46,12 +46,12 @@ const test_cases = [ deployInformation: "foundry-project/mul_output.json", publicInputsLength: 0, }, - // { - // case: "compiler/integration-tests/test/circuits/main", - // compiled: "foundry-project/out/main.sol/UltraVerifier.json", - // deployInformation: "foundry-project/main_output.json", - // publicInputsLength: 32, - // }, + { + case: "compiler/integration-tests/test/circuits/main", + compiled: "foundry-project/out/main.sol/UltraVerifier.json", + deployInformation: "foundry-project/main_output.json", + publicInputsLength: 32, + }, ]; const numberOfThreads = navigator.hardwareConcurrency || 1; @@ -191,7 +191,7 @@ test_cases.forEach((testInfo) => { } else { const publicInputs = proof.slice(0, testInfo.publicInputsLength); const slicedProof = proof.slice(testInfo.publicInputsLength); - result = await contract.verify(slicedProof, publicInputs); + result = await contract.verify(slicedProof, [publicInputs]); } expect(result).to.be.true; From 6199f432fdf3c92a52f9bc166e08b454f9460df7 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 17:18:04 -0400 Subject: [PATCH 100/108] Console log result --- .../test/integration/browser/compile_prove_verify.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index c1a75fa438d..15aaa0dfed8 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -194,6 +194,8 @@ test_cases.forEach((testInfo) => { result = await contract.verify(slicedProof, [publicInputs]); } + console.log({ ...testInfo, result }) + expect(result).to.be.true; } catch (error) { console.error("Error while submitting the proof:", error); From 5c8f97ba38d0fd78df4cdb7c7f66f66a4beb3c32 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 25 Sep 2023 17:35:01 -0400 Subject: [PATCH 101/108] Changes for merging --- .github/workflows/test-integration.yml | 15 ++++++--------- .../browser/compile_prove_verify.test.ts | 2 -- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index aeae33f88f5..711fff8885d 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -1,15 +1,12 @@ name: test-integration on: - push: - branches: - - jb-test-solidity-verifier - # workflow_dispatch: - # pull_request: - # paths: - # - ./compiler/integration-tests/** - # schedule: - # - cron: "0 2 * * *" # Run nightly at 2 AM UTC + workflow_dispatch: + pull_request: + paths: + - ./compiler/integration-tests/** + schedule: + - cron: "0 2 * * *" # Run nightly at 2 AM UTC jobs: build-nargo: diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 15aaa0dfed8..c1a75fa438d 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -194,8 +194,6 @@ test_cases.forEach((testInfo) => { result = await contract.verify(slicedProof, [publicInputs]); } - console.log({ ...testInfo, result }) - expect(result).to.be.true; } catch (error) { console.error("Error while submitting the proof:", error); From b7ac6f7a180fc2d074329a75333eb21d09b42944 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 26 Sep 2023 11:28:41 -0400 Subject: [PATCH 102/108] Change [Uint8Array] to Uint8Array[] --- .github/workflows/test-integration.yml | 15 +++++++++------ .../browser/compile_prove_verify.test.ts | 6 ++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 711fff8885d..aeae33f88f5 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -1,12 +1,15 @@ name: test-integration on: - workflow_dispatch: - pull_request: - paths: - - ./compiler/integration-tests/** - schedule: - - cron: "0 2 * * *" # Run nightly at 2 AM UTC + push: + branches: + - jb-test-solidity-verifier + # workflow_dispatch: + # pull_request: + # paths: + # - ./compiler/integration-tests/** + # schedule: + # - cron: "0 2 * * *" # Run nightly at 2 AM UTC jobs: build-nargo: diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index c1a75fa438d..4d7e75752c2 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -189,9 +189,11 @@ test_cases.forEach((testInfo) => { if (testInfo.publicInputsLength === 0) { result = await contract.verify(proof, []); } else { - const publicInputs = proof.slice(0, testInfo.publicInputsLength); + const publicInputs = Array.from({ length: testInfo.publicInputsLength }, (_, i) => + proof.slice(i, i + 1) + ); const slicedProof = proof.slice(testInfo.publicInputsLength); - result = await contract.verify(slicedProof, [publicInputs]); + result = await contract.verify(slicedProof, publicInputs); } expect(result).to.be.true; From f1d36028fbcb72bd504c75eb9c498369891d5bdd Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 26 Sep 2023 12:30:34 -0400 Subject: [PATCH 103/108] Modify publicsInput length --- .../test/integration/browser/compile_prove_verify.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 4d7e75752c2..1024dc6bbb9 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -189,7 +189,7 @@ test_cases.forEach((testInfo) => { if (testInfo.publicInputsLength === 0) { result = await contract.verify(proof, []); } else { - const publicInputs = Array.from({ length: testInfo.publicInputsLength }, (_, i) => + const publicInputs = Array.from({ length: testInfo.publicInputsLength / 32 }, (_, i) => proof.slice(i, i + 1) ); const slicedProof = proof.slice(testInfo.publicInputsLength); From 61f3f14f5d5c47e08e6ebe1c4ccd2c528343a2df Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Tue, 26 Sep 2023 17:50:21 +0100 Subject: [PATCH 104/108] Update compile_prove_verify.test.ts --- .../browser/compile_prove_verify.test.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 1024dc6bbb9..8fe1de35bb5 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -38,6 +38,7 @@ async function getFile(url: URL): Promise { } const CIRCUIT_SIZE = 2 ** 19; +const FIELD_ELEMENT_BYTES = 32; const test_cases = [ { @@ -50,7 +51,7 @@ const test_cases = [ case: "compiler/integration-tests/test/circuits/main", compiled: "foundry-project/out/main.sol/UltraVerifier.json", deployInformation: "foundry-project/main_output.json", - publicInputsLength: 32, + numPublicInputs: 1, }, ]; @@ -186,13 +187,14 @@ test_cases.forEach((testInfo) => { try { let result; - if (testInfo.publicInputsLength === 0) { + if (testInfo.numPublicInputs === 0) { result = await contract.verify(proof, []); } else { - const publicInputs = Array.from({ length: testInfo.publicInputsLength / 32 }, (_, i) => - proof.slice(i, i + 1) - ); - const slicedProof = proof.slice(testInfo.publicInputsLength); + const publicInputs = Array.from({ length: testInfo.numPublicInputs }, (_, i) => { + const offset = i * FIELD_ELEMENT_BYTES; + return proof.slice(offset, offset + FIELD_ELEMENT_BYTES) + }); + const slicedProof = proof.slice(testInfo.numPublicInputs * FIELD_ELEMENT_BYTES); result = await contract.verify(slicedProof, publicInputs); } From 5400eb728fe212feddf10c0c13950f7b147092ed Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Tue, 26 Sep 2023 17:53:01 +0100 Subject: [PATCH 105/108] Update compile_prove_verify.test.ts --- .../test/integration/browser/compile_prove_verify.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 8fe1de35bb5..ee60c80947c 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -45,7 +45,7 @@ const test_cases = [ case: "tooling/nargo_cli/tests/execution_success/1_mul", compiled: "foundry-project/out/1_mul.sol/UltraVerifier.json", deployInformation: "foundry-project/mul_output.json", - publicInputsLength: 0, + numPublicInputs: 0, }, { case: "compiler/integration-tests/test/circuits/main", From 5ac123b466271442d333d4b0ab282bd103dd3524 Mon Sep 17 00:00:00 2001 From: Tom French Date: Tue, 26 Sep 2023 18:08:05 +0100 Subject: [PATCH 106/108] chore: fix linter --- .../browser/compile_prove_verify.test.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index ee60c80947c..ea9f4db73a9 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -190,11 +190,16 @@ test_cases.forEach((testInfo) => { if (testInfo.numPublicInputs === 0) { result = await contract.verify(proof, []); } else { - const publicInputs = Array.from({ length: testInfo.numPublicInputs }, (_, i) => { - const offset = i * FIELD_ELEMENT_BYTES; - return proof.slice(offset, offset + FIELD_ELEMENT_BYTES) - }); - const slicedProof = proof.slice(testInfo.numPublicInputs * FIELD_ELEMENT_BYTES); + const publicInputs = Array.from( + { length: testInfo.numPublicInputs }, + (_, i) => { + const offset = i * FIELD_ELEMENT_BYTES; + return proof.slice(offset, offset + FIELD_ELEMENT_BYTES); + }, + ); + const slicedProof = proof.slice( + testInfo.numPublicInputs * FIELD_ELEMENT_BYTES, + ); result = await contract.verify(slicedProof, publicInputs); } From 7ff4b946d954310b3d45c0ed4570d1d9aa4e967b Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 26 Sep 2023 14:45:33 -0400 Subject: [PATCH 107/108] Set up schedule and dispatch --- .github/workflows/test-integration.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index ecfe00eb3e7..0c8eefed9d3 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -1,15 +1,12 @@ name: test-integration on: - push: - branches: - - jb-test-solidity-verifier - # workflow_dispatch: - # pull_request: - # paths: - # - ./compiler/integration-tests/** - # schedule: - # - cron: "0 2 * * *" # Run nightly at 2 AM UTC + workflow_dispatch: + pull_request: + paths: + - ./compiler/integration-tests/** + schedule: + - cron: "0 2 * * *" # Run nightly at 2 AM UTC jobs: build-nargo: From 10b6ed1d7026198875be884555b1bb6db4f2f3ec Mon Sep 17 00:00:00 2001 From: Tom French Date: Tue, 26 Sep 2023 21:09:12 +0100 Subject: [PATCH 108/108] chore: install JS dependencies on github runner --- .github/workflows/test-integration.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 0c8eefed9d3..09e54b288dc 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -194,6 +194,23 @@ jobs: - name: Install Yarn dependencies uses: ./.github/actions/setup + - name: Install jq + run: sudo apt-get install jq + + - name: Install wasm-bindgen-cli + uses: taiki-e/install-action@v2 + with: + tool: wasm-bindgen-cli@0.2.86 + + - name: Install toml2json + uses: taiki-e/install-action@v2 + with: + tool: toml2json@1.3.1 + + - name: Install wasm-opt + run: | + npm i wasm-opt -g + - name: Install Foundry uses: onbjerg/foundry-toolchain@v1 with: @@ -230,6 +247,7 @@ jobs: forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/1_mul.sol:UltraVerifier --json > mul_output.json forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/main.sol:UltraVerifier --json > main_output.json + - name: Setup `integration-tests` run: | yarn workspace @noir-lang/source-resolver build