From e934e872d5a2fb3ca46646436de25777a33c4737 Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Thu, 27 Jun 2024 19:42:41 +0100 Subject: [PATCH] fix: TS LSP being slow (#7181) Potential fix for Typescript LSP being slow. Based on https://github.com/microsoft/TypeScript/issues/42761#issuecomment-778368320 and https://github.com/microsoft/TypeScript/issues/52994 --------- Co-authored-by: Santiago Palladino --- .vscode/settings.json | 1 + yarn-project/.earthlyignore | 7 +- yarn-project/.gitignore | 7 +- yarn-project/Earthfile | 15 ++-- yarn-project/accounts/.prettierignore | 2 +- yarn-project/accounts/package.json | 5 +- yarn-project/accounts/package.local.json | 12 +++- .../accounts/scripts/copy-contracts.sh | 12 +++- yarn-project/accounts/src/ecdsa/artifact.ts | 2 +- yarn-project/accounts/src/schnorr/artifact.ts | 2 +- .../accounts/src/single_key/artifact.ts | 2 +- yarn-project/accounts/tsconfig.json | 2 +- yarn-project/noir-contracts.js/package.json | 10 +-- .../noir-contracts.js/package.local.json | 4 +- .../scripts/generate-types.sh | 9 +++ yarn-project/noir-contracts.js/tsconfig.json | 5 +- .../.prettierignore | 2 +- .../noir-protocol-circuits-types/package.json | 7 +- .../package.local.json | 12 +++- .../noir-protocol-circuits-types/src/index.ts | 68 +++++++++---------- .../src/scripts/generate_declaration_files.ts | 17 +++++ .../src/scripts/generate_ts_from_abi.ts | 2 +- .../tsconfig.json | 6 +- .../protocol-contracts/.prettierignore | 2 +- yarn-project/protocol-contracts/package.json | 5 +- .../protocol-contracts/package.local.json | 12 +++- .../scripts/copy-contracts.sh | 13 +++- .../src/auth-registry/artifact.ts | 2 +- .../src/class-registerer/artifact.ts | 2 +- .../src/gas-token/artifact.ts | 2 +- .../src/instance-deployer/artifact.ts | 2 +- .../src/key-registry/artifact.ts | 2 +- .../src/multi-call-entrypoint/artifact.ts | 2 +- yarn-project/protocol-contracts/tsconfig.json | 2 +- .../simulator/src/public/public_kernel.ts | 3 +- yarn-project/simulator/src/rollup/rollup.ts | 4 +- yarn-project/tsconfig.json | 5 +- yarn-project/types/src/noir/index.ts | 2 + 38 files changed, 167 insertions(+), 104 deletions(-) create mode 100644 yarn-project/noir-protocol-circuits-types/src/scripts/generate_declaration_files.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index 86a0427f790..630178ad32a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -169,4 +169,5 @@ "**/noir/noir-repo/docs/versioned_docs/**": true }, "cmake.sourceDirectory": "${workspaceFolder}/barretenberg/cpp", + "typescript.tsserver.maxTsServerMemory": 4096, } diff --git a/yarn-project/.earthlyignore b/yarn-project/.earthlyignore index 90a25913737..bd9d331e9a6 100644 --- a/yarn-project/.earthlyignore +++ b/yarn-project/.earthlyignore @@ -39,10 +39,9 @@ cmake-build-debug **/tsconfig.tsbuildinfo **/.eslintcache **/target -accounts/src/artifacts +accounts/artifacts aztec-faucet/data* aztec-node/data* -aztec-js/src/account_contract/artifacts aztec/log circuits.js/fixtures/*.json docs/dist @@ -51,8 +50,8 @@ end-to-end/log end-to-end/data end-to-end/src/web/main.js end-to-end/src/web/main.js.LICENSE.txt -entry-points/src/artifacts l1-contracts/generated +noir-protocol-circuits-types/artifacts builder/target/ builder/proofs/ builder/Prover.toml @@ -64,7 +63,7 @@ builder/Verifier.toml builder/src/target builder/src/crs builder/src/types -protocol-contracts/src/artifacts +protocol-contracts/artifacts scripts/tmp noir-contracts.js/src noir-contracts.js/artifacts/ diff --git a/yarn-project/.gitignore b/yarn-project/.gitignore index e92d481c252..e044af6d3bd 100644 --- a/yarn-project/.gitignore +++ b/yarn-project/.gitignore @@ -12,10 +12,9 @@ **/.debounce-* **/.tsc.pid **/*.result -accounts/src/artifacts +accounts/artifacts aztec-faucet/data* aztec-node/data* -aztec-js/src/account_contract/artifacts aztec/log circuits.js/fixtures/*.json circuits.js/src/structs/kernel/private_kernel_reset_circuit_private_inputs_variants.ts @@ -25,9 +24,9 @@ end-to-end/log end-to-end/data end-to-end/src/web/main.js end-to-end/src/web/main.js.LICENSE.txt -entry-points/src/artifacts l1-artifacts/generated l1-contracts/generated +noir-protocol-circuits-types/artifacts builder/target/ builder/proofs/ builder/Prover.toml @@ -40,7 +39,7 @@ builder/src/target builder/src/crs builder/src/types noir-protocol-circuits-types/src/types/ -protocol-contracts/src/artifacts +protocol-contracts/artifacts scripts/tmp noir-contracts.js/src noir-contracts.js/artifacts/ diff --git a/yarn-project/Earthfile b/yarn-project/Earthfile index 1f4e2fdc790..162949f4a43 100644 --- a/yarn-project/Earthfile +++ b/yarn-project/Earthfile @@ -73,8 +73,7 @@ bb-cli: ../barretenberg/ts/dest/browser \ aztec.js/dest/main.js \ end-to-end \ - **/src \ - **/artifacts + **/src # yarn symlinks the binary to node_modules/.bin ENTRYPOINT ["/usr/src/yarn-project/node_modules/.bin/bb-cli"] @@ -124,8 +123,7 @@ txe: ../l1-contracts \ ../barretenberg/ts/src \ ../barretenberg/ts/dest/node-cjs \ - ../barretenberg/ts/dest/browser \ - **/artifacts + ../barretenberg/ts/dest/browser SAVE ARTIFACT /usr/src /usr/src aztec-prod: @@ -140,8 +138,7 @@ aztec-prod: ../barretenberg/ts/dest/browser \ aztec.js/dest/main.js \ end-to-end \ - **/src \ - **/artifacts + **/src COPY --dir +rollup-verifier-contract/usr/src/bb /usr/src SAVE ARTIFACT /usr/src /usr/src @@ -172,8 +169,7 @@ aztec-faucet-build: ../barretenberg/ts/dest/browser \ aztec.js/dest/main.js \ end-to-end \ - **/src \ - **/artifacts + **/src SAVE ARTIFACT /usr/src /usr/src aztec-faucet: @@ -193,8 +189,7 @@ end-to-end-prod: ../l1-contracts \ ../barretenberg/ts/src \ ../barretenberg/ts/dest/node-cjs \ - ../barretenberg/ts/dest/browser \ - **/artifacts + ../barretenberg/ts/dest/browser COPY --dir +rollup-verifier-contract/usr/src/bb /usr/src SAVE ARTIFACT /usr/src /usr/src diff --git a/yarn-project/accounts/.prettierignore b/yarn-project/accounts/.prettierignore index 2ade63ee6f9..eb6b23ceb90 100644 --- a/yarn-project/accounts/.prettierignore +++ b/yarn-project/accounts/.prettierignore @@ -1 +1 @@ -src/artifacts/*.json \ No newline at end of file +artifacts/*.json \ No newline at end of file diff --git a/yarn-project/accounts/package.json b/yarn-project/accounts/package.json index 90d2d36ab83..b1209964ae4 100644 --- a/yarn-project/accounts/package.json +++ b/yarn-project/accounts/package.json @@ -28,7 +28,7 @@ "generate:noir-contracts": "./scripts/copy-contracts.sh", "build:dev": "tsc -b --watch", "build:ts": "tsc -b", - "clean": "rm -rf ./dest .tsbuildinfo ./src/artifacts", + "clean": "rm -rf ./dest .tsbuildinfo ./artifacts", "formatting": "run -T prettier --check ./src && run -T eslint ./src", "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src", "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests" @@ -91,7 +91,8 @@ "files": [ "dest", "src", - "!*.test.*" + "!*.test.*", + "artifacts" ], "engines": { "node": ">=18" diff --git a/yarn-project/accounts/package.local.json b/yarn-project/accounts/package.local.json index c5987104cfc..6e3a34a9358 100644 --- a/yarn-project/accounts/package.local.json +++ b/yarn-project/accounts/package.local.json @@ -5,6 +5,12 @@ "generate:noir-contracts": "./scripts/copy-contracts.sh", "build:dev": "tsc -b --watch", "build:ts": "tsc -b", - "clean": "rm -rf ./dest .tsbuildinfo ./src/artifacts" - } -} + "clean": "rm -rf ./dest .tsbuildinfo ./artifacts" + }, + "files": [ + "dest", + "src", + "artifacts", + "!*.test.*" + ] +} \ No newline at end of file diff --git a/yarn-project/accounts/scripts/copy-contracts.sh b/yarn-project/accounts/scripts/copy-contracts.sh index 8b945155a9d..5984357006a 100755 --- a/yarn-project/accounts/scripts/copy-contracts.sh +++ b/yarn-project/accounts/scripts/copy-contracts.sh @@ -1,9 +1,17 @@ #! /bin/bash set -euo pipefail -mkdir -p ./src/artifacts +mkdir -p ./artifacts contracts=(schnorr_account_contract-SchnorrAccount ecdsa_account_contract-EcdsaAccount schnorr_single_key_account_contract-SchnorrSingleKeyAccount) +decl=$(cat < ./artifacts/${contract#*-}.d.json.ts done \ No newline at end of file diff --git a/yarn-project/accounts/src/ecdsa/artifact.ts b/yarn-project/accounts/src/ecdsa/artifact.ts index 54ec3212dd0..a38c97a094f 100644 --- a/yarn-project/accounts/src/ecdsa/artifact.ts +++ b/yarn-project/accounts/src/ecdsa/artifact.ts @@ -1,5 +1,5 @@ import { type NoirCompiledContract, loadContractArtifact } from '@aztec/aztec.js'; -import EcdsaAccountContractJson from '../artifacts/EcdsaAccount.json' assert { type: 'json' }; +import EcdsaAccountContractJson from '../../artifacts/EcdsaAccount.json' assert { type: 'json' }; export const EcdsaAccountContractArtifact = loadContractArtifact(EcdsaAccountContractJson as NoirCompiledContract); diff --git a/yarn-project/accounts/src/schnorr/artifact.ts b/yarn-project/accounts/src/schnorr/artifact.ts index f7cac3337f7..88c1c5d1e4e 100644 --- a/yarn-project/accounts/src/schnorr/artifact.ts +++ b/yarn-project/accounts/src/schnorr/artifact.ts @@ -1,5 +1,5 @@ import { type NoirCompiledContract, loadContractArtifact } from '@aztec/aztec.js'; -import SchnorrAccountContractJson from '../artifacts/SchnorrAccount.json' assert { type: 'json' }; +import SchnorrAccountContractJson from '../../artifacts/SchnorrAccount.json' assert { type: 'json' }; export const SchnorrAccountContractArtifact = loadContractArtifact(SchnorrAccountContractJson as NoirCompiledContract); diff --git a/yarn-project/accounts/src/single_key/artifact.ts b/yarn-project/accounts/src/single_key/artifact.ts index 55a819dc570..f48ee9a14e8 100644 --- a/yarn-project/accounts/src/single_key/artifact.ts +++ b/yarn-project/accounts/src/single_key/artifact.ts @@ -1,6 +1,6 @@ import { type NoirCompiledContract, loadContractArtifact } from '@aztec/aztec.js'; -import SchnorrSingleKeyAccountContractJson from '../artifacts/SchnorrSingleKeyAccount.json' assert { type: 'json' }; +import SchnorrSingleKeyAccountContractJson from '../../artifacts/SchnorrSingleKeyAccount.json' assert { type: 'json' }; export const SchnorrSingleKeyAccountContractArtifact = loadContractArtifact( SchnorrSingleKeyAccountContractJson as NoirCompiledContract, diff --git a/yarn-project/accounts/tsconfig.json b/yarn-project/accounts/tsconfig.json index 0b48acf92f7..62dae97b860 100644 --- a/yarn-project/accounts/tsconfig.json +++ b/yarn-project/accounts/tsconfig.json @@ -28,5 +28,5 @@ "path": "../types" } ], - "include": ["src", "src/**/*.json"] + "include": ["src", "artifacts/*.d.json.ts"] } diff --git a/yarn-project/noir-contracts.js/package.json b/yarn-project/noir-contracts.js/package.json index 881226f0a93..0a86d66706b 100644 --- a/yarn-project/noir-contracts.js/package.json +++ b/yarn-project/noir-contracts.js/package.json @@ -3,14 +3,14 @@ "version": "0.1.0", "type": "module", "exports": { - ".": "./dest/src/index.js", - "./artifacts/*": "./dest/artifacts/*.json", - "./*": "./dest/src/*.js" + ".": "./dest/index.js", + "./artifacts/*": "./artifacts/*.json", + "./*": "./dest/*.js" }, "scripts": { "build": "yarn clean && yarn generate", "build:dev": "tsc -b --watch", - "clean": "rm -rf .tsbuildinfo ./artifacts ./codegenCache.json", + "clean": "rm -rf ./dest .tsbuildinfo ./artifacts ./src ./codegenCache.json", "formatting": "run -T prettier --check ./src && run -T eslint ./src", "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src", "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests", @@ -73,4 +73,4 @@ "engines": { "node": ">=18" } -} +} \ No newline at end of file diff --git a/yarn-project/noir-contracts.js/package.local.json b/yarn-project/noir-contracts.js/package.local.json index 5dd3e0100f9..4cab71fc4dd 100644 --- a/yarn-project/noir-contracts.js/package.local.json +++ b/yarn-project/noir-contracts.js/package.local.json @@ -3,6 +3,6 @@ "build": "yarn clean && yarn generate", "generate": "yarn generate:noir-contracts", "generate:noir-contracts": "./scripts/generate-types.sh && run -T prettier -w ./src --loglevel warn", - "clean": "rm -rf .tsbuildinfo ./artifacts ./codegenCache.json" + "clean": "rm -rf ./dest .tsbuildinfo ./artifacts ./src ./codegenCache.json" } -} +} \ No newline at end of file diff --git a/yarn-project/noir-contracts.js/scripts/generate-types.sh b/yarn-project/noir-contracts.js/scripts/generate-types.sh index f7355440508..8c1168b24e8 100755 --- a/yarn-project/noir-contracts.js/scripts/generate-types.sh +++ b/yarn-project/noir-contracts.js/scripts/generate-types.sh @@ -19,12 +19,21 @@ echo "// Auto generated module - do not edit!" >"$INDEX" # Ensure the artifacts directory exists mkdir -p artifacts +decl=$(cat < "artifacts/$dts_file" done # Generate types for the contracts diff --git a/yarn-project/noir-contracts.js/tsconfig.json b/yarn-project/noir-contracts.js/tsconfig.json index caf5e40c801..92add33fb36 100644 --- a/yarn-project/noir-contracts.js/tsconfig.json +++ b/yarn-project/noir-contracts.js/tsconfig.json @@ -2,7 +2,7 @@ "extends": "..", "compilerOptions": { "outDir": "dest", - "rootDir": ".", + "rootDir": "src", "tsBuildInfoFile": ".tsbuildinfo" }, "references": [ @@ -15,8 +15,7 @@ ], "include": [ "src", - "artifacts", - "artifacts/*.json" + "artifacts/*.d.json.ts" ], "exclude": [ "dest" diff --git a/yarn-project/noir-protocol-circuits-types/.prettierignore b/yarn-project/noir-protocol-circuits-types/.prettierignore index 595a24e0611..2adf7da0bda 100644 --- a/yarn-project/noir-protocol-circuits-types/.prettierignore +++ b/yarn-project/noir-protocol-circuits-types/.prettierignore @@ -1,2 +1,2 @@ crates -src/target +artifacts diff --git a/yarn-project/noir-protocol-circuits-types/package.json b/yarn-project/noir-protocol-circuits-types/package.json index dab1d3a0e72..4f1b5e1fd38 100644 --- a/yarn-project/noir-protocol-circuits-types/package.json +++ b/yarn-project/noir-protocol-circuits-types/package.json @@ -12,12 +12,12 @@ ], "scripts": { "build": "yarn clean && yarn generate && tsc -b", - "clean": "rm -rf ./dest .tsbuildinfo src/types src/target", + "clean": "rm -rf ./dest .tsbuildinfo src/types artifacts", "formatting": "run -T prettier --check ./src && run -T eslint ./src", "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src", "formatting:fix:types": "NODE_OPTIONS='--max-old-space-size=8096' run -T eslint --fix ./src/types && run -T prettier -w ./src/types", "generate": "yarn generate:noir-circuits", - "generate:noir-circuits": "mkdir -p ./src/target && cp ../../noir-projects/noir-protocol-circuits/target/* ./src/target && node --no-warnings --loader ts-node/esm src/scripts/generate_ts_from_abi.ts && run -T prettier -w ./src/types", + "generate:noir-circuits": "mkdir -p ./artifacts && cp ../../noir-projects/noir-protocol-circuits/target/* ./artifacts && node --no-warnings --loader ts-node/esm src/scripts/generate_declaration_files.ts && node --no-warnings --loader ts-node/esm src/scripts/generate_ts_from_abi.ts && run -T prettier -w ./src/types", "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests", "codegen": "yarn noir-codegen", "build:dev": "tsc -b --watch" @@ -82,7 +82,8 @@ "files": [ "dest", "src", - "!*.test.*" + "!*.test.*", + "artifacts" ], "types": "./dest/index.d.ts", "engines": { diff --git a/yarn-project/noir-protocol-circuits-types/package.local.json b/yarn-project/noir-protocol-circuits-types/package.local.json index 9ade866233e..e3deaa112a7 100644 --- a/yarn-project/noir-protocol-circuits-types/package.local.json +++ b/yarn-project/noir-protocol-circuits-types/package.local.json @@ -1,6 +1,12 @@ { "scripts": { "build": "yarn clean && yarn generate && tsc -b", - "clean": "rm -rf ./dest .tsbuildinfo src/types src/target" - } -} + "clean": "rm -rf ./dest .tsbuildinfo src/types artifacts" + }, + "files": [ + "dest", + "src", + "artifacts", + "!*.test.*" + ] +} \ No newline at end of file diff --git a/yarn-project/noir-protocol-circuits-types/src/index.ts b/yarn-project/noir-protocol-circuits-types/src/index.ts index b6ba9bd4097..789ff0f92f7 100644 --- a/yarn-project/noir-protocol-circuits-types/src/index.ts +++ b/yarn-project/noir-protocol-circuits-types/src/index.ts @@ -30,40 +30,40 @@ import { type Abi, abiDecode, abiEncode } from '@noir-lang/noirc_abi'; import { type WitnessMap } from '@noir-lang/types'; import { strict as assert } from 'assert'; -import EmptyNestedJson from './target/empty_nested.json' assert { type: 'json' }; -import EmptyNestedSimulatedJson from './target/empty_nested_simulated.json' assert { type: 'json' }; -import BaseParityJson from './target/parity_base.json' assert { type: 'json' }; -import RootParityJson from './target/parity_root.json' assert { type: 'json' }; -import PrivateKernelEmptyJson from './target/private_kernel_empty.json' assert { type: 'json' }; -import PrivateKernelEmptySimulatedJson from './target/private_kernel_empty_simulated.json' assert { type: 'json' }; -import PrivateKernelInitJson from './target/private_kernel_init.json' assert { type: 'json' }; -import PrivateKernelInitSimulatedJson from './target/private_kernel_init_simulated.json' assert { type: 'json' }; -import PrivateKernelInnerJson from './target/private_kernel_inner.json' assert { type: 'json' }; -import PrivateKernelInnerSimulatedJson from './target/private_kernel_inner_simulated.json' assert { type: 'json' }; -import PrivateKernelResetJson from './target/private_kernel_reset.json' assert { type: 'json' }; -import PrivateKernelResetBigJson from './target/private_kernel_reset_big.json' assert { type: 'json' }; -import PrivateKernelResetMediumJson from './target/private_kernel_reset_medium.json' assert { type: 'json' }; -import PrivateKernelResetSimulatedJson from './target/private_kernel_reset_simulated.json' assert { type: 'json' }; -import PrivateKernelResetBigSimulatedJson from './target/private_kernel_reset_simulated_big.json' assert { type: 'json' }; -import PrivateKernelResetMediumSimulatedJson from './target/private_kernel_reset_simulated_medium.json' assert { type: 'json' }; -import PrivateKernelResetSmallSimulatedJson from './target/private_kernel_reset_simulated_small.json' assert { type: 'json' }; -import PrivateKernelResetSmallJson from './target/private_kernel_reset_small.json' assert { type: 'json' }; -import PrivateKernelTailJson from './target/private_kernel_tail.json' assert { type: 'json' }; -import PrivateKernelTailSimulatedJson from './target/private_kernel_tail_simulated.json' assert { type: 'json' }; -import PrivateKernelTailToPublicJson from './target/private_kernel_tail_to_public.json' assert { type: 'json' }; -import PrivateKernelTailToPublicSimulatedJson from './target/private_kernel_tail_to_public_simulated.json' assert { type: 'json' }; -import PublicKernelAppLogicJson from './target/public_kernel_app_logic.json' assert { type: 'json' }; -import PublicKernelAppLogicSimulatedJson from './target/public_kernel_app_logic_simulated.json' assert { type: 'json' }; -import PublicKernelSetupJson from './target/public_kernel_setup.json' assert { type: 'json' }; -import PublicKernelSetupSimulatedJson from './target/public_kernel_setup_simulated.json' assert { type: 'json' }; -import PublicKernelTailJson from './target/public_kernel_tail.json' assert { type: 'json' }; -import PublicKernelTailSimulatedJson from './target/public_kernel_tail_simulated.json' assert { type: 'json' }; -import PublicKernelTeardownJson from './target/public_kernel_teardown.json' assert { type: 'json' }; -import PublicKernelTeardownSimulatedJson from './target/public_kernel_teardown_simulated.json' assert { type: 'json' }; -import BaseRollupJson from './target/rollup_base.json' assert { type: 'json' }; -import BaseRollupSimulatedJson from './target/rollup_base_simulated.json' assert { type: 'json' }; -import MergeRollupJson from './target/rollup_merge.json' assert { type: 'json' }; -import RootRollupJson from './target/rollup_root.json' assert { type: 'json' }; +import EmptyNestedJson from '../artifacts/empty_nested.json' assert { type: 'json' }; +import EmptyNestedSimulatedJson from '../artifacts/empty_nested_simulated.json' assert { type: 'json' }; +import BaseParityJson from '../artifacts/parity_base.json' assert { type: 'json' }; +import RootParityJson from '../artifacts/parity_root.json' assert { type: 'json' }; +import PrivateKernelEmptyJson from '../artifacts/private_kernel_empty.json' assert { type: 'json' }; +import PrivateKernelEmptySimulatedJson from '../artifacts/private_kernel_empty_simulated.json' assert { type: 'json' }; +import PrivateKernelInitJson from '../artifacts/private_kernel_init.json' assert { type: 'json' }; +import PrivateKernelInitSimulatedJson from '../artifacts/private_kernel_init_simulated.json' assert { type: 'json' }; +import PrivateKernelInnerJson from '../artifacts/private_kernel_inner.json' assert { type: 'json' }; +import PrivateKernelInnerSimulatedJson from '../artifacts/private_kernel_inner_simulated.json' assert { type: 'json' }; +import PrivateKernelResetJson from '../artifacts/private_kernel_reset.json' assert { type: 'json' }; +import PrivateKernelResetBigJson from '../artifacts/private_kernel_reset_big.json' assert { type: 'json' }; +import PrivateKernelResetMediumJson from '../artifacts/private_kernel_reset_medium.json' assert { type: 'json' }; +import PrivateKernelResetSimulatedJson from '../artifacts/private_kernel_reset_simulated.json' assert { type: 'json' }; +import PrivateKernelResetBigSimulatedJson from '../artifacts/private_kernel_reset_simulated_big.json' assert { type: 'json' }; +import PrivateKernelResetMediumSimulatedJson from '../artifacts/private_kernel_reset_simulated_medium.json' assert { type: 'json' }; +import PrivateKernelResetSmallSimulatedJson from '../artifacts/private_kernel_reset_simulated_small.json' assert { type: 'json' }; +import PrivateKernelResetSmallJson from '../artifacts/private_kernel_reset_small.json' assert { type: 'json' }; +import PrivateKernelTailJson from '../artifacts/private_kernel_tail.json' assert { type: 'json' }; +import PrivateKernelTailSimulatedJson from '../artifacts/private_kernel_tail_simulated.json' assert { type: 'json' }; +import PrivateKernelTailToPublicJson from '../artifacts/private_kernel_tail_to_public.json' assert { type: 'json' }; +import PrivateKernelTailToPublicSimulatedJson from '../artifacts/private_kernel_tail_to_public_simulated.json' assert { type: 'json' }; +import PublicKernelAppLogicJson from '../artifacts/public_kernel_app_logic.json' assert { type: 'json' }; +import PublicKernelAppLogicSimulatedJson from '../artifacts/public_kernel_app_logic_simulated.json' assert { type: 'json' }; +import PublicKernelSetupJson from '../artifacts/public_kernel_setup.json' assert { type: 'json' }; +import PublicKernelSetupSimulatedJson from '../artifacts/public_kernel_setup_simulated.json' assert { type: 'json' }; +import PublicKernelTailJson from '../artifacts/public_kernel_tail.json' assert { type: 'json' }; +import PublicKernelTailSimulatedJson from '../artifacts/public_kernel_tail_simulated.json' assert { type: 'json' }; +import PublicKernelTeardownJson from '../artifacts/public_kernel_teardown.json' assert { type: 'json' }; +import PublicKernelTeardownSimulatedJson from '../artifacts/public_kernel_teardown_simulated.json' assert { type: 'json' }; +import BaseRollupJson from '../artifacts/rollup_base.json' assert { type: 'json' }; +import BaseRollupSimulatedJson from '../artifacts/rollup_base_simulated.json' assert { type: 'json' }; +import MergeRollupJson from '../artifacts/rollup_merge.json' assert { type: 'json' }; +import RootRollupJson from '../artifacts/rollup_root.json' assert { type: 'json' }; import { mapBaseOrMergeRollupPublicInputsFromNoir, mapBaseParityInputsToNoir, diff --git a/yarn-project/noir-protocol-circuits-types/src/scripts/generate_declaration_files.ts b/yarn-project/noir-protocol-circuits-types/src/scripts/generate_declaration_files.ts new file mode 100644 index 00000000000..98a5f2f06b4 --- /dev/null +++ b/yarn-project/noir-protocol-circuits-types/src/scripts/generate_declaration_files.ts @@ -0,0 +1,17 @@ +import { fileURLToPath } from '@aztec/foundation/url'; + +import { readdir, writeFile } from 'fs/promises'; +import { join } from 'path'; + +const content = `\ +import { type NoirCompiledCircuit } from '@aztec/types/noir'; +const circuit: NoirCompiledCircuit; +export = circuit; +`; + +const target = fileURLToPath(new URL('../../artifacts', import.meta.url).href); +const files = await readdir(target); +for (const file of files) { + const name = file.replace('.json', ''); + await writeFile(join(target, `${name}.d.json.ts`), content); +} diff --git a/yarn-project/noir-protocol-circuits-types/src/scripts/generate_ts_from_abi.ts b/yarn-project/noir-protocol-circuits-types/src/scripts/generate_ts_from_abi.ts index 4c3734e42e6..acb52af5f5b 100644 --- a/yarn-project/noir-protocol-circuits-types/src/scripts/generate_ts_from_abi.ts +++ b/yarn-project/noir-protocol-circuits-types/src/scripts/generate_ts_from_abi.ts @@ -45,7 +45,7 @@ const main = async () => { const programs: [string, CompiledCircuit][] = []; // Collect all circuits for (const circuit of circuits) { - const rawData = await fs.readFile(`./src/target/${circuit}.json`, 'utf-8'); + const rawData = await fs.readFile(`./artifacts/${circuit}.json`, 'utf-8'); const abiObj: CompiledCircuit = JSON.parse(rawData); programs.push([pascalCase(circuit), abiObj]); } diff --git a/yarn-project/noir-protocol-circuits-types/tsconfig.json b/yarn-project/noir-protocol-circuits-types/tsconfig.json index 632b9eed778..390735ab54c 100644 --- a/yarn-project/noir-protocol-circuits-types/tsconfig.json +++ b/yarn-project/noir-protocol-circuits-types/tsconfig.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "dest", "rootDir": "src", - "tsBuildInfoFile": ".tsbuildinfo" + "tsBuildInfoFile": ".tsbuildinfo", + "resolveJsonModule": true }, "references": [ { @@ -28,6 +29,5 @@ "path": "../merkle-tree" } ], - "include": ["src", "src/**/*.json"], - "exclude": ["src/contracts"] + "include": ["src", "artifacts/*.d.json.ts"] } diff --git a/yarn-project/protocol-contracts/.prettierignore b/yarn-project/protocol-contracts/.prettierignore index 2ade63ee6f9..eb6b23ceb90 100644 --- a/yarn-project/protocol-contracts/.prettierignore +++ b/yarn-project/protocol-contracts/.prettierignore @@ -1 +1 @@ -src/artifacts/*.json \ No newline at end of file +artifacts/*.json \ No newline at end of file diff --git a/yarn-project/protocol-contracts/package.json b/yarn-project/protocol-contracts/package.json index 48007fea086..c7bff393480 100644 --- a/yarn-project/protocol-contracts/package.json +++ b/yarn-project/protocol-contracts/package.json @@ -23,7 +23,7 @@ "generate:noir-contracts": "./scripts/copy-contracts.sh", "build:dev": "tsc -b --watch", "build:ts": "tsc -b", - "clean": "rm -rf ./dest .tsbuildinfo ./src/artifacts", + "clean": "rm -rf ./dest .tsbuildinfo ./artifacts", "formatting": "run -T prettier --check ./src && run -T eslint ./src", "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src", "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests" @@ -84,7 +84,8 @@ "files": [ "dest", "src", - "!*.test.*" + "!*.test.*", + "artifacts" ], "engines": { "node": ">=18" diff --git a/yarn-project/protocol-contracts/package.local.json b/yarn-project/protocol-contracts/package.local.json index c5987104cfc..6e3a34a9358 100644 --- a/yarn-project/protocol-contracts/package.local.json +++ b/yarn-project/protocol-contracts/package.local.json @@ -5,6 +5,12 @@ "generate:noir-contracts": "./scripts/copy-contracts.sh", "build:dev": "tsc -b --watch", "build:ts": "tsc -b", - "clean": "rm -rf ./dest .tsbuildinfo ./src/artifacts" - } -} + "clean": "rm -rf ./dest .tsbuildinfo ./artifacts" + }, + "files": [ + "dest", + "src", + "artifacts", + "!*.test.*" + ] +} \ No newline at end of file diff --git a/yarn-project/protocol-contracts/scripts/copy-contracts.sh b/yarn-project/protocol-contracts/scripts/copy-contracts.sh index 239445f9bbc..5001bf8c254 100755 --- a/yarn-project/protocol-contracts/scripts/copy-contracts.sh +++ b/yarn-project/protocol-contracts/scripts/copy-contracts.sh @@ -1,6 +1,6 @@ #! /bin/bash set -euo pipefail -mkdir -p ./src/artifacts +mkdir -p ./artifacts contracts=( contract_class_registerer_contract-ContractClassRegisterer @@ -11,6 +11,15 @@ contracts=( multi_call_entrypoint_contract-MultiCallEntrypoint ) + +decl=$(cat < ./artifacts/${contract#*-}.d.json.ts done diff --git a/yarn-project/protocol-contracts/src/auth-registry/artifact.ts b/yarn-project/protocol-contracts/src/auth-registry/artifact.ts index d33c2a9820f..030414f5d45 100644 --- a/yarn-project/protocol-contracts/src/auth-registry/artifact.ts +++ b/yarn-project/protocol-contracts/src/auth-registry/artifact.ts @@ -1,6 +1,6 @@ import { loadContractArtifact } from '@aztec/types/abi'; import { type NoirCompiledContract } from '@aztec/types/noir'; -import AuthRegistryJson from '../artifacts/AuthRegistry.json' assert { type: 'json' }; +import AuthRegistryJson from '../../artifacts/AuthRegistry.json' assert { type: 'json' }; export const AuthRegistryArtifact = loadContractArtifact(AuthRegistryJson as NoirCompiledContract); diff --git a/yarn-project/protocol-contracts/src/class-registerer/artifact.ts b/yarn-project/protocol-contracts/src/class-registerer/artifact.ts index 433bf7b269c..9f1f360b4c5 100644 --- a/yarn-project/protocol-contracts/src/class-registerer/artifact.ts +++ b/yarn-project/protocol-contracts/src/class-registerer/artifact.ts @@ -1,7 +1,7 @@ import { loadContractArtifact } from '@aztec/types/abi'; import { type NoirCompiledContract } from '@aztec/types/noir'; -import ContractClassRegistererJson from '../artifacts/ContractClassRegisterer.json' assert { type: 'json' }; +import ContractClassRegistererJson from '../../artifacts/ContractClassRegisterer.json' assert { type: 'json' }; export const ContractClassRegistererArtifact = loadContractArtifact( ContractClassRegistererJson as NoirCompiledContract, diff --git a/yarn-project/protocol-contracts/src/gas-token/artifact.ts b/yarn-project/protocol-contracts/src/gas-token/artifact.ts index 0dbaf8c2d74..9d83dd2d21b 100644 --- a/yarn-project/protocol-contracts/src/gas-token/artifact.ts +++ b/yarn-project/protocol-contracts/src/gas-token/artifact.ts @@ -1,6 +1,6 @@ import { loadContractArtifact } from '@aztec/types/abi'; import { type NoirCompiledContract } from '@aztec/types/noir'; -import GasTokenJson from '../artifacts/GasToken.json' assert { type: 'json' }; +import GasTokenJson from '../../artifacts/GasToken.json' assert { type: 'json' }; export const GasTokenArtifact = loadContractArtifact(GasTokenJson as NoirCompiledContract); diff --git a/yarn-project/protocol-contracts/src/instance-deployer/artifact.ts b/yarn-project/protocol-contracts/src/instance-deployer/artifact.ts index 809e35873ac..03dffc51462 100644 --- a/yarn-project/protocol-contracts/src/instance-deployer/artifact.ts +++ b/yarn-project/protocol-contracts/src/instance-deployer/artifact.ts @@ -1,7 +1,7 @@ import { loadContractArtifact } from '@aztec/types/abi'; import { type NoirCompiledContract } from '@aztec/types/noir'; -import ContractInstanceDeployerJson from '../artifacts/ContractInstanceDeployer.json' assert { type: 'json' }; +import ContractInstanceDeployerJson from '../../artifacts/ContractInstanceDeployer.json' assert { type: 'json' }; export const ContractInstanceDeployerArtifact = loadContractArtifact( ContractInstanceDeployerJson as NoirCompiledContract, diff --git a/yarn-project/protocol-contracts/src/key-registry/artifact.ts b/yarn-project/protocol-contracts/src/key-registry/artifact.ts index 89436d313e6..5feb280a624 100644 --- a/yarn-project/protocol-contracts/src/key-registry/artifact.ts +++ b/yarn-project/protocol-contracts/src/key-registry/artifact.ts @@ -1,6 +1,6 @@ import { loadContractArtifact } from '@aztec/types/abi'; import { type NoirCompiledContract } from '@aztec/types/noir'; -import KeyRegistryJson from '../artifacts/KeyRegistry.json' assert { type: 'json' }; +import KeyRegistryJson from '../../artifacts/KeyRegistry.json' assert { type: 'json' }; export const KeyRegistryArtifact = loadContractArtifact(KeyRegistryJson as NoirCompiledContract); diff --git a/yarn-project/protocol-contracts/src/multi-call-entrypoint/artifact.ts b/yarn-project/protocol-contracts/src/multi-call-entrypoint/artifact.ts index b3cf23f9f41..9f259a2d824 100644 --- a/yarn-project/protocol-contracts/src/multi-call-entrypoint/artifact.ts +++ b/yarn-project/protocol-contracts/src/multi-call-entrypoint/artifact.ts @@ -1,6 +1,6 @@ import { loadContractArtifact } from '@aztec/types/abi'; import { type NoirCompiledContract } from '@aztec/types/noir'; -import MultiCallEntrypoint from '../artifacts/MultiCallEntrypoint.json' assert { type: 'json' }; +import MultiCallEntrypoint from '../../artifacts/MultiCallEntrypoint.json' assert { type: 'json' }; export const MultiCallEntrypointArtifact = loadContractArtifact(MultiCallEntrypoint as NoirCompiledContract); diff --git a/yarn-project/protocol-contracts/tsconfig.json b/yarn-project/protocol-contracts/tsconfig.json index 01c876235ce..96ab4e32557 100644 --- a/yarn-project/protocol-contracts/tsconfig.json +++ b/yarn-project/protocol-contracts/tsconfig.json @@ -16,5 +16,5 @@ "path": "../types" } ], - "include": ["src", "src/**/*.json"] + "include": ["src", "artifacts/*.d.json.ts"] } diff --git a/yarn-project/simulator/src/public/public_kernel.ts b/yarn-project/simulator/src/public/public_kernel.ts index c48c9ed4512..6910123b54e 100644 --- a/yarn-project/simulator/src/public/public_kernel.ts +++ b/yarn-project/simulator/src/public/public_kernel.ts @@ -21,8 +21,9 @@ import { convertSimulatedPublicTeardownInputsToWitnessMap, convertSimulatedPublicTeardownOutputFromWitnessMap, } from '@aztec/noir-protocol-circuits-types'; -import { type SimulationProvider, WASMSimulator } from '@aztec/simulator'; +import { WASMSimulator } from '../providers/acvm_wasm.js'; +import { type SimulationProvider } from '../providers/simulation_provider.js'; import { type PublicKernelCircuitSimulator } from './public_kernel_circuit_simulator.js'; /** diff --git a/yarn-project/simulator/src/rollup/rollup.ts b/yarn-project/simulator/src/rollup/rollup.ts index 114873499a7..58c72653d8f 100644 --- a/yarn-project/simulator/src/rollup/rollup.ts +++ b/yarn-project/simulator/src/rollup/rollup.ts @@ -28,7 +28,9 @@ import { convertSimulatedBaseRollupInputsToWitnessMap, convertSimulatedBaseRollupOutputsFromWitnessMap, } from '@aztec/noir-protocol-circuits-types'; -import { type SimulationProvider, WASMSimulator } from '@aztec/simulator'; + +import { WASMSimulator } from '../providers/acvm_wasm.js'; +import { type SimulationProvider } from '../providers/simulation_provider.js'; /** * Circuit simulator for the rollup circuits. diff --git a/yarn-project/tsconfig.json b/yarn-project/tsconfig.json index 52b02c625b2..68777079e4a 100644 --- a/yarn-project/tsconfig.json +++ b/yarn-project/tsconfig.json @@ -16,7 +16,8 @@ "resolveJsonModule": true, "composite": true, "skipLibCheck": true, - "noImplicitOverride": true + "noImplicitOverride": true, + "allowArbitraryExtensions": true }, "references": [ { "path": "accounts/tsconfig.json" }, @@ -50,5 +51,5 @@ { "path": "cli/tsconfig.json" } ], "files": ["./@types/jest/index.d.ts"], - "exclude": ["node_modules"] + "exclude": ["node_modules", "**/node_modules", "**/.*/"] } diff --git a/yarn-project/types/src/noir/index.ts b/yarn-project/types/src/noir/index.ts index 7361d6687db..41b860a3719 100644 --- a/yarn-project/types/src/noir/index.ts +++ b/yarn-project/types/src/noir/index.ts @@ -18,6 +18,8 @@ export const AZTEC_VIEW_ATTRIBUTE = 'aztec(view)'; export interface NoirFunctionAbi { /** The parameters of the function. */ parameters: ABIParameter[]; + /** TODO */ + error_types: Record; /** The return type of the function. */ return_type: { /**