Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
13 changes: 11 additions & 2 deletions .github/workflows/network-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ jobs:

$REPO/spartan/scripts/generate_devnet_config.sh ${{ env.VALUES_FILE }}

- name: Generate sepolia accounts
id: generate-sepolia-accounts
if: ${{ inputs.sepolia_deployment == 'true' }}
run: |
REPO=$(git rev-parse --show-toplevel)
mnemonic=$(bash $REPO/spartan/scripts/prepare_sepolia_accounts.sh ${{ env.VALUES_FILE }} 1)
echo "::add-mask::$mnemonic"
echo "mnemonic=$mnemonic" >> "$GITHUB_OUTPUT"

- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
Expand All @@ -187,7 +196,7 @@ jobs:
continue-on-error: true
run: |
if ${{ inputs.sepolia_deployment == 'true' }}; then
export L1_DEPLOYMENT_MNEMONIC="${{ secrets.SEPOLIA_ACCOUNTS_MNEMONIC }}"
export L1_DEPLOYMENT_MNEMONIC="${{ steps.generate-sepolia-accounts.outputs.mnemonic }}"
terraform destroy -auto-approve \
-var="RELEASE_NAME=${{ env.NAMESPACE }}" \
-var="VALUES_FILE=${{ env.VALUES_FILE }}" \
Expand Down Expand Up @@ -216,7 +225,7 @@ jobs:
working-directory: ./spartan/terraform/deploy-release
run: |
if ${{ inputs.sepolia_deployment == 'true' }}; then
export L1_DEPLOYMENT_MNEMONIC="${{ secrets.SEPOLIA_ACCOUNTS_MNEMONIC }}"
export L1_DEPLOYMENT_MNEMONIC="${{ steps.generate-sepolia-accounts.outputs.mnemonic }}"
terraform plan \
-var="RELEASE_NAME=${{ env.NAMESPACE }}" \
-var="VALUES_FILE=${{ env.VALUES_FILE }}" \
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/nightly-kind-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ jobs:
export EXTERNAL_ETHEREUM_CONSENSUS_HOST_API_KEY=${{ secrets.SEPOLIA_API_KEY }}
export EXTERNAL_ETHEREUM_CONSENSUS_HOST_API_KEY_HEADER=${{ env.GCP_API_KEY_HEADER }}
export L1_DEPLOYMENT_PRIVATE_KEY=${{ secrets.SEPOLIA_L1_DEPLOYMENT_PRIVATE_KEY }}
export L1_ACCOUNTS_MNEMONIC="${{ secrets.SEPOLIA_ACCOUNTS_MNEMONIC }}"
SEPOLIA_RUN=true INSTALL_METRICS=false ./spartan/scripts/test_kind.sh "./src/spartan/${{ matrix.config.test }}" "${{ matrix.config.values }}"
ci3/cache_upload_flag "$artifact"
fi
Expand Down
14 changes: 7 additions & 7 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"awsvpc",
"aztecprotocol",
"barretenberg",
"barretenberg",
"bbfree",
"bbmalloc",
"benesjan",
Expand Down Expand Up @@ -121,8 +120,6 @@
"gossipsub",
"Governance",
"grumpkin",
"grumpkin",
"gtest",
"gtest",
"gzipped",
"hackmd",
Expand Down Expand Up @@ -181,13 +178,13 @@
"multiaddr",
"multiaddrs",
"multiarch",
"multicall",
"multiformats",
"multivalue",
"muxers",
"nada",
"namespacing",
"napi",
"napi",
"Nargo",
"nixpkgs",
"nodebuffer",
Expand Down Expand Up @@ -223,6 +220,7 @@
"Pokeable",
"preauthenticated",
"precompute",
"prefunded",
"preimage",
"preimages",
"prestat",
Expand Down Expand Up @@ -288,18 +286,17 @@
"tldr",
"tmpfs",
"toplevel",
"toplevel",
"tparam",
"transferables",
"transitioner",
"trivago",
"tsbuildinfo",
"tsdoc",
"txes",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

