diff --git a/.github/scripts/extract_l1_addresses.sh b/.github/scripts/extract_l1_addresses.sh new file mode 100755 index 000000000000..b0946446ffba --- /dev/null +++ b/.github/scripts/extract_l1_addresses.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +FILE_PATH=./script_output + +# 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 diff --git a/.github/workflows/devnet-deploys.yml b/.github/workflows/devnet-deploys.yml index 1120fef4628c..2f006de8e361 100644 --- a/.github/workflows/devnet-deploys.yml +++ b/.github/workflows/devnet-deploys.yml @@ -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 @@ -35,8 +37,8 @@ jobs: with: { ref: "${{ env.GIT_COMMIT }}" } - uses: ./.github/ci-setup-action with: - dockerhub_password: "${{ secrets.DOCKERHUB_PASSWORD }}" concurrency_key: build-release-artifacts-${{ github.actor }} + dockerhub_password: "${{ secrets.DOCKERHUB_PASSWORD }}" - name: "Build & Push images" timeout-minutes: 40 # Run the build steps for each image with version and arch, push to dockerhub @@ -60,6 +62,32 @@ 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 + uses: actions/github-script@v6 + 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.outputs.fileChanged == 'true' + run: | + earthly-ci --no-output ./yarn-project/cli+deploy-l1-contracts \ + --PRIVATE_KEY=${{ secrets.SEQ_1_PUBLISHER_PRIVATE_KEY }} \ + --RPC_URL=https://${{ env.DEPLOY_TAG }}-mainnet-fork.aztec.network:8545/${{ secrets.FORK_API_KEY }} \ + | tee ${{ env.FILE_PATH }} + ./scripts/extract_l1_addresses.sh ${{ env.FILE_PATH }} + + - name: Apply l1-contracts Terraform + if: steps.check_changes.outputs.fileChanged == 'true' + working-directory: ./l1-contracts/terraform + run: | + terraform init -input=false -backend-config="key=devnet/l1-contracts" + terraform apply -input=false -auto-approve + - name: Deploy P2P Bootstrap Nodes working-directory: ./yarn-project/p2p-bootstrap/terraform run: | diff --git a/iac/mainnet-fork/terraform/main.tf b/iac/mainnet-fork/terraform/main.tf index 08198ba5e0b5..026469d3920b 100644 --- a/iac/mainnet-fork/terraform/main.tf +++ b/iac/mainnet-fork/terraform/main.tf @@ -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": [ { diff --git a/l1-contracts/Earthfile b/l1-contracts/Earthfile index 2df4d56e48a9..5e1e559be621 100644 --- a/l1-contracts/Earthfile +++ b/l1-contracts/Earthfile @@ -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" diff --git a/l1-contracts/REDEPLOY b/l1-contracts/REDEPLOY index 8d0fb412c885..fe5516129dec 100644 --- a/l1-contracts/REDEPLOY +++ b/l1-contracts/REDEPLOY @@ -1,2 +1,2 @@ # Append value to force redeploy -5 \ No newline at end of file +1 \ No newline at end of file diff --git a/l1-contracts/scripts/ci_deploy_contracts.sh b/l1-contracts/scripts/ci_deploy_contracts.sh deleted file mode 100755 index 73dcf50f1a8c..000000000000 --- a/l1-contracts/scripts/ci_deploy_contracts.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -export ETHEREUM_HOST=https://$DEPLOY_TAG-mainnet-fork.aztec.network:8545/$FORK_API_KEY - -REPOSITORY="l1-contracts" - -CONTENT_HASH=$(calculate_content_hash $REPOSITORY) - -echo "Last successfully published commit: $CONTENT_HASH" - -# Check if image hash has already been deployed. -if check_rebuild "cache-$CONTENT_HASH-$DEPLOY_TAG-deployed" $REPOSITORY; then - echo "No changes detected, no contract deploy necessary." - # Set global variable for redeployment of contracts - echo export CONTRACTS_DEPLOYED=0 >>$BASH_ENV - exit 0 -fi - -# Login to pull our ecr images with docker. -retry ecr_login - -# Contract addresses will be saved in the serve directory -mkdir -p serve -FILE_PATH=./serve/contract_addresses.json -CLI_IMAGE=$(calculate_image_uri cli) -retry docker pull $CLI_IMAGE - -# remove 0x prefix from private key -PRIVATE_KEY=${CONTRACT_PUBLISHER_PRIVATE_KEY#0x} - -# Retries up to 3 times with 10 second intervals -ATTEMPTS=3 -for i in $(seq 1 $ATTEMPTS); do - docker run \ - $CLI_IMAGE \ - deploy-l1-contracts -u $ETHEREUM_HOST -p $PRIVATE_KEY | tee $FILE_PATH && break - [ "$i" != "$ATTEMPTS" ] && sleep 10 -done - -## Result format is: -# Rollup Address: 0xe33d37702bb94e83ca09e7dc804c9f4c4ab8ee4a -# Registry Address: 0xf02a70628c4e0d7c41f231f9af24c1678a030438 -# L1 -> L2 Inbox Address: 0xdf34a07c7da15630d3b5d6bb17651d548a6e9d8f -# L2 -> L1 Outbox address: 0xf6b1b3c2c393fe55fe577a1f528bd72a76589ab0 -# Contract Deployment Emitter Address: 0xf3ecc6e9428482a74687ee5f7b96f4dff8781454 -# Availability Oracle Address: 0x610178da211fef7d417bc0e6fed39f05609ad788 -# Gas Token Address: 0x9e4b815648c4a98a9bce6a899cecbaf3758cf23c -# Gas Portal Address: 0xda5dea39534f67f33deb38ec3b1e438fa893bf2c - -# 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"* ]]; then - export TF_VAR_ROLLUP_CONTRACT_ADDRESS=$address - echo "TF_VAR_ROLLUP_CONTRACT_ADDRESS=$TF_VAR_ROLLUP_CONTRACT_ADDRESS" - elif [[ $line == *"Registry"* ]]; then - export TF_VAR_REGISTRY_CONTRACT_ADDRESS=$address - echo "TF_VAR_REGISTRY_CONTRACT_ADDRESS=$TF_VAR_REGISTRY_CONTRACT_ADDRESS" - elif [[ $line == *"Inbox"* ]]; then - export TF_VAR_INBOX_CONTRACT_ADDRESS=$address - echo "TF_VAR_INBOX_CONTRACT_ADDRESS=$TF_VAR_INBOX_CONTRACT_ADDRESS" - elif [[ $line == *"Outbox"* ]]; then - export TF_VAR_OUTBOX_CONTRACT_ADDRESS=$address - echo "TF_VAR_OUTBOX_CONTRACT_ADDRESS=$TF_VAR_OUTBOX_CONTRACT_ADDRESS" - elif [[ $line == *"Oracle"* ]]; 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"* ]]; 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"* ]]; 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" - -if [ "$DRY_DEPLOY" -eq 1 ]; then - echo "DRY_DEPLOY: deploy_terraform l1-contracts ./terraform" - echo "DRY_DEPLOY: tag_remote_image $REPOSITORY cache-$CONTENT_HASH cache-$CONTENT_HASH-$DEPLOY_TAG-deployed" -else - # 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 -fi - -# Set global variable for redeployment of contracts -echo export CONTRACTS_DEPLOYED=1 >>$BASH_ENV diff --git a/yarn-project/Earthfile b/yarn-project/Earthfile index 1f4e2fdc7906..c94a8019935d 100644 --- a/yarn-project/Earthfile +++ b/yarn-project/Earthfile @@ -115,7 +115,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. @@ -179,7 +179,7 @@ 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 diff --git a/yarn-project/cli/Earthfile b/yarn-project/cli/Earthfile new file mode 100644 index 000000000000..18bc82b114d7 --- /dev/null +++ b/yarn-project/cli/Earthfile @@ -0,0 +1,20 @@ +VERSION 0.8 + + +aztec-cli: + FROM ../+build + RUN yarn workspaces focus @aztec/cli --production && yarn cache clean + + 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"] + +deploy-l1-contracts: + FROM +aztec-cli + ARG PRIVATE_KEY + ARG RPC_URL + ENV PRIVATE_KEY=$PRIVATE_KEY + ENV ETHEREUM_HOST=$RPC_URL + RUN echo "Deploying L1 contracts with PRIVATE_KEY=$PRIVATE_KEY and RPC_URL=$RPC_URL" + RUN --entrypoint deploy-l1-contracts diff --git a/yarn-project/ethereum/src/deploy_l1_contracts.ts b/yarn-project/ethereum/src/deploy_l1_contracts.ts index d8d145b95389..c6feb14af171 100644 --- a/yarn-project/ethereum/src/deploy_l1_contracts.ts +++ b/yarn-project/ethereum/src/deploy_l1_contracts.ts @@ -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.