From d32979e34e112676b0d56b40cae126bf27dd21ab Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Thu, 2 Nov 2023 08:57:27 +0000 Subject: [PATCH] chore: restore noir-version.json --- build_manifest.yml | 2 +- yarn-project/aztec-sandbox/src/bin/index.ts | 6 ++-- .../noir-compiler/src/compile/nargo.ts | 34 +++++-------------- .../noir-compiler/src/noir-version.json | 4 +++ .../noir-compiler/src/noir-version.ts | 9 ++++- .../pxe/src/pxe_service/pxe_service.ts | 4 +-- 6 files changed, 26 insertions(+), 33 deletions(-) create mode 100644 yarn-project/noir-compiler/src/noir-version.json diff --git a/build_manifest.yml b/build_manifest.yml index 4c2bb8e7e22..ee4ff6b60cc 100644 --- a/build_manifest.yml +++ b/build_manifest.yml @@ -96,7 +96,7 @@ yarn-project-base: yarn-project: buildDir: yarn-project rebuildPatterns: - - ^yarn-project/.*\.(ts|tsx|js|cjs|mjs|json|html|md|sh)$ + - ^yarn-project/.*\.(ts|tsx|js|cjs|mjs|json|html|md|sh|nr|toml)$ - ^yarn-project/Dockerfile dependencies: - yarn-project-base diff --git a/yarn-project/aztec-sandbox/src/bin/index.ts b/yarn-project/aztec-sandbox/src/bin/index.ts index c9d072866d2..fd6fab2c55d 100644 --- a/yarn-project/aztec-sandbox/src/bin/index.ts +++ b/yarn-project/aztec-sandbox/src/bin/index.ts @@ -3,7 +3,7 @@ import { createAztecNodeRpcServer } from '@aztec/aztec-node'; import { deployInitialSandboxAccounts } from '@aztec/aztec.js'; import { createDebugLogger } from '@aztec/foundation/log'; import { fileURLToPath } from '@aztec/foundation/url'; -import { noirWasmVersion } from '@aztec/noir-compiler/noir-version'; +import { NoirWasmVersion } from '@aztec/noir-compiler/noir-version'; import { createPXERpcServer } from '@aztec/pxe'; import { readFileSync } from 'fs'; @@ -52,7 +52,7 @@ async function main() { const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json'); const version = JSON.parse(readFileSync(packageJsonPath).toString()).version; - logger.info(`Setting up Aztec Sandbox v${version} (noir v${noirWasmVersion}), please stand by...`); + logger.info(`Setting up Aztec Sandbox v${version} (noir v${NoirWasmVersion}), please stand by...`); const { pxe, node, stop, accounts } = await createAndInitialiseSandbox(); @@ -85,7 +85,7 @@ async function main() { logger.info( `${splash}\n${github}\n\n` .concat(...accountStrings) - .concat(`Aztec Sandbox v${version} (noir v${noirWasmVersion}) is now ready for use!`), + .concat(`Aztec Sandbox v${version} (noir v${NoirWasmVersion}) is now ready for use!`), ); } diff --git a/yarn-project/noir-compiler/src/compile/nargo.ts b/yarn-project/noir-compiler/src/compile/nargo.ts index 5405d061f76..85443ebf631 100644 --- a/yarn-project/noir-compiler/src/compile/nargo.ts +++ b/yarn-project/noir-compiler/src/compile/nargo.ts @@ -4,9 +4,8 @@ import { execSync } from 'child_process'; import { readFileSync, readdirSync, statSync, unlinkSync } from 'fs'; import { emptyDirSync } from 'fs-extra'; import path from 'path'; -import { parse } from 'semver'; -import { noirWasmVersion } from '../noir-version.js'; +import { NoirCommit, NoirTag } from '../index.js'; import { NoirCompilationArtifacts, NoirCompiledContract, NoirDebugMetadata } from '../noir_artifact.js'; /** Compilation options */ @@ -36,37 +35,20 @@ export class NargoContractCompiler { const stdio = this.opts.quiet ? 'ignore' : 'inherit'; const nargoBin = this.opts.nargoBin ?? 'nargo'; const version = execSync(`${nargoBin} --version`, { cwd: this.projectPath, stdio: 'pipe' }).toString(); - this.checkNargoBinVersion(version); + this.checkNargoBinVersion(version.replace('\n', '')); emptyDirSync(this.getTargetFolder()); execSync(`${nargoBin} compile --no-backend`, { cwd: this.projectPath, stdio }); return Promise.resolve(this.collectArtifacts()); } private checkNargoBinVersion(version: string) { - const outputLines = version.split('\n'); - const nargoVersionLine = outputLines.find(line => line.indexOf('nargo') !== -1); - const nargoVer = nargoVersionLine?.match(/(\d+\.\d+\.\d+)/)?.[1]; - - if (!nargoVer) { - this.log('Warning: nargo version could not be determined.'); - return; - } - - const noirWasmSemver = parse(noirWasmVersion); - - if (noirWasmSemver?.compareMain(nargoVer) === 0) { - if (!this.opts.quiet) { - this.log(`Using Nargo v${nargoVer}`); - } - return; + if (!version.includes(NoirCommit)) { + this.log( + `Warning: the nargo version installed locally does not match the expected one. This may cause issues when compiling or deploying contracts. Consider updating your nargo or aztec-cli installation. \n- Expected: ${NoirTag} (git version hash: ${NoirCommit})\n- Found: ${version}`, + ); + } else if (!this.opts.quiet) { + this.log(`Using ${version}`); } - - this.log(`\ -Warning: the nargo version installed locally does not match the expected one. This may cause issues when compiling or deploying contracts. Consider updating your nargo or aztec-cli installation. - - Expected: ${noirWasmSemver?.major}.${noirWasmSemver?.minor}.${noirWasmSemver?.patch} (git version hash: ${ - noirWasmSemver?.prerelease[0] - }) - - Found: ${outputLines.join(' ')}`); } private collectArtifacts(): NoirCompilationArtifacts[] { diff --git a/yarn-project/noir-compiler/src/noir-version.json b/yarn-project/noir-compiler/src/noir-version.json new file mode 100644 index 00000000000..9b08583c70f --- /dev/null +++ b/yarn-project/noir-compiler/src/noir-version.json @@ -0,0 +1,4 @@ +{ + "tag": "v0.18.0-aztec.4", + "commit": "9d9ee7a09ab972180dcb8ad59cdf1d6dd17e5794" +} diff --git a/yarn-project/noir-compiler/src/noir-version.ts b/yarn-project/noir-compiler/src/noir-version.ts index 64e89f60464..43f9383e7d4 100644 --- a/yarn-project/noir-compiler/src/noir-version.ts +++ b/yarn-project/noir-compiler/src/noir-version.ts @@ -1,5 +1,12 @@ import { readFileSync } from 'node:fs'; +import NoirVersion from './noir-version.json' assert { type: 'json' }; + // read package.json at runtime instead of compile time so that we keep rootDir as-is in tsconfig const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8')); -export const noirWasmVersion = pkg.dependencies['@noir-lang/noir_wasm']; + +export const NoirWasmVersion = pkg.dependencies['@noir-lang/noir_wasm']; +export const NoirTag = NoirVersion.tag; +export const NoirCommit = NoirVersion.commit; + +export { NoirVersion }; diff --git a/yarn-project/pxe/src/pxe_service/pxe_service.ts b/yarn-project/pxe/src/pxe_service/pxe_service.ts index bc54943821a..5bfecd08323 100644 --- a/yarn-project/pxe/src/pxe_service/pxe_service.ts +++ b/yarn-project/pxe/src/pxe_service/pxe_service.ts @@ -22,7 +22,7 @@ import { encodeArguments } from '@aztec/foundation/abi'; import { padArrayEnd } from '@aztec/foundation/collection'; import { Fr } from '@aztec/foundation/fields'; import { DebugLogger, createDebugLogger } from '@aztec/foundation/log'; -import { noirWasmVersion } from '@aztec/noir-compiler/noir-version'; +import { NoirWasmVersion } from '@aztec/noir-compiler/noir-version'; import { AuthWitness, AztecNode, @@ -421,7 +421,7 @@ export class PXEService implements PXE { const nodeInfo: NodeInfo = { sandboxVersion: this.sandboxVersion, - compatibleNargoVersion: noirWasmVersion, + compatibleNargoVersion: NoirWasmVersion, chainId, protocolVersion: version, l1ContractAddresses: contractAddresses,