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

fix(spartan): each tx bot replica gets its own l1 private key #12219

Merged
merged 5 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 0 additions & 4 deletions .github/workflows/network-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ jobs:
-var="AZTEC_DOCKER_IMAGE=${{ env.AZTEC_DOCKER_IMAGE }}" \
-var="L1_DEPLOYMENT_PRIVATE_KEY=${{ secrets.SEPOLIA_L1_DEPLOYMENT_PRIVATE_KEY }}" \
-var="L1_DEPLOYMENT_MNEMONIC=$L1_DEPLOYMENT_MNEMONIC" \
-var="BOT_L1_MNEMONIC=$L1_DEPLOYMENT_MNEMONIC" \
-var="EXTERNAL_ETHEREUM_HOST=${{ env.EXTERNAL_ETHEREUM_HOST }}" \
-var="EXTERNAL_ETHEREUM_CONSENSUS_HOST=${{ env.EXTERNAL_ETHEREUM_CONSENSUS_HOST }}" \
-var="EXTERNAL_ETHEREUM_CONSENSUS_HOST_API_KEY=${{ secrets.SEPOLIA_API_KEY }}" \
Expand All @@ -208,7 +207,6 @@ jobs:
-var="GKE_CLUSTER_CONTEXT=${{ env.GKE_CLUSTER_CONTEXT }}" \
-var="AZTEC_DOCKER_IMAGE=${{ env.AZTEC_DOCKER_IMAGE }}" \
-var="L1_DEPLOYMENT_MNEMONIC=${{ steps.get-mnemonic.outputs.mnemonic }}" \
-var="BOT_L1_MNEMONIC=$L1_DEPLOYMENT_MNEMONIC" \
-lock=${{ inputs.respect_tf_lock }}
fi

Expand All @@ -224,7 +222,6 @@ jobs:
-var="AZTEC_DOCKER_IMAGE=${{ env.AZTEC_DOCKER_IMAGE }}" \
-var="L1_DEPLOYMENT_PRIVATE_KEY=${{ secrets.SEPOLIA_L1_DEPLOYMENT_PRIVATE_KEY }}" \
-var="L1_DEPLOYMENT_MNEMONIC=$L1_DEPLOYMENT_MNEMONIC" \
-var="BOT_L1_MNEMONIC=$L1_DEPLOYMENT_MNEMONIC" \
-var="L1_DEPLOYMENT_SALT=${DEPLOYMENT_SALT:-$RANDOM}" \
-var="EXTERNAL_ETHEREUM_HOST=${{ env.EXTERNAL_ETHEREUM_HOST }}" \
-var="EXTERNAL_ETHEREUM_CONSENSUS_HOST=${{ env.EXTERNAL_ETHEREUM_CONSENSUS_HOST }}" \
Expand All @@ -240,7 +237,6 @@ jobs:
-var="AZTEC_DOCKER_IMAGE=${{ env.AZTEC_DOCKER_IMAGE }}" \
-var="L1_DEPLOYMENT_MNEMONIC=${{ steps.get-mnemonic.outputs.mnemonic }}" \
-var="L1_DEPLOYMENT_SALT=${DEPLOYMENT_SALT:-$RANDOM}" \
-var="BOT_L1_MNEMONIC=$L1_DEPLOYMENT_MNEMONIC" \
-out=tfplan \
-lock=${{ inputs.respect_tf_lock }}
fi
Expand Down
1 change: 1 addition & 0 deletions spartan/aztec-network/files/config/get-private-key.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export VALIDATOR_PRIVATE_KEY=$private_key
export L1_PRIVATE_KEY=$private_key
export SEQ_PUBLISHER_PRIVATE_KEY=$private_key
export PROVER_PUBLISHER_PRIVATE_KEY=$private_key
export BOT_L1_PRIVATE_KEY=$private_key
EOF

