-
Notifications
You must be signed in to change notification settings - Fork 599
fix: kind on sepolia + balance consolidation + sepolia values service indices #12473
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 all commits
2066865
be1b729
d62d099
cf71c99
a0ff1d5
b5f59eb
d9f2d3e
5f21a16
1565217
fcf8201
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
|
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. Should we delete this file if it's now copied into the heml template? Or can we embed it somehow, to avoid having it duplicated?
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. Don't think there's a 'nice' way to embed it. I kept it just bc it may still be useful to be run ad-hoc sometimes but can delete
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. Let's throw in a comment in both places about it being duplicated then, so future us don't accidentally change one but not the other |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Helper script for consolidating balances on Sepolia, that were previously dispersed across multiple accounts. | ||
| # The script uses the mnemonic to get the accounts' private keys & calculate which ones were funded from a helm chart yaml. | ||
| # Usage: ./consolidate-sepolia-balances.sh <mnemonic> <funding_address> <values_file> | ||
| # Environment variables: | ||
| # ETHEREUM_HOSTS (must be provided) | ||
|
|
||
| # IMPORTANT NOTE: The script should be the same as the one found in the consolidate-balances.yaml template. | ||
| # This standalone is left here for ad-hoc use if needed. | ||
|
|
||
| set -exu | ||
|
|
||
| mnemonic=$1 | ||
| funding_address=${2:-"0x33D525f5ac95c2BCf98b644738C7d5673480493A"} | ||
| values_file=${3:-"ignition-testnet"} | ||
|
|
||
| XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-"$HOME/.config"} | ||
|
|
||
| ETHEREUM_RPC_URL=$(echo "$ETHEREUM_HOSTS" | cut -d',' -f1) | ||
|
|
||
| # 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 | ||
|
|
||
| # Get values from the values file | ||
| value_yamls="../aztec-network/values/$values_file ../aztec-network/values.yaml" | ||
|
|
||
| # Get the number of replicas for each service | ||
| num_validators=$(./read_value.sh "validator.replicas" $value_yamls) | ||
| num_provers=$(./read_value.sh "proverNode.replicas" $value_yamls) | ||
|
|
||
| # Get the key index start values | ||
| validator_key_index_start=$(./read_value.sh "aztec.validatorKeyIndexStart" $value_yamls) | ||
| prover_key_index_start=$(./read_value.sh "aztec.proverKeyIndexStart" $value_yamls) | ||
| bot_key_index_start=$(./read_value.sh "aztec.botKeyIndexStart" $value_yamls) | ||
|
|
||
| # bots might be disabled | ||
| bot_enabled=$(./read_value.sh "bot.enabled" $value_yamls) | ||
| if [ "$bot_enabled" = "true" ]; then | ||
| num_bots=$(./read_value.sh "bot.replicas" $value_yamls) | ||
| else | ||
| num_bots=0 | ||
| fi | ||
|
|
||
| # Build an array of indices to check | ||
| declare -a indices_to_check | ||
|
|
||
| # Add validator indices | ||
| for ((i = 0; i < num_validators; i++)); do | ||
| indices_to_check+=($((validator_key_index_start + i))) | ||
| done | ||
|
|
||
| # Add prover indices | ||
| for ((i = 0; i < num_provers; i++)); do | ||
| indices_to_check+=($((prover_key_index_start + i))) | ||
| done | ||
|
|
||
| # Add bot indices if enabled | ||
| if [ "$bot_enabled" = "true" ]; then | ||
| for ((i = 0; i < num_bots; i++)); do | ||
| indices_to_check+=($((bot_key_index_start + i))) | ||
| done | ||
| fi | ||
|
|
||
| echo "Checking balances for ${#indices_to_check[@]} accounts..." | ||
|
|
||
| # For each index in our list | ||
| for i in "${indices_to_check[@]}"; 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_RPC_URL") | ||
|
|
||
| if [ "$balance" != "0" ]; then | ||
| gas_price=$(cast gas-price --rpc-url "$ETHEREUM_RPC_URL") | ||
| 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)) | ||
|
Comment on lines
+85
to
+86
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. Shouldn't we also account for
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, hasn't been an issue when I've used this script, ig the 20% buffer that's added is enough?
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. Maybe we're just sending legacy txs? Nvm then, if it works it works. |
||
|
|
||
| if [ "$send_amount" -gt "0" ]; then | ||
| echo "Sending $send_amount wei from $address (index $i) to $funding_address" | ||
| cast send --private-key "$private_key" --rpc-url "$ETHEREUM_RPC_URL" "$funding_address" \ | ||
| --value "$send_amount" --gas-price "$gas_price" --async | ||
|
Comment on lines
+90
to
+91
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. I assume that if this fails, 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. yeah |
||
| else | ||
| echo "Balance too low to cover gas costs for $address (index $i)" | ||
| fi | ||
| else | ||
| echo "No balance in $address (index $i)" | ||
| fi | ||
| done | ||
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.
I understand the idea is to just rely on the default values file, right?
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.
yep 👍