deliberate?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes, cspell annotations annoy me so I add stuff 😬

@spypsy spypsy Feb 24, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oh just saw that it was already there 😬 . Seems my editor fixed alphabetic arrangemenet & removed duplicates

"typechain",
"typecheck",
"typegen",
"typeparam",
"txes",
"undeployed",
"undici",
"unexclude",
Expand Down Expand Up @@ -328,6 +325,7 @@
"webassembly",
"WITGEN",
"workdir",
"yamls",
"yamux",
"yarnrc",
"zerocash",
Expand Down Expand Up @@ -358,5 +356,7 @@
"lib",
"*.cmake"
],
"flagWords": ["anonymous"]
"flagWords": [
"anonymous"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
set -eu

mnemonic=$1
# at least 2 accounts are needed for the validator and prover nodes
num_accounts=${2:-"2"}
funding_address=${3:-"0x33D525f5ac95c2BCf98b644738C7d5673480493A"}

XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-"$HOME/.config"}

# Install cast if needed
if ! command -v cast &>/dev/null; then
curl -L https://foundry.paradigm.xyz | bash
$HOME/.foundry/bin/foundryup && export PATH="$PATH:$HOME/.foundry/bin" ||
$XDG_CONFIG_HOME/.foundry/bin/foundryup && export PATH="$PATH:$XDG_CONFIG_HOME/.foundry/bin"
fi

# For each index
for i in $(seq 0 $((num_accounts - 1))); do
# Get address and private key for this index
address=$(cast wallet address --mnemonic "$mnemonic" --mnemonic-index $i)
private_key=$(cast wallet private-key --mnemonic "$mnemonic" --mnemonic-index $i)

# Get balance
balance=$(cast balance $address --rpc-url "$ETHEREUM_HOST")

if [ "$balance" != "0" ]; then
gas_price=$(cast gas-price --rpc-url "$ETHEREUM_HOST")
gas_price=$((gas_price * 120 / 100)) # Add 20% to gas price
gas_cost=$((21000 * gas_price))

# Calculate amount to send (balance - gas cost)
send_amount=$((balance - gas_cost))

if [ "$send_amount" -gt "0" ]; then
echo "Sending $send_amount wei from $address to $funding_address"
cast send --private-key "$private_key" --rpc-url "$ETHEREUM_HOST" "$funding_address" \
--value "$send_amount" --gas-price "$gas_price" --async
else
echo "Balance too low to cover gas costs for $address"
fi
else
echo "No balance in $address"
fi
done
4 changes: 2 additions & 2 deletions spartan/aztec-network/files/config/deploy-l1-contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ RETRY_DELAY=15

for attempt in $(seq 1 $MAX_RETRIES); do
# Construct base command
base_cmd="LOG_LEVEL=debug node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js deploy-l1-contracts --test-accounts"
base_cmd="LOG_LEVEL=debug node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js deploy-l1-contracts"

# Add account - use private key if set, otherwise use mnemonic
if [ -n "${L1_DEPLOYMENT_PRIVATE_KEY:-}" ]; then
base_cmd="$base_cmd --private-key $L1_DEPLOYMENT_PRIVATE_KEY"
else
base_cmd="$base_cmd --mnemonic '$MNEMONIC'"
base_cmd="$base_cmd --mnemonic '$MNEMONIC' --test-accounts"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

How come you only want test accounts here?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Separately, I have a PR that just pulls this into the aztec.testAccounts

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

huh must've added this by mistake, will remove thx 👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oh wait nvm now I see what I did.. we don't have test accounts for sepolia

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

But this "test accounts" is referring to L2 test accounts. It impacts the genesis state in the rollup.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ah mb thought it was for L1 genesis state. And this doesn't need anything different done in L1? will add back

fi