cat /shared/config/keys.env
28 changes: 25 additions & 3 deletions spartan/aztec-network/templates/transaction-bot.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- if .Values.bot.enabled }}
apiVersion: apps/v1
kind: Deployment
kind: StatefulSet
metadata:
name: {{ include "aztec-network.fullname" . }}-bot
labels:
Expand Down Expand Up @@ -45,6 +45,29 @@ spec:
emptyDir: {}
initContainers:
{{- include "aztec-network.serviceAddressSetupContainer" . | nindent 8 }}
- name: get-private-key
image: {{ .Values.images.foundry.image }}
imagePullPolicy: {{ .Values.images.foundry.pullPolicy }}
command:
- "/bin/sh"
- "-c"
- |
source /scripts/get-private-key.sh
volumeMounts:
- name: scripts
mountPath: /scripts
- name: config
mountPath: /shared/config
env:
- name: KEY_INDEX_START
value: {{ .Values.aztec.botKeyIndexStart | quote }}
- name: MNEMONIC
value: {{ .Values.aztec.l1DeploymentMnemonic }}
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name

- name: wait-for-aztec-node
image: "{{ .Values.images.curl.image }}"
command:
Expand Down Expand Up @@ -79,6 +102,7 @@ spec:
- |
source /shared/config/service-addresses
cat /shared/config/service-addresses
source /shared/config/keys.env
{{- if .Values.bot.nodeUrl }}
export AZTEC_NODE_URL={{ .Values.bot.nodeUrl }}
{{- else if .Values.network.public }}
Expand Down Expand Up @@ -109,8 +133,6 @@ spec:
value: "1"
- name: LOG_LEVEL
value: "{{ .Values.bot.logLevel }}"
- name: BOT_L1_MNEMONIC
value: "{{ .Values.bot.l1Mnemonic }}"
- name: BOT_PRIVATE_KEY
value: "{{ .Values.bot.botPrivateKey }}"
- name: BOT_TX_INTERVAL_SECONDS
Expand Down
3 changes: 2 additions & 1 deletion spartan/aztec-network/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ aztec:
## The number of extra accounts to prefund
extraAccountsStartIndex: 2000
extraAccounts: 10

botKeyIndexStart: 3000
l1Salt: "" # leave empty for random salt

