diff --git a/.github/scripts/latest.js b/.github/scripts/latest.js index 45b8f58..e781aca 100644 --- a/.github/scripts/latest.js +++ b/.github/scripts/latest.js @@ -1,28 +1,55 @@ const { writeFileSync } = require('fs'); +const GITHUB_PAGES = 3; + async function main() { const fetchOpts = { + params: { per_page: 100 }, 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.substring(1); - const latestPreRelease = filtered.find(release => release.prerelease).tag_name.substring(1); + const versions = []; + for (let i = 0; i < GITHUB_PAGES; i++) { + const res = await fetch( + `https://api.github.com/repos/noir-lang/noir/releases?page=${i + 1}`, + fetchOpts, + ); + + const data = await res.json(); + + const filtered = data.filter( + release => !release.tag_name.includes('aztec') && !release.tag_name.includes('nightly'), + ); + versions.push(...filtered); + } + + const latestStable = versions.find(release => !release.prerelease).tag_name.substring(1); + + /** + * TODO: test the prerelease! + * + * The problem with the prerelease is that if the test runs for both the stable and the prerelease, + * and the prerelease has a breaking change, then the stable will fail. + * + * If we update the the starter to match the prerelease, then the stable will fail. + * + * This means that if there is a breaking change in a prerelease, we will ALWAYS get a warning 😄, which defeats the purpose. + * + * A solution would be to have a separate "prerelease" branch that is updated with the prerelease. And the CI runs on that branch. + * However, Noir hasn't yet reached a state where, for example, there is ALWAYS a prerelease newer than the stable. + * Sometimes the stable is the last one, and there is a prerelease buried somewhere that never got the honor of being promoted to stable. + * + * So for now, we will just ignore the prerelease. + */ + + // const latestPreRelease = versions.find(release => release.prerelease).tag_name.substring(1); - // TODO: add the prerelease to this object! const workflowOutput = JSON.stringify({ stable: latestStable, - prerelease: latestPreRelease, + // prerelease: latestPreRelease, }); console.log(workflowOutput); // DON'T REMOVE, GITHUB WILL CAPTURE THIS OUTPUT } diff --git a/vite-hardhat/components/index.tsx b/vite-hardhat/components/index.tsx index 461fd36..3bf17d0 100644 --- a/vite-hardhat/components/index.tsx +++ b/vite-hardhat/components/index.tsx @@ -13,10 +13,8 @@ import React from 'react'; import { Noir } from '@noir-lang/noir_js'; import { BarretenbergBackend, flattenPublicInputs } from '@noir-lang/backend_barretenberg'; import { CompiledCircuit, ProofData } from '@noir-lang/types'; -import { compile } from '@noir-lang/noir_wasm'; +import { compile, PathToFileSourceMap } from '@noir-lang/noir_wasm'; -// @ts-ignore -import { initializeResolver } from '@noir-lang/source-resolver'; import { useAccount, useConnect, useContractWrite } from 'wagmi'; import { contractCallConfig } from '../utils/wagmi.jsx'; import { bytesToHex } from 'viem'; @@ -25,12 +23,9 @@ async function getCircuit(name: string) { const res = await fetch(new URL('../circuits/src/main.nr', import.meta.url)); const noirSource = await res.text(); - initializeResolver((id: string) => { - const source = noirSource; - return source; - }); - - const compiled = compile('main'); + const sourceMap = new PathToFileSourceMap(); + sourceMap.add_source_code('main.nr', noirSource); + const compiled = compile('main.nr', undefined, undefined, sourceMap); return compiled; } diff --git a/vite-hardhat/package.json b/vite-hardhat/package.json index 542e200..7737fd9 100644 --- a/vite-hardhat/package.json +++ b/vite-hardhat/package.json @@ -11,11 +11,10 @@ "test": "NODE_OPTIONS='--experimental-loader ts-node/esm/transpile-only' hardhat test" }, "dependencies": { - "@noir-lang/backend_barretenberg": "^0.19.4", - "@noir-lang/noir_js": "^0.19.4", - "@noir-lang/noir_wasm": "^0.19.4", - "@noir-lang/source-resolver": "^0.19.4", - "@noir-lang/types": "^0.19.4", + "@noir-lang/backend_barretenberg": "0.22.0", + "@noir-lang/noir_js": "0.22.0", + "@noir-lang/noir_wasm": "0.22.0", + "@noir-lang/types": "0.22.0", "@nomicfoundation/hardhat-network-helpers": "^1.0.0", "@nomicfoundation/hardhat-toolbox-viem": "1.0.0", "@nomicfoundation/hardhat-viem": "1.0.0", diff --git a/vite-hardhat/test/index.ts b/vite-hardhat/test/index.ts index 701d0a4..f414fde 100644 --- a/vite-hardhat/test/index.ts +++ b/vite-hardhat/test/index.ts @@ -4,12 +4,17 @@ import hre from 'hardhat'; import { Noir } from '@noir-lang/noir_js'; import { BarretenbergBackend } from '@noir-lang/backend_barretenberg'; -import { CompileResult, CompiledProgram, compile } from '@noir-lang/noir_wasm'; -import path from 'path'; +import { compile, PathToFileSourceMap } from '@noir-lang/noir_wasm'; +import { join } from 'path'; import { ProofData } from '@noir-lang/types'; +import { readFileSync } from 'fs'; const getCircuit = async (name: string) => { - const compiled = await compile(path.resolve('circuits', 'src', `${name}.nr`)); + const sourcePath = new URL('../circuits/src/main.nr', import.meta.url); + const sourceMap = new PathToFileSourceMap(); + + sourceMap.add_source_code(sourcePath.pathname, readFileSync(join(sourcePath.pathname), 'utf-8')); + const compiled = compile(sourcePath.pathname, undefined, undefined, sourceMap); return compiled; }; diff --git a/vite-hardhat/yarn.lock b/vite-hardhat/yarn.lock index b07042a..d1943b4 100644 --- a/vite-hardhat/yarn.lock +++ b/vite-hardhat/yarn.lock @@ -756,50 +756,45 @@ "@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.38.0": + version "0.38.0" + resolved "https://registry.yarnpkg.com/@noir-lang/acvm_js/-/acvm_js-0.38.0.tgz#c51da3d42c969fffa19d567f187763ff165cb83e" + integrity sha512-bf5RcE7KmcjZ86j9Esm/KoHQhW3EEIv/qvKFy15jfgqPjTrXsUC7s9vif7/ZXpJKUMxu55zluNTTJtIGoNwy+A== -"@noir-lang/backend_barretenberg@^0.19.4": - version "0.19.4" - resolved "https://registry.yarnpkg.com/@noir-lang/backend_barretenberg/-/backend_barretenberg-0.19.4.tgz#77deb7fc365466437b3ddd7fc97a74f01870f1dd" - integrity sha512-gk8uyx3qJAXp7hNgzBpAyyoK5BV/8zoB+kQqVStuue6D9ByMTxvqL3juJ0Ivm+NYN/IqBIIkuFNTgiaD/2gHsA== +"@noir-lang/backend_barretenberg@0.22.0": + version "0.22.0" + resolved "https://registry.yarnpkg.com/@noir-lang/backend_barretenberg/-/backend_barretenberg-0.22.0.tgz#3eda26b4275dfd73ec7c47af984860efff600eb8" + integrity sha512-jS8AEajl+h3Bfa2JS2yANb4/i31LKqDOGvr4eE/86ffM5dt+GXbDmWPRfaEoACUQkDZ7RpNbCBRtujqLNU5RtQ== dependencies: "@aztec/bb.js" "0.16.0" - "@noir-lang/types" "0.19.4" + "@noir-lang/types" "0.22.0" 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.22.0": + version "0.22.0" + resolved "https://registry.yarnpkg.com/@noir-lang/noir_js/-/noir_js-0.22.0.tgz#ef7e7533d7042c321cd033cd9b1b97ddcccdad99" + integrity sha512-Wnh/015ehPCa2OgOo/URcrTzaeYI0Lmm+i5GKNYtZzoPWgsaHBoK0hDtEPkg7s5NSVwX5iVAcV4V5HUgxLBUpw== 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.38.0" + "@noir-lang/noirc_abi" "0.22.0" + "@noir-lang/types" "0.22.0" -"@noir-lang/noir_wasm@^0.19.4": - version "0.19.4" - resolved "https://registry.yarnpkg.com/@noir-lang/noir_wasm/-/noir_wasm-0.19.4.tgz#b556c97761015c4733bceb16b47c8c16b665a4b6" - integrity sha512-RcZ7Fgm+YiTyvGKNEiHWefiY8I2972Yd6F3z0txmyzsu6XkUek0JR4k/PAwbl5/5NwpLVUdaxHW3qDhlazaguQ== +"@noir-lang/noir_wasm@0.22.0": + version "0.22.0" + resolved "https://registry.yarnpkg.com/@noir-lang/noir_wasm/-/noir_wasm-0.22.0.tgz#a5dff8b2674b7df252d3c75097e1a323297297a2" + integrity sha512-5x9XNdTqMGWnuqSa/C+YwvkSJHTigaJev8DLcpN1KfENwhboXG1nCN9A9fAKWelVwfSHjtuv+dR4TJo2x964xQ== -"@noir-lang/noirc_abi@0.19.4": - version "0.19.4" - 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.22.0": + version "0.22.0" + resolved "https://registry.yarnpkg.com/@noir-lang/noirc_abi/-/noirc_abi-0.22.0.tgz#f6dd2d8440d8026d50a8df89b1dcadbbd184fb5d" + integrity sha512-Rxt0qX6IexMeDiytDAg5z2AvlUe3MOOmeUCi9d1ovqF/Cj9ZUZc+LVOdkR5r11bgAMApURFXZo3idvz3v/MO0g== -"@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" - integrity sha512-rXv1iFeuGsBHGN6+Va8fX1PslXZzaLEaZMigNaPwafBamkmL79OuJR8zknJQSDuAd92f9nDPvI1EieAIeuIiJg== - -"@noir-lang/types@0.19.4", "@noir-lang/types@^0.19.4": - version "0.19.4" - resolved "https://registry.yarnpkg.com/@noir-lang/types/-/types-0.19.4.tgz#bef8fc4d4023b78cfb77c66272418a1c5ea55327" - integrity sha512-NInyF1IQ1qNidhqyu1dxIYMatehnLI7eZz+9DaWH9t8TDA1RjIiUZ3wF2j/ukeTrk3RrhS+wj4t2cCVwv/aEiA== +"@noir-lang/types@0.22.0": + version "0.22.0" + resolved "https://registry.yarnpkg.com/@noir-lang/types/-/types-0.22.0.tgz#9566b105dd3ccf6a3c42e28cac12388d10c66a12" + integrity sha512-0xiQru499ZCK04Fs26eHpk5IP0f38VNKgIrVCnyjMKYQ0XTtVJQxUt/hqZV0cmqOEuCtfPcSYu2pzv1p50yNig== dependencies: - "@noir-lang/noirc_abi" "0.19.4" + "@noir-lang/noirc_abi" "0.22.0" "@nomicfoundation/ethereumjs-block@5.0.2": version "5.0.2"