From 04c526ba082d6c01f4d038f1bedd5e69f4751d7d Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Wed, 8 Jan 2025 20:43:08 +0000 Subject: [PATCH] fix: update readme --- spartan/aztec-network/eth-devnet/README.md | 29 ++++++++++- spartan/aztec-network/eth-devnet/create.sh | 56 +++++++++++----------- 2 files changed, 54 insertions(+), 31 deletions(-) diff --git a/spartan/aztec-network/eth-devnet/README.md b/spartan/aztec-network/eth-devnet/README.md index d2933b25acef..786be2137e03 100644 --- a/spartan/aztec-network/eth-devnet/README.md +++ b/spartan/aztec-network/eth-devnet/README.md @@ -8,12 +8,37 @@ ## Args -TODO: +Args can be supplied via environment variables. -- add the deployment mnemonic etc +### NUMBER_OF_KEYS + +This determines the number of accounts that will be prefunded with eth on the execution layer. + +### MNEMONIC + +The seed phrase from which the keys will be derived. + +### BLOCK_TIME + +The time in seconds between blocks. + +### GAS_LIMIT + +The gas limit for the execution layer. + +### CHAIN_ID + +The chain id for the execution layer. --- +## Common Pitfalls + +If you are struggling to get the network up and running, it is usually due to the genesis.json file having different values from the config.yaml + genesis.ssz file. Make sure that you do not edit any of them by accident after ./create.sh is run. +Note that this script places the configuration values within the /out folder, it will not actually run the testnet. + +SSZ files are not passable thorugh config maps, so they must be base64 encoded, then decoded in the container before running. + Generating an Ethereum testnet requires a few ingredients: ## Genesis.json file diff --git a/spartan/aztec-network/eth-devnet/create.sh b/spartan/aztec-network/eth-devnet/create.sh index 90a9aa39f8c6..ddbedc7f521f 100755 --- a/spartan/aztec-network/eth-devnet/create.sh +++ b/spartan/aztec-network/eth-devnet/create.sh @@ -6,7 +6,7 @@ set -euo pipefail -REPO=$(git rev-parse --show-toplevel)/spartan/aztec-network/eth-devnet +DIR_PATH=$(git rev-parse --show-toplevel)/spartan/aztec-network/eth-devnet ## Genesis configuration values are provided as environment variables NUMBER_OF_KEYS=${NUMBER_OF_KEYS:-16} @@ -88,36 +88,36 @@ prefund_accounts() { # Uses the eth2-testnet-generator to generate beacon genesis state (genesis.ssz file) # The selected eth1 block create_beacon_genesis() { - local mnemonics_path="$1" - local beacon_config_path="$2" - local execution_genesis_path="$3" + local execution_genesis_path="$1" + local beacon_mnemonics_path="./config/mnemonics.yaml" + local beacon_config_path="./config/config.yaml" local beacon_genesis_path="./out" echo "Creating beacon genesis using:" - echo " Mnemonics path: $mnemonics_path" + echo " Beacon mnemonics path: $beacon_mnemonics_path" echo " Beacon config path: $beacon_config_path" echo " Execution genesis path: $execution_genesis_path" # update the templates block time if it is provided - cp "$REPO/$beacon_config_path" "$REPO/out/config.yaml" + cp "$DIR_PATH/$beacon_config_path" "$DIR_PATH/out/config.yaml" if [[ -n "${BLOCK_TIME:-}" ]]; then - yq eval ".SECONDS_PER_SLOT = ${BLOCK_TIME}" -i "$REPO/out/config.yaml" - yq eval ".SECONDS_PER_ETH1_BLOCK = ${BLOCK_TIME}" -i "$REPO/out/config.yaml" + yq eval ".SECONDS_PER_SLOT = ${BLOCK_TIME}" -i "$DIR_PATH/out/config.yaml" + yq eval ".SECONDS_PER_ETH1_BLOCK = ${BLOCK_TIME}" -i "$DIR_PATH/out/config.yaml" fi # Update the chain id if it is provided if [[ -n "${CHAIN_ID:-}" ]]; then - yq eval ".DEPOSIT_CHAIN_ID = ${CHAIN_ID}" -i "$REPO/out/config.yaml" - yq eval ".DEPOSIT_NETWORK_ID = ${CHAIN_ID}" -i "$REPO/out/config.yaml" + yq eval ".DEPOSIT_CHAIN_ID = ${CHAIN_ID}" -i "$DIR_PATH/out/config.yaml" + yq eval ".DEPOSIT_NETWORK_ID = ${CHAIN_ID}" -i "$DIR_PATH/out/config.yaml" fi # Run the protolamba's eth2 testnet genesis container - echo "$REPO/config:/app/config" - echo "$REPO/out:/app/out" + echo "$DIR_PATH/config:/app/config" + echo "$DIR_PATH/out:/app/out" docker run --rm \ - -v "$REPO/config:/app/config" \ - -v "$REPO/out:/app/out" \ + -v "$DIR_PATH/config:/app/config" \ + -v "$DIR_PATH/out:/app/out" \ maddiaa/eth2-testnet-genesis deneb \ --config="./out/config.yaml" \ --preset-phase0=minimal \ @@ -128,7 +128,7 @@ create_beacon_genesis() { --eth1-config="./out/genesis.json" \ --state-output="${beacon_genesis_path}/genesis.ssz" \ --tranches-dir="$beacon_genesis_path" \ - --mnemonics="$mnemonics_path" \ + --mnemonics="$beacon_mnemonics_path" \ --eth1-withdrawal-address="0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \ --eth1-match-genesis-time @@ -141,31 +141,29 @@ create_beacon_genesis() { } create_deposit_contract_block() { - echo 0 > "$REPO/out/deposit_contract_block.txt" - echo "Deposit contract block created at $REPO/out/deposit_contract_block.txt" + echo 0 > "$DIR_PATH/out/deposit_contract_block.txt" + echo "Deposit contract block created at $DIR_PATH/out/deposit_contract_block.txt" } +## The ssz file must be written in base64 in order for a config map to accept it write_ssz_file_base64() { - local ssz_file="$REPO/out/genesis.ssz" - local output_file="$REPO/out/genesis-ssz" + local ssz_file="$DIR_PATH/out/genesis.ssz" + local output_file="$DIR_PATH/out/genesis-ssz" base64 -w 0 "$ssz_file" > "$output_file" echo "SSZ file base64 encoded at $output_file" } # Main +beacon_config_path="$DIR_PATH/config/config.yaml" +genesis_json_path="$DIR_PATH/config/genesis.json" -# TODO: FIX THIS Files are relative to the mounted repo -mnemonics_path="./config/mnemonics.yaml" -beacon_config_path="./config/config.yaml" -execution_genesis_path="./config/genesis.json" - -mkdir -p "$REPO/out" +mkdir -p "$DIR_PATH/out" -create_execution_genesis "$REPO/config/genesis.json" "$REPO/out/genesis.json" -create_beacon_genesis "$mnemonics_path" "$beacon_config_path" "$REPO/out/genesis.json" +create_execution_genesis "$DIR_PATH/config/genesis.json" "$DIR_PATH/out/genesis.json" +create_beacon_genesis "$DIR_PATH/out/genesis.json" create_deposit_contract_block write_ssz_file_base64 -cp "$REPO/$beacon_config_path" "$REPO/out/config.yaml" -cp "$REPO/config/jwt-secret.hex" "$REPO/out/jwt-secret.hex" +cp "$beacon_config_path" "$DIR_PATH/out/config.yaml" +cp "$DIR_PATH/config/jwt-secret.hex" "$DIR_PATH/out/jwt-secret.hex" echo "Genesis files copied to ./out"