Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: compile noir contracts with noir_wasm #2737

Merged
merged 35 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1035a8a
perf: avoid second yarn install
alexghr Oct 23, 2023
6dcff34
feat: add noir_wasm
alexghr Oct 23, 2023
9fe0024
refactor: remove nargo
alexghr Oct 23, 2023
50176b6
refactor: alternative way to patch ts-jest
alexghr Oct 25, 2023
ec6024c
fix: include yarn patches in yarn-project-base
alexghr Oct 25, 2023
007abef
fix: common package.json
alexghr Oct 25, 2023
d9c2810
ci: add noir-compiler-build to cci config
alexghr Oct 25, 2023
6466bb3
chore: update noir_wasm
alexghr Oct 25, 2023
6d0fba2
refactor: remove noir-contracts-build image
alexghr Oct 25, 2023
45e243b
fix: yarn-project docker image
alexghr Oct 25, 2023
ad8df0e
chore: purge noir-version.json
alexghr Oct 25, 2023
1d481e5
Merge branch 'master' into alexg/feat/noir-wasm
alexghr Oct 25, 2023
d299290
chore: lint
alexghr Oct 25, 2023
71c1bf3
chore: update acvm
alexghr Oct 26, 2023
1b328b2
fix: resolve project path before compiling
alexghr Oct 26, 2023
82c01e2
fix: throw an error if can't compile
alexghr Oct 26, 2023
ec25afb
test: update expected error messages
alexghr Oct 26, 2023
bea08d0
chore: restore nargo
alexghr Oct 26, 2023
f3fea51
chore: fix nargo snapshot tests in CI
alexghr Oct 26, 2023
e43465b
fix: specify correct type for compiler flag
alexghr Oct 26, 2023
89ea930
Update yarn-project/noir-compiler/src/compile/noir/dependencies/githu…
alexghr Oct 27, 2023
eb8c172
Update yarn-project/noir-compiler/src/compile/noir/dependencies/githu…
alexghr Oct 27, 2023
bdbb0af
Update yarn-project/noir-compiler/src/compile/noir/noir-wasm-compiler.ts
alexghr Oct 27, 2023
8317f5f
fix: address code review
alexghr Oct 27, 2023
f8c7c7d
fix: add zod to parse Nargo.toml
alexghr Oct 27, 2023
fed8f58
refactor: only look at src directory
alexghr Oct 27, 2023
66283b4
fix: safely generate a filename from a git url
alexghr Oct 27, 2023
bf4244d
fix: add comment to ts-jest patch
alexghr Oct 27, 2023
62975d3
refactor: use memfs
alexghr Oct 27, 2023
54a002e
fix: write deps to tmp files and atomically move
alexghr Oct 27, 2023
f957f14
fix: code review
alexghr Oct 27, 2023
f34ddf1
fix: binary is latin1
alexghr Oct 27, 2023
334d51f
fix: tmp directory when extracting
alexghr Oct 27, 2023
df88d72
Merge remote-tracking branch 'origin/master' into alexg/feat/noir-wasm
alexghr Oct 27, 2023
85d15c4
chore: update package.json
alexghr Oct 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions yarn-project/.yarn/patches/ts-jest-npm-29.1.1-04e888e48e.patch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why was this needed? Not something that can be fixed via jest config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@noir-lang/source-resolver uses global scope to keep a function to read file contents with. This is used by @noir-lang/noir_wasm. The wasm compiler loads it as CJS so we have to load it as CJS also. I used .cts file to do this and the jest plugin we use to compile TS at runtime doesn't support .cts files yet kulshekhar/ts-jest#3996

