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: deploy l1 contracts on devnet #7306

Merged
merged 43 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
acc1c8f
chore: 1st attempt at automatic devnet deployment
spypsy Jun 20, 2024
d3b6a29
fix FULL_IMAGE var
spypsy Jun 21, 2024
e214015
fix missing vars
spypsy Jun 21, 2024
1a45de7
rm contract address vars
spypsy Jun 21, 2024
368cb6e
fix deploy p2p
spypsy Jun 21, 2024
d38fe6e
fix ecs name
spypsy Jun 24, 2024
26fd7e6
hardcode fork url
spypsy Jun 24, 2024
80253eb
force new deployments
spypsy Jun 24, 2024
16fe39b
hardcode aztec-dev in tf file
spypsy Jun 24, 2024
4ed2e5b
separate node - prover terraforms
spypsy Jun 25, 2024
cdfd127
add data resources
spypsy Jun 25, 2024
7e20a58
add provider block
spypsy Jun 26, 2024
b88a3ea
merge with master
spypsy Jun 26, 2024
a5d45bf
Merge branch 'master' into devnet
spypsy Jun 26, 2024
c19aae1
undo formatting
spypsy Jun 26, 2024
38bc061
undo formatting again
spypsy Jun 26, 2024
a04678a
cancel-in-progress
spypsy Jun 26, 2024
cf32b29
fix ecs task def name
spypsy Jun 26, 2024
2aa4eb0
fix aws_ecs_service name ref
spypsy Jun 26, 2024
b400d3b
fix container names
spypsy Jun 26, 2024
bf8c939
PR fixes
spypsy Jun 28, 2024
543f660
remove ref from main.tf
spypsy Jun 28, 2024
898388c
use deploy_tag again for fork url
spypsy Jun 28, 2024
ce09a75
feat: deploy L1 contracts on GA (#7262)
spypsy Jul 2, 2024
e1a9b5d
chore: redeploy L1 contracts (#7263)
spypsy Jul 2, 2024
2bd87c1
fix: fetch-depth 0 (#7264)
spypsy Jul 2, 2024
7afe0d6
chore: redeploy devnet (#7265)
spypsy Jul 2, 2024
987ba1a
chore: redeploy & log (#7266)
spypsy Jul 2, 2024
1227447
fix: use result key (#7267)
spypsy Jul 2, 2024
49170e4
fix: setup-action (#7268)
spypsy Jul 2, 2024
8c3fcc6
fix: action ordering (#7270)
spypsy Jul 2, 2024
e3c45ec
fix: publish cli image to dockerhub (#7274)
spypsy Jul 2, 2024
dbde910
fix: checkout depth on setup (#7275)
spypsy Jul 2, 2024
0f7e6ec
fix: typo (#7276)
spypsy Jul 2, 2024
d574047
fix: input script's file_path (#7278)
spypsy Jul 2, 2024
9c512c0
chore: redeploy l1 contracts (#7295)
spypsy Jul 3, 2024
b46079a
fix: docker run cmd (#7296)
spypsy Jul 3, 2024
ea3102c
fix: taint EFS on l1 redeploy (#7300)
spypsy Jul 3, 2024
dbdb71e
fix: master conflicts (#7303)
spypsy Jul 3, 2024
56c52f9
fix: init terraform in all cases (#7304)
spypsy Jul 3, 2024
b26dd72
merge with master
spypsy Jul 3, 2024
3f37de6
fix merge
spypsy Jul 3, 2024
7afe45f
undo noir changes
spypsy Jul 3, 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
47 changes: 47 additions & 0 deletions .github/scripts/extract_l1_addresses.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

FILE_PATH=$1

# Read the file line by line
while IFS= read -r line; do
# Extract the hexadecimal address using awk
address=$(echo "$line" | awk '{print $NF}')

# Assign the address to the respective variable based on the line content
if [[ $line == *"Rollup Address"* ]]; then
export TF_VAR_ROLLUP_CONTRACT_ADDRESS=$address
echo "TF_VAR_ROLLUP_CONTRACT_ADDRESS=$TF_VAR_ROLLUP_CONTRACT_ADDRESS"
elif [[ $line == *"Registry Address"* ]]; then
export TF_VAR_REGISTRY_CONTRACT_ADDRESS=$address
echo "TF_VAR_REGISTRY_CONTRACT_ADDRESS=$TF_VAR_REGISTRY_CONTRACT_ADDRESS"
elif [[ $line == *"Inbox Address"* ]]; then
export TF_VAR_INBOX_CONTRACT_ADDRESS=$address
echo "TF_VAR_INBOX_CONTRACT_ADDRESS=$TF_VAR_INBOX_CONTRACT_ADDRESS"
elif [[ $line == *"Outbox Address"* ]]; then
export TF_VAR_OUTBOX_CONTRACT_ADDRESS=$address
echo "TF_VAR_OUTBOX_CONTRACT_ADDRESS=$TF_VAR_OUTBOX_CONTRACT_ADDRESS"
elif [[ $line == *"Oracle Address"* ]]; then
export TF_VAR_AVAILABILITY_ORACLE_CONTRACT_ADDRESS=$address
echo "TF_VAR_AVAILABILITY_ORACLE_CONTRACT_ADDRESS=$TF_VAR_AVAILABILITY_ORACLE_CONTRACT_ADDRESS"
elif [[ $line == *"Gas Token Address"* ]]; then
export TF_VAR_GAS_TOKEN_CONTRACT_ADDRESS=$address
echo "TF_VAR_GAS_TOKEN_CONTRACT_ADDRESS=$TF_VAR_GAS_TOKEN_CONTRACT_ADDRESS"
elif [[ $line == *"Gas Portal Address"* ]]; then
export TF_VAR_GAS_PORTAL_CONTRACT_ADDRESS=$address
echo "TF_VAR_GAS_PORTAL_CONTRACT_ADDRESS=$TF_VAR_GAS_PORTAL_CONTRACT_ADDRESS"
else
echo "Unknown contract address: $line"
fi
done <"$FILE_PATH"

# echo all addresses into github env
echo "TF_VAR_ROLLUP_CONTRACT_ADDRESS=$TF_VAR_ROLLUP_CONTRACT_ADDRESS" >>$GITHUB_ENV
echo "TF_VAR_REGISTRY_CONTRACT_ADDRESS=$TF_VAR_REGISTRY_CONTRACT_ADDRESS" >>$GITHUB_ENV
echo "TF_VAR_INBOX_CONTRACT_ADDRESS=$TF_VAR_INBOX_CONTRACT_ADDRESS" >>$GITHUB_ENV
echo "TF_VAR_OUTBOX_CONTRACT_ADDRESS=$TF_VAR_OUTBOX_CONTRACT_ADDRESS" >>$GITHUB_ENV
echo "TF_VAR_AVAILABILITY_ORACLE_CONTRACT_ADDRESS=$TF_VAR_AVAILABILITY_ORACLE_CONTRACT_ADDRESS" >>$GITHUB_ENV
echo "TF_VAR_GAS_TOKEN_CONTRACT_ADDRESS=$TF_VAR_GAS_TOKEN_CONTRACT_ADDRESS" >>$GITHUB_ENV
echo "TF_VAR_GAS_PORTAL_CONTRACT_ADDRESS=$TF_VAR_GAS_PORTAL_CONTRACT_ADDRESS" >>$GITHUB_ENV

# Set global variable for redeployment of contracts
echo "CONTRACTS_DEPLOYED=1" >>$GITHUB_ENV
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: CI
on:
push:
branches: [master]
pull_request: {}
pull_request:
branches-ignore: [devnet]
workflow_dispatch:
inputs: {}

Expand Down
77 changes: 69 additions & 8 deletions .github/workflows/devnet-deploys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ concurrency:
env:
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
GIT_COMMIT: ${{ github.sha }}
DEPLOY_TAG: devnet
FILE_PATH: ./l1-contracts/addresses.txt
# TF Vars
TF_VAR_DOCKERHUB_ACCOUNT: aztecprotocol
TF_VAR_CHAIN_ID: 31337
Expand All @@ -29,26 +31,49 @@ jobs:
secrets: inherit

build:
needs: setup
runs-on: ${{ github.actor }}-x86
steps:
- uses: actions/checkout@v4
with: { ref: "${{ env.GIT_COMMIT }}" }
with:
ref: "${{ env.GIT_COMMIT }}"
fetch-depth: 0
- uses: ./.github/ci-setup-action
with:
dockerhub_password: "${{ secrets.DOCKERHUB_PASSWORD }}"
concurrency_key: build-release-artifacts-${{ github.actor }}
- name: "Build & Push images"
dockerhub_password: "${{ secrets.DOCKERHUB_PASSWORD }}"
- name: "Build & Push aztec images"
timeout-minutes: 40
# Run the build steps for each image with version and arch, push to dockerhub
run: |
earthly-ci --no-output --push ./yarn-project+export-aztec-arch --DIST_TAG=${{ env.DEPLOY_TAG }}

- name: Check if L1 contracts need deployment
id: check_changes_build
uses: actions/github-script@v7
with:
script: |
const { execSync } = require('child_process');
const changedFiles = execSync('git diff --name-only ${{ github.event.before }} ${{ github.sha }}').toString().split('\n');
const fileChanged = changedFiles.includes('l1-contracts/REDEPLOY');
return fileChanged

- name: "Build & Push cli image"
if: steps.check_changes_build.outputs.result == 'true'
timeout-minutes: 40
# Run the build steps for each image with version and arch, push to dockerhub
run: |
earthly-ci --no-output --push ./yarn-project+export-aztec-arch --DIST_TAG=devnet
earthly-ci --no-output --push ./yarn-project+export-cli --DIST_TAG=${{ env.DEPLOY_TAG }}

terraform_deploy:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
with: { ref: "${{ env.GIT_COMMIT }}" }
with:
ref: "${{ env.GIT_COMMIT }}"
fetch-depth: 0
- uses: ./.github/ci-setup-action
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.7.5
Expand All @@ -60,20 +85,56 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2

- name: Check if L1 contracts need deployment
id: check_changes_release
uses: actions/github-script@v7
with:
script: |
const { execSync } = require('child_process');
const changedFiles = execSync('git diff --name-only ${{ github.event.before }} ${{ github.sha }}').toString().split('\n');
const fileChanged = changedFiles.includes('l1-contracts/REDEPLOY');
return fileChanged
- name: Deploy L1 Contracts
if: steps.check_changes_release.outputs.result == 'true'
run: |
docker pull aztecprotocol/cli:${{ env.DEPLOY_TAG }}
docker run aztecprotocol/cli:${{ env.DEPLOY_TAG }} \
deploy-l1-contracts -p ${{ secrets.SEQ_1_PUBLISHER_PRIVATE_KEY }} \
-u https://${{ env.DEPLOY_TAG }}-mainnet-fork.aztec.network:8545/${{ secrets.FORK_API_KEY }} \
| tee ${{ env.FILE_PATH }}
./.github/scripts/extract_l1_addresses.sh ${{ env.FILE_PATH }}

- name: Apply l1-contracts Terraform
if: steps.check_changes_release.outputs.result == 'true'
working-directory: ./l1-contracts/terraform
run: |
terraform init -input=false -backend-config="key=${{ env.DEPLOY_TAG }}/l1-contracts"
terraform apply -input=false -auto-approve

- name: Deploy P2P Bootstrap Nodes
working-directory: ./yarn-project/p2p-bootstrap/terraform
run: |
terraform init -input=false -backend-config="key=devnet/p2p-bootstrap"
terraform init -input=false -backend-config="key=${{ env.DEPLOY_TAG }}/p2p-bootstrap"
terraform apply -input=false -auto-approve

- name: Init Aztec Node Terraform
working-directory: ./yarn-project/aztec/terraform/node
run: |
terraform init -input=false -backend-config="key=${{ env.DEPLOY_TAG }}/aztec-node"

- name: Taint node filesystem if L1 contracts are redeployed
if: steps.check_changes_release.outputs.result == 'true'
working-directory: ./yarn-project/aztec/terraform/node
run: |
terraform state list | grep 'aws_efs_file_system.node_data_store' | xargs -n1 terraform taint

- name: Deploy Aztec Nodes
working-directory: ./yarn-project/aztec/terraform/node
run: |
terraform init -input=false -backend-config="key=devnet/aztec-node"
terraform apply -input=false -auto-approve

- name: Deploy Provers
working-directory: ./yarn-project/aztec/terraform/prover
run: |
terraform init -input=false -backend-config="key=devnet/prover"
terraform init -input=false -backend-config="key=${{ env.DEPLOY_TAG }}/prover"
terraform apply -input=false -auto-approve
2 changes: 1 addition & 1 deletion iac/mainnet-fork/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ resource "aws_ecs_task_definition" "aztec_mainnet_fork" {
[
{
"name": "${var.DEPLOY_TAG}-mainnet-fork",
"image": "${var.DOCKERHUB_ACCOUNT}/mainnet-fork:${var.DEPLOY_TAG}",
"image": "${var.DOCKERHUB_ACCOUNT}/mainnet-fork:aztec-dev",
"essential": true,
"environment": [
{
Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ VERSION 0.8
build:
FROM ../build-images+build
WORKDIR /usr/src/l1-contracts
COPY --dir lib scripts src terraform test *.json *.toml *.sh .
COPY --dir lib src terraform test *.json *.toml *.sh .
#RUN git init && git add . && yarn lint && yarn slither && yarn slither-has-diff
# "slither": "forge clean && forge build --build-info --skip '*/test/**' --force && slither . --checklist --ignore-compile --show-ignored-findings --config-file ./slither.config.json | tee slither_output.md",
# "slither-has-diff": "./slither_has_diff.sh"
Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/REDEPLOY
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Append value to force redeploy
5
1
96 changes: 0 additions & 96 deletions l1-contracts/scripts/ci_deploy_contracts.sh

This file was deleted.

2 changes: 1 addition & 1 deletion noir/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,4 @@ bench-publish-acir-bb:
RUN mkdir -p ./log
RUN docker run -v "$(pwd)/log":/log -e LOG_FILE=/log/bench-acir.jsonl --rm aztecprotocol/barretenberg-acir-benches:$AZTEC_DOCKER_TAG ./bench_acir_tests.sh

DO ../+UPLOAD_LOGS --PULL_REQUEST=$PULL_REQUEST --BRANCH=$BRANCH --COMMIT_HASH=$COMMIT_HASH
DO ../+UPLOAD_LOGS --PULL_REQUEST=$PULL_REQUEST --BRANCH=$BRANCH --COMMIT_HASH=$COMMIT_HASH
47 changes: 39 additions & 8 deletions yarn-project/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ rollup-verifier-contract:
RUN --entrypoint write-contract -c RootRollupArtifact -n UltraVerifier.sol
SAVE ARTIFACT /usr/src/bb /usr/src/bb

txe:
txe:
FROM +build
RUN yarn workspaces focus @aztec/txe --production && yarn cache clean
# Remove a bunch of stuff that we don't need that takes up space.
Expand Down Expand Up @@ -175,10 +175,47 @@ aztec-faucet-build:
aztec-faucet:
FROM ubuntu:noble
RUN apt update && apt install nodejs curl -y && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY +aztec-faucet/usr/src /usr/src
COPY +aztec-faucet-build/usr/src /usr/src
ENTRYPOINT ["node", "--no-warnings", "/usr/src/yarn-project/aztec-faucet/dest/bin/index.js"]
LET port=8080

export-aztec-faucet:
FROM +aztec-faucet
ARG DIST_TAG="latest"
ARG ARCH
SAVE IMAGE --push aztecprotocol/aztec-faucet:${DIST_TAG}${ARCH:+-$ARCH}

cli-build:
FROM +build
RUN yarn workspaces focus @aztec/cli --production && yarn cache clean
RUN rm -rf \
../noir-projects \
../l1-contracts \
../barretenberg/ts/src \
../barretenberg/ts/dest/node-cjs \
../barretenberg/ts/dest/browser \
aztec.js/dest/main.js \
end-to-end \
**/src \
**/artifacts
SAVE ARTIFACT /usr/src /usr/src

cli:
FROM ubuntu:noble
RUN apt update && apt install nodejs curl -y && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY +cli-build/usr/src /usr/src

RUN mkdir /cache && chmod 777 /cache
ENV XDG_CACHE_HOME /cache
VOLUME "/cache"
ENTRYPOINT ["node", "--no-warnings", "/usr/src/yarn-project/cli/dest/bin/index.js"]

export-cli:
FROM +cli
ARG DIST_TAG="latest"
ARG ARCH
SAVE IMAGE --push aztecprotocol/cli:${DIST_TAG}${ARCH:+-$ARCH}

# We care about creating a slimmed down e2e image because we have to serialize it from earthly to docker for running.
end-to-end-prod:
FROM +build
Expand Down Expand Up @@ -247,12 +284,6 @@ export-aztec-arch:
ARG ARCH
SAVE IMAGE --push aztecprotocol/aztec:${DIST_TAG}${ARCH:+-$ARCH}

export-aztec-faucet:
FROM +aztec-faucet
ARG DIST_TAG="latest"
ARG ARCH
SAVE IMAGE --push aztecprotocol/aztec-faucet:${DIST_TAG}${ARCH:+-$ARCH}

export-end-to-end:
ARG EARTHLY_GIT_HASH
FROM +end-to-end
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/ethereum/src/deploy_l1_contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function createL1Clients(
}

/**
* Deploys the aztec L1 contracts; Rollup, Contract Deployment Emitter & (optionally) Decoder Helper.
* Deploys the aztec L1 contracts; Rollup & (optionally) Decoder Helper.
* @param rpcUrl - URL of the ETH RPC to use for deployment.
* @param account - Private Key or HD Account that will deploy the contracts.
* @param chain - The chain instance to deploy to.
Expand Down
Loading