Skip to content
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
47 changes: 35 additions & 12 deletions .github/workflows/fund-sepolia-accounts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,37 @@ on:
required: true
type: string
default: sepolia-accounts-mnemonic
ref:
description: The branch or tag to checkout
required: false
type: string
default: master
secrets:
GCP_SA_KEY:
required: true
SEPOLIA_FUNDING_PRIVATE_KEY:
required: true
GCP_SEPOLIA_URL:
required: true
GCP_SEPOLIA_API_KEY:
required: true

workflow_dispatch:
inputs:
values_file:
description: The values file to use, e.g. 1-validators.yaml
required: true
type: string
sepolia_accounts_mnemonic_secret_name:
description: The name of the secret which holds the sepolia accounts mnemonic. Will create a new one if it doesn't exist.
required: true
type: string
default: sepolia-accounts-mnemonic
ref:
description: The branch or tag to checkout
required: false
type: string
default: master

jobs:
fund-sepolia-accounts:
Expand All @@ -20,7 +51,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
ref: ${{ inputs.ref || github.ref || 'master' }}

- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
Expand All @@ -30,14 +61,6 @@ jobs:
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2

- name: Install cast
run: |
if ! command -v cast &>/dev/null; then
echo "Installing cast..."
curl -L https://foundry.paradigm.xyz | bash
$HOME/.foundry/bin/foundryup
fi

- name: Get mnemonic
id: get-mnemonic
run: |
Expand Down Expand Up @@ -66,15 +89,15 @@ jobs:
export ETHEREUM_HOST="https://json-rpc.${{ secrets.GCP_SEPOLIA_URL }}?key=${{ secrets.GCP_SEPOLIA_API_KEY }}"

echo "Funding accounts..."
$REPO/spartan/scripts/fund_sepolia_accounts.sh ${{ inputs.values_file }} "$MNEMONIC_FILE"
$REPO/spartan/scripts/prepare_sepolia_accounts.sh ${{ inputs.values_file }} 30 "$MNEMONIC_FILE"
mnemonic=$(cat "$MNEMONIC_FILE")
rm "$MNEMONIC_FILE"
echo "::add-mask::$mnemonic"
echo "mnemonic=$mnemonic" >> "$GITHUB_OUTPUT"

- name: Save mnemonic to GCP
if: ${{ steps.get-mnemonic.outputs.new_mnemonic == 'true' }}
if: ${{ steps.fund-accounts.outputs.new_mnemonic == 'true' }}
run: |
echo "Saving mnemonic to GCP"
echo "::add-mask::${{ steps.get-mnemonic.outputs.mnemonic }}"
echo "::add-mask::${{ steps.fund-accounts.outputs.mnemonic }}"
gcloud secrets versions add latest --secret=${{ inputs.sepolia_accounts_mnemonic_secret_name }} --data-file="$MNEMONIC_FILE"
45 changes: 22 additions & 23 deletions .github/workflows/network-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,27 @@ on:
type: string
default: "false"
sepolia_accounts_mnemonic_secret_name:
description: The name of the secret which holds the sepolia accounts mnemonic
description: The name of the secret which holds the sepolia accounts mnemonic (required for sepolia deployment)
required: false
type: string
default: sepolia-accounts-mnemonic

jobs:
fund_sepolia_accounts:
if: ${{ inputs.sepolia_deployment == 'true' }}
uses: ./.github/workflows/fund-sepolia-accounts.yml
with:
values_file: ${{ inputs.values_file }}
sepolia_accounts_mnemonic_secret_name: ${{ inputs.sepolia_accounts_mnemonic_secret_name }}
ref: ${{ inputs.ref || github.ref || 'master' }}
secrets:
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
SEPOLIA_FUNDING_PRIVATE_KEY: ${{ secrets.SEPOLIA_FUNDING_PRIVATE_KEY }}
GCP_SEPOLIA_URL: ${{ secrets.GCP_SEPOLIA_URL }}
GCP_SEPOLIA_API_KEY: ${{ secrets.GCP_SEPOLIA_API_KEY }}

network_deployment:
needs: fund_sepolia_accounts
# This job will run on Ubuntu
runs-on: ubuntu-latest
concurrency:
Expand Down Expand Up @@ -129,6 +143,13 @@ jobs:
with:
ref: ${{ inputs.ref || github.ref }}

- name: Check values
run: |
echo "inputs.ref: ${{ inputs.ref }}"
echo "github.ref: ${{ github.ref }}"
ls -la .github/workflows/
ls -la .github/workflows/fund-sepolia-accounts.yml

- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
Expand Down Expand Up @@ -172,28 +193,6 @@ jobs:

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

- name: Fund sepolia accounts
uses: ./.github/workflows/fund-sepolia-accounts.yml
if: ${{ inputs.sepolia_deployment == 'true' }}
with:
values_file: ${{ env.VALUES_FILE }}
sepolia_accounts_mnemonic_secret_name: ${{ inputs.sepolia_accounts_mnemonic_secret_name }}

- 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="https://json-rpc.${{ secrets.GCP_SEPOLIA_URL }}?key=${{ secrets.GCP_SEPOLIA_API_KEY }}"
echo "Preparing sepolia accounts..."
MNEMONIC_FILE=$(mktemp)
$REPO/spartan/scripts/prepare_sepolia_accounts.sh ${{ env.VALUES_FILE }} 30 "$MNEMONIC_FILE"
mnemonic=$(cat "$MNEMONIC_FILE")
rm "$MNEMONIC_FILE"
echo "::add-mask::$mnemonic"
echo "mnemonic=$mnemonic" >> "$GITHUB_OUTPUT"

- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
Expand Down
6 changes: 5 additions & 1 deletion spartan/scripts/prepare_sepolia_accounts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ if ! command -v yq &>/dev/null; then
fi

# Convert ETH to wei
if [[ ! "$eth_amount" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
echo "Error: Invalid ETH amount: $eth_amount"
exit 1
fi
wei_amount=$(cast to-wei "$eth_amount" ether)

value_yamls="../aztec-network/values/$values_file ../aztec-network/values.yaml"
Expand Down Expand Up @@ -91,7 +95,7 @@ max_index=$((max_index > bot_max_index ? max_index : bot_max_index))
total_accounts=$((num_validators + num_provers + num_bots))

# Check if mnemonic is provided
if [ -z "$MNEMONIC" ]; then
if [ "${MNEMONIC:-}" = "" ]; then
# Create a new mnemonic
echo "Creating mnemonic..."
cast wallet new-mnemonic --json >"$tmp_filename"
Expand Down
Loading