bootNode:
Expand Down Expand Up @@ -204,7 +206,6 @@ bot:
logLevel: "debug; info: aztec:simulator, json-rpc"
replicas: 1
botPrivateKey: "0xcafe"
l1Mnemonic: "test test test test test test test test test test test junk"
txIntervalSeconds: 24
privateTransfersPerTx: 0
publicTransfersPerTx: 1
Expand Down
8 changes: 6 additions & 2 deletions spartan/scripts/generate_devnet_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export EXTRA_ACCOUNTS_START_INDEX=$(./read_value.sh "aztec.extraAccountsStartInd
export NUMBER_OF_PROVER_KEYS=$(./read_value.sh "proverNode.replicas" $value_yamls)
export PROVER_KEY_START_INDEX=$(./read_value.sh "aztec.proverKeyIndexStart" $value_yamls)

export NUMBER_OF_BOT_KEYS=$(./read_value.sh "bot.replicas" $value_yamls)
export BOT_KEY_START_INDEX=$(./read_value.sh "aztec.botKeyIndexStart" $value_yamls)

export MNEMONIC=${MNEMONIC:-$(./read_value.sh "aztec.l1DeploymentMnemonic" $value_yamls)}
export BLOCK_TIME=$(./read_value.sh "ethereum.blockTime" $value_yamls)
export GAS_LIMIT=$(./read_value.sh "ethereum.gasLimit" $value_yamls)
Expand All @@ -21,8 +24,9 @@ export CHAIN_ID=$(./read_value.sh "ethereum.chainId" $value_yamls)
VALIDATOR_KEY_INDICES=$(seq $VALIDATOR_KEY_START_INDEX $((VALIDATOR_KEY_START_INDEX + NUMBER_OF_VALIDATOR_KEYS - 1)))
EXTRA_ACCOUNTS_INDICES=$(seq $EXTRA_ACCOUNTS_START_INDEX $((EXTRA_ACCOUNTS_START_INDEX + EXTRA_ACCOUNTS - 1)))
PROVER_KEY_INDICES=$(seq $PROVER_KEY_START_INDEX $((PROVER_KEY_START_INDEX + NUMBER_OF_PROVER_KEYS - 1)))
BOT_KEY_INDICES=$(seq $BOT_KEY_START_INDEX $((BOT_KEY_START_INDEX + NUMBER_OF_BOT_KEYS - 1)))

export PREFUNDED_MNEMONIC_INDICES=$(echo "$VALIDATOR_KEY_INDICES $EXTRA_ACCOUNTS_INDICES $PROVER_KEY_INDICES" | tr ' ' '\n' | sort -u | tr '\n' ',' | sed 's/,$//')
export PREFUNDED_MNEMONIC_INDICES=$(echo "$VALIDATOR_KEY_INDICES $EXTRA_ACCOUNTS_INDICES $PROVER_KEY_INDICES $BOT_KEY_INDICES" | tr ' ' '\n' | sort -u | tr '\n' ',' | sed 's/,$//')

echo "Generating eth devnet config..."
echo "PREFUNDED_MNEMONIC_INDICES: $PREFUNDED_MNEMONIC_INDICES"
Expand All @@ -31,4 +35,4 @@ echo "BLOCK_TIME: $BLOCK_TIME"
echo "GAS_LIMIT: $GAS_LIMIT"
echo "CHAIN_ID: $CHAIN_ID"

../aztec-network/eth-devnet/create.sh
../aztec-network/eth-devnet/create.sh
1 change: 0 additions & 1 deletion spartan/scripts/test_kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,5 @@ export AZTEC_SLOT_DURATION="$aztec_slot_duration"
export AZTEC_EPOCH_DURATION="$aztec_epoch_duration"
export AZTEC_PROOF_SUBMISSION_WINDOW="$aztec_proof_submission_window"
export L1_ACCOUNT_MNEMONIC="$l1_account_mnemonic"
export BOT_L1_MNEMONIC="$l1_account_mnemonic"

yarn --cwd ../../yarn-project/end-to-end test --forceExit "$test"
5 changes: 0 additions & 5 deletions spartan/terraform/deploy-release/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ variable "L1_DEPLOYMENT_MNEMONIC" {
default = ""
}

variable "BOT_L1_MNEMONIC" {
type = string
default = "test test test test test test test test test test test junk"
}

variable "L1_DEPLOYMENT_PRIVATE_KEY" {
description = "Private key to use for the L1 contract deployments"
type = string
Expand Down
1 change: 0 additions & 1 deletion yarn-project/aztec/terraform/bot/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ resource "aws_ecs_task_definition" "aztec-bot" {
]
environment = [
{ name = "BOT_L1_PRIVATE_KEY", value = var.BOT_L1_PRIVATE_KEY },
{ name = "BOT_L1_MNEMONIC", value = var.BOT_L1_MNEMONIC },
{ name = "BOT_PRIVATE_KEY", value = var.BOT_PRIVATE_KEY },
{ name = "BOT_NO_START", value = var.BOT_NO_START },
{ name = "BOT_TX_INTERVAL_SECONDS", value = var.BOT_TX_INTERVAL_SECONDS },
Expand Down
5 changes: 0 additions & 5 deletions yarn-project/aztec/terraform/bot/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ variable "BOT_L1_PRIVATE_KEY" {
default = ""
}

variable "BOT_L1_MNEMONIC" {
type = string
default = "test test test test test test test test test test test junk"
}

variable "BOT_PRIVATE_KEY" {
type = string
}
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/bot/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class BotFactory {
if (!l1RpcUrl) {
throw new Error('L1 Rpc url is required to bridge the fee juice to fund the deployment of the account.');
}
const mnemonicOrPrivateKey = this.config.l1Mnemonic || this.config.l1PrivateKey;
const mnemonicOrPrivateKey = this.config.l1PrivateKey || this.config.l1Mnemonic;
if (!mnemonicOrPrivateKey) {
throw new Error(
'Either a mnemonic or private key of an L1 account is required to bridge the fee juice to fund the deployment of the account.',
Expand Down
Loading