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: static.aztec.network #7649

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
28 changes: 14 additions & 14 deletions .github/workflows/devnet-deploys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
L1_CHAIN_ID: 677692
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
CONTRACT_S3_BUCKET: s3://static.aztec.network
# TF Vars
TF_VAR_DOCKERHUB_ACCOUNT: aztecprotocol
TF_VAR_L1_CHAIN_ID: 677692
Expand All @@ -29,7 +30,6 @@ env:
TF_VAR_FAUCET_ACCOUNT_INDEX: 5
TF_VAR_BOT_API_KEY: ${{ secrets.BOT_API_KEY }}
TF_VAR_BOT_PRIVATE_KEY: ${{ secrets.BOT_PRIVATE_KEY }}
CONTRACT_S3_BUCKET: s3://aztec-devnet-deployments

jobs:
setup:
Expand Down Expand Up @@ -127,14 +127,14 @@ jobs:
--rpc-url https://${{ env.DEPLOY_TAG }}-mainnet-fork.aztec.network:8545/${{ secrets.FORK_API_KEY }} \
--l1-chain-id ${{ env.L1_CHAIN_ID }} \
--json \
| tee ./l1-contract_addresses.json
| tee ./l1_contracts.json

# upload contract addresses to S3
aws s3 cp ./l1-contract_addresses.json ${{ env.CONTRACT_S3_BUCKET }}/l1_contract_addresses.json
aws s3 cp ./l1_contracts.json ${{ env.CONTRACT_S3_BUCKET }}/${{ env.DEPLOY_TAG }}/l1_contracts.json

# export contract addresses so they can be used by subsequent terraform deployments
function extract() {
jq -r ".$1" ./l1-contract_addresses.json
jq -r ".$1" ./l1_contracts.json
}

echo "TF_VAR_ROLLUP_CONTRACT_ADDRESS=$(extract rollupAddress)" >>$GITHUB_ENV
Expand Down Expand Up @@ -209,22 +209,22 @@ jobs:
--rpc-url https://api.aztec.network/${{ env.DEPLOY_TAG }}/aztec-pxe/${{ secrets.FORK_API_KEY }} \
--l1-chain-id ${{ env.L1_CHAIN_ID }} \
--json \
| tee ./protocol-contracts.json
| tee ./protocol_contracts.json

aws s3 cp ./protocol-contracts.json ${{ env.CONTRACT_S3_BUCKET }}/protocol-contracts.json
aws s3 cp ./protocol_contracts.json ${{ env.CONTRACT_S3_BUCKET }}/${{ env.DEPLOY_TAG }}/protocol_contracts.json

- name: Bootstrap devnet
- name: Bootstrap network
run: |
set -e
docker run aztecprotocol/aztec:${{ env.DEPLOY_TAG }} bootstrap-devnet \
docker run aztecprotocol/aztec:${{ env.DEPLOY_TAG }} bootstrap-network \
--rpc-url https://api.aztec.network/${{ env.DEPLOY_TAG }}/aztec-pxe/${{ secrets.FORK_API_KEY }} \
--l1-rpc-url https://${{ env.DEPLOY_TAG }}-mainnet-fork.aztec.network:8545/${{ secrets.FORK_API_KEY }} \
--l1-chain-id ${{ env.L1_CHAIN_ID }} \
--l1-private-key ${{ secrets.SEQ_1_PUBLISHER_PRIVATE_KEY }} \
--json \
| tee ./devnet-contracts.json
| tee ./basic_contracts.json

aws s3 cp ./devnet-contracts.json ${{ env.CONTRACT_S3_BUCKET }}/devnet-contracts.json
aws s3 cp ./basic_contracts.json ${{ env.CONTRACT_S3_BUCKET }}/${{ env.DEPLOY_TAG }}/basic_contracts.json

