From 0d2d386b8a156d79e663f5ded14e67ee624379be Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Fri, 27 Oct 2023 17:02:34 +0100 Subject: [PATCH 1/6] feat: make noir_wasm the default compiler --- .circleci/config.yml | 13 -- build_manifest.yml | 14 +- yarn-project/Dockerfile | 19 +- yarn-project/aztec-sandbox/src/bin/index.ts | 6 +- yarn-project/noir-compiler/package.json | 6 +- .../src/__snapshots__/index.test.ts.snap | 188 +++++++++++++++++- .../noir-compiler/src/cli/contract.ts | 4 +- .../src/compile/noir/noir-wasm-compiler.ts | 8 +- yarn-project/noir-contracts/.dockerignore | 9 - yarn-project/noir-contracts/Dockerfile | 20 -- .../noir-contracts/scripts/compile_all.sh | 12 +- .../noir-contracts/scripts/types_all.sh | 3 - .../noir-contracts/src/scripts/copy_output.ts | 38 +--- .../pxe/src/pxe_service/pxe_service.ts | 4 +- yarn-project/yarn.lock | 31 ++- 15 files changed, 236 insertions(+), 139 deletions(-) delete mode 100644 yarn-project/noir-contracts/.dockerignore delete mode 100644 yarn-project/noir-contracts/Dockerfile diff --git a/.circleci/config.yml b/.circleci/config.yml index 49097fff0e3..bb420c5da89 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -373,17 +373,6 @@ jobs: name: "Build and test" command: build l1-contracts - noir-contracts-build: - machine: - image: ubuntu-2204:2023.07.2 - resource_class: large - steps: - - *checkout - - *setup_env - - run: - name: Build - command: build noir-contracts-build | add_timestamps - yarn-project-base: machine: image: ubuntu-2204:2023.07.2 @@ -1237,7 +1226,6 @@ workflows: <<: *defaults - l1-contracts: *defaults - - noir-contracts-build: *defaults - mainnet-fork: *defaults - deploy-mainnet-fork: @@ -1254,7 +1242,6 @@ workflows: - yarn-project: requires: - yarn-project-base - - noir-contracts-build <<: *defaults - yarn-project-formatting: requires: diff --git a/build_manifest.yml b/build_manifest.yml index 8f9f89acc41..ee4ff6b60cc 100644 --- a/build_manifest.yml +++ b/build_manifest.yml @@ -83,17 +83,6 @@ circuits-x86_64-linux-clang-assert: l1-contracts: buildDir: l1-contracts -# We should move the noir source code to the top of the repo. -# It's currently under yarn-project which looks very circular, but it isn't. -# We're specific with our rebuild patterns as we depend on aztec.nr, but it doesn't have its own build. -noir-contracts-build: - buildDir: yarn-project - projectDir: yarn-project/noir-contracts - rebuildPatterns: - - ^yarn-project/noir-contracts/ - - ^yarn-project/noir-compiler/src/noir-version.json - - ^yarn-project/aztec-nr/ - yarn-project-base: buildDir: yarn-project projectDir: yarn-project/yarn-project-base @@ -107,11 +96,10 @@ 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 - - noir-contracts-build aztec-sandbox: buildDir: yarn-project diff --git a/yarn-project/Dockerfile b/yarn-project/Dockerfile index ee4f1455cb8..6a87e5515af 100644 --- a/yarn-project/Dockerfile +++ b/yarn-project/Dockerfile @@ -1,21 +1,16 @@ # This base dockerfile adds all the remaining source files, performs artifact generation, and builds the project. # See yarn-project-base/Dockerfile for deeper insight into why things are how they are. -FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/noir-contracts-build as noir FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/yarn-project-base as builder +RUN apk add bash perl + # Copy in the entire workspace. COPY . . -# Generate Noir contract TypeScript artifacts. -COPY --from=noir /usr/src/yarn-project/noir-contracts/target /usr/src/yarn-project/noir-contracts/target -# Run yarn build to have the json artifacts available for the types generator, generate types, build again. -RUN apk add perl -RUN cd /usr/src/yarn-project/noir-contracts && yarn build && ./scripts/types_all.sh && yarn build -# Cleanup to reduce final image size. -RUN rm -rf noir-contracts/target - -# Build the entire project. -RUN yarn tsc -b +RUN yarn workspace @aztec/foundation build && \ + yarn workspace @aztec/noir-compiler build && \ + yarn workspace @aztec/noir-contracts noir:build:all && \ + yarn tsc -b # Build aztec.js web artifact RUN cd /usr/src/yarn-project/aztec.js && yarn build:web @@ -37,4 +32,4 @@ RUN cp /usr/src/circuits/cpp/build-wasm/bin/aztec3-circuits.wasm /usr/src/yarn-p WORKDIR /usr/src/yarn-project -ENTRYPOINT ["yarn"] \ No newline at end of file +ENTRYPOINT ["yarn"] diff --git a/yarn-project/aztec-sandbox/src/bin/index.ts b/yarn-project/aztec-sandbox/src/bin/index.ts index 463a2b65b35..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 { NoirVersion } 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} (nargo ${NoirVersion.tag}), 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} (nargo ${NoirVersion.tag}) 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/package.json b/yarn-project/noir-compiler/package.json index d0479220470..0e12c1730b5 100644 --- a/yarn-project/noir-compiler/package.json +++ b/yarn-project/noir-compiler/package.json @@ -47,8 +47,8 @@ "dependencies": { "@aztec/foundation": "workspace:^", "@ltd/j-toml": "^1.38.0", - "@noir-lang/noir_wasm": "0.18.0-3919619.aztec", - "@noir-lang/source-resolver": "0.18.0-3919619.aztec", + "@noir-lang/noir_wasm": "0.18.0-a098541.aztec", + "@noir-lang/source-resolver": "0.18.0-a098541.aztec", "base64-js": "^1.5.1", "commander": "^9.0.0", "fs-extra": "^11.1.1", @@ -59,6 +59,7 @@ "lodash.upperfirst": "^4.3.1", "memfs": "^4.6.0", "pako": "^2.1.0", + "semver": "^7.5.4", "tslib": "^2.4.0", "unzipit": "^1.4.3" }, @@ -74,6 +75,7 @@ "@types/lodash.upperfirst": "^4.3.7", "@types/node": "^18.7.23", "@types/pako": "^2.0.0", + "@types/semver": "^7.5.4", "jest": "^29.5.0", "ts-jest": "^29.1.0", "ts-node": "^10.9.1", diff --git a/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap b/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap index 30ce21b864f..d9a5005e7ff 100644 --- a/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap +++ b/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap @@ -382,7 +382,193 @@ export class TestContractContract extends ContractBase { exports[`noir-compiler using wasm binary compiles the test contract 1`] = ` [ { - "debug": undefined, + "debug": { + "debugSymbols": [ + "eJyrVsrJT04syczPK1ayqlYyULKKrlYqLkjMA/GKSxKLSpSsDE0MdZRS81KALFOzWh2ltMycVCC7VgdDpbEJVKGZOVydsSkWhUaGZlCVRiaWCKW1sbW1AA1jLOg=", + "eJyrVsrJT04syczPK1ayqq6tBQAz9wY7", + ], + "fileMap": { + "1": { + "path": "/home/ubuntu/host/aztec-packages/yarn-project/noir-compiler/src/fixtures/test_contract/src/main.nr", + "source": "contract TestContract { + use dep::test::module::foo; + + fn constructor(param: Field, pub_param: pub Field) -> pub [Field; 2] { + [foo::bar(param), param + pub_param] + } + + open fn openFunction() -> pub Field { + 42 + } + +} +", + }, + "3": { + "path": "std/hash.nr", + "source": "mod poseidon; + +#[foreign(sha256)] +pub fn sha256(_input : [u8; N]) -> [u8; 32] {} + +#[foreign(blake2s)] +pub fn blake2s(_input : [u8; N]) -> [u8; 32] {} + +pub fn pedersen(input : [Field; N]) -> [Field; 2] { + pedersen_with_separator(input, 0) +} + +#[foreign(pedersen)] +pub fn pedersen_with_separator(_input : [Field; N], _separator : u32) -> [Field; 2] {} + +pub fn pedersen_hash(input : [Field; N]) -> Field { + pedersen_hash_with_separator(input, 0) +} + +#[foreign(pedersen_hash)] +pub fn pedersen_hash_with_separator(_input : [Field; N], _separator : u32) -> Field {} + +#[foreign(hash_to_field_128_security)] +pub fn hash_to_field(_input : [Field; N]) -> Field {} + +#[foreign(keccak256)] +pub fn keccak256(_input : [u8; N], _message_size: u32) -> [u8; 32] {} + +// mimc-p/p implementation +// constants are (publicly generated) random numbers, for instance using keccak as a ROM. +// You must use constants generated for the native field +// Rounds number should be ~ log(p)/log(exp) +// For 254 bit primes, exponent 7 and 91 rounds seems to be recommended +fn mimc(x: Field, k: Field, constants: [Field; N], exp : Field) -> Field { + //round 0 + let mut t = x + k; + let mut h = t.pow_32(exp); + //next rounds + for i in 1 .. constants.len() { + t = h + k + constants[i]; + h = t.pow_32(exp); + }; + h + k +} + +global MIMC_BN254_ROUNDS = 91; + +//mimc implementation with hardcoded parameters for BN254 curve. +pub fn mimc_bn254(array: [Field; N]) -> Field { + //mimc parameters + let exponent = 7; + //generated from seed "mimc" using keccak256 + let constants: [Field; MIMC_BN254_ROUNDS] = [ + 0, + 20888961410941983456478427210666206549300505294776164667214940546594746570981, + 15265126113435022738560151911929040668591755459209400716467504685752745317193, + 8334177627492981984476504167502758309043212251641796197711684499645635709656, + 1374324219480165500871639364801692115397519265181803854177629327624133579404, + 11442588683664344394633565859260176446561886575962616332903193988751292992472, + 2558901189096558760448896669327086721003508630712968559048179091037845349145, + 11189978595292752354820141775598510151189959177917284797737745690127318076389, + 3262966573163560839685415914157855077211340576201936620532175028036746741754, + 17029914891543225301403832095880481731551830725367286980611178737703889171730, + 4614037031668406927330683909387957156531244689520944789503628527855167665518, + 19647356996769918391113967168615123299113119185942498194367262335168397100658, + 5040699236106090655289931820723926657076483236860546282406111821875672148900, + 2632385916954580941368956176626336146806721642583847728103570779270161510514, + 17691411851977575435597871505860208507285462834710151833948561098560743654671, + 11482807709115676646560379017491661435505951727793345550942389701970904563183, + 8360838254132998143349158726141014535383109403565779450210746881879715734773, + 12663821244032248511491386323242575231591777785787269938928497649288048289525, + 3067001377342968891237590775929219083706800062321980129409398033259904188058, + 8536471869378957766675292398190944925664113548202769136103887479787957959589, + 19825444354178182240559170937204690272111734703605805530888940813160705385792, + 16703465144013840124940690347975638755097486902749048533167980887413919317592, + 13061236261277650370863439564453267964462486225679643020432589226741411380501, + 10864774797625152707517901967943775867717907803542223029967000416969007792571, + 10035653564014594269791753415727486340557376923045841607746250017541686319774, + 3446968588058668564420958894889124905706353937375068998436129414772610003289, + 4653317306466493184743870159523234588955994456998076243468148492375236846006, + 8486711143589723036499933521576871883500223198263343024003617825616410932026, + 250710584458582618659378487568129931785810765264752039738223488321597070280, + 2104159799604932521291371026105311735948154964200596636974609406977292675173, + 16313562605837709339799839901240652934758303521543693857533755376563489378839, + 6032365105133504724925793806318578936233045029919447519826248813478479197288, + 14025118133847866722315446277964222215118620050302054655768867040006542798474, + 7400123822125662712777833064081316757896757785777291653271747396958201309118, + 1744432620323851751204287974553233986555641872755053103823939564833813704825, + 8316378125659383262515151597439205374263247719876250938893842106722210729522, + 6739722627047123650704294650168547689199576889424317598327664349670094847386, + 21211457866117465531949733809706514799713333930924902519246949506964470524162, + 13718112532745211817410303291774369209520657938741992779396229864894885156527, + 5264534817993325015357427094323255342713527811596856940387954546330728068658, + 18884137497114307927425084003812022333609937761793387700010402412840002189451, + 5148596049900083984813839872929010525572543381981952060869301611018636120248, + 19799686398774806587970184652860783461860993790013219899147141137827718662674, + 19240878651604412704364448729659032944342952609050243268894572835672205984837, + 10546185249390392695582524554167530669949955276893453512788278945742408153192, + 5507959600969845538113649209272736011390582494851145043668969080335346810411, + 18177751737739153338153217698774510185696788019377850245260475034576050820091, + 19603444733183990109492724100282114612026332366576932662794133334264283907557, + 10548274686824425401349248282213580046351514091431715597441736281987273193140, + 1823201861560942974198127384034483127920205835821334101215923769688644479957, + 11867589662193422187545516240823411225342068709600734253659804646934346124945, + 18718569356736340558616379408444812528964066420519677106145092918482774343613, + 10530777752259630125564678480897857853807637120039176813174150229243735996839, + 20486583726592018813337145844457018474256372770211860618687961310422228379031, + 12690713110714036569415168795200156516217175005650145422920562694422306200486, + 17386427286863519095301372413760745749282643730629659997153085139065756667205, + 2216432659854733047132347621569505613620980842043977268828076165669557467682, + 6309765381643925252238633914530877025934201680691496500372265330505506717193, + 20806323192073945401862788605803131761175139076694468214027227878952047793390, + 4037040458505567977365391535756875199663510397600316887746139396052445718861, + 19948974083684238245321361840704327952464170097132407924861169241740046562673, + 845322671528508199439318170916419179535949348988022948153107378280175750024, + 16222384601744433420585982239113457177459602187868460608565289920306145389382, + 10232118865851112229330353999139005145127746617219324244541194256766741433339, + 6699067738555349409504843460654299019000594109597429103342076743347235369120, + 6220784880752427143725783746407285094967584864656399181815603544365010379208, + 6129250029437675212264306655559561251995722990149771051304736001195288083309, + 10773245783118750721454994239248013870822765715268323522295722350908043393604, + 4490242021765793917495398271905043433053432245571325177153467194570741607167, + 19596995117319480189066041930051006586888908165330319666010398892494684778526, + 837850695495734270707668553360118467905109360511302468085569220634750561083, + 11803922811376367215191737026157445294481406304781326649717082177394185903907, + 10201298324909697255105265958780781450978049256931478989759448189112393506592, + 13564695482314888817576351063608519127702411536552857463682060761575100923924, + 9262808208636973454201420823766139682381973240743541030659775288508921362724, + 173271062536305557219323722062711383294158572562695717740068656098441040230, + 18120430890549410286417591505529104700901943324772175772035648111937818237369, + 20484495168135072493552514219686101965206843697794133766912991150184337935627, + 19155651295705203459475805213866664350848604323501251939850063308319753686505, + 11971299749478202793661982361798418342615500543489781306376058267926437157297, + 18285310723116790056148596536349375622245669010373674803854111592441823052978, + 7069216248902547653615508023941692395371990416048967468982099270925308100727, + 6465151453746412132599596984628739550147379072443683076388208843341824127379, + 16143532858389170960690347742477978826830511669766530042104134302796355145785, + 19362583304414853660976404410208489566967618125972377176980367224623492419647, + 1702213613534733786921602839210290505213503664731919006932367875629005980493, + 10781825404476535814285389902565833897646945212027592373510689209734812292327, + 4212716923652881254737947578600828255798948993302968210248673545442808456151, + 7594017890037021425366623750593200398174488805473151513558919864633711506220, + 18979889247746272055963929241596362599320706910852082477600815822482192194401, + 13602139229813231349386885113156901793661719180900395818909719758150455500533, + ]; + + let mut r = 0; + for elem in array { + let h = mimc(elem, r, constants, exponent); + r = r + elem + h; + } + r +} +", + }, + "35": { + "path": "/test/module/foo.nr", + "source": "fn bar(param: Field) -> Field { + dep::std::hash::pedersen([param])[0] +}", + }, + }, + }, "events": [], "functions": [ { diff --git a/yarn-project/noir-compiler/src/cli/contract.ts b/yarn-project/noir-compiler/src/cli/contract.ts index 6174d49f856..20b61de076a 100644 --- a/yarn-project/noir-compiler/src/cli/contract.ts +++ b/yarn-project/noir-compiler/src/cli/contract.ts @@ -25,7 +25,7 @@ export function compileContract(program: Command, name = 'contract', log: LogFn .option('-o, --outdir ', 'Output folder for the binary artifacts, relative to the project path', 'target') .option('-ts, --typescript ', 'Optional output folder for generating typescript wrappers', undefined) .option('-i, --interface ', 'Optional output folder for generating an Aztec.nr contract interface', undefined) - .option('-c --compiler ', 'Which compiler to use. Either nargo or wasm. Defaults to nargo', 'nargo') + .option('-c --compiler ', 'Which compiler to use. Either nargo or wasm. Defaults to nargo', 'wasm') .description('Compiles the contracts in the target project') .action( @@ -40,7 +40,7 @@ export function compileContract(program: Command, name = 'contract', log: LogFn }, /* eslint-enable jsdoc/require-jsdoc */ ) => { - const { outdir, typescript, interface: noirInterface, compiler = 'nargo' } = options; + const { outdir, typescript, interface: noirInterface, compiler } = options; if (typeof projectPath !== 'string') throw new Error(`Missing project path argument`); if (compiler !== 'nargo' && compiler !== 'wasm') throw new Error(`Invalid compiler: ${compiler}`); const currentDir = process.cwd(); diff --git a/yarn-project/noir-compiler/src/compile/noir/noir-wasm-compiler.ts b/yarn-project/noir-compiler/src/compile/noir/noir-wasm-compiler.ts index cd077a4034e..462e014fcff 100644 --- a/yarn-project/noir-compiler/src/compile/noir/noir-wasm-compiler.ts +++ b/yarn-project/noir-compiler/src/compile/noir/noir-wasm-compiler.ts @@ -81,14 +81,18 @@ export class NoirWasmContractCompiler { initializeResolver(this.#resolveFile); try { - const contract = await compile(this.#package.getEntryPointPath(), true, { + const result = compile(this.#package.getEntryPointPath(), true, { /* eslint-disable camelcase */ root_dependencies: this.#dependencyManager.getEntrypointDependencies(), library_dependencies: this.#dependencyManager.getLibraryDependencies(), /* eslint-enable camelcase */ }); - return [{ contract }]; + if (!('contract' in result)) { + throw new Error('No contract found in compilation result'); + } + + return [result]; } catch (err) { if (err instanceof Error && err.name === 'CompileError') { this.#processCompileError(err as CompileError); diff --git a/yarn-project/noir-contracts/.dockerignore b/yarn-project/noir-contracts/.dockerignore deleted file mode 100644 index a87f12a1b1d..00000000000 --- a/yarn-project/noir-contracts/.dockerignore +++ /dev/null @@ -1,9 +0,0 @@ -dest -node_modules -target -src/artifacts/_ -src/types/_ -Dockerfile.build -Dockerfile.lint -Dockerfile.types -README.md diff --git a/yarn-project/noir-contracts/Dockerfile b/yarn-project/noir-contracts/Dockerfile deleted file mode 100644 index 5600d0a9e98..00000000000 --- a/yarn-project/noir-contracts/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM ubuntu:lunar -RUN apt-get update && apt-get install -y \ - jq \ - curl \ - git \ - sed -WORKDIR /usr/src/yarn-project -COPY noir-contracts noir-contracts -COPY noir-compiler noir-compiler -COPY aztec-nr aztec-nr -WORKDIR /usr/src/yarn-project/noir-contracts - -# Download and extract nargo -ENV NARGO_HOME="/usr/src/yarn-project/noir-contracts/.nargo" -RUN ./scripts/install_noirup.sh $(pwd) -ENV PATH="/usr/src/yarn-project/noir-contracts/.nargo/bin:${PATH}" - -RUN ./scripts/install_noir.sh -RUN ./scripts/compile_all.sh -RUN ./scripts/nargo_test_ci.sh diff --git a/yarn-project/noir-contracts/scripts/compile_all.sh b/yarn-project/noir-contracts/scripts/compile_all.sh index 1cd26131e89..32de820a630 100755 --- a/yarn-project/noir-contracts/scripts/compile_all.sh +++ b/yarn-project/noir-contracts/scripts/compile_all.sh @@ -1,13 +1,3 @@ #!/bin/bash -# Compiles all noir contracts - -source ./scripts/nargo_check.sh - -echo "Checking noir version" -nargo_check - -# Runs the compile scripts for all contracts. echo "Compiling all contracts" - -# ./scripts/compile.sh $(./scripts/get_all_contracts.sh) -nargo compile --workspace --no-backend +./scripts/compile.sh $(./scripts/get_all_contracts.sh) diff --git a/yarn-project/noir-contracts/scripts/types_all.sh b/yarn-project/noir-contracts/scripts/types_all.sh index fe2b1685276..5cbb3ce9d91 100755 --- a/yarn-project/noir-contracts/scripts/types_all.sh +++ b/yarn-project/noir-contracts/scripts/types_all.sh @@ -1,6 +1,3 @@ #!/bin/bash # Run the types script for all files ./scripts/types.sh $(./scripts/get_all_contracts.sh) - -# Remove the debug files as they are no longer needed and can cause prettier and build issues -rm -r ./target/debug* diff --git a/yarn-project/noir-contracts/src/scripts/copy_output.ts b/yarn-project/noir-contracts/src/scripts/copy_output.ts index 5477b601335..de71b9586ff 100644 --- a/yarn-project/noir-contracts/src/scripts/copy_output.ts +++ b/yarn-project/noir-contracts/src/scripts/copy_output.ts @@ -1,10 +1,6 @@ import { ContractArtifact } from '@aztec/foundation/abi'; import { createConsoleLogger } from '@aztec/foundation/log'; -import { - generateContractArtifact, - generateNoirContractInterface, - generateTypescriptContractInterface, -} from '@aztec/noir-compiler'; +import { generateNoirContractInterface, generateTypescriptContractInterface } from '@aztec/noir-compiler'; import { readFileSync, writeFileSync } from 'fs'; import camelCase from 'lodash.camelcase'; @@ -45,34 +41,6 @@ function writeToProject(artifact: any) { } } -/** - * Processes nargo workspace artifacts - * @param projectName - The project name - * @param contractName - The contract name - */ -function processNargoWorkspaceArtifact(projectName: string, contractName: string) { - const artifactFile = `${projectName}-${contractName}.json`; - - const buildJsonFilePath = `./target/${artifactFile}`; - const buildJson = JSON.parse(readFileSync(buildJsonFilePath).toString()); - - const debugArtifactFile = `debug_${artifactFile}`; - let debug = undefined; - - try { - const debugJsonFilePath = `./target/${debugArtifactFile}`; - const debugJson = JSON.parse(readFileSync(debugJsonFilePath).toString()); - if (debugJson) { - debug = debugJson; - } - } catch (err) { - // Ignore - } - // Remove extraneous information from the buildJson (which was output by Nargo) to hone in on the function data we actually care about: - const artifactJson: ContractArtifact = generateContractArtifact({ contract: buildJson, debug }); - return artifactJson; -} - /** * Processes an artifact generated by noir-compiler. * Currently unused. This should be used once contracts are compiled with `noir-compiler` instead of Nargo. @@ -80,7 +48,7 @@ function processNargoWorkspaceArtifact(projectName: string, contractName: string * @param projectName - The name of the project * @param contractName - The name of the contract */ -function _processNoirCompilerArtifact(projectName: string, contractName: string) { +function processNoirCompilerArtifact(projectName: string, contractName: string) { const artifactJsonFilePath = `src/contracts/${projectName}/target/${contractName}.json`; const artifactJson: ContractArtifact = JSON.parse(readFileSync(artifactJsonFilePath).toString()); return artifactJson; @@ -92,7 +60,7 @@ const main = () => { const projectName = `${snakeCase(name)}_contract`; const contractName = upperFirst(camelCase(name)); - const artifactJson = processNargoWorkspaceArtifact(projectName, contractName); + const artifactJson = processNoirCompilerArtifact(projectName, contractName); // Write the artifact: const artifactsDir = 'src/artifacts'; diff --git a/yarn-project/pxe/src/pxe_service/pxe_service.ts b/yarn-project/pxe/src/pxe_service/pxe_service.ts index 44fa8db2e41..d1efcd73044 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 { NoirVersion } from '@aztec/noir-compiler/noir-version'; +import { NoirWasmVersion } from '@aztec/noir-compiler/noir-version'; import { AuthWitness, AztecNode, @@ -429,7 +429,7 @@ export class PXEService implements PXE { const nodeInfo: NodeInfo = { sandboxVersion: this.sandboxVersion, - compatibleNargoVersion: NoirVersion.tag, + compatibleNargoVersion: NoirWasmVersion, chainId, protocolVersion: version, l1ContractAddresses: contractAddresses, diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index e46fc104a11..7431ac8b87d 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -588,8 +588,8 @@ __metadata: "@aztec/foundation": "workspace:^" "@jest/globals": ^29.5.0 "@ltd/j-toml": ^1.38.0 - "@noir-lang/noir_wasm": 0.18.0-3919619.aztec - "@noir-lang/source-resolver": 0.18.0-3919619.aztec + "@noir-lang/noir_wasm": 0.18.0-a098541.aztec + "@noir-lang/source-resolver": 0.18.0-a098541.aztec "@rushstack/eslint-patch": ^1.1.4 "@types/fs-extra": ^11.0.1 "@types/jest": ^29.5.0 @@ -600,6 +600,7 @@ __metadata: "@types/lodash.upperfirst": ^4.3.7 "@types/node": ^18.7.23 "@types/pako": ^2.0.0 + "@types/semver": ^7.5.4 base64-js: ^1.5.1 commander: ^9.0.0 fs-extra: ^11.1.1 @@ -611,6 +612,7 @@ __metadata: lodash.upperfirst: ^4.3.1 memfs: ^4.6.0 pako: ^2.1.0 + semver: ^7.5.4 ts-jest: ^29.1.0 ts-node: ^10.9.1 tslib: ^2.4.0 @@ -3572,12 +3574,12 @@ __metadata: languageName: node linkType: hard -"@noir-lang/noir_wasm@npm:0.18.0-3919619.aztec": - version: 0.18.0-3919619.aztec - resolution: "@noir-lang/noir_wasm@npm:0.18.0-3919619.aztec" +"@noir-lang/noir_wasm@npm:0.18.0-a098541.aztec": + version: 0.18.0-a098541.aztec + resolution: "@noir-lang/noir_wasm@npm:0.18.0-a098541.aztec" peerDependencies: - "@noir-lang/source-resolver": 0.18.0-3919619.aztec - checksum: 34102eaeaf250cf6c324ba9021ffb88695de2eaf6c648b882ad1bd9f1db3434f3af854a5b13302972a0e9cf34b7921008ca162c4ea68807590e567d343f2cec0 + "@noir-lang/source-resolver": 0.18.0-a098541.aztec + checksum: 844fe1991a4dec862b242d41fee947d19c2b2e2588490f92c82d230a87f5b0ade53aefcb35e6a520181c9ff81536698ac49fca79df6a28ba6e995f56f36d3a1a languageName: node linkType: hard @@ -3588,10 +3590,10 @@ __metadata: languageName: node linkType: hard -"@noir-lang/source-resolver@npm:0.18.0-3919619.aztec": - version: 0.18.0-3919619.aztec - resolution: "@noir-lang/source-resolver@npm:0.18.0-3919619.aztec" - checksum: c7f39beba745fe9ca1b05c1df91bfb76c82704c18390740dbfea480e5e5ed98b7861e62341e2179fa4f5db3e327825336e1f8fe3452e081f4974be438c6b00f5 +"@noir-lang/source-resolver@npm:0.18.0-a098541.aztec": + version: 0.18.0-a098541.aztec + resolution: "@noir-lang/source-resolver@npm:0.18.0-a098541.aztec" + checksum: 876640b3577394078e0a9799c9281001038d07cfb8d35d9b6398a4e1d6b071d5db84ff9b271ec4b9582a79352cd41b2e59a27c8b394580a9f57b85d0d0918d76 languageName: node linkType: hard @@ -5057,6 +5059,13 @@ __metadata: languageName: node linkType: hard +"@types/semver@npm:^7.5.4": + version: 7.5.4 + resolution: "@types/semver@npm:7.5.4" + checksum: 120c0189f6fec5f2d12d0d71ac8a4cfa952dc17fa3d842e8afddb82bba8828a4052f8799c1653e2b47ae1977435f38e8985658fde971905ce5afb8e23ee97ecf + languageName: node + linkType: hard + "@types/send@npm:*": version: 0.17.1 resolution: "@types/send@npm:0.17.1" From 3242a149a27cfeb5a646232362a393a889336a10 Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Fri, 27 Oct 2023 18:01:08 +0100 Subject: [PATCH 2/6] fix: remove debug info from snapshot --- .../src/__snapshots__/index.test.ts.snap | 374 ------------------ yarn-project/noir-compiler/src/index.test.ts | 5 +- 2 files changed, 2 insertions(+), 377 deletions(-) diff --git a/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap b/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap index d9a5005e7ff..b6d5ee76689 100644 --- a/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap +++ b/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap @@ -3,193 +3,6 @@ exports[`noir-compiler using nargo compiles the test contract 1`] = ` [ { - "debug": { - "debugSymbols": [ - "eJyrVsrJT04syczPK1ayqlYyULKKrlYqLkjMA/GKSxKLSpSsDE0MdZRS81KALFOzWh2ltMycVCC7VgdDpbEJVKGZOVydsSkWhUaGZlCVRiaWCKW1sbW1AA1jLOg=", - "eJyrVsrJT04syczPK1ayqq6tBQAz9wY7", - ], - "fileMap": { - "1": { - "path": "/home/ubuntu/host/aztec-packages/yarn-project/noir-compiler/src/fixtures/test_contract/src/main.nr", - "source": "contract TestContract { - use dep::test::module::foo; - - fn constructor(param: Field, pub_param: pub Field) -> pub [Field; 2] { - [foo::bar(param), param + pub_param] - } - - open fn openFunction() -> pub Field { - 42 - } - -} -", - }, - "3": { - "path": "std/hash.nr", - "source": "mod poseidon; - -#[foreign(sha256)] -pub fn sha256(_input : [u8; N]) -> [u8; 32] {} - -#[foreign(blake2s)] -pub fn blake2s(_input : [u8; N]) -> [u8; 32] {} - -pub fn pedersen(input : [Field; N]) -> [Field; 2] { - pedersen_with_separator(input, 0) -} - -#[foreign(pedersen)] -pub fn pedersen_with_separator(_input : [Field; N], _separator : u32) -> [Field; 2] {} - -pub fn pedersen_hash(input : [Field; N]) -> Field { - pedersen_hash_with_separator(input, 0) -} - -#[foreign(pedersen_hash)] -pub fn pedersen_hash_with_separator(_input : [Field; N], _separator : u32) -> Field {} - -#[foreign(hash_to_field_128_security)] -pub fn hash_to_field(_input : [Field; N]) -> Field {} - -#[foreign(keccak256)] -pub fn keccak256(_input : [u8; N], _message_size: u32) -> [u8; 32] {} - -// mimc-p/p implementation -// constants are (publicly generated) random numbers, for instance using keccak as a ROM. -// You must use constants generated for the native field -// Rounds number should be ~ log(p)/log(exp) -// For 254 bit primes, exponent 7 and 91 rounds seems to be recommended -fn mimc(x: Field, k: Field, constants: [Field; N], exp : Field) -> Field { - //round 0 - let mut t = x + k; - let mut h = t.pow_32(exp); - //next rounds - for i in 1 .. constants.len() { - t = h + k + constants[i]; - h = t.pow_32(exp); - }; - h + k -} - -global MIMC_BN254_ROUNDS = 91; - -//mimc implementation with hardcoded parameters for BN254 curve. -pub fn mimc_bn254(array: [Field; N]) -> Field { - //mimc parameters - let exponent = 7; - //generated from seed "mimc" using keccak256 - let constants: [Field; MIMC_BN254_ROUNDS] = [ - 0, - 20888961410941983456478427210666206549300505294776164667214940546594746570981, - 15265126113435022738560151911929040668591755459209400716467504685752745317193, - 8334177627492981984476504167502758309043212251641796197711684499645635709656, - 1374324219480165500871639364801692115397519265181803854177629327624133579404, - 11442588683664344394633565859260176446561886575962616332903193988751292992472, - 2558901189096558760448896669327086721003508630712968559048179091037845349145, - 11189978595292752354820141775598510151189959177917284797737745690127318076389, - 3262966573163560839685415914157855077211340576201936620532175028036746741754, - 17029914891543225301403832095880481731551830725367286980611178737703889171730, - 4614037031668406927330683909387957156531244689520944789503628527855167665518, - 19647356996769918391113967168615123299113119185942498194367262335168397100658, - 5040699236106090655289931820723926657076483236860546282406111821875672148900, - 2632385916954580941368956176626336146806721642583847728103570779270161510514, - 17691411851977575435597871505860208507285462834710151833948561098560743654671, - 11482807709115676646560379017491661435505951727793345550942389701970904563183, - 8360838254132998143349158726141014535383109403565779450210746881879715734773, - 12663821244032248511491386323242575231591777785787269938928497649288048289525, - 3067001377342968891237590775929219083706800062321980129409398033259904188058, - 8536471869378957766675292398190944925664113548202769136103887479787957959589, - 19825444354178182240559170937204690272111734703605805530888940813160705385792, - 16703465144013840124940690347975638755097486902749048533167980887413919317592, - 13061236261277650370863439564453267964462486225679643020432589226741411380501, - 10864774797625152707517901967943775867717907803542223029967000416969007792571, - 10035653564014594269791753415727486340557376923045841607746250017541686319774, - 3446968588058668564420958894889124905706353937375068998436129414772610003289, - 4653317306466493184743870159523234588955994456998076243468148492375236846006, - 8486711143589723036499933521576871883500223198263343024003617825616410932026, - 250710584458582618659378487568129931785810765264752039738223488321597070280, - 2104159799604932521291371026105311735948154964200596636974609406977292675173, - 16313562605837709339799839901240652934758303521543693857533755376563489378839, - 6032365105133504724925793806318578936233045029919447519826248813478479197288, - 14025118133847866722315446277964222215118620050302054655768867040006542798474, - 7400123822125662712777833064081316757896757785777291653271747396958201309118, - 1744432620323851751204287974553233986555641872755053103823939564833813704825, - 8316378125659383262515151597439205374263247719876250938893842106722210729522, - 6739722627047123650704294650168547689199576889424317598327664349670094847386, - 21211457866117465531949733809706514799713333930924902519246949506964470524162, - 13718112532745211817410303291774369209520657938741992779396229864894885156527, - 5264534817993325015357427094323255342713527811596856940387954546330728068658, - 18884137497114307927425084003812022333609937761793387700010402412840002189451, - 5148596049900083984813839872929010525572543381981952060869301611018636120248, - 19799686398774806587970184652860783461860993790013219899147141137827718662674, - 19240878651604412704364448729659032944342952609050243268894572835672205984837, - 10546185249390392695582524554167530669949955276893453512788278945742408153192, - 5507959600969845538113649209272736011390582494851145043668969080335346810411, - 18177751737739153338153217698774510185696788019377850245260475034576050820091, - 19603444733183990109492724100282114612026332366576932662794133334264283907557, - 10548274686824425401349248282213580046351514091431715597441736281987273193140, - 1823201861560942974198127384034483127920205835821334101215923769688644479957, - 11867589662193422187545516240823411225342068709600734253659804646934346124945, - 18718569356736340558616379408444812528964066420519677106145092918482774343613, - 10530777752259630125564678480897857853807637120039176813174150229243735996839, - 20486583726592018813337145844457018474256372770211860618687961310422228379031, - 12690713110714036569415168795200156516217175005650145422920562694422306200486, - 17386427286863519095301372413760745749282643730629659997153085139065756667205, - 2216432659854733047132347621569505613620980842043977268828076165669557467682, - 6309765381643925252238633914530877025934201680691496500372265330505506717193, - 20806323192073945401862788605803131761175139076694468214027227878952047793390, - 4037040458505567977365391535756875199663510397600316887746139396052445718861, - 19948974083684238245321361840704327952464170097132407924861169241740046562673, - 845322671528508199439318170916419179535949348988022948153107378280175750024, - 16222384601744433420585982239113457177459602187868460608565289920306145389382, - 10232118865851112229330353999139005145127746617219324244541194256766741433339, - 6699067738555349409504843460654299019000594109597429103342076743347235369120, - 6220784880752427143725783746407285094967584864656399181815603544365010379208, - 6129250029437675212264306655559561251995722990149771051304736001195288083309, - 10773245783118750721454994239248013870822765715268323522295722350908043393604, - 4490242021765793917495398271905043433053432245571325177153467194570741607167, - 19596995117319480189066041930051006586888908165330319666010398892494684778526, - 837850695495734270707668553360118467905109360511302468085569220634750561083, - 11803922811376367215191737026157445294481406304781326649717082177394185903907, - 10201298324909697255105265958780781450978049256931478989759448189112393506592, - 13564695482314888817576351063608519127702411536552857463682060761575100923924, - 9262808208636973454201420823766139682381973240743541030659775288508921362724, - 173271062536305557219323722062711383294158572562695717740068656098441040230, - 18120430890549410286417591505529104700901943324772175772035648111937818237369, - 20484495168135072493552514219686101965206843697794133766912991150184337935627, - 19155651295705203459475805213866664350848604323501251939850063308319753686505, - 11971299749478202793661982361798418342615500543489781306376058267926437157297, - 18285310723116790056148596536349375622245669010373674803854111592441823052978, - 7069216248902547653615508023941692395371990416048967468982099270925308100727, - 6465151453746412132599596984628739550147379072443683076388208843341824127379, - 16143532858389170960690347742477978826830511669766530042104134302796355145785, - 19362583304414853660976404410208489566967618125972377176980367224623492419647, - 1702213613534733786921602839210290505213503664731919006932367875629005980493, - 10781825404476535814285389902565833897646945212027592373510689209734812292327, - 4212716923652881254737947578600828255798948993302968210248673545442808456151, - 7594017890037021425366623750593200398174488805473151513558919864633711506220, - 18979889247746272055963929241596362599320706910852082477600815822482192194401, - 13602139229813231349386885113156901793661719180900395818909719758150455500533, - ]; - - let mut r = 0; - for elem in array { - let h = mimc(elem, r, constants, exponent); - r = r + elem + h; - } - r -} -", - }, - "35": { - "path": "/home/ubuntu/host/aztec-packages/yarn-project/noir-compiler/src/fixtures/test_lib/src/module/foo.nr", - "source": "fn bar(param: Field) -> Field { - dep::std::hash::pedersen([param])[0] -}", - }, - }, - }, "events": [], "functions": [ { @@ -382,193 +195,6 @@ export class TestContractContract extends ContractBase { exports[`noir-compiler using wasm binary compiles the test contract 1`] = ` [ { - "debug": { - "debugSymbols": [ - "eJyrVsrJT04syczPK1ayqlYyULKKrlYqLkjMA/GKSxKLSpSsDE0MdZRS81KALFOzWh2ltMycVCC7VgdDpbEJVKGZOVydsSkWhUaGZlCVRiaWCKW1sbW1AA1jLOg=", - "eJyrVsrJT04syczPK1ayqq6tBQAz9wY7", - ], - "fileMap": { - "1": { - "path": "/home/ubuntu/host/aztec-packages/yarn-project/noir-compiler/src/fixtures/test_contract/src/main.nr", - "source": "contract TestContract { - use dep::test::module::foo; - - fn constructor(param: Field, pub_param: pub Field) -> pub [Field; 2] { - [foo::bar(param), param + pub_param] - } - - open fn openFunction() -> pub Field { - 42 - } - -} -", - }, - "3": { - "path": "std/hash.nr", - "source": "mod poseidon; - -#[foreign(sha256)] -pub fn sha256(_input : [u8; N]) -> [u8; 32] {} - -#[foreign(blake2s)] -pub fn blake2s(_input : [u8; N]) -> [u8; 32] {} - -pub fn pedersen(input : [Field; N]) -> [Field; 2] { - pedersen_with_separator(input, 0) -} - -#[foreign(pedersen)] -pub fn pedersen_with_separator(_input : [Field; N], _separator : u32) -> [Field; 2] {} - -pub fn pedersen_hash(input : [Field; N]) -> Field { - pedersen_hash_with_separator(input, 0) -} - -#[foreign(pedersen_hash)] -pub fn pedersen_hash_with_separator(_input : [Field; N], _separator : u32) -> Field {} - -#[foreign(hash_to_field_128_security)] -pub fn hash_to_field(_input : [Field; N]) -> Field {} - -#[foreign(keccak256)] -pub fn keccak256(_input : [u8; N], _message_size: u32) -> [u8; 32] {} - -// mimc-p/p implementation -// constants are (publicly generated) random numbers, for instance using keccak as a ROM. -// You must use constants generated for the native field -// Rounds number should be ~ log(p)/log(exp) -// For 254 bit primes, exponent 7 and 91 rounds seems to be recommended -fn mimc(x: Field, k: Field, constants: [Field; N], exp : Field) -> Field { - //round 0 - let mut t = x + k; - let mut h = t.pow_32(exp); - //next rounds - for i in 1 .. constants.len() { - t = h + k + constants[i]; - h = t.pow_32(exp); - }; - h + k -} - -global MIMC_BN254_ROUNDS = 91; - -//mimc implementation with hardcoded parameters for BN254 curve. -pub fn mimc_bn254(array: [Field; N]) -> Field { - //mimc parameters - let exponent = 7; - //generated from seed "mimc" using keccak256 - let constants: [Field; MIMC_BN254_ROUNDS] = [ - 0, - 20888961410941983456478427210666206549300505294776164667214940546594746570981, - 15265126113435022738560151911929040668591755459209400716467504685752745317193, - 8334177627492981984476504167502758309043212251641796197711684499645635709656, - 1374324219480165500871639364801692115397519265181803854177629327624133579404, - 11442588683664344394633565859260176446561886575962616332903193988751292992472, - 2558901189096558760448896669327086721003508630712968559048179091037845349145, - 11189978595292752354820141775598510151189959177917284797737745690127318076389, - 3262966573163560839685415914157855077211340576201936620532175028036746741754, - 17029914891543225301403832095880481731551830725367286980611178737703889171730, - 4614037031668406927330683909387957156531244689520944789503628527855167665518, - 19647356996769918391113967168615123299113119185942498194367262335168397100658, - 5040699236106090655289931820723926657076483236860546282406111821875672148900, - 2632385916954580941368956176626336146806721642583847728103570779270161510514, - 17691411851977575435597871505860208507285462834710151833948561098560743654671, - 11482807709115676646560379017491661435505951727793345550942389701970904563183, - 8360838254132998143349158726141014535383109403565779450210746881879715734773, - 12663821244032248511491386323242575231591777785787269938928497649288048289525, - 3067001377342968891237590775929219083706800062321980129409398033259904188058, - 8536471869378957766675292398190944925664113548202769136103887479787957959589, - 19825444354178182240559170937204690272111734703605805530888940813160705385792, - 16703465144013840124940690347975638755097486902749048533167980887413919317592, - 13061236261277650370863439564453267964462486225679643020432589226741411380501, - 10864774797625152707517901967943775867717907803542223029967000416969007792571, - 10035653564014594269791753415727486340557376923045841607746250017541686319774, - 3446968588058668564420958894889124905706353937375068998436129414772610003289, - 4653317306466493184743870159523234588955994456998076243468148492375236846006, - 8486711143589723036499933521576871883500223198263343024003617825616410932026, - 250710584458582618659378487568129931785810765264752039738223488321597070280, - 2104159799604932521291371026105311735948154964200596636974609406977292675173, - 16313562605837709339799839901240652934758303521543693857533755376563489378839, - 6032365105133504724925793806318578936233045029919447519826248813478479197288, - 14025118133847866722315446277964222215118620050302054655768867040006542798474, - 7400123822125662712777833064081316757896757785777291653271747396958201309118, - 1744432620323851751204287974553233986555641872755053103823939564833813704825, - 8316378125659383262515151597439205374263247719876250938893842106722210729522, - 6739722627047123650704294650168547689199576889424317598327664349670094847386, - 21211457866117465531949733809706514799713333930924902519246949506964470524162, - 13718112532745211817410303291774369209520657938741992779396229864894885156527, - 5264534817993325015357427094323255342713527811596856940387954546330728068658, - 18884137497114307927425084003812022333609937761793387700010402412840002189451, - 5148596049900083984813839872929010525572543381981952060869301611018636120248, - 19799686398774806587970184652860783461860993790013219899147141137827718662674, - 19240878651604412704364448729659032944342952609050243268894572835672205984837, - 10546185249390392695582524554167530669949955276893453512788278945742408153192, - 5507959600969845538113649209272736011390582494851145043668969080335346810411, - 18177751737739153338153217698774510185696788019377850245260475034576050820091, - 19603444733183990109492724100282114612026332366576932662794133334264283907557, - 10548274686824425401349248282213580046351514091431715597441736281987273193140, - 1823201861560942974198127384034483127920205835821334101215923769688644479957, - 11867589662193422187545516240823411225342068709600734253659804646934346124945, - 18718569356736340558616379408444812528964066420519677106145092918482774343613, - 10530777752259630125564678480897857853807637120039176813174150229243735996839, - 20486583726592018813337145844457018474256372770211860618687961310422228379031, - 12690713110714036569415168795200156516217175005650145422920562694422306200486, - 17386427286863519095301372413760745749282643730629659997153085139065756667205, - 2216432659854733047132347621569505613620980842043977268828076165669557467682, - 6309765381643925252238633914530877025934201680691496500372265330505506717193, - 20806323192073945401862788605803131761175139076694468214027227878952047793390, - 4037040458505567977365391535756875199663510397600316887746139396052445718861, - 19948974083684238245321361840704327952464170097132407924861169241740046562673, - 845322671528508199439318170916419179535949348988022948153107378280175750024, - 16222384601744433420585982239113457177459602187868460608565289920306145389382, - 10232118865851112229330353999139005145127746617219324244541194256766741433339, - 6699067738555349409504843460654299019000594109597429103342076743347235369120, - 6220784880752427143725783746407285094967584864656399181815603544365010379208, - 6129250029437675212264306655559561251995722990149771051304736001195288083309, - 10773245783118750721454994239248013870822765715268323522295722350908043393604, - 4490242021765793917495398271905043433053432245571325177153467194570741607167, - 19596995117319480189066041930051006586888908165330319666010398892494684778526, - 837850695495734270707668553360118467905109360511302468085569220634750561083, - 11803922811376367215191737026157445294481406304781326649717082177394185903907, - 10201298324909697255105265958780781450978049256931478989759448189112393506592, - 13564695482314888817576351063608519127702411536552857463682060761575100923924, - 9262808208636973454201420823766139682381973240743541030659775288508921362724, - 173271062536305557219323722062711383294158572562695717740068656098441040230, - 18120430890549410286417591505529104700901943324772175772035648111937818237369, - 20484495168135072493552514219686101965206843697794133766912991150184337935627, - 19155651295705203459475805213866664350848604323501251939850063308319753686505, - 11971299749478202793661982361798418342615500543489781306376058267926437157297, - 18285310723116790056148596536349375622245669010373674803854111592441823052978, - 7069216248902547653615508023941692395371990416048967468982099270925308100727, - 6465151453746412132599596984628739550147379072443683076388208843341824127379, - 16143532858389170960690347742477978826830511669766530042104134302796355145785, - 19362583304414853660976404410208489566967618125972377176980367224623492419647, - 1702213613534733786921602839210290505213503664731919006932367875629005980493, - 10781825404476535814285389902565833897646945212027592373510689209734812292327, - 4212716923652881254737947578600828255798948993302968210248673545442808456151, - 7594017890037021425366623750593200398174488805473151513558919864633711506220, - 18979889247746272055963929241596362599320706910852082477600815822482192194401, - 13602139229813231349386885113156901793661719180900395818909719758150455500533, - ]; - - let mut r = 0; - for elem in array { - let h = mimc(elem, r, constants, exponent); - r = r + elem + h; - } - r -} -", - }, - "35": { - "path": "/test/module/foo.nr", - "source": "fn bar(param: Field) -> Field { - dep::std::hash::pedersen([param])[0] -}", - }, - }, - }, "events": [], "functions": [ { diff --git a/yarn-project/noir-compiler/src/index.test.ts b/yarn-project/noir-compiler/src/index.test.ts index ead724aca47..39c84e61210 100644 --- a/yarn-project/noir-compiler/src/index.test.ts +++ b/yarn-project/noir-compiler/src/index.test.ts @@ -33,6 +33,7 @@ describe('noir-compiler', () => { const nargoAvailable = isNargoAvailable(); const conditionalDescribe = nargoAvailable ? describe : describe.skip; const conditionalIt = nargoAvailable ? it : it.skip; + const withoutDebug = ({ debug: _debug, ...rest }: ContractArtifact): Omit => rest; function compilerTest(compileFn: (path: string, opts: { log: LogFn }) => Promise) { let compiled: ContractArtifact[]; @@ -41,7 +42,7 @@ describe('noir-compiler', () => { }); it('compiles the test contract', () => { - expect(compiled).toMatchSnapshot(); + expect(compiled.map(withoutDebug)).toMatchSnapshot(); }); it('generates typescript interface', () => { @@ -69,8 +70,6 @@ describe('noir-compiler', () => { compileUsingNargo(projectPath, { log }), ]); - const withoutDebug = ({ debug: _debug, ...rest }: ContractArtifact): Omit => rest; - expect(nargoArtifact.map(withoutDebug)).toEqual(noirWasmArtifact.map(withoutDebug)); }); }); From a536cf12ec55331bed8a6aafe04978fe60613352 Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Wed, 1 Nov 2023 16:13:19 +0000 Subject: [PATCH 3/6] chore: update bootstrap cd use --- yarn-project/bootstrap.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/yarn-project/bootstrap.sh b/yarn-project/bootstrap.sh index e5bc73c47de..56dfd3fe574 100755 --- a/yarn-project/bootstrap.sh +++ b/yarn-project/bootstrap.sh @@ -17,16 +17,14 @@ set -eu yarn install --immutable # Build the necessary dependencies for Aztec.nr contracts typegen. -for DIR in foundation noir-compiler; do - echo "Building $DIR..." - cd $DIR - yarn build - cd .. +for package in "@aztec/foundation" "@aztec/noir-compiler"; do + echo "Building $package" + yarn workspace $package build done # Run remake bindings before building Aztec.nr contracts or l1 contracts as they depend on files created by it. -yarn --cwd circuits.js remake-bindings -yarn --cwd circuits.js remake-constants +yarn workspace @aztec/circuits.js remake-bindings +yarn workspace @aztec/circuits.js remake-constants (cd noir-contracts && ./bootstrap.sh) (cd boxes && ./bootstrap.sh) From f4c008ccf96dfbf3f949c5795bba5637cda23ffc Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Wed, 1 Nov 2023 16:44:36 +0000 Subject: [PATCH 4/6] fix: update noir src fixtures --- .../noir-compiler/src/__snapshots__/index.test.ts.snap | 4 ++-- .../noir-compiler/src/fixtures/test_lib/src/module/foo.nr | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap b/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap index b6d5ee76689..9289b916192 100644 --- a/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap +++ b/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap @@ -6,7 +6,7 @@ exports[`noir-compiler using nargo compiles the test contract 1`] = ` "events": [], "functions": [ { - "bytecode": "H4sIAAAAAAAA/61RQQ7DMAij6bL3QIAGbvvKoqX/f8G0TqVSem4tWTYXC9kZABLsmDY+Q4/7G37e+IAz5tBXKF4DTTdmpSGLcRHptXRiemPxZoqibTEyUtNPMeZuYtWbV3QS7rSq8xph+b6/cOz28GnY4N9pHjr+AWqna3ugAQAA", + "bytecode": "H4sIAAAAAAAA/62QUQqEMAxEY7ew10maxCZ/e5Ut1vufQFRsoX7rQJiZnyG8CAABLk3HfZv3vrX8gbt6/zXHZ6Lpxa0wbDHOIjWnSkx/TF5MUbTMRkZquiRjriaWvXhGJ+FKqzqvbSy+9xeOXHsOA/+TaRwY7+UbOCacAQAA", "functionType": "secret", "isInternal": false, "name": "constructor", @@ -198,7 +198,7 @@ exports[`noir-compiler using wasm binary compiles the test contract 1`] = ` "events": [], "functions": [ { - "bytecode": "H4sIAAAAAAAA/61RQQ7DMAij6bL3QIAGbvvKoqX/f8G0TqVSem4tWTYXC9kZABLsmDY+Q4/7G37e+IAz5tBXKF4DTTdmpSGLcRHptXRiemPxZoqibTEyUtNPMeZuYtWbV3QS7rSq8xph+b6/cOz28GnY4N9pHjr+AWqna3ugAQAA", + "bytecode": "H4sIAAAAAAAA/62QUQqEMAxEY7ew10maxCZ/e5Ut1vufQFRsoX7rQJiZnyG8CAABLk3HfZv3vrX8gbt6/zXHZ6Lpxa0wbDHOIjWnSkx/TF5MUbTMRkZquiRjriaWvXhGJ+FKqzqvbSy+9xeOXHsOA/+TaRwY7+UbOCacAQAA", "functionType": "secret", "isInternal": false, "name": "constructor", diff --git a/yarn-project/noir-compiler/src/fixtures/test_lib/src/module/foo.nr b/yarn-project/noir-compiler/src/fixtures/test_lib/src/module/foo.nr index 61316bc9280..e0c82fb1960 100644 --- a/yarn-project/noir-compiler/src/fixtures/test_lib/src/module/foo.nr +++ b/yarn-project/noir-compiler/src/fixtures/test_lib/src/module/foo.nr @@ -1,3 +1,3 @@ -fn bar(param: Field) -> Field { - dep::std::hash::pedersen([param])[0] -} \ No newline at end of file +pub fn bar(param: Field) -> Field { + dep::std::hash::pedersen_hash([param]) +} From aa4b5b066d551f12fbfe0b7633b325777dfa72db Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Wed, 1 Nov 2023 16:56:13 +0000 Subject: [PATCH 5/6] chore: rethrow --- .../noir-compiler/src/compile/noir/noir-wasm-compiler.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/yarn-project/noir-compiler/src/compile/noir/noir-wasm-compiler.ts b/yarn-project/noir-compiler/src/compile/noir/noir-wasm-compiler.ts index 462e014fcff..d1762387dbb 100644 --- a/yarn-project/noir-compiler/src/compile/noir/noir-wasm-compiler.ts +++ b/yarn-project/noir-compiler/src/compile/noir/noir-wasm-compiler.ts @@ -96,11 +96,9 @@ export class NoirWasmContractCompiler { } catch (err) { if (err instanceof Error && err.name === 'CompileError') { this.#processCompileError(err as CompileError); - } else { - this.#log('Error compiling contract ' + err); } - throw new Error("Couldn't compile contract"); + throw err; } } From 4fbdc95ac27a22f968f96991a95ed5ac247e66b6 Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Thu, 2 Nov 2023 14:16:31 +0000 Subject: [PATCH 6/6] chore: bump noir_wasm --- yarn-project/noir-compiler/package.json | 4 ++-- yarn-project/yarn.lock | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/yarn-project/noir-compiler/package.json b/yarn-project/noir-compiler/package.json index 0e12c1730b5..a437f21d033 100644 --- a/yarn-project/noir-compiler/package.json +++ b/yarn-project/noir-compiler/package.json @@ -47,8 +47,8 @@ "dependencies": { "@aztec/foundation": "workspace:^", "@ltd/j-toml": "^1.38.0", - "@noir-lang/noir_wasm": "0.18.0-a098541.aztec", - "@noir-lang/source-resolver": "0.18.0-a098541.aztec", + "@noir-lang/noir_wasm": "0.18.0-6ca33a2.aztec", + "@noir-lang/source-resolver": "0.18.0-6ca33a2.aztec", "base64-js": "^1.5.1", "commander": "^9.0.0", "fs-extra": "^11.1.1", diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 7431ac8b87d..d967b98b7f9 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -588,8 +588,8 @@ __metadata: "@aztec/foundation": "workspace:^" "@jest/globals": ^29.5.0 "@ltd/j-toml": ^1.38.0 - "@noir-lang/noir_wasm": 0.18.0-a098541.aztec - "@noir-lang/source-resolver": 0.18.0-a098541.aztec + "@noir-lang/noir_wasm": 0.18.0-6ca33a2.aztec + "@noir-lang/source-resolver": 0.18.0-6ca33a2.aztec "@rushstack/eslint-patch": ^1.1.4 "@types/fs-extra": ^11.0.1 "@types/jest": ^29.5.0 @@ -3574,12 +3574,12 @@ __metadata: languageName: node linkType: hard -"@noir-lang/noir_wasm@npm:0.18.0-a098541.aztec": - version: 0.18.0-a098541.aztec - resolution: "@noir-lang/noir_wasm@npm:0.18.0-a098541.aztec" +"@noir-lang/noir_wasm@npm:0.18.0-6ca33a2.aztec": + version: 0.18.0-6ca33a2.aztec + resolution: "@noir-lang/noir_wasm@npm:0.18.0-6ca33a2.aztec" peerDependencies: - "@noir-lang/source-resolver": 0.18.0-a098541.aztec - checksum: 844fe1991a4dec862b242d41fee947d19c2b2e2588490f92c82d230a87f5b0ade53aefcb35e6a520181c9ff81536698ac49fca79df6a28ba6e995f56f36d3a1a + "@noir-lang/source-resolver": 0.18.0-6ca33a2.aztec + checksum: 1654cf4a86b600ad33717306253e94623efb017a9a99fc90a1ecde8b3fe909e8a8b5a339dd84ec5b20daa2c15aa60697cda6b84b90f4f201647f68581a5655be languageName: node linkType: hard @@ -3590,10 +3590,10 @@ __metadata: languageName: node linkType: hard -"@noir-lang/source-resolver@npm:0.18.0-a098541.aztec": - version: 0.18.0-a098541.aztec - resolution: "@noir-lang/source-resolver@npm:0.18.0-a098541.aztec" - checksum: 876640b3577394078e0a9799c9281001038d07cfb8d35d9b6398a4e1d6b071d5db84ff9b271ec4b9582a79352cd41b2e59a27c8b394580a9f57b85d0d0918d76 +"@noir-lang/source-resolver@npm:0.18.0-6ca33a2.aztec": + version: 0.18.0-6ca33a2.aztec + resolution: "@noir-lang/source-resolver@npm:0.18.0-6ca33a2.aztec" + checksum: 95f3426f7c40737be2f40bf793ecc555ecab7f1a782f27fd3dbcbf37197db0d2bf3fe8a5554e69e842cdb59a7e2d11a575d32ef82d92312c438cf892f5a98a6a languageName: node linkType: hard