-
Notifications
You must be signed in to change notification settings - Fork 615
chore: new mnemonic deployments on sepolia #12076
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
Changes from 5 commits
8c60236
e4cd094
417500e
110107f
c450dfa
43203a0
059b9d2
0706a28
b049e41
4b8f630
201d858
3bb6d03
b7b0336
07fa90b
de99ca7
f8519c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How come you only want test accounts here?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Separately, I have a PR that just pulls this into the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. huh must've added this by mistake, will remove thx 👍
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
| 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 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we rather want
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 }} | ||
| 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 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deliberate?
There was a problem hiding this comment.
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 😬
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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