# Add validators if INIT_VALIDATORS is true
Expand Down
47 changes: 47 additions & 0 deletions spartan/aztec-network/templates/consolidate-balances.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{- if .Values.ethereum.execution.externalHost }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ .Release.Name }}-consolidate-balances
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": pre-delete

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we rather want post-delete? It looks like pre-delete runs in response to any resource getting deleted, but we probably want to consolidate funds after everything has been cleaned up?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

makes sense, updating!

"helm.sh/hook-delete-policy": hook-succeeded,hook-failed
"helm.sh/hook-weight": "-5"
spec:
template:
metadata:
labels:
{{- include "aztec-network.selectorLabels" . | nindent 8 }}
app: consolidate-balances
spec:
restartPolicy: OnFailure
{{- if .Values.network.public }}
serviceAccountName: {{ include "aztec-network.fullname" . }}-node
{{- end }}
volumes:
- name: config
emptyDir: {}
- name: scripts
configMap:
name: {{ include "aztec-network.fullname" . }}-scripts
containers:
- name: consolidate-balances
{{- include "aztec-network.image" . | nindent 10 }}
volumeMounts:
- name: scripts
mountPath: /scripts
- name: config
mountPath: /shared/config
command:
- /bin/bash
- -c
- |
cp /scripts/consolidate-sepolia-balances.sh /tmp/consolidate-sepolia-balances.sh
chmod +x /tmp/consolidate-sepolia-balances.sh
/tmp/consolidate-sepolia-balances.sh "{{ .Values.aztec.l1DeploymentMnemonic }}" {{ add .Values.validator.replicas .Values.proverNode.replicas }}
env:
- name: ETHEREUM_HOST
value: "{{ .Values.ethereum.execution.externalHost }}"
{{ end }}
3 changes: 2 additions & 1 deletion spartan/aztec-network/templates/scripts-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ data:
{{ .Files.Get "files/config/get-private-key.sh" | nindent 4 }}
get-validator-addresses.sh: |
{{ .Files.Get "files/config/get-validator-addresses.sh" | nindent 4 }}

consolidate-sepolia-balances.sh: |
{{ .Files.Get "files/cleanup/consolidate-sepolia-balances.sh" | nindent 4 }}
7 changes: 5 additions & 2 deletions spartan/aztec-network/values/ci-sepolia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ aztec:
proofSubmissionWindow: 8
realProofs: false
l1DeploymentMnemonic: ""
validatorKeyIndexStart: 49
proverKeyIndexStart: 52
validatorKeyIndexStart: 0
proverKeyIndexStart: 3

network:
setupL2Contracts: false

ethereum:
chainId: "11155111"
Expand Down
2 changes: 1 addition & 1 deletion spartan/aztec-network/values/ignition-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ aztec:
realProofs: true
l1DeploymentMnemonic: ""
validatorKeyIndexStart: 0
proverKeyIndexStart: 48
proverKeyIndexStart: 3

network:
setupL2Contracts: false
Expand Down
4 changes: 2 additions & 2 deletions spartan/aztec-network/values/rc-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ aztec:
realProofs: true
# TODO: Will need to change these as ignition will be using them
l1DeploymentMnemonic: ""
validatorKeyIndexStart: 4
proverKeyIndexStart: 52
validatorKeyIndexStart: 0
proverKeyIndexStart: 48