deploy-faucet:
runs-on: ubuntu-latest
Expand All @@ -249,11 +249,11 @@ jobs:
- name: Retrieve contract addresses
run: |
set -e
aws s3 cp ${{ env.CONTRACT_S3_BUCKET }}/l1_contract_addresses.json ./l1-contract_addresses.json
aws s3 cp ${{ env.CONTRACT_S3_BUCKET }}/devnet-contracts.json ./devnet-contracts.json
aws s3 cp ${{ env.CONTRACT_S3_BUCKET }}/${{ env.DEPLOY_TAG }}/l1_contracts.json ./l1_contracts.json
aws s3 cp ${{ env.CONTRACT_S3_BUCKET }}/${{ env.DEPLOY_TAG }}/basic_contracts.json ./basic_contracts.json

echo "TF_VAR_GAS_TOKEN_CONTRACT_ADDRESS=$(jq -r '.gasTokenAddress' ./l1-contract_addresses.json)" >>$GITHUB_ENV
echo "TF_VAR_DEV_COIN_CONTRACT_ADDRESS=$(jq -r '.devCoinL1' ./devnet-contracts.json)" >>$GITHUB_ENV
echo "TF_VAR_GAS_TOKEN_CONTRACT_ADDRESS=$(jq -r '.gasTokenAddress' ./l1_contracts.json)" >>$GITHUB_ENV
echo "TF_VAR_DEV_COIN_CONTRACT_ADDRESS=$(jq -r '.devCoinL1' ./basic_contracts.json)" >>$GITHUB_ENV

- name: Deploy Faucet
working-directory: ./yarn-project/aztec-faucet
Expand Down
58 changes: 56 additions & 2 deletions l1-contracts/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,72 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "3.74.2"
version = "5.29.0"
}
}
}

data "terraform_remote_state" "aztec2_iac" {
backend = "s3"
config = {
bucket = "aztec-terraform"
key = "aztec2/iac"
region = "eu-west-2"
}
}

variable "DEPLOY_TAG" {
type = string
}

# S3 Bucket to store contract addresses
resource "aws_s3_bucket" "contract_addresses" {
bucket = "aztec-${var.DEPLOY_TAG}-deployments"
bucket = "static.aztec.network"
}

resource "aws_s3_bucket_website_configuration" "addresses_website_bucket" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor thing: I'd move the S3 bucket and & cloudfront distribution to a separate terraform file since they're not strictly related to L1 contracts. I think it will make discovering the source code easier?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree. This stuff should be elsewhere

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed, moving to iac folder

bucket = aws_s3_bucket.contract_addresses.id

index_document {
suffix = "aztec-static"
}
}

resource "aws_s3_bucket_public_access_block" "addresses_public_access" {
bucket = aws_s3_bucket.contract_addresses.id

block_public_acls = false
block_public_policy = false
ignore_public_acls = false
restrict_public_buckets = false
}

resource "aws_s3_bucket_policy" "addresses_bucket_policy" {
bucket = aws_s3_bucket.contract_addresses.id

policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Principal = "*"
Action = "s3:GetObject"
Resource = "arn:aws:s3:::${aws_s3_bucket.contract_addresses.id}/*"
}
]
})
}

resource "aws_route53_record" "static" {
zone_id = data.terraform_remote_state.aztec2_iac.outputs.aws_route53_zone_id
name = "static.aztec.network"
type = "A"

alias {
name = aws_s3_bucket_website_configuration.addresses_website_bucket.website_domain
zone_id = aws_s3_bucket.contract_addresses.hosted_zone_id
evaluate_target_health = true
}
}

variable "ROLLUP_CONTRACT_ADDRESS" {
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/cli/src/cmds/devnet/index.ts
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we'll have to rename this folder in a future PR.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { ETHEREUM_HOST, l1ChainIdOption, parseEthereumAddress, pxeOption } from

export function injectCommands(program: Command, log: LogFn, debugLogger: DebugLogger) {
program
.command('bootstrap-devnet')
.description('Bootstrap the devnet')
.command('bootstrap-network')
.description('Bootstrap a new network')
.addOption(pxeOption)
.addOption(l1ChainIdOption)
.requiredOption(
Expand Down
Loading