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

fix: TS LSP being slow #7181

Merged
merged 10 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,5 @@
"**/noir/noir-repo/docs/versioned_docs/**": true
},
"cmake.sourceDirectory": "${workspaceFolder}/barretenberg/cpp",
"typescript.tsserver.maxTsServerMemory": 4096,
}
7 changes: 3 additions & 4 deletions yarn-project/.earthlyignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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/
Expand Down
7 changes: 3 additions & 4 deletions yarn-project/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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/
Expand Down
15 changes: 5 additions & 10 deletions yarn-project/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/accounts/.prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
src/artifacts/*.json
artifacts/*.json
5 changes: 3 additions & 2 deletions yarn-project/accounts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -91,7 +91,8 @@
"files": [
"dest",
"src",
"!*.test.*"
"!*.test.*",
"artifacts"
],
"engines": {
"node": ">=18"
Expand Down
12 changes: 9 additions & 3 deletions yarn-project/accounts/package.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.*"
]
}
12 changes: 10 additions & 2 deletions yarn-project/accounts/scripts/copy-contracts.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF
import { type NoirCompiledContract } from '@aztec/types/noir';
const circuit: NoirCompiledContract;
export = circuit;
EOF
);

for contract in "${contracts[@]}"; do
cp "../../noir-projects/noir-contracts/target/$contract.json" ./src/artifacts/${contract#*-}.json
cp "../../noir-projects/noir-contracts/target/$contract.json" ./artifacts/${contract#*-}.json
echo "$decl" > ./artifacts/${contract#*-}.d.json.ts
done
2 changes: 1 addition & 1 deletion yarn-project/accounts/src/ecdsa/artifact.ts
Original file line number Diff line number Diff line change
@@ -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);
2 changes: 1 addition & 1 deletion yarn-project/accounts/src/schnorr/artifact.ts
Original file line number Diff line number Diff line change
@@ -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);
2 changes: 1 addition & 1 deletion yarn-project/accounts/src/single_key/artifact.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/accounts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
"path": "../types"
}
],
"include": ["src", "src/**/*.json"]
"include": ["src", "artifacts/*.d.json.ts"]
}
10 changes: 5 additions & 5 deletions yarn-project/noir-contracts.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -73,4 +73,4 @@
"engines": {
"node": ">=18"
}
}
}
4 changes: 2 additions & 2 deletions yarn-project/noir-contracts.js/package.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
9 changes: 9 additions & 0 deletions yarn-project/noir-contracts.js/scripts/generate-types.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,21 @@ echo "// Auto generated module - do not edit!" >"$INDEX"
# Ensure the artifacts directory exists
mkdir -p artifacts

decl=$(cat <<EOF
import { type NoirCompiledContract } from '@aztec/types/noir';
const circuit: NoirCompiledContract;
export = circuit;
EOF
);

for ABI in $(find ../../noir-projects/noir-contracts/target -maxdepth 1 -type f ! -name 'debug_*' -name '*.json'); do
# Extract the filename from the path
filename=$(basename "$ABI")
dts_file=$(echo $filename | sed 's/.json/.d.json.ts/g');

# Copy the JSON file to the artifacts folder
cp "$ABI" "artifacts/$filename"
echo "$decl" > "artifacts/$dts_file"
done

# Generate types for the contracts
Expand Down
5 changes: 2 additions & 3 deletions yarn-project/noir-contracts.js/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "..",
"compilerOptions": {
"outDir": "dest",
"rootDir": ".",
"rootDir": "src",
"tsBuildInfoFile": ".tsbuildinfo"
},
"references": [
Expand All @@ -15,8 +15,7 @@
],
"include": [
"src",
"artifacts",
"artifacts/*.json"
"artifacts/*.d.json.ts"
],
"exclude": [
"dest"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/noir-protocol-circuits-types/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
crates
src/target
artifacts
7 changes: 4 additions & 3 deletions yarn-project/noir-protocol-circuits-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -82,7 +82,8 @@
"files": [
"dest",
"src",
"!*.test.*"
"!*.test.*",
"artifacts"
],
"types": "./dest/index.d.ts",
"engines": {
Expand Down
12 changes: 9 additions & 3 deletions yarn-project/noir-protocol-circuits-types/package.local.json
Original file line number Diff line number Diff line change
@@ -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.*"
]
}
Loading
Loading