Skip to content

Commit 470f10c

Browse files
authored
feat: scaffold deploy-scenario-network.yml (#16553)
# Add Scenario Network Deployment Workflow This PR adds a new workflow for deploying a complete scenario network, which includes: 1. A new `deploy-scenario-network.yml` workflow that orchestrates the deployment of both an Ethereum devnet and rollup contracts 2. Updates to the `deploy-eth-devnet.yml` workflow to: - Accept a custom mnemonic as an input parameter - Expose deployment results (RPC URL, WebSocket URL, Beacon URL, Chain ID) as workflow outputs - Mask the mnemonic in logs for security 3. Updates to the Terraform configuration in `deploy-eth-devnet`: - Use the provided mnemonic instead of fetching from Google Secret Manager - Support both static IPs and cluster IPs for services - Add proper output handling for both IP types 4. Updates to the rollup contracts deployment to properly use the validators parameter These changes enable more flexible and composable deployment workflows for testing scenarios.
2 parents 6746d32 + f30a344 commit 470f10c

File tree

6 files changed

+239
-15
lines changed

6 files changed

+239
-15
lines changed

.github/workflows/deploy-eth-devnet.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,31 @@ on:
5959
required: false
6060
type: string
6161
default: "false"
62+
mnemonic:
63+
description: The mnemonic to use for the eth devnet
64+
required: false
65+
type: string
66+
default: "test test test test test test test test test test test junk"
6267
secrets:
6368
GCP_SA_KEY:
6469
description: The JSON key for the GCP service account
6570
required: true
6671
KUBECONFIG_B64:
6772
description: The base64 encoded kubeconfig
6873
required: true
74+
outputs:
75+
rpc_url:
76+
description: The RPC URL for the eth devnet
77+
value: ${{ jobs.deploy_eth_devnet.outputs.rpc_url }}
78+
ws_url:
79+
description: The WebSocket URL for the eth devnet
80+
value: ${{ jobs.deploy_eth_devnet.outputs.ws_url }}
81+
beacon_url:
82+
description: The Beacon URL for the eth devnet
83+
value: ${{ jobs.deploy_eth_devnet.outputs.beacon_url }}
84+
chain_id:
85+
description: The chain ID for the eth devnet
86+
value: ${{ jobs.deploy_eth_devnet.outputs.chain_id }}
6987

7088
workflow_dispatch:
7189
inputs:
@@ -114,10 +132,20 @@ on:
114132
required: false
115133
type: string
116134
default: "false"
135+
mnemonic:
136+
description: The mnemonic to use for the eth devnet
137+
required: false
138+
type: string
139+
default: "test test test test test test test test test test test junk"
117140

118141
jobs:
119142
deploy_eth_devnet:
120143
runs-on: ubuntu-latest
144+
outputs:
145+
rpc_url: ${{ steps.get-eth-devnet-results.outputs.rpc_url }}
146+
ws_url: ${{ steps.get-eth-devnet-results.outputs.ws_url }}
147+
beacon_url: ${{ steps.get-eth-devnet-results.outputs.beacon_url }}
148+
chain_id: ${{ steps.get-eth-devnet-results.outputs.chain_id }}
121149
env:
122150
TF_STATE_BUCKET: aztec-terraform
123151
REGION: us-west1-a
@@ -131,6 +159,11 @@ jobs:
131159
TF_VAR_RESOURCE_PROFILE: ${{ inputs.resource_profile || 'prod' }}
132160

133161
steps:
162+
- name: Mask the mnemonic
163+
id: mask-mnemonic
164+
run: |
165+
echo "::add-mask::${{ inputs.mnemonic }}"
166+
134167
- name: Debug inputs
135168
run: |
136169
echo "cluster: ${{ inputs.cluster }}"
@@ -179,3 +212,27 @@ jobs:
179212
working-directory: ./spartan/terraform/deploy-eth-devnet
180213
run: |
181214
terraform apply tfplan
215+
216+
- name: Get eth devnet deployment results
217+
id: get-eth-devnet-results
218+
working-directory: ./spartan/terraform/deploy-eth-devnet
219+
220+
run: |
221+
echo "=== Eth Devnet Deployment Results ==="
222+
223+
# Get outputs from the eth-devnet deployment
224+
RPC_URL=$(terraform output -raw eth_execution_rpc_url)
225+
WS_URL=$(terraform output -raw eth_execution_ws_url)
226+
BEACON_URL=$(terraform output -raw eth_beacon_api_url)
227+
CHAIN_ID=$(terraform output -raw chain_id)
228+
229+
echo "RPC_URL: $RPC_URL"
230+
echo "WS_URL: $WS_URL"
231+
echo "BEACON_URL: $BEACON_URL"
232+
echo "CHAIN_ID: $CHAIN_ID"
233+
234+
# Export as outputs for other steps
235+
echo "rpc_url=$RPC_URL" >> $GITHUB_OUTPUT
236+
echo "ws_url=$WS_URL" >> $GITHUB_OUTPUT
237+
echo "beacon_url=$BEACON_URL" >> $GITHUB_OUTPUT
238+
echo "chain_id=$CHAIN_ID" >> $GITHUB_OUTPUT
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: Deploy Scenario Network
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
cluster:
7+
description: The cluster to deploy to, e.g. aztec-gke-private or kind
8+
required: true
9+
type: string
10+
namespace:
11+
description: The namespace to deploy to
12+
required: true
13+
type: string
14+
ref:
15+
description: The branch name to deploy from
16+
required: true
17+
type: string
18+
default: "next"
19+
aztec_docker_image:
20+
description: The Docker image to use for the Aztec contracts
21+
required: true
22+
type: string
23+
default: "aztecprotocol/aztec:8ebe8d7c45190b002c77e29358f2b307a23b5336"
24+
devnet_mnemonic:
25+
description: The mnemonic to use for the devnet
26+
required: true
27+
type: string
28+
default: "test test test test test test test test test test test junk"
29+
rollup_deployment_mnemonic:
30+
description: The mnemonic to use for the rollup deployment
31+
required: true
32+
type: string
33+
default: "test test test test test test test test test test test junk"
34+
secrets:
35+
GCP_SA_KEY:
36+
description: The JSON key for the GCP service account
37+
required: true
38+
KUBECONFIG_B64:
39+
description: The base64 encoded kubeconfig
40+
required: true
41+
42+
workflow_dispatch:
43+
inputs:
44+
cluster:
45+
description: The cluster to deploy to, e.g. aztec-gke-private or kind
46+
required: true
47+
type: string
48+
default: "kind"
49+
namespace:
50+
description: The namespace to deploy to
51+
required: true
52+
type: string
53+
default: "eth-devnet"
54+
ref:
55+
description: The branch name to deploy from.
56+
required: true
57+
type: string
58+
default: "next"
59+
aztec_docker_image:
60+
description: The Docker image to use for the Aztec contracts
61+
required: true
62+
type: string
63+
default: "aztecprotocol/aztec:8ebe8d7c45190b002c77e29358f2b307a23b5336"
64+
devnet_mnemonic:
65+
description: The mnemonic to use for the devnet
66+
required: true
67+
type: string
68+
default: "test test test test test test test test test test test junk"
69+
rollup_deployment_mnemonic:
70+
description: The mnemonic to use for the rollup deployment
71+
required: true
72+
type: string
73+
default: "test test test test test test test test test test test junk"
74+
75+
jobs:
76+
# First job: Deploy the Eth Devnet
77+
scenario_dispatch_deploy_eth_devnet:
78+
uses: ./.github/workflows/deploy-eth-devnet.yml
79+
with:
80+
cluster: ${{ inputs.cluster }}
81+
namespace: ${{ inputs.namespace }}
82+
ref: ${{ inputs.ref }}
83+
# Prefilled values for scenario network
84+
chain_id: 1337
85+
block_time: 4 # Faster block time for scenario testing
86+
gas_limit: "32000000" # Higher gas limit for complex scenarios
87+
resource_profile: ${{ inputs.cluster == 'kind' && 'dev' || 'prod' }}
88+
create_static_ips: ${{ inputs.cluster == 'kind' && 'false' || 'true' }}
89+
run_terraform_destroy: "false"
90+
mnemonic: ${{ inputs.devnet_mnemonic }}
91+
secrets:
92+
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
93+
KUBECONFIG_B64: ${{ secrets.KUBECONFIG_B64 }}
94+
95+
scenario_dispatch_deploy_rollup_contracts:
96+
needs: scenario_dispatch_deploy_eth_devnet
97+
uses: ./.github/workflows/deploy-rollup-contracts.yml
98+
with:
99+
cluster: ${{ inputs.cluster }}
100+
namespace: ${{ inputs.namespace }}
101+
ref: ${{ inputs.ref }}
102+
l1_rpc_urls: ${{ needs.scenario_dispatch_deploy_eth_devnet.outputs.rpc_url }}
103+
l1_chain_id: ${{ needs.scenario_dispatch_deploy_eth_devnet.outputs.chain_id }}
104+
aztec_docker_image: ${{ inputs.aztec_docker_image }}
105+
mnemonic: ${{ inputs.rollup_deployment_mnemonic }}
106+
salt: "456"
107+
# indices 1,2,3,4 on the junk mnemonic
108+
validators: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8,0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC,0x90F79bf6EB2c4f870365E785982E1f101E93b906,0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65"
109+
sponsored_fpc: true
110+
real_verifier: true
111+
# Aztec environment variables
112+
aztec_slot_duration: 12
113+
aztec_epoch_duration: 32
114+
aztec_target_committee_size: 4
115+
aztec_proof_submission_epochs: 1
116+
aztec_activation_threshold: 100
117+
aztec_ejection_threshold: 50
118+
aztec_slashing_quorum: 6
119+
aztec_slashing_round_size: 10
120+
aztec_governance_proposer_quorum: 6
121+
aztec_governance_proposer_round_size: 10
122+
aztec_mana_target: 1000000
123+
aztec_proving_cost_per_mana: 100
124+
secrets:
125+
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
126+
KUBECONFIG_B64: ${{ secrets.KUBECONFIG_B64 }}
127+
128+
deploy_scenario_network:
129+
needs: scenario_dispatch_deploy_rollup_contracts
130+
runs-on: ubuntu-latest
131+
env:
132+
TF_STATE_BUCKET: aztec-terraform
133+
REGION: us-west1-a
134+
# Common Terraform variables as environment variables
135+
TF_VAR_NAMESPACE: ${{ inputs.namespace || 'eth-devnet' }}
136+
137+
steps:
138+
- name: Deploy scenario network
139+
run: |
140+
echo "Deployed scenario network!"

spartan/terraform/deploy-eth-devnet/main.tf

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ provider "helm" {
4040
}
4141
}
4242

