From 3a4d932e01c0505a9d56c42f4bd6f3877a411d4c Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Fri, 29 Sep 2023 02:10:48 -0400 Subject: [PATCH 01/10] Add scripts for testing --- .github/workflows/test-integration.yml | 36 ++++--------------- .gitignore | 3 ++ .../integration-tests/codegen-verifiers.sh | 16 +++++++++ .../integration-tests/deploy-verifiers.sh | 13 +++++++ compiler/integration-tests/forge-init.sh | 9 +++++ compiler/integration-tests/setup-project.sh | 5 +++ 6 files changed, 52 insertions(+), 30 deletions(-) create mode 100644 compiler/integration-tests/codegen-verifiers.sh create mode 100644 compiler/integration-tests/deploy-verifiers.sh create mode 100644 compiler/integration-tests/forge-init.sh create mode 100644 compiler/integration-tests/setup-project.sh diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 00eb7d4b5bc..c3d0ba7f02e 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -1,6 +1,9 @@ name: test-integration on: + push: + branches: + - jb-integration-scripts workflow_dispatch: pull_request: paths: @@ -211,36 +214,9 @@ jobs: with: version: nightly - - name: Run Anvil - run: | - anvil > /dev/null 2>&1 & - sleep 10 - - - 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 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 compiler/integration-tests/test/circuits/main/contract/main/plonk_vk.sol foundry-project/src/main.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 --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 project + working-directory: compiler/integration-tests + run: bash setup-project.sh - name: Setup `integration-tests` run: | diff --git a/.gitignore b/.gitignore index 94e8f1a8db0..efc958fecd9 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,6 @@ compiler/wasm/web tooling/noirc_abi_wasm/nodejs tooling/noirc_abi_wasm/web tooling/noir_js/lib + +# Testing +foundry-project \ No newline at end of file diff --git a/compiler/integration-tests/codegen-verifiers.sh b/compiler/integration-tests/codegen-verifiers.sh new file mode 100644 index 00000000000..6fb1bd59eb0 --- /dev/null +++ b/compiler/integration-tests/codegen-verifiers.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +cd "$(dirname "$0")" + +# Run codegen-verifier for 1_mul +cd ../../tooling/nargo_cli/tests/execution_success/1_mul +nargo codegen-verifier + +# Run codegen-verifier for main +cd ../../../compiler/integration-tests/test/circuits/main +nargo codegen-verifier + +# Copy compiled contracts from the root of compiler/integration-tests +cd ../../.. +cp tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol foundry-project/src/1_mul.sol +cp compiler/integration-tests/test/circuits/main/contract/main/plonk_vk.sol foundry-project/src/main.sol diff --git a/compiler/integration-tests/deploy-verifiers.sh b/compiler/integration-tests/deploy-verifiers.sh new file mode 100644 index 00000000000..38e1028c2ba --- /dev/null +++ b/compiler/integration-tests/deploy-verifiers.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +cd "$(dirname "$0")" + +anvil > /dev/null 2>&1 & +sleep 10 + +cd foundry-project + +forge build + +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 diff --git a/compiler/integration-tests/forge-init.sh b/compiler/integration-tests/forge-init.sh new file mode 100644 index 00000000000..160ed794e87 --- /dev/null +++ b/compiler/integration-tests/forge-init.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +cd "$(dirname "$0")" + +# Create forge project +forge init --no-git --no-commit --force foundry-project + +# Remove default .sol files +rm -rf ./foundry-project/*/**.sol diff --git a/compiler/integration-tests/setup-project.sh b/compiler/integration-tests/setup-project.sh new file mode 100644 index 00000000000..5ed411a28be --- /dev/null +++ b/compiler/integration-tests/setup-project.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +bash forge-init.sh +bash codegen-verifiers.sh +bash deploy-verifiers.sh From d6b61af794a08df51657b64c2558c52a29b65732 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Fri, 29 Sep 2023 02:22:58 -0400 Subject: [PATCH 02/10] Fix paths --- compiler/integration-tests/codegen-verifiers.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/integration-tests/codegen-verifiers.sh b/compiler/integration-tests/codegen-verifiers.sh index 6fb1bd59eb0..d476c0b6eba 100644 --- a/compiler/integration-tests/codegen-verifiers.sh +++ b/compiler/integration-tests/codegen-verifiers.sh @@ -3,14 +3,13 @@ cd "$(dirname "$0")" # Run codegen-verifier for 1_mul -cd ../../tooling/nargo_cli/tests/execution_success/1_mul +cd tooling/nargo_cli/tests/execution_success/1_mul nargo codegen-verifier # Run codegen-verifier for main -cd ../../../compiler/integration-tests/test/circuits/main +cd compiler/integration-tests/test/circuits/main nargo codegen-verifier # Copy compiled contracts from the root of compiler/integration-tests -cd ../../.. cp tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol foundry-project/src/1_mul.sol cp compiler/integration-tests/test/circuits/main/contract/main/plonk_vk.sol foundry-project/src/main.sol From e99a7858ffcbd60527b9d5946915a3b9008393dc Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Fri, 29 Sep 2023 02:36:21 -0400 Subject: [PATCH 03/10] Add pwd --- compiler/integration-tests/codegen-verifiers.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/integration-tests/codegen-verifiers.sh b/compiler/integration-tests/codegen-verifiers.sh index d476c0b6eba..67f5010eaf8 100644 --- a/compiler/integration-tests/codegen-verifiers.sh +++ b/compiler/integration-tests/codegen-verifiers.sh @@ -2,6 +2,8 @@ cd "$(dirname "$0")" +pwd + # Run codegen-verifier for 1_mul cd tooling/nargo_cli/tests/execution_success/1_mul nargo codegen-verifier From 1907de95ed61c4443e26f73e567b13978c597cdc Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Fri, 29 Sep 2023 02:49:57 -0400 Subject: [PATCH 04/10] Replace cd .. --- compiler/integration-tests/codegen-verifiers.sh | 4 +--- compiler/integration-tests/deploy-verifiers.sh | 2 +- compiler/integration-tests/forge-init.sh | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/compiler/integration-tests/codegen-verifiers.sh b/compiler/integration-tests/codegen-verifiers.sh index 67f5010eaf8..b0d195084c7 100644 --- a/compiler/integration-tests/codegen-verifiers.sh +++ b/compiler/integration-tests/codegen-verifiers.sh @@ -1,8 +1,6 @@ #!/bin/bash -cd "$(dirname "$0")" - -pwd +cd ../.. # Run codegen-verifier for 1_mul cd tooling/nargo_cli/tests/execution_success/1_mul diff --git a/compiler/integration-tests/deploy-verifiers.sh b/compiler/integration-tests/deploy-verifiers.sh index 38e1028c2ba..5cc21db8239 100644 --- a/compiler/integration-tests/deploy-verifiers.sh +++ b/compiler/integration-tests/deploy-verifiers.sh @@ -1,6 +1,6 @@ #!/bin/bash -cd "$(dirname "$0")" +cd ../.. anvil > /dev/null 2>&1 & sleep 10 diff --git a/compiler/integration-tests/forge-init.sh b/compiler/integration-tests/forge-init.sh index 160ed794e87..fbfc12d57d5 100644 --- a/compiler/integration-tests/forge-init.sh +++ b/compiler/integration-tests/forge-init.sh @@ -1,6 +1,6 @@ #!/bin/bash -cd "$(dirname "$0")" +cd ../.. # Create forge project forge init --no-git --no-commit --force foundry-project From d19b4c2bb441043dc46036d407298838315ba385 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Fri, 29 Sep 2023 03:04:14 -0400 Subject: [PATCH 05/10] Fix cds --- compiler/integration-tests/codegen-verifiers.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/integration-tests/codegen-verifiers.sh b/compiler/integration-tests/codegen-verifiers.sh index b0d195084c7..5384547b1c3 100644 --- a/compiler/integration-tests/codegen-verifiers.sh +++ b/compiler/integration-tests/codegen-verifiers.sh @@ -5,10 +5,12 @@ cd ../.. # Run codegen-verifier for 1_mul cd tooling/nargo_cli/tests/execution_success/1_mul nargo codegen-verifier +cd ../../../../.. # Run codegen-verifier for main cd compiler/integration-tests/test/circuits/main nargo codegen-verifier +cd ../../../../.. # Copy compiled contracts from the root of compiler/integration-tests cp tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol foundry-project/src/1_mul.sol From f2ca58e945163ba9a3fb437355260db2ad9911e0 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Fri, 29 Sep 2023 03:26:18 -0400 Subject: [PATCH 06/10] Revert trigger --- .github/workflows/test-integration.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index c3d0ba7f02e..9b3977bcc87 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -1,9 +1,6 @@ name: test-integration on: - push: - branches: - - jb-integration-scripts workflow_dispatch: pull_request: paths: From 7503e87cede8aa49c6dffee172879c2070ae6a37 Mon Sep 17 00:00:00 2001 From: Tom French Date: Fri, 29 Sep 2023 11:45:14 +0100 Subject: [PATCH 07/10] chore: update scripts to be path independent --- .github/workflows/test-integration.yml | 2 +- .../integration-tests/codegen-verifiers.sh | 17 ----------------- compiler/integration-tests/forge-init.sh | 9 --------- .../scripts/codegen-verifiers.sh | 18 ++++++++++++++++++ .../{ => scripts}/deploy-verifiers.sh | 10 +++++----- .../integration-tests/scripts/forge-init.sh | 13 +++++++++++++ .../integration-tests/scripts/setup-project.sh | 7 +++++++ compiler/integration-tests/setup-project.sh | 5 ----- 8 files changed, 44 insertions(+), 37 deletions(-) delete mode 100644 compiler/integration-tests/codegen-verifiers.sh delete mode 100644 compiler/integration-tests/forge-init.sh create mode 100644 compiler/integration-tests/scripts/codegen-verifiers.sh rename compiler/integration-tests/{ => scripts}/deploy-verifiers.sh (75%) create mode 100644 compiler/integration-tests/scripts/forge-init.sh create mode 100644 compiler/integration-tests/scripts/setup-project.sh delete mode 100644 compiler/integration-tests/setup-project.sh diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 9b3977bcc87..00bda8b0bd2 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -213,7 +213,7 @@ jobs: - name: Setup project working-directory: compiler/integration-tests - run: bash setup-project.sh + run: bash ./scripts/setup-project.sh - name: Setup `integration-tests` run: | diff --git a/compiler/integration-tests/codegen-verifiers.sh b/compiler/integration-tests/codegen-verifiers.sh deleted file mode 100644 index 5384547b1c3..00000000000 --- a/compiler/integration-tests/codegen-verifiers.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -cd ../.. - -# Run codegen-verifier for 1_mul -cd tooling/nargo_cli/tests/execution_success/1_mul -nargo codegen-verifier -cd ../../../../.. - -# Run codegen-verifier for main -cd compiler/integration-tests/test/circuits/main -nargo codegen-verifier -cd ../../../../.. - -# Copy compiled contracts from the root of compiler/integration-tests -cp tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol foundry-project/src/1_mul.sol -cp compiler/integration-tests/test/circuits/main/contract/main/plonk_vk.sol foundry-project/src/main.sol diff --git a/compiler/integration-tests/forge-init.sh b/compiler/integration-tests/forge-init.sh deleted file mode 100644 index fbfc12d57d5..00000000000 --- a/compiler/integration-tests/forge-init.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -cd ../.. - -# Create forge project -forge init --no-git --no-commit --force foundry-project - -# Remove default .sol files -rm -rf ./foundry-project/*/**.sol diff --git a/compiler/integration-tests/scripts/codegen-verifiers.sh b/compiler/integration-tests/scripts/codegen-verifiers.sh new file mode 100644 index 00000000000..8fd3cb7eccc --- /dev/null +++ b/compiler/integration-tests/scripts/codegen-verifiers.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +self_path=$(dirname "$(readlink -f "$0")") + +repo_root=$self_path/../../.. + +# Run codegen-verifier for 1_mul +mul_dir=$repo_root/tooling/nargo_cli/tests/execution_success/1_mul +nargo --program-dir $mul_dir codegen-verifier + +# Run codegen-verifier for main +main_dir=$repo_root/compiler/integration-tests/test/circuits/main +nargo --program-dir $main_dir codegen-verifier + +# Copy compiled contracts from the root of compiler/integration-tests +src_dir=$self_path/../foundry-project/src +cp $mul_dir/contract/1_mul/plonk_vk.sol $src_dir/1_mul.sol +cp $main_dir/contract/main/plonk_vk.sol $src_dir/main.sol diff --git a/compiler/integration-tests/deploy-verifiers.sh b/compiler/integration-tests/scripts/deploy-verifiers.sh similarity index 75% rename from compiler/integration-tests/deploy-verifiers.sh rename to compiler/integration-tests/scripts/deploy-verifiers.sh index 5cc21db8239..0e93e92a80e 100644 --- a/compiler/integration-tests/deploy-verifiers.sh +++ b/compiler/integration-tests/scripts/deploy-verifiers.sh @@ -1,13 +1,13 @@ #!/bin/bash -cd ../.. +self_path=$(dirname "$(readlink -f "$0")") +cd $self_path/../foundry-project +forge build + +# TODO: bring anvil back to foreground when not in CI anvil > /dev/null 2>&1 & sleep 10 -cd foundry-project - -forge build - 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 diff --git a/compiler/integration-tests/scripts/forge-init.sh b/compiler/integration-tests/scripts/forge-init.sh new file mode 100644 index 00000000000..e2b86611e92 --- /dev/null +++ b/compiler/integration-tests/scripts/forge-init.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +self_path=$(dirname "$(readlink -f "$0")") + +project_path=$self_path/../foundry-project + +# Create forge project +forge init --no-git --no-commit --no-deps --force $project_path + +# Remove unwanted files +rm -rf $project_path/script +rm -rf $project_path/src/*.sol +rm -rf $project_path/test diff --git a/compiler/integration-tests/scripts/setup-project.sh b/compiler/integration-tests/scripts/setup-project.sh new file mode 100644 index 00000000000..202c53bce1e --- /dev/null +++ b/compiler/integration-tests/scripts/setup-project.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +self_path=$(dirname "$(readlink -f "$0")") + +bash $self_path/forge-init.sh +bash $self_path/codegen-verifiers.sh +bash $self_path/deploy-verifiers.sh diff --git a/compiler/integration-tests/setup-project.sh b/compiler/integration-tests/setup-project.sh deleted file mode 100644 index 5ed411a28be..00000000000 --- a/compiler/integration-tests/setup-project.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -bash forge-init.sh -bash codegen-verifiers.sh -bash deploy-verifiers.sh From 7f6737f91a46150a415bce5aae35ff576a6fc606 Mon Sep 17 00:00:00 2001 From: Tom French Date: Fri, 29 Sep 2023 11:46:13 +0100 Subject: [PATCH 08/10] chore: update gitignore --- .gitignore | 3 --- compiler/integration-tests/.gitignore | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) create mode 100644 compiler/integration-tests/.gitignore diff --git a/.gitignore b/.gitignore index efc958fecd9..94e8f1a8db0 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,3 @@ compiler/wasm/web tooling/noirc_abi_wasm/nodejs tooling/noirc_abi_wasm/web tooling/noir_js/lib - -# Testing -foundry-project \ No newline at end of file diff --git a/compiler/integration-tests/.gitignore b/compiler/integration-tests/.gitignore new file mode 100644 index 00000000000..3ae88ef1783 --- /dev/null +++ b/compiler/integration-tests/.gitignore @@ -0,0 +1 @@ +foundry-project From 6b8abbc1b86ee079b469d80531372a45c00bedfc Mon Sep 17 00:00:00 2001 From: Tom French Date: Fri, 29 Sep 2023 12:26:15 +0100 Subject: [PATCH 09/10] chore: handle anvil gracefully locally vs in CI --- .github/workflows/test-integration.yml | 3 +++ .../integration-tests/scripts/deploy-verifiers.sh | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 00bda8b0bd2..f990cef32fa 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -8,6 +8,9 @@ on: schedule: - cron: "0 2 * * *" # Run nightly at 2 AM UTC +env: + CI: true + jobs: build-nargo: runs-on: ubuntu-latest diff --git a/compiler/integration-tests/scripts/deploy-verifiers.sh b/compiler/integration-tests/scripts/deploy-verifiers.sh index 0e93e92a80e..b39d26f86aa 100644 --- a/compiler/integration-tests/scripts/deploy-verifiers.sh +++ b/compiler/integration-tests/scripts/deploy-verifiers.sh @@ -5,9 +5,19 @@ cd $self_path/../foundry-project forge build -# TODO: bring anvil back to foreground when not in CI -anvil > /dev/null 2>&1 & +CI=${CI:-false} +if [[ $CI = true ]]; then + anvil > /dev/null 2>&1 & +else + anvil & + pid=$! +fi + sleep 10 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 + +if [[ $CI = false ]]; then + wait $pid +fi From cf93bde7ad87faa31cc643eb562cf6d9af639b75 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 29 Sep 2023 12:26:43 +0100 Subject: [PATCH 10/10] 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 f990cef32fa..4de55ad3f79 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -214,7 +214,7 @@ jobs: with: version: nightly - - name: Setup project + - name: Deploy verifier contracts to Anvil working-directory: compiler/integration-tests run: bash ./scripts/setup-project.sh