images:
aztec:
Expand Down
7 changes: 6 additions & 1 deletion spartan/scripts/deploy_kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function generate_overrides {
local overrides="$1"
if [ -n "$overrides" ]; then
# Split the comma-separated string into an array and generate --set arguments
IFS=',' read -ra OVERRIDE_ARRAY <<< "$overrides"
IFS=',' read -ra OVERRIDE_ARRAY <<<"$overrides"
for override in "${OVERRIDE_ARRAY[@]}"; do
echo "--set $override"
done
Expand All @@ -79,6 +79,11 @@ function generate_overrides {
if [ "$sepolia_deployment" != "true" ]; then
echo "Generating devnet config..."
./generate_devnet_config.sh "$values_file"
else
echo "Generating sepolia accounts..."
L1_ACCOUNTS_MNEMONIC=$(./prepare_sepolia_accounts.sh "$values_file")
# write the mnemonic to a file
echo "$L1_ACCOUNTS_MNEMONIC" >mnemonic.tmp
fi

# Install the Helm chart
Expand Down
2 changes: 1 addition & 1 deletion spartan/scripts/generate_devnet_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export PREFUNDED_MNEMONIC_INDICES=$(echo "$VALIDATOR_KEY_INDICES $EXTRA_ACCOUNTS

echo "Generating eth devnet config..."
echo "PREFUNDED_MNEMONIC_INDICES: $PREFUNDED_MNEMONIC_INDICES"
echo "MNEMONIC: $MNEMONIC"
echo "MNEMONIC: $(echo $MNEMONIC | cut -d' ' -f1-2)..."
echo "BLOCK_TIME: $BLOCK_TIME"
echo "GAS_LIMIT: $GAS_LIMIT"
echo "CHAIN_ID: $CHAIN_ID"
Expand Down
71 changes: 71 additions & 0 deletions spartan/scripts/prepare_sepolia_accounts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash
set -eu

values_file=$1
eth_amount=${2:-"1"}
XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-"$HOME/.config"}

value_yamls="../aztec-network/values/$values_file ../aztec-network/values.yaml"

num_validators=$(./read_value.sh "validator.replicas" $value_yamls)
num_provers=$(./read_value.sh "proverNode.replicas" $value_yamls)
num_accounts=$((num_validators + num_provers))

# Install bc if needed
if ! command -v bc &>/dev/null; then
apt-get update && apt-get install -y bc
fi

# Install cast if needed
if ! command -v cast &>/dev/null; then
curl -L https://foundry.paradigm.xyz | bash
$HOME/.foundry/bin/foundryup && export PATH="$PATH:$HOME/.foundry/bin" ||
$XDG_CONFIG_HOME/.foundry/bin/foundryup && export PATH="$PATH:$XDG_CONFIG_HOME/.foundry/bin"
fi

# Install yq if needed
if ! command -v yq &>/dev/null; then
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq
chmod +x /usr/local/bin/yq
fi

# Create a new mnemonic with the required number of accounts
cast wallet new-mnemonic --accounts "$num_accounts" --json >output.json
MNEMONIC=$(jq -r '.mnemonic' output.json)
ADDRESSES=$(jq -r '.accounts[].address' output.json)

# Convert ETH to wei
wei_amount=$(cast to-wei "$eth_amount" ether)

# Get current gas price and add 50% buffer

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: busted comment?

gas_price=$(cast gas-price --rpc-url "$ETHEREUM_HOST")
gas_price=$((gas_price * 125 / 100)) # Add 25% to gas price

# Build 'calls' string in the format:
# [(0xADDR,false,wei_amount,0x),(0xADDR2,false,wei_amount,0x)]
calls="["
for addr in $ADDRESSES; do
calls+="(${addr},false,${wei_amount},0x),"
done
calls=${calls%,}
calls+="]"

# Total value = wei_amount * num_accounts
total_value=$(echo "$wei_amount * $num_accounts" | bc)

multicall_address="0xcA11bde05977b3631167028862bE2a173976CA11" # Sepolia Multicall3 contract

TX_HASH=$(cast send "$multicall_address" \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ah multicall for this is nice

"aggregate3Value((address,bool,uint256,bytes)[])" \
"$calls" \
--value "$total_value" \
--private-key "$FUNDING_PRIVATE_KEY" \
--rpc-url "$ETHEREUM_HOST" \
--json --gas-price "$gas_price")

echo >&2 "Sent ${wei_amount} wei to ${num_accounts} addresses in tx $TX_HASH"

# Remove temp file
rm output.json

echo "$MNEMONIC"
Loading