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: Use yarns topological build to get rid of explicit sequential steps, and let it solve. #4868

Merged
merged 32 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4c907af
Move noir subrepo
charlielye Feb 27, 2024
4e9fe0a
path updates. only build needed packages.
charlielye Feb 27, 2024
e4c5d01
Merge remote-tracking branch 'origin' into cl/min_noir_build
charlielye Feb 27, 2024
1359311
path fixes
charlielye Feb 27, 2024
dc2d741
path fixes
charlielye Feb 27, 2024
1c6392e
path fixes
charlielye Feb 28, 2024
43be395
Run all noir tests in ci. Slow. Might need splitting out into separat…
charlielye Feb 28, 2024
6095911
fix dep
charlielye Feb 28, 2024
8a668fe
Separate noir build and test.
charlielye Feb 28, 2024
c127417
fix
charlielye Feb 28, 2024
ae34166
No-repo was a bad idea. We really need it for build state tracking. U…
charlielye Feb 28, 2024
a15d06c
Docker too clever and nooped scratch. rm dir instead.
charlielye Feb 28, 2024
4c67bbd
This might work.
charlielye Feb 28, 2024
e59a00f
fix
charlielye Feb 28, 2024
b62268d
fix
charlielye Feb 28, 2024
fad332f
Merge remote-tracking branch 'origin/master' into cl/min_noir_build
charlielye Feb 28, 2024
f5196d9
use yarn topological build
charlielye Feb 28, 2024
aa92c54
constants sol is handled out of ci.
charlielye Feb 28, 2024
4a8ea92
Merge branch 'master' into cl/yp-build-improv
charlielye Feb 29, 2024
90e5869
Fix dep
charlielye Mar 1, 2024
9576162
fix
charlielye Mar 1, 2024
5a7f0d7
Merge branch 'master' into cl/yp-build-improv
charlielye Mar 1, 2024
bab6c1c
Fast incremental.
charlielye Mar 1, 2024
65931ed
Fallback to full build if incremental fails.
charlielye Mar 1, 2024
eb8dbce
prject ref
charlielye Mar 1, 2024
d21ea9e
constant generator shouldnt need foundation.
charlielye Mar 1, 2024
842f461
Don't rebuild constants.
charlielye Mar 1, 2024
95067ad
fix formatting
charlielye Mar 1, 2024
bf291a0
fix formatting
charlielye Mar 1, 2024
a71e690
fix formatting
charlielye Mar 1, 2024
3b7d37b
Review cleanup.
charlielye Mar 1, 2024
31b0de5
Performance improv
charlielye Mar 2, 2024
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
2 changes: 1 addition & 1 deletion build-system/scripts/remove_old_images
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ REPOSITORY=$1
shift

IMAGE_COMMIT_URI=$(calculate_image_uri $REPOSITORY)
for IMAGE in $(docker images --format "{{.ID}}" aztecprotocol/$REPOSITORY --filter "before=$IMAGE_COMMIT_URI"); do
for IMAGE in $(docker images --format "{{.ID}}" $ECR_URL/$REPOSITORY --filter "before=$IMAGE_COMMIT_URI"); do
echo "Removing $IMAGE..."
docker rmi --force $IMAGE
done
14 changes: 7 additions & 7 deletions noir-projects/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ fi
# Attempt to just pull artefacts from CI and exit on success.
[ -n "${USE_CACHE:-}" ] && ./bootstrap_cache.sh && exit

PROJECTS=(
noir-contracts
noir-protocol-circuits
)
g="\033[32m" # Green
b="\033[34m" # Blue
r="\033[0m" # Reset

for PROJECT in "${PROJECTS[@]}"; do
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can delete PROJECTS since it's left unused

(cd "./$PROJECT" && ./bootstrap.sh "$@")
done
((cd "./noir-contracts" && ./bootstrap.sh) > >(awk -v g="$g" -v r="$r" '$0=g"contracts: "r $0')) &
((cd "./noir-protocol-circuits" && ./bootstrap.sh) > >(awk -v b="$b" -v r="$r" '$0=b"protocol-circuits: "r $0')) &