alexghr marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/dist/constants.js b/dist/constants.js
index 15a900a5ea36e38e7344d5713cdffa1edbdd539d..879c59892b4bd13470146d82a17691dd8ac0d25b 100644
--- a/dist/constants.js
+++ b/dist/constants.js
@@ -4,8 +4,8 @@ exports.DEFAULT_JEST_TEST_MATCH = exports.JS_EXT_TO_TREAT_AS_ESM = exports.TS_EX
exports.LINE_FEED = '\n';
exports.DECLARATION_TYPE_EXT = '.d.ts';
exports.JS_JSX_EXTENSIONS = ['.js', '.jsx'];
-exports.TS_TSX_REGEX = /\.m?tsx?$/;
-exports.JS_JSX_REGEX = /\.m?jsx?$/;
+exports.TS_TSX_REGEX = /\.[cm]?tsx?$/;
+exports.JS_JSX_REGEX = /\.[cm]?jsx?$/;
// `extensionsToTreatAsEsm` will throw error with `.mjs`
exports.TS_EXT_TO_TREAT_AS_ESM = ['.ts', '.tsx', '.mts'];
exports.JS_EXT_TO_TREAT_AS_ESM = ['.jsx'];
2 changes: 1 addition & 1 deletion yarn-project/acir-simulator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"jest": {
"preset": "ts-jest/presets/default-esm",
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.m?js$": "$1"
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
},
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
"rootDir": "./src"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/archiver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"jest": {
"preset": "ts-jest/presets/default-esm",
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.m?js$": "$1"
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
},
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
"rootDir": "./src"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-faucet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"jest": {
"preset": "ts-jest/presets/default-esm",
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.m?js$": "$1"
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
},
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
"rootDir": "./src"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"jest": {
"preset": "ts-jest/presets/default-esm",
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.m?js$": "$1"
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
},
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
"rootDir": "./src"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-sandbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"jest": {
"preset": "ts-jest/presets/default-esm",
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.m?js$": "$1"
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
},
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
"rootDir": "./src"
Expand Down
2 changes: 1 addition & 1 deletion 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 NoirVersion from '@aztec/noir-compiler/noir-version';
import { NoirVersion } from '@aztec/noir-compiler/noir-version';
import { createPXERpcServer } from '@aztec/pxe';

import { readFileSync } from 'fs';
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"jest": {
"preset": "ts-jest/presets/default-esm",
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.m?js$": "$1"
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
},
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
"rootDir": "./src"
Expand Down
2 changes: 0 additions & 2 deletions yarn-project/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ yarn --cwd circuits.js remake-constants
(cd boxes && ./bootstrap.sh)
(cd .. && l1-contracts/bootstrap.sh)

# Until we push .yarn/cache, we still need to install.
yarn
# We do not need to build individual packages, yarn build will build the root tsconfig.json
yarn build

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"jest": {
"preset": "ts-jest/presets/default-esm",
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.m?js$": "$1"
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
},
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
"rootDir": "./src"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"jest": {
"preset": "ts-jest/presets/default-esm",
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.m?js$": "$1"
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
},
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
"rootDir": "./src"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/cli/src/unbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export async function unboxContract(

if (!contractNames.includes(contractName)) {
log(
`The noir contract named "${contractName}" was not found in "@aztec/boxes" package. Valid options are:
`The noir contract named "${contractName}" was not found in "@aztec/boxes" package. Valid options are:
${contractNames.join('\n\t')}
We recommend "token" as a default.`,
);
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/ethereum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"jest": {
"preset": "ts-jest/presets/default-esm",
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.m?js$": "$1"
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
},
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
"rootDir": "./src"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/foundation/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = {
plugins: ['@typescript-eslint', 'eslint-plugin-tsdoc', 'jsdoc', 'no-only-tests'],
overrides: [
{
files: ['*.ts', '*.tsx'],
files: ['*.cts', '*.ts', '*.tsx'],
alexghr marked this conversation as resolved.
Show resolved Hide resolved
parserOptions: {
// hacky workaround for CI not having the same tsconfig setup
project: true,
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/foundation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"jest": {
"preset": "ts-jest/presets/default-esm",
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.m?js$": "$1"
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
},
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
"rootDir": "./src"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/key-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"jest": {
"preset": "ts-jest/presets/default-esm",
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.m?js$": "$1"
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
},
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
"rootDir": "./src"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/merkle-tree/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"jest": {
"preset": "ts-jest/presets/default-esm",
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.m?js$": "$1"
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
},
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
"rootDir": "./src",
Expand Down
17 changes: 14 additions & 3 deletions yarn-project/noir-compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,23 @@
"jest": {
"preset": "ts-jest/presets/default-esm",
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.m?js$": "$1"
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
},
"moduleFileExtensions": [
"js",
"ts",
"cts"
],
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
"rootDir": "./src"
"rootDir": "./src",
"transform": {
"^.+\\.cts$": "ts-jest"
}
},
"dependencies": {
"@aztec/foundation": "workspace:^",
"@noir-lang/noir_wasm": "0.18.0-3919619.aztec",
"@noir-lang/source-resolver": "0.18.0-3919619.aztec",
"base64-js": "^1.5.1",
"commander": "^9.0.0",
"fs-extra": "^11.1.1",
Expand All @@ -48,7 +58,8 @@
"lodash.upperfirst": "^4.3.1",
"pako": "^2.1.0",
"toml": "^3.0.0",
"tslib": "^2.4.0"
"tslib": "^2.4.0",
"unzipit": "^1.4.3"
},
"devDependencies": {
"@jest/globals": "^29.5.0",
Expand Down
Loading