Skip to content

Commit

Permalink
add deployer to genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
just-mitch committed Dec 4, 2024
1 parent 37c1095 commit 5480465
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/network-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
-var="values_file=${{ env.VALUES_FILE }}" \
-var="gke_cluster_context=${{ env.GKE_CLUSTER_CONTEXT }}" \
-var="aztec_docker_image=${{ env.AZTEC_DOCKER_IMAGE }}" \
-var="boot_node_deployment_mnemonic=${{ steps.get-mnemonic.outputs.mnemonic }}" \
-var="l1_deployment_mnemonic=${{ steps.get-mnemonic.outputs.mnemonic }}" \
-out=tfplan \
-lock=${{ inputs.respect_tf_lock }}
Expand Down
3 changes: 0 additions & 3 deletions spartan/aztec-network/files/config/deploy-l1-contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ set -exu
CHAIN_ID=$1


# Use default account, it is funded on our dev machine
# export PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"

# Run the deploy-l1-contracts command and capture the output
output=""
# if INIT_VALIDATORS is true, then we need to pass the validators flag to the deploy-l1-contracts command
Expand Down
2 changes: 1 addition & 1 deletion spartan/aztec-network/templates/boot-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ spec:
- name: INIT_VALIDATORS
value: "true"
- name: MNEMONIC
value: "{{ .Values.bootNode.deploymentMnemonic }}"
value: "{{ .Values.aztec.l1DeploymentMnemonic }}"
- name: ETHEREUM_SLOT_DURATION
value: "{{ .Values.ethereum.blockTime }}"
- name: AZTEC_SLOT_DURATION
Expand Down
43 changes: 41 additions & 2 deletions spartan/aztec-network/templates/reth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,43 @@ spec:
{{- if .Values.network.public }}
hostNetwork: true
{{- end }}
initContainers:
- name: prepare-genesis
image: node:18-alpine
command: ["/bin/sh", "-c"]
args:
- |
cd /tmp
npm init -y
npm install ethers@6
cat > derive.js << 'EOF'
const { ethers } = require('ethers');
const fs = require('fs');
async function main() {
const mnemonic = process.env.DEPLOYMENT_MNEMONIC;
const wallet = ethers.Wallet.fromPhrase(mnemonic);
const genesis = JSON.parse(fs.readFileSync('/genesis-template/genesis.json', 'utf8'));
genesis.alloc[wallet.address] = {
balance: '0x3635c9adc5dea00000' // 1000 ETH in wei
};
fs.writeFileSync('/genesis-output/genesis.json', JSON.stringify(genesis, null, 2));
}
main().catch(console.error);
EOF
node derive.js
env:
- name: DEPLOYMENT_MNEMONIC
value: {{ .Values.aztec.l1DeploymentMnemonic }}
volumeMounts:
- name: genesis-template
mountPath: /genesis-template
- name: genesis-output
mountPath: /genesis-output
containers:
- name: ethereum
image: "{{ .Values.images.reth.image }}"
Expand All @@ -40,17 +77,19 @@ spec:
volumeMounts:
- name: shared-volume
mountPath: /data
- name: genesis
- name: genesis-output
mountPath: /genesis
resources:
{{- toYaml .Values.ethereum.resources | nindent 12 }}
volumes:
- name: shared-volume
persistentVolumeClaim:
claimName: {{ include "aztec-network.fullname" . }}-ethereum-pvc
- name: genesis
- name: genesis-template
configMap:
name: {{ include "aztec-network.fullname" . }}-reth-genesis
- name: genesis-output
emptyDir: {}
{{if not .Values.network.public }}
---
apiVersion: v1
Expand Down
2 changes: 1 addition & 1 deletion spartan/aztec-network/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ aztec:
slotDuration: 24 # in seconds, aka L2 slot duration. Must be a multiple of {{ ethereum.blockTime }}
epochDuration: 16 # how many L2 slots in an epoch
epochProofClaimWindow: 13 # in L2 slots
l1DeploymentMnemonic: "test test test test test test test test test test test junk" # the mnemonic used when deploying contracts

bootNode:
deploymentMnemonic: "test test test test test test test test test test test junk"
peerIdPrivateKey: ""
externalHost: ""
replicas: 1
Expand Down
1 change: 1 addition & 0 deletions spartan/aztec-network/values/1-validators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ validator:
bootNode:
validator:
disabled: true
deploymentMnemonic: "slender solid order lift mirror pretty profit awake shine trumpet stock budget"
4 changes: 2 additions & 2 deletions spartan/terraform/deploy-release/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ resource "helm_release" "aztec-gke-cluster" {
}

set {
name = "bootNode.deploymentMnemonic"
value = var.boot_node_deployment_mnemonic
name = "aztec.l1DeploymentMnemonic"
value = var.l1_deployment_mnemonic
}

# Setting timeout and wait conditions
Expand Down
4 changes: 2 additions & 2 deletions spartan/terraform/deploy-release/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ variable "aztec_docker_image" {
type = string
}

variable "boot_node_deployment_mnemonic" {
description = "Mnemonic to use for the boot node contract deployments"
variable "l1_deployment_mnemonic" {
description = "Mnemonic to use for the L1 contract deployments"
type = string
sensitive = true
}

0 comments on commit 5480465

Please sign in to comment.