diff --git a/.github/workflows/network-deploy.yml b/.github/workflows/network-deploy.yml index d584af13585..b81ee3ff972 100644 --- a/.github/workflows/network-deploy.yml +++ b/.github/workflows/network-deploy.yml @@ -168,6 +168,17 @@ 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) + export FUNDING_PRIVATE_KEY=${{ secrets.SEPOLIA_FUNDING_PRIVATE_KEY }} + export ETHEREUM_HOST=${{ env.EXTERNAL_ETHEREUM_HOST }} + mnemonic=$(bash $REPO/spartan/scripts/prepare_sepolia_accounts.sh ${{ env.VALUES_FILE }} 5) + echo "::add-mask::$mnemonic" + echo "mnemonic=$mnemonic" >> "$GITHUB_OUTPUT" + - name: Setup Terraform uses: hashicorp/setup-terraform@v2 with: @@ -187,7 +198,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 }}" \ @@ -214,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 }}" \ diff --git a/.github/workflows/nightly-kind-test.yml b/.github/workflows/nightly-kind-test.yml index 0d61e6f3592..25bf25e2de0 100644 --- a/.github/workflows/nightly-kind-test.yml +++ b/.github/workflows/nightly-kind-test.yml @@ -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 diff --git a/cspell.json b/cspell.json index fd53e5a554d..63925f55342 100644 --- a/cspell.json +++ b/cspell.json @@ -179,6 +179,7 @@ "multiaddr", "multiaddrs", "multiarch", + "multicall", "multiformats", "multivalue", "muxers", @@ -220,6 +221,7 @@ "Pokeable", "preauthenticated", "precompute", + "prefunded", "preimage", "preimages", "prestat", @@ -324,6 +326,7 @@ "webassembly", "WITGEN", "workdir", + "yamls", "yamux", "yarnrc", "zerocash", diff --git a/spartan/aztec-network/files/cleanup/consolidate-sepolia-balances.sh b/spartan/aztec-network/files/cleanup/consolidate-sepolia-balances.sh new file mode 100755 index 00000000000..491f68c01aa --- /dev/null +++ b/spartan/aztec-network/files/cleanup/consolidate-sepolia-balances.sh @@ -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 diff --git a/spartan/aztec-network/files/config/get-private-key.sh b/spartan/aztec-network/files/config/get-private-key.sh index a9e5b56fc2a..4b42fe03767 100755 --- a/spartan/aztec-network/files/config/get-private-key.sh +++ b/spartan/aztec-network/files/config/get-private-key.sh @@ -1,7 +1,7 @@ #!/bin/bash set -eu -# We get the index in the config map from the pod name, which will have the validator index within it +# We get the index in the config map from the pod name, which will have the service index within it KEY_INDEX=$(echo $POD_NAME | awk -F'-' '{print $NF}') # Add the index to the start index to get the private key index PRIVATE_KEY_INDEX=$((KEY_INDEX_START + KEY_INDEX)) @@ -14,7 +14,7 @@ echo "MNEMONIC: $(echo $MNEMONIC | cut -d' ' -f1-2)..." # Get the private key from the mnemonic private_key=$(cast wallet private-key "$MNEMONIC" --mnemonic-index $PRIVATE_KEY_INDEX) -# Note, currently writing both prover and sequencer keys for all nodes for convinience +# Note, currently writing keys for all services for convenience cat </shared/config/keys.env export VALIDATOR_PRIVATE_KEY=$private_key export L1_PRIVATE_KEY=$private_key diff --git a/spartan/aztec-network/templates/consolidate-balances.yaml b/spartan/aztec-network/templates/consolidate-balances.yaml new file mode 100644 index 00000000000..2718967a71f --- /dev/null +++ b/spartan/aztec-network/templates/consolidate-balances.yaml @@ -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": post-delete + "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 }} diff --git a/spartan/aztec-network/templates/scripts-configmap.yaml b/spartan/aztec-network/templates/scripts-configmap.yaml index 556f1b6d03b..1ed70831520 100644 --- a/spartan/aztec-network/templates/scripts-configmap.yaml +++ b/spartan/aztec-network/templates/scripts-configmap.yaml @@ -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 }} diff --git a/spartan/aztec-network/values/ci-sepolia.yaml b/spartan/aztec-network/values/ci-sepolia.yaml index 8290c4159a0..bed249dd276 100644 --- a/spartan/aztec-network/values/ci-sepolia.yaml +++ b/spartan/aztec-network/values/ci-sepolia.yaml @@ -3,8 +3,12 @@ aztec: proofSubmissionWindow: 8 realProofs: false l1DeploymentMnemonic: "" - validatorKeyIndexStart: 49 - proverKeyIndexStart: 52 + validatorKeyIndexStart: 0 + proverKeyIndexStart: 3 + botKeyIndexStart: 4 + +network: + setupL2Contracts: false ethereum: chainId: "11155111" diff --git a/spartan/aztec-network/values/ignition-testnet.yaml b/spartan/aztec-network/values/ignition-testnet.yaml index 4c045b88a27..8f5638bbe61 100644 --- a/spartan/aztec-network/values/ignition-testnet.yaml +++ b/spartan/aztec-network/values/ignition-testnet.yaml @@ -5,7 +5,7 @@ aztec: realProofs: true l1DeploymentMnemonic: "" validatorKeyIndexStart: 0 - proverKeyIndexStart: 48 + proverKeyIndexStart: 3 network: setupL2Contracts: false diff --git a/spartan/aztec-network/values/rc-2.yaml b/spartan/aztec-network/values/rc-2.yaml index 6ae96570c7a..450a0f3b413 100644 --- a/spartan/aztec-network/values/rc-2.yaml +++ b/spartan/aztec-network/values/rc-2.yaml @@ -5,8 +5,9 @@ aztec: realProofs: true # TODO: Will need to change these as ignition will be using them l1DeploymentMnemonic: "" - validatorKeyIndexStart: 4 - proverKeyIndexStart: 52 + validatorKeyIndexStart: 0 + proverKeyIndexStart: 48 + botKeyIndexStart: 49 images: aztec: diff --git a/spartan/aztec-network/values/sepolia-3-validators-with-metrics.yaml b/spartan/aztec-network/values/sepolia-3-validators-with-metrics.yaml index eaf8a23978d..e53f849e9cc 100644 --- a/spartan/aztec-network/values/sepolia-3-validators-with-metrics.yaml +++ b/spartan/aztec-network/values/sepolia-3-validators-with-metrics.yaml @@ -3,6 +3,9 @@ telemetry: aztec: realProofs: false + validatorKeyIndexStart: 0 + proverKeyIndexStart: 3 + botKeyIndexStart: 4 network: setupL2Contracts: false @@ -10,8 +13,6 @@ network: ethereum: l1DeploymentMnemonic: - proverKeyIndexStart: 0 - validatorKeyIndexStart: 1 chainId: "11155111" execution: externalHost: diff --git a/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml b/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml index 7a7728fda95..f17743a60a5 100644 --- a/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml +++ b/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml @@ -1,6 +1,12 @@ telemetry: enabled: true +aztec: + l1DeploymentMnemonic: "" + validatorKeyIndexStart: 0 + proverKeyIndexStart: 48 + botKeyIndexStart: 49 + network: setupL2Contracts: false public: false @@ -12,6 +18,8 @@ ethereum: externalHost: beacon: externalHost: + apiKey: "" + apiKeyHeader: "" validator: l1FixedPriorityFeePerGas: 2 @@ -19,53 +27,6 @@ validator: l1GasPriceMax: 500 replicas: 48 validatorKeys: - validatorAddresses: - - 0xcD92B30FeFbD2752fF80dD1d152347B1C0b80555 - - 0x3eb04876AEaC0ecB2095D5be5FCE965BE114f6Ea - - 0x69746Fc304C08331C5B3F0E4A8Be82Bbe9079de7 - - 0x11eCa503d1A4C89EA801B5428690844378FF8EDb - - 0x690944149F6090F8B8131d21B7C9243f44953dA3 - - 0x9991124C826d4b469544A326B8e93C7ea6291Df6 - - 0x790a1ACe055c42Ef0aDd7C94b0605e68F4F7ac32 - - 0x3bb53E1A35768B250185d9a1E3A220dfcFD21959 - - 0x1a42bfAF536DD0931AbDb6C7b5d6a2e795849111 - - 0x0b69F2c3b1DCe6974c860655C1B1A0bE209F0EEe - - 0x15dC3B5b63B2846Caf36631b4cc89EC2133484A3 - - 0xEb81BB1891ad6bDB88Bd870703e8E8ca809bF76e - - 0xe484C194039a2D1334F9f701e6AeEAdb2b1009F8 - - 0xC1f9e958888FcfB74C0f72FF4fcA8525a2FD7577 - - 0x27A99682eF70cE26CBe981B2E0BEA2f608bfD44D - - 0xb010Fb11B64Ad756721884d84E66dF0Aa96F1f5f - - 0xC5E960E795284a7AF2F1b5ED3acb17cE51143342 - - 0x44C08d1b44C5D099ecCB626297541E9214aED279 - - 0x78117dD80E4e54EFFd9546Dce1719fB5df30a0A1 - - 0x941d42B68BE5B50f32b24e39c7C48A07Cda37f34 - - 0xAbE28C0BA704111b03903BCBC92c486CE457eC3C - - 0xb0F15e42B0b234070C222B02e173b1e1263E9Bad - - 0xbEaB732a958301EF542DD465DFfcaaa7DA0D64cA - - 0x56C4277eACF43a4a19dEafa2617776f88566C9A8 - - 0xfCaEA5838C6C5a90DA0DE920a122998D7F72e049 - - 0xB204ed1f6cD2E7609421477DA004Aad34eD44aa2 - - 0x5e6a2e947b506f0E06E94b5C421097564c1bf7B1 - - 0x4f321D1922ECDAc05F137E6E9cD2b2873D02b13C - - 0x7964e6211fC121Fb4577d25729724aD97AfD6349 - - 0x3Bf8F13D4D2d218B25C91F3C5d983c3cd25c686D - - 0xb310E13232e3a85b19123adA4E0762B3dC50B4E6 - - 0x8C0B299a706beB7FCE32F820A40f558451534880 - - 0xF88c298c08A46d235d688Eb9CFEA7A1B704842bC - - 0xe2a2ff6cA23AeCD58Aa5c2E5bEA89c2142Ce20cc - - 0x47D8383296B3Db67726fFb4dbDE21a15A17f5084 - - 0xdE5e20DCB0781072341294f8bEfd3811E043f5Ca - - 0x686aC93A652194D6F7f3CF996C61B72cab1A3B4e - - 0x719b0E230E9c9F42C6485cc4DF0347318ced8daa - - 0x829CC1ad52d6c09e9F2249B69C42B99180FC8c17 - - 0xEf051f942CAE84d86c8DED6f45632547E4f6b945 - - 0x54D1aDec93f2EbA4fb90Bb140b56bd822c867e7D - - 0x879B29Bcef645E778136A2Ab727dc1691c089DE7 - - 0x88f7C34641378E6e82F3e949c067589A0B38eacd - - 0x96C668DE46451ECD4F8C8FB16D342EC679f6E87f - - 0x981f78212b18671aA5A449d482001EDC1e00303D - - 0x6BE5a2c8250A2c8342E96a365957933DEbe22ca0 validator: disabled: false diff --git a/spartan/aztec-network/values/sepolia-48-validators-with-proving-and-metrics.yaml b/spartan/aztec-network/values/sepolia-48-validators-with-proving-and-metrics.yaml index 9f28f252e8f..a521e8ee23d 100644 --- a/spartan/aztec-network/values/sepolia-48-validators-with-proving-and-metrics.yaml +++ b/spartan/aztec-network/values/sepolia-48-validators-with-proving-and-metrics.yaml @@ -3,6 +3,10 @@ telemetry: aztec: realProofs: true + l1DeploymentMnemonic: "" + validatorKeyIndexStart: 0 + proverKeyIndexStart: 48 + botKeyIndexStart: 49 images: aztec: @@ -32,53 +36,6 @@ validator: requests: memory: "512Mi" validatorKeys: - validatorAddresses: - - 0xcD92B30FeFbD2752fF80dD1d152347B1C0b80555 - - 0x3eb04876AEaC0ecB2095D5be5FCE965BE114f6Ea - - 0x69746Fc304C08331C5B3F0E4A8Be82Bbe9079de7 - - 0x11eCa503d1A4C89EA801B5428690844378FF8EDb - - 0x690944149F6090F8B8131d21B7C9243f44953dA3 - - 0x9991124C826d4b469544A326B8e93C7ea6291Df6 - - 0x790a1ACe055c42Ef0aDd7C94b0605e68F4F7ac32 - - 0x3bb53E1A35768B250185d9a1E3A220dfcFD21959 - - 0x1a42bfAF536DD0931AbDb6C7b5d6a2e795849111 - - 0x0b69F2c3b1DCe6974c860655C1B1A0bE209F0EEe - - 0x15dC3B5b63B2846Caf36631b4cc89EC2133484A3 - - 0xEb81BB1891ad6bDB88Bd870703e8E8ca809bF76e - - 0xe484C194039a2D1334F9f701e6AeEAdb2b1009F8 - - 0xC1f9e958888FcfB74C0f72FF4fcA8525a2FD7577 - - 0x27A99682eF70cE26CBe981B2E0BEA2f608bfD44D - - 0xb010Fb11B64Ad756721884d84E66dF0Aa96F1f5f - - 0xC5E960E795284a7AF2F1b5ED3acb17cE51143342 - - 0x44C08d1b44C5D099ecCB626297541E9214aED279 - - 0x78117dD80E4e54EFFd9546Dce1719fB5df30a0A1 - - 0x941d42B68BE5B50f32b24e39c7C48A07Cda37f34 - - 0xAbE28C0BA704111b03903BCBC92c486CE457eC3C - - 0xb0F15e42B0b234070C222B02e173b1e1263E9Bad - - 0xbEaB732a958301EF542DD465DFfcaaa7DA0D64cA - - 0x56C4277eACF43a4a19dEafa2617776f88566C9A8 - - 0xfCaEA5838C6C5a90DA0DE920a122998D7F72e049 - - 0xB204ed1f6cD2E7609421477DA004Aad34eD44aa2 - - 0x5e6a2e947b506f0E06E94b5C421097564c1bf7B1 - - 0x4f321D1922ECDAc05F137E6E9cD2b2873D02b13C - - 0x7964e6211fC121Fb4577d25729724aD97AfD6349 - - 0x3Bf8F13D4D2d218B25C91F3C5d983c3cd25c686D - - 0xb310E13232e3a85b19123adA4E0762B3dC50B4E6 - - 0x8C0B299a706beB7FCE32F820A40f558451534880 - - 0xF88c298c08A46d235d688Eb9CFEA7A1B704842bC - - 0xe2a2ff6cA23AeCD58Aa5c2E5bEA89c2142Ce20cc - - 0x47D8383296B3Db67726fFb4dbDE21a15A17f5084 - - 0xdE5e20DCB0781072341294f8bEfd3811E043f5Ca - - 0x686aC93A652194D6F7f3CF996C61B72cab1A3B4e - - 0x719b0E230E9c9F42C6485cc4DF0347318ced8daa - - 0x829CC1ad52d6c09e9F2249B69C42B99180FC8c17 - - 0xEf051f942CAE84d86c8DED6f45632547E4f6b945 - - 0x54D1aDec93f2EbA4fb90Bb140b56bd822c867e7D - - 0x879B29Bcef645E778136A2Ab727dc1691c089DE7 - - 0x88f7C34641378E6e82F3e949c067589A0B38eacd - - 0x96C668DE46451ECD4F8C8FB16D342EC679f6E87f - - 0x981f78212b18671aA5A449d482001EDC1e00303D - - 0x6BE5a2c8250A2c8342E96a365957933DEbe22ca0 validator: disabled: false diff --git a/spartan/scripts/deploy_kind.sh b/spartan/scripts/deploy_kind.sh index 8e380576533..ce1d8093bb8 100755 --- a/spartan/scripts/deploy_kind.sh +++ b/spartan/scripts/deploy_kind.sh @@ -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 @@ -76,7 +76,14 @@ function generate_overrides { # and are used to generate the genesis.json file. # We need to read these values and pass them into the eth devnet create.sh script # so that it can generate the genesis.json and config.yaml file with the correct values. -if [ "$sepolia_deployment" != "true" ]; then +if [ "$sepolia_deployment" = "true" ]; then + echo "Generating sepolia accounts..." + set +x + L1_ACCOUNTS_MNEMONIC=$(./prepare_sepolia_accounts.sh "$values_file") + # write the mnemonic to a file + echo "$L1_ACCOUNTS_MNEMONIC" >mnemonic.tmp + set -x +else echo "Generating devnet config..." ./generate_devnet_config.sh "$values_file" fi @@ -93,6 +100,7 @@ helm_set_args=( # If this is a sepolia run, we need to write some values if [ "$sepolia_deployment" = "true" ]; then + set +x helm_set_args+=( --set ethereum.execution.externalHost="$EXTERNAL_ETHEREUM_HOST" --set ethereum.beacon.externalHost="$EXTERNAL_ETHEREUM_CONSENSUS_HOST" @@ -107,6 +115,7 @@ if [ "$sepolia_deployment" = "true" ]; then if [ -n "${EXTERNAL_ETHEREUM_CONSENSUS_HOST_API_KEY_HEADER:-}" ]; then helm_set_args+=(--set ethereum.beacon.apiKeyHeader="$EXTERNAL_ETHEREUM_CONSENSUS_HOST_API_KEY_HEADER") fi + set -x fi helm upgrade --install spartan ../aztec-network \ diff --git a/spartan/scripts/generate_devnet_config.sh b/spartan/scripts/generate_devnet_config.sh index 0fdb9dad17d..5a6752ccf49 100755 --- a/spartan/scripts/generate_devnet_config.sh +++ b/spartan/scripts/generate_devnet_config.sh @@ -30,7 +30,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" diff --git a/spartan/scripts/prepare_sepolia_accounts.sh b/spartan/scripts/prepare_sepolia_accounts.sh new file mode 100755 index 00000000000..923b451ed35 --- /dev/null +++ b/spartan/scripts/prepare_sepolia_accounts.sh @@ -0,0 +1,72 @@ +#!/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_bots=$(./read_value.sh "bot.replicas" $value_yamls) +num_accounts=$((num_validators + num_provers + num_bots)) + +# 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 25% buffer +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" \ + "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" diff --git a/spartan/scripts/test_kind.sh b/spartan/scripts/test_kind.sh index b9a1ebc1826..5f0a6b4bea8 100755 --- a/spartan/scripts/test_kind.sh +++ b/spartan/scripts/test_kind.sh @@ -74,7 +74,7 @@ trap cleanup SIGINT SIGTERM EXIT stern_pid="" function copy_stern_to_log { # Start stern in a subshell, capture its PID, and pipe output to cache_log so it is uploaded - stern spartan -n "$namespace" > "logs/kind-$namespace.log" &>/dev/null & + stern spartan -n "$namespace" >"logs/kind-$namespace.log" &>/dev/null & stern_pid=$! } @@ -83,7 +83,7 @@ copy_stern_to_log # uses VALUES_FILE, CHAOS_VALUES, AZTEC_DOCKER_TAG and INSTALL_TIMEOUT optional env vars if [ "$fresh_install" != "no-deploy" ]; then - OVERRIDES="$OVERRIDES" ./deploy_kind.sh $namespace $values_file $sepolia_run + deploy_result=$(OVERRIDES="$OVERRIDES" ./deploy_kind.sh $namespace $values_file $sepolia_run) fi # Find 6 free ports between 9000 and 10000 @@ -110,7 +110,16 @@ ethereum_slot_duration=$(./read_value.sh "ethereum.blockTime" $value_yamls) aztec_slot_duration=$(./read_value.sh "aztec.slotDuration" $value_yamls) aztec_epoch_duration=$(./read_value.sh "aztec.epochDuration" $value_yamls) aztec_proof_submission_window=$(./read_value.sh "aztec.proofSubmissionWindow" $value_yamls) -l1_account_mnemonic=$(./read_value.sh "aztec.l1DeploymentMnemonic" $value_yamls) + +if [ "$sepolia_run" = "true" ]; then + # Read the mnemonic from file mnemonic.tmp + set +x + l1_account_mnemonic=$(cat mnemonic.tmp) + set -x + rm mnemonic.tmp +else + l1_account_mnemonic=$(./read_value.sh "aztec.l1DeploymentMnemonic" $value_yamls) +fi echo "RUNNING TEST: $test" # Run test locally. @@ -138,6 +147,8 @@ export ETHEREUM_SLOT_DURATION="$ethereum_slot_duration" export AZTEC_SLOT_DURATION="$aztec_slot_duration" export AZTEC_EPOCH_DURATION="$aztec_epoch_duration" export AZTEC_PROOF_SUBMISSION_WINDOW="$aztec_proof_submission_window" +set +x export L1_ACCOUNT_MNEMONIC="$l1_account_mnemonic" +set -x yarn --cwd ../../yarn-project/end-to-end test --forceExit "$test"