Skip to content

Commit

Permalink
fix(ci): check if l1 contracts img has been deployed (#3531)
Browse files Browse the repository at this point in the history
  • Loading branch information
spypsy authored Dec 4, 2023
1 parent c3b9cce commit ac1f03c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 33 deletions.
2 changes: 0 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ jobs:
create_ecr_manifest cli x86_64,arm64
create_ecr_manifest aztec-faucet x86_64
create_ecr_manifest mainnet-fork x86_64
create_ecr_manifest l1-contracts x86_64
boxes-blank-react:
machine:
Expand Down Expand Up @@ -996,7 +995,6 @@ jobs:
deploy_dockerhub cli x86_64,arm64
deploy_dockerhub aztec-faucet x86_64
deploy_dockerhub mainnet-fork x86_64
deploy_dockerhub l1-contracts x86_64
deploy-devnet:
machine:
Expand Down
2 changes: 0 additions & 2 deletions build-system/scripts/setup_env
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ echo export DEPLOY_TAG=$DEPLOY_TAG >> $BASH_ENV
echo export BRANCH=$BRANCH >> $BASH_ENV
echo export PULL_REQUEST=$PULL_REQUEST >> $BASH_ENV
echo export DRY_DEPLOY=${DRY_DEPLOY:-0} >> $BASH_ENV
echo export FORK_API_KEY=${FORK_API_KEY:-} >> $BASH_ENV
echo export CONTRACT_PUBLISHER_PRIVATE_KEY=${CONTRACT_PUBLISHER_PRIVATE_KEY:-} >> $BASH_ENV

# We want very strict failures on any failing command, undefined variable, or commands that pipe to other commands.
echo set -euo pipefail >> $BASH_ENV
Expand Down
15 changes: 9 additions & 6 deletions l1-contracts/scripts/ci_deploy_contracts.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/bash

FORCE_DEPLOY=${2:-"false"}

export ETHEREUM_HOST=$DEPLOY_TAG-mainnet-fork.aztec.network:8545/$FORK_API_KEY

REPOSITORY="l1-contracts"

CONTENT_HASH=$(calculate_content_hash $REPOSITORY)

# If we have previously successful commit, we can early out if nothing relevant has changed since.
if [[ $FORCE_DEPLOY == 'false' ]] && check_rebuild cache-"$CONTENT_HASH" $REPOSITORY; then
echo "No contract deploy necessary."
echo "Last successfully published commit: $CONTENT_HASH"

# Check if image hash has alredy been deployed.
if check_rebuild "cache-$CONTENT_HASH-$DEPLOY_TAG-deployed" $REPOSITORY; then
echo "No changes detected, no contract deploy necessary."
exit 0
fi

Expand All @@ -19,7 +19,7 @@ mkdir -p serve
docker run \
-v $(pwd)/serve:/usr/src/contracts/serve \
-e ETHEREUM_HOST=$ETHEREUM_HOST -e PRIVATE_KEY=$CONTRACT_PUBLISHER_PRIVATE_KEY \
aztecprotocol/l1-contracts:$DEPLOY_TAG \
"$ECR_URL/l1-contracts:cache-$CONTENT_HASH"-x86_64 \
./scripts/deploy_contracts.sh

# Write the contract addresses as terraform variables
Expand All @@ -30,3 +30,6 @@ done

# Write TF state variables
deploy_terraform l1-contracts ./terraform

# Tag the image as deployed.
retry tag_remote_image $REPOSITORY cache-$CONTENT_HASH cache-$CONTENT_HASH-$DEPLOY_TAG-deployed
43 changes: 20 additions & 23 deletions yarn-project/noir-contracts/scripts/types.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#!/bin/bash

# Example:
Expand All @@ -8,7 +7,7 @@

# Enable strict mode:
# Exit on error (set -e), treat unset variables as an error (set -u),
set -eu;
set -eu

artifacts_dir="src/artifacts"
types_dir="src/types"
Expand All @@ -17,42 +16,40 @@ types_dir="src/types"
mkdir -p $types_dir
mkdir -p $artifacts_dir


ROOT=$(pwd)

write_import() {
CONTRACT_NAME=$1
NAME=$(echo $CONTRACT_NAME | perl -pe 's/(^|_)(\w)/\U$2/g')
CONTRACT_NAME=$1
NAME=$(echo $CONTRACT_NAME | perl -pe 's/(^|_)(\w)/\U$2/g')

echo "import ${NAME}Json from './${CONTRACT_NAME}_contract.json' assert { type: 'json' };" >> "$artifacts_dir/index.ts";
echo "import ${NAME}Json from './${CONTRACT_NAME}_contract.json' assert { type: 'json' };" >>"$artifacts_dir/index.ts"
}

write_export() {
CONTRACT_NAME=$1
NAME=$(echo $CONTRACT_NAME | perl -pe 's/(^|_)(\w)/\U$2/g')
CONTRACT_NAME=$1
NAME=$(echo $CONTRACT_NAME | perl -pe 's/(^|_)(\w)/\U$2/g')

# artifacts
echo "export const ${NAME}ContractArtifact = ${NAME}Json as ContractArtifact;" >> "$artifacts_dir/index.ts";
echo "Written typescript for $NAME"
# artifacts
echo "export const ${NAME}ContractArtifact = ${NAME}Json as ContractArtifact;" >>"$artifacts_dir/index.ts"
echo "Written typescript for $NAME"

# types
echo "export * from './${CONTRACT_NAME}.js';" >> "$types_dir/index.ts";
# types
echo "export * from './${CONTRACT_NAME}.js';" >>"$types_dir/index.ts"
}


process() {
CONTRACT=$1

cd $ROOT
NODE_OPTIONS=--no-warnings yarn ts-node --esm src/scripts/copy_source.ts $CONTRACT_NAME
NODE_OPTIONS="--no-warnings --loader ts-node/esm" yarn ts-node --esm src/scripts/copy_source.ts $CONTRACT_NAME

echo "Creating types for $CONTRACT"
NODE_OPTIONS=--no-warnings yarn ts-node --esm src/scripts/copy_output.ts $CONTRACT_NAME
NODE_OPTIONS="--no-warnings --loader ts-node/esm" yarn ts-node --esm src/scripts/copy_output.ts $CONTRACT_NAME
}

format(){
format() {
echo "Formatting contract folders"
yarn run -T prettier -w ../aztec.js/src/artifacts/*.json ./$types_dir/*.ts
yarn run -T prettier -w ../aztec.js/src/artifacts/*.json ./$types_dir/*.ts
echo -e "Done\n"
}

Expand All @@ -69,14 +66,14 @@ wait
rm -f $artifacts_dir/index.ts || true

# Generate artifacts package index.ts
echo "// Auto generated module\n" > "$artifacts_dir/index.ts";
echo "import { ContractArtifact } from '@aztec/foundation/abi';" >> "$artifacts_dir/index.ts";
echo "// Auto generated module\n" >"$artifacts_dir/index.ts"
echo "import { ContractArtifact } from '@aztec/foundation/abi';" >>"$artifacts_dir/index.ts"

# Generate types package index.ts
echo "// Auto generated module\n" > "$types_dir/index.ts";
echo "// Auto generated module\n" >"$types_dir/index.ts"
for CONTRACT_NAME in "$@"; do
write_import $CONTRACT_NAME
write_export $CONTRACT_NAME
write_import $CONTRACT_NAME
write_export $CONTRACT_NAME
done

# only run the rest when the full flag is set
Expand Down

0 comments on commit ac1f03c

Please sign in to comment.