From 65de5d7dfd17b87b76df7e36b9acd23c66fa2a05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro=20Sousa?= Date: Mon, 18 Dec 2023 11:33:46 +0000 Subject: [PATCH 1/6] feat: adding some CI to vite-hardhat --- .github/workflows/vite_hardhat.yaml | 39 +++++++++++++++++++++++++++ .github/workflows/with_foundry.yaml | 42 ++++++++++++++--------------- 2 files changed, 59 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/vite_hardhat.yaml diff --git a/.github/workflows/vite_hardhat.yaml b/.github/workflows/vite_hardhat.yaml new file mode 100644 index 0000000..701800b --- /dev/null +++ b/.github/workflows/vite_hardhat.yaml @@ -0,0 +1,39 @@ +name: PR - vite-hardhat +on: + push: +# pull_request: +# paths: +# - 'vite-hardhat/**' + +jobs: + test-vite-hardhat: + runs-on: ubuntu-latest + defaults: + run: + working-directory: vite-hardhat + + steps: + - uses: actions/checkout@v4 + + - name: Enable Corepack before setting up Node + run: corepack enable + + - uses: actions/setup-node@v4 + with: + node-version: 20.10.0 + cache: 'yarn' + + - name: Install + run: yarn --immutable + shell: bash + + - name: 'Create env file' + run: | + touch .env + echo SEPOLIA_ALCHEMY_KEY="${{ secrets.SEPOLIA_ALCHEMY_KEY }}" >> .env + echo SEPOLIA_DEPLOYER_PRIVATE_KEY="${{ secrets.SEPOLIA_DEPLOYER_PRIVATE_KEY }}" >> .env + echo MUMBAI_ALCHEMY_KEY"=${{ secrets.MUMBAI_ALCHEMY_KEY }}" >> .env + echo MUMBAI_DEPLOYER_PRIVATE_KEY="${{ secrets.MUMBAI_DEPLOYER_PRIVATE_KEY }}" >> .env + + - name: Run test + run: yarn test diff --git a/.github/workflows/with_foundry.yaml b/.github/workflows/with_foundry.yaml index 4667899..355c6af 100644 --- a/.github/workflows/with_foundry.yaml +++ b/.github/workflows/with_foundry.yaml @@ -1,39 +1,37 @@ -# a github workflow that runs curl -L https://foundry.paradigm.xyz | bash then nargo codegen-verifier then nargo prove p - -name: Run Tests on PR +name: PR - with-foundry on: pull_request: paths: - 'with-foundry/**' jobs: - test: + test-with-foundry: defaults: run: working-directory: with-foundry runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - - name: Install Nargo - uses: noir-lang/noirup@v0.1.2 - with: - toolchain: 0.11.0 + - name: Install Nargo + uses: noir-lang/noirup@v0.1.2 + with: + toolchain: 0.11.0 - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 - - name: Generate verifier contract - run: | - nargo codegen-verifier - working-directory: with-foundry/circuits + - name: Generate verifier contract + run: | + nargo codegen-verifier + working-directory: with-foundry/circuits - - name: Generate proof - run: | - nargo prove - working-directory: with-foundry/circuits + - name: Generate proof + run: | + nargo prove + working-directory: with-foundry/circuits - - name: Test with Foundry - run: | - forge test --optimize --optimizer-runs 5000 --evm-version london + - name: Test with Foundry + run: | + forge test --optimize --optimizer-runs 5000 --evm-version london From b018ca7a3778008a434c7363950f95ea6b35e120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro=20Sousa?= Date: Mon, 18 Dec 2023 17:18:42 +0000 Subject: [PATCH 2/6] Adding some drift testing --- .github/actions/setup/action.yml | 34 ++++++++++++++ .github/scripts/latest.js | 26 +++++++++++ .github/workflows/nightly.yaml | 71 +++++++++++++++++++++++++++++ .github/workflows/vite_hardhat.yaml | 7 ++- .gitignore | 3 ++ vite-hardhat/yarn.lock | 34 +++++++++----- 6 files changed, 160 insertions(+), 15 deletions(-) create mode 100644 .github/actions/setup/action.yml create mode 100644 .github/scripts/latest.js create mode 100644 .github/workflows/nightly.yaml diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..af53672 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,34 @@ +name: Install Yarn dependencies +description: Installs the workspace's yarn dependencies and caches them +inputs: + project: + description: The project to install dependencies for + required: true + version: + description: The version of the project to install dependencies for + required: true + +runs: + using: composite + steps: + - name: Enable Corepack before setting up Node + run: corepack enable + shell: bash + + - uses: actions/setup-node@v4 + with: + node-version-file: '${{ inputs.project }}/package.json' + cache: 'yarn' + + - name: Install + run: yarn --immutable + shell: bash + + - name: Install Nargo + uses: noir-lang/noirup@v0.1.2 + with: + toolchain: ${{ inputs.version }} + + - name: Use Nargo + run: nargo --version + shell: bash diff --git a/.github/scripts/latest.js b/.github/scripts/latest.js new file mode 100644 index 0000000..44feeda --- /dev/null +++ b/.github/scripts/latest.js @@ -0,0 +1,26 @@ +const { writeFileSync } = require('fs'); + +async function main() { + const fetchOpts = { + headers: {}, + }; + + if (process.env.GITHUB_TOKEN) + fetchOpts.headers = { Authorization: `token ${process.env.GITHUB_TOKEN}` }; + + const res = await fetch('https://api.github.com/repos/noir-lang/noir/releases', fetchOpts); + + const data = await res.json(); + + const filtered = data.filter( + release => !release.tag_name.includes('aztec') && !release.tag_name.includes('nightly'), + ); + + const latestStable = filtered.find(release => !release.prerelease).tag_name; + const latestPreRelease = filtered.find(release => release.prerelease).tag_name; + + const workflowOutput = JSON.stringify({ stable: latestStable, prerelease: latestPreRelease }); + console.log(workflowOutput); // DON'T REMOVE, GITHUB WILL CAPTURE THIS OUTPUT +} + +main(); diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml new file mode 100644 index 0000000..380245a --- /dev/null +++ b/.github/workflows/nightly.yaml @@ -0,0 +1,71 @@ +name: Nightly drift test + +on: + pull_request: + paths: + - 'vite-hardhat/**' + +jobs: + setup: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + + - name: Get versions to test for drift + id: versions_step + run: | + output=$(node ./.github/scripts/latestStable.js) + echo "Output from Node.js script: $output" + echo "::set-output name=versionArray::$output" + + - name: Set Up Matrix + id: set-matrix + run: | + VERSIONS='${{ steps.versions_step.outputs.versionArray }}' + echo "Versions for Matrix: $VERSIONS" + MATRIX=$(echo "$VERSIONS" | jq -c '{versions: .} | .versions | to_entries | map({key: .key, value: (.value | sub("^v"; ""))})') + echo "::set-output name=matrix::{\"include\":$MATRIX}" + + test-drift-vite-hardhat: + needs: setup + runs-on: ubuntu-latest + defaults: + run: + working-directory: vite-hardhat + strategy: + matrix: ${{fromJson(needs.setup.outputs.matrix)}} + steps: + - uses: actions/checkout@v4 + + - name: Set up test environment + uses: ./.github/actions/setup + with: + project: vite-hardhat + version: ${{ matrix.value }} + + - name: Install test version + run: | + yarn add \ + @noir-lang/noir_js@${{ matrix.value }} \ + @noir-lang/backend_barretenberg@${{ matrix.value }} \ + @noir-lang/noir_wasm@${{ matrix.value }} \ + @noir-lang/types@${{ matrix.value }} + + - name: 'Create env file' + run: | + touch .env + echo SEPOLIA_ALCHEMY_KEY="${{ secrets.SEPOLIA_ALCHEMY_KEY }}" >> .env + echo SEPOLIA_DEPLOYER_PRIVATE_KEY="${{ secrets.SEPOLIA_DEPLOYER_PRIVATE_KEY }}" >> .env + echo MUMBAI_ALCHEMY_KEY"=${{ secrets.MUMBAI_ALCHEMY_KEY }}" >> .env + echo MUMBAI_DEPLOYER_PRIVATE_KEY="${{ secrets.MUMBAI_DEPLOYER_PRIVATE_KEY }}" >> .env + + - name: Generate verifier contract + run: | + nargo codegen-verifier + working-directory: vite-hardhat/circuits + + - name: Run test + run: yarn test + continue-on-error: ${{ matrix.key == 'prerelease' }} diff --git a/.github/workflows/vite_hardhat.yaml b/.github/workflows/vite_hardhat.yaml index 701800b..5e2d19b 100644 --- a/.github/workflows/vite_hardhat.yaml +++ b/.github/workflows/vite_hardhat.yaml @@ -1,9 +1,8 @@ name: PR - vite-hardhat on: - push: -# pull_request: -# paths: -# - 'vite-hardhat/**' + pull_request: + paths: + - 'vite-hardhat/**' jobs: test-vite-hardhat: diff --git a/.gitignore b/.gitignore index 0028c9f..972f3b5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ node_modules package-lock.json + +# To use with nektos/act +.github/event.json diff --git a/vite-hardhat/yarn.lock b/vite-hardhat/yarn.lock index b07042a..a7c6ee7 100644 --- a/vite-hardhat/yarn.lock +++ b/vite-hardhat/yarn.lock @@ -756,10 +756,10 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@noir-lang/acvm_js@0.35.0": - version "0.35.0" - resolved "https://registry.yarnpkg.com/@noir-lang/acvm_js/-/acvm_js-0.35.0.tgz#81130d0236c259b2fb47b0d8efc577bbb5ee18f9" - integrity sha512-LiQUSF3P4/1VGfMZc0hSivLs4oiPsRt+ADFBMF7sOg4oaImeQ4L6tu0Og2Wh1Pc0k2y1EXdv1EKxN2N1WRDdKg== +"@noir-lang/acvm_js@0.37.1": + version "0.37.1" + resolved "https://registry.yarnpkg.com/@noir-lang/acvm_js/-/acvm_js-0.37.1.tgz#5cf3523a4a07e6c0cad95084afa633ce2e9d5600" + integrity sha512-VBAq2XoyTnxQyjJ6YNwnWMFZRZfPedJRm+tazDhzcilk85gzjet+yvDWB7VekjG3VY3q+WFo8zI9xbltoTTmPg== "@noir-lang/backend_barretenberg@^0.19.4": version "0.19.4" @@ -770,14 +770,14 @@ "@noir-lang/types" "0.19.4" fflate "^0.8.0" -"@noir-lang/noir_js@^0.19.4": - version "0.19.4" - resolved "https://registry.yarnpkg.com/@noir-lang/noir_js/-/noir_js-0.19.4.tgz#e71fc27e28a17cd03b21e498aaaf0f901b2bb75e" - integrity sha512-V/3jLoor3dMuYuv0ad154M0Ko1xZWxx0qoRDLC/Y/xMH5Wbe5yH4yOvBjCXzQ0dLG5JX1IWGOCC7xxzpStk+hA== +"@noir-lang/noir_js@^0.21.0": + version "0.21.0" + resolved "https://registry.yarnpkg.com/@noir-lang/noir_js/-/noir_js-0.21.0.tgz#df9ceaee68cb186c5cd816dc6176f6eb6ccf7db3" + integrity sha512-KqB5HAC64WGc1yddxAycbDUaUICp5F0foTLgtjQzJLLxRSxlQEa3uomtoLV0ocCFdF4MQd9S6tywgehHVTwvoQ== dependencies: - "@noir-lang/acvm_js" "0.35.0" - "@noir-lang/noirc_abi" "0.19.4" - "@noir-lang/types" "0.19.4" + "@noir-lang/acvm_js" "0.37.1" + "@noir-lang/noirc_abi" "0.21.0" + "@noir-lang/types" "0.21.0" "@noir-lang/noir_wasm@^0.19.4": version "0.19.4" @@ -789,6 +789,11 @@ resolved "https://registry.yarnpkg.com/@noir-lang/noirc_abi/-/noirc_abi-0.19.4.tgz#a51e76efabf70d49de92ca0a114ef5721ab857a4" integrity sha512-g3fa3rVGyvnqu1BQdXytCPzIFQDvK1kH9uMjNrEz5UG/LKl+EPvIl1Te8FcOsSi5/eVSbMWveyz3HJu+SwMjDQ== +"@noir-lang/noirc_abi@0.21.0": + version "0.21.0" + resolved "https://registry.yarnpkg.com/@noir-lang/noirc_abi/-/noirc_abi-0.21.0.tgz#00d9771e79855375dd00d0f978dc823fa3b9f35e" + integrity sha512-vVM1QRTFecZdCXminhgoW3sBsZJMsHOO+Sh8rG353r+n4GSgNR/oP3OQEOHlaJgq2wT9hCqcFU4gT954DfzawA== + "@noir-lang/source-resolver@^0.19.4": version "0.19.4" resolved "https://registry.yarnpkg.com/@noir-lang/source-resolver/-/source-resolver-0.19.4.tgz#cd1fb5909e783f45ccd8ee90fbd9bba406da0634" @@ -801,6 +806,13 @@ dependencies: "@noir-lang/noirc_abi" "0.19.4" +"@noir-lang/types@0.21.0": + version "0.21.0" + resolved "https://registry.yarnpkg.com/@noir-lang/types/-/types-0.21.0.tgz#c64d9b25c48522c4b5edadd657bcaddf6c872b21" + integrity sha512-v6CC04mvydBOGMVRCQd9Ytvz5Bjn0pGCE5ENDD+ROjs6+U5wShW5InFBQu5j9UixKybYUtuXk+5TMpuJ/yagog== + dependencies: + "@noir-lang/noirc_abi" "0.21.0" + "@nomicfoundation/ethereumjs-block@5.0.2": version "5.0.2" resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-block/-/ethereumjs-block-5.0.2.tgz#13a7968f5964f1697da941281b7f7943b0465d04" From 556514b9f5e1e6d911e436b19ded624fb3763895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro=20Sousa?= Date: Tue, 19 Dec 2023 16:49:51 +0000 Subject: [PATCH 3/6] fixes --- .github/scripts/latest.js | 3 ++- .github/workflows/nightly.yaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/scripts/latest.js b/.github/scripts/latest.js index 44feeda..3052b74 100644 --- a/.github/scripts/latest.js +++ b/.github/scripts/latest.js @@ -19,7 +19,8 @@ async function main() { const latestStable = filtered.find(release => !release.prerelease).tag_name; const latestPreRelease = filtered.find(release => release.prerelease).tag_name; - const workflowOutput = JSON.stringify({ stable: latestStable, prerelease: latestPreRelease }); + // TODO: add the prerelease to this object! + const workflowOutput = JSON.stringify({ stable: latestStable }); console.log(workflowOutput); // DON'T REMOVE, GITHUB WILL CAPTURE THIS OUTPUT } diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index 380245a..15e1206 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -16,7 +16,7 @@ jobs: - name: Get versions to test for drift id: versions_step run: | - output=$(node ./.github/scripts/latestStable.js) + output=$(node ./.github/scripts/latest.js) echo "Output from Node.js script: $output" echo "::set-output name=versionArray::$output" From 86218e09f49bb72395331833be4bde4c11f8b8b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro=20Sousa?= Date: Tue, 19 Dec 2023 17:02:46 +0000 Subject: [PATCH 4/6] fixes --- .github/workflows/nightly.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index 15e1206..560699d 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -26,7 +26,7 @@ jobs: VERSIONS='${{ steps.versions_step.outputs.versionArray }}' echo "Versions for Matrix: $VERSIONS" MATRIX=$(echo "$VERSIONS" | jq -c '{versions: .} | .versions | to_entries | map({key: .key, value: (.value | sub("^v"; ""))})') - echo "::set-output name=matrix::{\"include\":$MATRIX}" + echo "::set-output name=matrix::{\"include\":$MATRIX}" test-drift-vite-hardhat: needs: setup From c545fe9589b195e7dad6bb08d2f06a6de82532e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro=20Sousa?= Date: Tue, 19 Dec 2023 18:04:50 +0000 Subject: [PATCH 5/6] fixing yarn lock --- vite-hardhat/yarn.lock | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/vite-hardhat/yarn.lock b/vite-hardhat/yarn.lock index a7c6ee7..b07042a 100644 --- a/vite-hardhat/yarn.lock +++ b/vite-hardhat/yarn.lock @@ -756,10 +756,10 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@noir-lang/acvm_js@0.37.1": - version "0.37.1" - resolved "https://registry.yarnpkg.com/@noir-lang/acvm_js/-/acvm_js-0.37.1.tgz#5cf3523a4a07e6c0cad95084afa633ce2e9d5600" - integrity sha512-VBAq2XoyTnxQyjJ6YNwnWMFZRZfPedJRm+tazDhzcilk85gzjet+yvDWB7VekjG3VY3q+WFo8zI9xbltoTTmPg== +"@noir-lang/acvm_js@0.35.0": + version "0.35.0" + resolved "https://registry.yarnpkg.com/@noir-lang/acvm_js/-/acvm_js-0.35.0.tgz#81130d0236c259b2fb47b0d8efc577bbb5ee18f9" + integrity sha512-LiQUSF3P4/1VGfMZc0hSivLs4oiPsRt+ADFBMF7sOg4oaImeQ4L6tu0Og2Wh1Pc0k2y1EXdv1EKxN2N1WRDdKg== "@noir-lang/backend_barretenberg@^0.19.4": version "0.19.4" @@ -770,14 +770,14 @@ "@noir-lang/types" "0.19.4" fflate "^0.8.0" -"@noir-lang/noir_js@^0.21.0": - version "0.21.0" - resolved "https://registry.yarnpkg.com/@noir-lang/noir_js/-/noir_js-0.21.0.tgz#df9ceaee68cb186c5cd816dc6176f6eb6ccf7db3" - integrity sha512-KqB5HAC64WGc1yddxAycbDUaUICp5F0foTLgtjQzJLLxRSxlQEa3uomtoLV0ocCFdF4MQd9S6tywgehHVTwvoQ== +"@noir-lang/noir_js@^0.19.4": + version "0.19.4" + resolved "https://registry.yarnpkg.com/@noir-lang/noir_js/-/noir_js-0.19.4.tgz#e71fc27e28a17cd03b21e498aaaf0f901b2bb75e" + integrity sha512-V/3jLoor3dMuYuv0ad154M0Ko1xZWxx0qoRDLC/Y/xMH5Wbe5yH4yOvBjCXzQ0dLG5JX1IWGOCC7xxzpStk+hA== dependencies: - "@noir-lang/acvm_js" "0.37.1" - "@noir-lang/noirc_abi" "0.21.0" - "@noir-lang/types" "0.21.0" + "@noir-lang/acvm_js" "0.35.0" + "@noir-lang/noirc_abi" "0.19.4" + "@noir-lang/types" "0.19.4" "@noir-lang/noir_wasm@^0.19.4": version "0.19.4" @@ -789,11 +789,6 @@ resolved "https://registry.yarnpkg.com/@noir-lang/noirc_abi/-/noirc_abi-0.19.4.tgz#a51e76efabf70d49de92ca0a114ef5721ab857a4" integrity sha512-g3fa3rVGyvnqu1BQdXytCPzIFQDvK1kH9uMjNrEz5UG/LKl+EPvIl1Te8FcOsSi5/eVSbMWveyz3HJu+SwMjDQ== -"@noir-lang/noirc_abi@0.21.0": - version "0.21.0" - resolved "https://registry.yarnpkg.com/@noir-lang/noirc_abi/-/noirc_abi-0.21.0.tgz#00d9771e79855375dd00d0f978dc823fa3b9f35e" - integrity sha512-vVM1QRTFecZdCXminhgoW3sBsZJMsHOO+Sh8rG353r+n4GSgNR/oP3OQEOHlaJgq2wT9hCqcFU4gT954DfzawA== - "@noir-lang/source-resolver@^0.19.4": version "0.19.4" resolved "https://registry.yarnpkg.com/@noir-lang/source-resolver/-/source-resolver-0.19.4.tgz#cd1fb5909e783f45ccd8ee90fbd9bba406da0634" @@ -806,13 +801,6 @@ dependencies: "@noir-lang/noirc_abi" "0.19.4" -"@noir-lang/types@0.21.0": - version "0.21.0" - resolved "https://registry.yarnpkg.com/@noir-lang/types/-/types-0.21.0.tgz#c64d9b25c48522c4b5edadd657bcaddf6c872b21" - integrity sha512-v6CC04mvydBOGMVRCQd9Ytvz5Bjn0pGCE5ENDD+ROjs6+U5wShW5InFBQu5j9UixKybYUtuXk+5TMpuJ/yagog== - dependencies: - "@noir-lang/noirc_abi" "0.21.0" - "@nomicfoundation/ethereumjs-block@5.0.2": version "5.0.2" resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-block/-/ethereumjs-block-5.0.2.tgz#13a7968f5964f1697da941281b7f7943b0465d04" From 1aff40dc23cb9a2ba510ce55922fc620294ff142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro=20Sousa?= Date: Tue, 19 Dec 2023 18:05:52 +0000 Subject: [PATCH 6/6] wrapping up --- .github/workflows/nightly.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index 560699d..456e51e 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -1,9 +1,11 @@ name: Nightly drift test on: - pull_request: - paths: - - 'vite-hardhat/**' + # Giving ourselves a way to trigger this manually + workflow_dispatch: + schedule: + # Run a nightly release at 2 AM UTC + - cron: '0 2 * * *' jobs: setup: @@ -26,7 +28,7 @@ jobs: VERSIONS='${{ steps.versions_step.outputs.versionArray }}' echo "Versions for Matrix: $VERSIONS" MATRIX=$(echo "$VERSIONS" | jq -c '{versions: .} | .versions | to_entries | map({key: .key, value: (.value | sub("^v"; ""))})') - echo "::set-output name=matrix::{\"include\":$MATRIX}" + echo "::set-output name=matrix::{\"include\":$MATRIX}" test-drift-vite-hardhat: needs: setup