wait
2 changes: 1 addition & 1 deletion yarn-project/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ noir-contracts.js/**/*.json
boxes/*/src/artifacts/*.json
boxes/*/src/artifacts/*.ts
boxes/*/src/contracts/target/*.json
*.md
*.md
20 changes: 3 additions & 17 deletions yarn-project/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# 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.
# This should *only* build what is necessary to:
# - Run the tests.
# - Run the formatter checks.
# Any subsequent build steps needed to support downstream containers should be done in those containers build files.
# This base dockerfile adds all the remaining source files and builds the project.
# See yarn-project-base/Dockerfile for why we have separate base Dockerfile.
FROM aztecprotocol/l1-contracts as contracts
FROM aztecprotocol/noir-projects as noir-projects
FROM aztecprotocol/boxes-files as boxes-files
Expand All @@ -13,15 +9,5 @@ COPY --from=contracts /usr/src/l1-contracts /usr/src/l1-contracts
COPY --from=noir-projects /usr/src/noir-projects /usr/src/noir-projects
COPY --from=boxes-files /usr/src/boxes /usr/src/boxes
COPY . .
# Generate L1 contract TypeScript artifacts.
RUN cd l1-artifacts && ./scripts/generate-artifacts.sh && rm -rf /usr/src/l1-contracts
# This is actually our code generation tool. Needed to build contract typescript wrappers.
RUN yarn workspace @aztec/noir-compiler build
# Generates typescript wrappers.
RUN yarn workspace @aztec/noir-contracts.js build
# We need to build accounts as it needs to copy in account contracts from noir-contracts.
RUN yarn workspace @aztec/accounts build:copy-contracts
RUN yarn workspace @aztec/protocol-contracts build:copy-contracts
RUN yarn workspace @aztec/noir-protocol-circuits-types build
RUN yarn tsc -b
RUN ./bootstrap.sh
ENTRYPOINT ["yarn"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

<3

1 change: 1 addition & 0 deletions yarn-project/accounts/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/artifacts/*.json
4 changes: 2 additions & 2 deletions yarn-project/accounts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"tsconfig": "./tsconfig.json"
},
"scripts": {
"build": "yarn clean && yarn build:copy-contracts && tsc -b",
"build:copy-contracts": "./scripts/copy-contracts.sh",
"build": "yarn clean && yarn generate && tsc -b",
"generate": "./scripts/copy-contracts.sh",
"build:dev": "tsc -b --watch",
"build:ts": "tsc -b",
"clean": "rm -rf ./dest .tsbuildinfo ./src/artifacts",
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/accounts/package.local.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"scripts": {
"build": "yarn clean && yarn build:copy-contracts && tsc -b",
"build:copy-contracts": "./scripts/copy-contracts.sh",
"build": "yarn clean && yarn generate && tsc -b",
"generate": "./scripts/copy-contracts.sh",
"build:dev": "tsc -b --watch",
"build:ts": "tsc -b",
"clean": "rm -rf ./dest .tsbuildinfo ./src/artifacts"
Expand Down
6 changes: 2 additions & 4 deletions yarn-project/accounts/scripts/copy-contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@ mkdir -p ./src/artifacts
contracts=(schnorr_account_contract-SchnorrAccount ecdsa_account_contract-EcdsaAccount schnorr_single_key_account_contract-SchnorrSingleKeyAccount)

for contract in "${contracts[@]}"; do
cp "../noir-contracts.js/artifacts/$contract.json" ./src/artifacts/${contract#*-}.json
done

yarn run -T prettier -w ./src/artifacts
cp "../../noir-projects/noir-contracts/target/$contract.json" ./src/artifacts/${contract#*-}.json
done
41 changes: 16 additions & 25 deletions yarn-project/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ major=${node_version%%.*}
rest=${node_version#*.}
minor=${rest%%.*}

YELLOW="\033[93m"
BLUE="\033[34m"
GREEN="\033[32m"
BOLD="\033[1m"
RESET="\033[0m"

if ((major < 18 || (major == 18 && minor < 19))); then
echo "Node.js version is less than 18.19. Exiting."
exit 1
Expand All @@ -27,32 +33,17 @@ if [ -n "$CMD" ]; then
fi
fi

# Fast build does not delete everything first.
# It regenerates all generated code, then performs an incremental tsc build.
echo -e "${BLUE}${BOLD}Attempting fast incremental build...${RESET}"
echo
yarn install --immutable

echo -e "\033[1mGenerating constants files...\033[0m"
# Required to run remake-constants.
yarn workspace @aztec/foundation build
# Run remake constants before building Aztec.nr contracts or l1 contracts as they depend on files created by it.
yarn workspace @aztec/circuits.js remake-constants

echo -e "\033[1mSetting up compiler and building contracts...\033[0m"
# This is actually our code generation tool. Needed to build contract typescript wrappers.
echo "Building noir compiler..."
yarn workspace @aztec/noir-compiler build
# Builds noir contracts (TODO: move this stage pre yarn-project). Generates typescript wrappers.
echo "Building contracts from noir-contracts..."
yarn workspace @aztec/noir-contracts.js build
# Bundle compiled contracts into other packages
echo "Copying account contracts..."
yarn workspace @aztec/accounts build:copy-contracts
echo "Copying protocol contracts..."
yarn workspace @aztec/protocol-contracts build:copy-contracts
# Build protocol circuits. TODO: move pre yarn-project.
echo "Building circuits from noir-protocol-circuits..."
yarn workspace @aztec/noir-protocol-circuits-types build

echo -e "\033[1mBuilding all packages...\033[0m"
yarn build
if ! yarn build:fast; then
echo -e "${YELLOW}${BOLD}Incremental build failed for some reason, attempting full build...${RESET}"
echo
yarn build
fi

echo
echo "Yarn project successfully built."
echo -e "${GREEN}Yarn project successfully built!${RESET}"
4 changes: 2 additions & 2 deletions yarn-project/circuits.js/src/scripts/constants.in.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { fileURLToPath } from '@aztec/foundation/url';

import * as fs from 'fs';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';

const NOIR_CONSTANTS_FILE = '../../../../noir-projects/noir-protocol-circuits/crates/types/src/constants.nr';
const TS_CONSTANTS_FILE = '../constants.gen.ts';
Expand Down Expand Up @@ -157,6 +156,7 @@ function main(): void {

// Solidity
const solidityTargetPath = join(__dirname, SOLIDITY_CONSTANTS_FILE);
fs.mkdirSync(dirname(solidityTargetPath), { recursive: true });
generateSolidityConstants(parsedContent, solidityTargetPath);
}

Expand Down
1 change: 1 addition & 0 deletions yarn-project/noir-compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"scripts": {
"build": "yarn clean && tsc -b",
"build:dev": "tsc -b --watch",
"generate": "tsc -b",
"clean": "rm -rf ./dest .tsbuildinfo",
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
Expand Down
5 changes: 3 additions & 2 deletions yarn-project/noir-contracts.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"./*": "./dest/src/*.js"
},
"scripts": {
"build": "yarn clean && yarn build:contracts && yarn formatting:fix",
"build": "yarn clean && yarn generate",
"build:dev": "tsc -b --watch",
"clean": "rm -rf .tsbuildinfo ./artifacts ./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 $(yarn bin jest) --passWithNoTests",
"build:contracts": "./scripts/generate-types.sh"
"generate": "./scripts/generate-types.sh && run -T prettier -w ./src"
},
"inherits": [
"../package.common.json",
Expand All @@ -33,6 +33,7 @@
"tslib": "^2.4.0"
},
"devDependencies": {
"@aztec/noir-compiler": "workspace:^",
"@jest/globals": "^29.5.0",
"@types/jest": "^29.5.0",
"jest": "^29.5.0",
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/noir-contracts.js/package.local.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"scripts": {
"build": "yarn clean && yarn build:contracts && yarn formatting:fix",
"build:contracts": "./scripts/generate-types.sh",
"build": "yarn clean && yarn generate",
"generate": "./scripts/generate-types.sh && run -T prettier -w ./src",
"clean": "rm -rf .tsbuildinfo ./artifacts ./codegenCache.json"
}
}
}
13 changes: 11 additions & 2 deletions yarn-project/noir-contracts.js/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@
"references": [
{
"path": "../aztec.js"
},
{
"path": "../noir-compiler"
}
],
"include": ["src", "artifacts", "artifacts/*.json"],
"exclude": ["dest"]
"include": [
"src",
"artifacts",
"artifacts/*.json"
],
"exclude": [
"dest"
]
}
4 changes: 2 additions & 2 deletions yarn-project/noir-protocol-circuits-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"./types": "./dest/types/index.js"
},
"scripts": {
"build": "yarn clean && yarn noir:types && tsc -b",
"build": "yarn clean && yarn generate && tsc -b",
"clean": "rm -rf ./dest .tsbuildinfo src/types src/target",
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
"formatting:fix": "NODE_OPTIONS='--max-old-space-size=8096' 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",
"noir:types": "cp -r ../../noir-projects/noir-protocol-circuits/target ./src/target && node --loader ts-node/esm src/scripts/generate_ts_from_abi.ts && yarn formatting:fix:types",
"generate": "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",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests"
},
"jest": {
Expand Down
8 changes: 5 additions & 3 deletions yarn-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
"formatting:fix": "FORCE_COLOR=true yarn workspaces foreach -p -v run formatting:fix",
"lint": "yarn eslint --cache --ignore-pattern l1-artifacts .",
"format": "yarn prettier --cache -w .",
"test": "FORCE_COLOR=true yarn workspaces foreach --exclude @aztec/aztec3-packages --exclude @aztec/end-to-end --exclude private-token -p -j ${JOBS:-unlimited} -v run test",
"build": "yarn workspace @aztec/l1-artifacts build && tsc -b tsconfig.json",
"build:dev": "yarn workspace @aztec/l1-artifacts build && tsc -b tsconfig.json --watch",
"test": "FORCE_COLOR=true yarn workspaces foreach --exclude @aztec/aztec3-packages --exclude @aztec/end-to-end -p -j ${JOBS:-unlimited} -v run test",
"build": "FORCE_COLOR=true yarn workspaces foreach --parallel --topological-dev --verbose --exclude @aztec/aztec3-packages --exclude @aztec/docs run build",
"build:fast": "yarn generate && tsc -b",
"build:dev": "tsc -b tsconfig.json --watch",
"generate": "FORCE_COLOR=true yarn workspaces foreach --parallel --topological-dev --verbose run generate",
"clean": "yarn workspaces foreach -p -v run clean"
},
"workspaces": [
Expand Down
1 change: 1 addition & 0 deletions yarn-project/protocol-contracts/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/artifacts/*.json
4 changes: 2 additions & 2 deletions yarn-project/protocol-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"tsconfig": "./tsconfig.json"
},
"scripts": {
"build": "yarn clean && yarn build:copy-contracts && tsc -b",
"build:copy-contracts": "./scripts/copy-contracts.sh",
"build": "yarn clean && yarn generate && tsc -b",
"generate": "./scripts/copy-contracts.sh",
"build:dev": "tsc -b --watch",
"build:ts": "tsc -b",
"clean": "rm -rf ./dest .tsbuildinfo ./src/artifacts",
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/protocol-contracts/package.local.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"scripts": {
"build": "yarn clean && yarn build:copy-contracts && tsc -b",
"build:copy-contracts": "./scripts/copy-contracts.sh",
"build": "yarn clean && yarn generate && tsc -b",
"generate": "./scripts/copy-contracts.sh",
"build:dev": "tsc -b --watch",
"build:ts": "tsc -b",
"clean": "rm -rf ./dest .tsbuildinfo ./src/artifacts"
Expand Down
6 changes: 2 additions & 4 deletions yarn-project/protocol-contracts/scripts/copy-contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@ contracts=(
)

for contract in "${contracts[@]}"; do
cp "../noir-contracts.js/artifacts/$contract.json" ./src/artifacts/${contract#*-}.json
done

yarn run -T prettier -w ./src/artifacts
cp "../../noir-projects/noir-contracts/target/$contract.json" ./src/artifacts/${contract#*-}.json
done
1 change: 1 addition & 0 deletions yarn-project/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ __metadata:
resolution: "@aztec/noir-contracts.js@workspace:noir-contracts.js"
dependencies:
"@aztec/aztec.js": "workspace:^"
"@aztec/noir-compiler": "workspace:^"
"@jest/globals": ^29.5.0
"@types/jest": ^29.5.0
jest: ^29.5.0
Expand Down
Loading