Skip to content

Commit

Permalink
Merge branch 'master' into palla/contract-deploy-20
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilWindle committed Mar 4, 2024
2 parents 62f0238 + 6b861bb commit 6d1b67a
Show file tree
Hide file tree
Showing 24 changed files with 81 additions and 84 deletions.
4 changes: 2 additions & 2 deletions barretenberg/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/AztecProtocol/barretenberg
branch = master
commit = 85a786795105adc13b1dc5c34418b09bd6ffe36f
parent = 032874a031ce9a5dde7da20864fbd456061adc43
commit = a3c713311e45192f775bef06080a6a13e7ab5603
parent = e6ce08f6d74db76a45e5dea69d5b7531ca99c769
method = merge
cmdver = 0.4.6
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
(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
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ contract StatefulTest {

#[aztec(public)]
fn increment_public_value(owner: AztecAddress, value: Field) {
assert_is_initialized(&mut context);
let loc = storage.public_values.at(owner);
loc.write(loc.read() + value);
}

#[aztec(public)]
fn increment_public_value_no_init_check(owner: AztecAddress, value: Field) {
let loc = storage.public_values.at(owner);
loc.write(loc.read() + value);
}
Expand Down
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"]
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
3 changes: 2 additions & 1 deletion yarn-project/end-to-end/src/e2e_deploy_contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ describe('e2e_deploy_contract', () => {
// requesting the corresponding contract class.
}, 60_000);

it('broadcasts an unconstrained function', async () => {
// TODO(@spalladino): Reenable this test
it.skip('broadcasts an unconstrained function', async () => {
const functionArtifact = artifact.functions.find(fn => fn.functionType === FunctionType.UNCONSTRAINED)!;
const selector = FunctionSelector.fromNameAndParameters(functionArtifact);
await broadcastUnconstrainedFunction(wallet, artifact, selector).send().wait();
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

0 comments on commit 6d1b67a

Please sign in to comment.