43-
# Get mnemonic from Google Secret Manager
44-
data "google_secret_manager_secret_version" "mnemonic_latest" {
45-
secret = var.MNEMONIC_SECRET_NAME
46-
}
43+
4744

4845
# Static IP addresses for eth-devnet services
4946
resource "google_compute_address" "eth_execution_ip" {
@@ -76,18 +73,19 @@ resource "null_resource" "generate_genesis" {
7673
chain_id = var.CHAIN_ID
7774
block_time = var.BLOCK_TIME
7875
gas_limit = var.GAS_LIMIT
79-
mnemonic = data.google_secret_manager_secret_version.mnemonic_latest.secret_data
76+
mnemonic = var.MNEMONIC
8077
}
8178

8279
provisioner "local-exec" {
8380
command = <<-EOT
8481
cd ../../eth-devnet
82+
rm -rf out/ tmp/
8583
8684
# Set environment variables for genesis generation
8785
export CHAIN_ID=${var.CHAIN_ID}
8886
export BLOCK_TIME=${var.BLOCK_TIME}
8987
export GAS_LIMIT="${var.GAS_LIMIT}"
90-
export MNEMONIC="${data.google_secret_manager_secret_version.mnemonic_latest.secret_data}"
88+
export MNEMONIC="${var.MNEMONIC}"
9189
export PREFUNDED_MNEMONIC_INDICES="${var.PREFUNDED_MNEMONIC_INDICES}"
9290
9391
# Use a custom directory for Foundry installation to avoid permission issues
@@ -126,7 +124,7 @@ resource "helm_release" "eth_devnet" {
126124

127125
set {
128126
name = "ethereum.validator.mnemonic"
129-
value = data.google_secret_manager_secret_version.mnemonic_latest.secret_data
127+
value = var.MNEMONIC
130128
}
131129

132130

@@ -151,3 +149,26 @@ resource "helm_release" "eth_devnet" {
151149
wait_for_jobs = false
152150
}
153151

152+
data "kubernetes_service" "eth_execution" {
153+
count = var.CREATE_STATIC_IPS ? 0 : 1
154+
provider = kubernetes.gke-cluster
155+
156+
metadata {
157+
name = "${var.RELEASE_PREFIX}-eth-execution"
158+
namespace = var.NAMESPACE
159+
}
160+
161+
depends_on = [helm_release.eth_devnet]
162+
}
163+
164+
data "kubernetes_service" "eth_beacon" {
165+
count = var.CREATE_STATIC_IPS ? 0 : 1
166+
provider = kubernetes.gke-cluster
167+
168+
metadata {
169+
name = "${var.RELEASE_PREFIX}-eth-beacon"
170+
namespace = var.NAMESPACE
171+
}
172+
173+
depends_on = [helm_release.eth_devnet]
174+
}

spartan/terraform/deploy-eth-devnet/outputs.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
output "eth_execution_ip" {
2-
description = "Static IP address for Ethereum execution client"
3-
value = var.CREATE_STATIC_IPS ? google_compute_address.eth_execution_ip[0].address : null
2+
description = "IP address for Ethereum execution client (Static IP or Cluster IP)"
3+
value = var.CREATE_STATIC_IPS ? google_compute_address.eth_execution_ip[0].address : data.kubernetes_service.eth_execution[0].spec[0].cluster_ip
44
}
55

66
output "eth_beacon_ip" {
7-
description = "Static IP address for Ethereum beacon client"
8-
value = var.CREATE_STATIC_IPS ? google_compute_address.eth_beacon_ip[0].address : null
7+
description = "IP address for Ethereum beacon client (Static IP or Cluster IP)"
8+
value = var.CREATE_STATIC_IPS ? google_compute_address.eth_beacon_ip[0].address : data.kubernetes_service.eth_beacon[0].spec[0].cluster_ip
99
}
1010

1111
output "eth_execution_rpc_url" {
1212
description = "Ethereum execution RPC URL"
13-
value = var.CREATE_STATIC_IPS ? "http://${google_compute_address.eth_execution_ip[0].address}:8545" : null
13+
value = var.CREATE_STATIC_IPS ? "http://${google_compute_address.eth_execution_ip[0].address}:8545" : "http://${data.kubernetes_service.eth_execution[0].spec[0].cluster_ip}:8545"
1414
}
1515

1616
output "eth_execution_ws_url" {
1717
description = "Ethereum execution WebSocket URL"
18-
value = var.CREATE_STATIC_IPS ? "ws://${google_compute_address.eth_execution_ip[0].address}:8546" : null
18+
value = var.CREATE_STATIC_IPS ? "ws://${google_compute_address.eth_execution_ip[0].address}:8546" : "ws://${data.kubernetes_service.eth_execution[0].spec[0].cluster_ip}:8546"
1919
}
2020

2121
output "eth_beacon_api_url" {
2222
description = "Ethereum beacon API URL"
23-
value = var.CREATE_STATIC_IPS ? "http://${google_compute_address.eth_beacon_ip[0].address}:5052" : null
23+
value = var.CREATE_STATIC_IPS ? "http://${google_compute_address.eth_beacon_ip[0].address}:5052" : "http://${data.kubernetes_service.eth_beacon[0].spec[0].cluster_ip}:5052"
2424
}
2525

2626
output "chain_id" {

spartan/terraform/deploy-eth-devnet/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ variable "ETH_DEVNET_VALUES" {
3434
default = "eth-devnet.yaml"
3535
}
3636

37+
variable "MNEMONIC" {
38+
description = "The mnemonic to use for the eth devnet"
39+
type = string
40+
default = "test test test test test test test test test test test junk"
41+
sensitive = true
42+
}
3743

3844

3945
variable "CREATE_STATIC_IPS" {

spartan/terraform/deploy-rollup-contracts/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ locals {
3131
["--l1-rpc-urls", var.L1_RPC_URLS],
3232
["--mnemonic", var.MNEMONIC],
3333
["--l1-chain-id", tostring(var.L1_CHAIN_ID)],
34-
# ["--validators", var.VALIDATORS],
34+
["--validators", var.VALIDATORS],
3535
["--json"], # Always output JSON for easier parsing
3636
var.SALT != null ? ["--salt", tostring(var.SALT)] : [],
3737
var.SPONSORED_FPC ? ["--sponsored-fpc"] : [],

0 commit comments

Comments
 (0)