Skip to content

Commit

Permalink
chore: restore noir-version.json
Browse files Browse the repository at this point in the history
  • Loading branch information
alexghr committed Nov 2, 2023
1 parent dc4c867 commit d32979e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 33 deletions.
2 changes: 1 addition & 1 deletion build_manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/aztec-sandbox/src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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!`),
);
}

Expand Down
34 changes: 8 additions & 26 deletions yarn-project/noir-compiler/src/compile/nargo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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[] {
Expand Down
4 changes: 4 additions & 0 deletions yarn-project/noir-compiler/src/noir-version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tag": "v0.18.0-aztec.4",
"commit": "9d9ee7a09ab972180dcb8ad59cdf1d6dd17e5794"
}
9 changes: 8 additions & 1 deletion yarn-project/noir-compiler/src/noir-version.ts
Original file line number Diff line number Diff line change
@@ -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 };
4 changes: 2 additions & 2 deletions yarn-project/pxe/src/pxe_service/pxe_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -421,7 +421,7 @@ export class PXEService implements PXE {

const nodeInfo: NodeInfo = {
sandboxVersion: this.sandboxVersion,
compatibleNargoVersion: noirWasmVersion,
compatibleNargoVersion: NoirWasmVersion,
chainId,
protocolVersion: version,
l1ContractAddresses: contractAddresses,
Expand Down

0 comments on commit d32979e

Please sign in to comment.