From 2e82f2c213b7ffccd2b5cfd3c165fbc92e270e1c Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Wed, 22 May 2024 10:26:03 +0200 Subject: [PATCH 1/7] fix: remove dups, rename metadata --- entrypoint.sh | 56 +++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index a7dccca..bec31a3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -8,27 +8,27 @@ gen_shared_files(){ . /apps/el-gen/.venv/bin/activate set -x # Shared files - mkdir -p /data/custom_config_data + mkdir -p /data/metadata if ! [ -f "/data/jwt/jwtsecret" ]; then mkdir -p /data/jwt echo -n 0x$(openssl rand -hex 32 | tr -d "\n") > /data/jwt/jwtsecret fi - if [ -f "/data/custom_config_data/genesis.json" ]; then - terminalTotalDifficulty=$(cat /data/custom_config_data/genesis.json | jq -r '.config.terminalTotalDifficulty | tostring') - sed -i "s/TERMINAL_TOTAL_DIFFICULTY:.*/TERMINAL_TOTAL_DIFFICULTY: $terminalTotalDifficulty/" /data/custom_config_data/config.yaml + if [ -f "/data/metadata/genesis.json" ]; then + terminalTotalDifficulty=$(cat /data/metadata/genesis.json | jq -r '.config.terminalTotalDifficulty | tostring') + sed -i "s/TERMINAL_TOTAL_DIFFICULTY:.*/TERMINAL_TOTAL_DIFFICULTY: $terminalTotalDifficulty/" /data/metadata/config.yaml fi } gen_el_config(){ . /apps/el-gen/.venv/bin/activate set -x - if ! [ -f "/data/custom_config_data/genesis.json" ]; then + if ! [ -f "/data/metadata/genesis.json" ]; then tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) - mkdir -p /data/custom_config_data + mkdir -p /data/metadata envsubst < /config/el/genesis-config.yaml > $tmp_dir/genesis-config.yaml - python3 /apps/el-gen/genesis_geth.py $tmp_dir/genesis-config.yaml > /data/custom_config_data/genesis.json - python3 /apps/el-gen/genesis_chainspec.py $tmp_dir/genesis-config.yaml > /data/custom_config_data/chainspec.json - python3 /apps/el-gen/genesis_besu.py $tmp_dir/genesis-config.yaml > /data/custom_config_data/besu.json + python3 /apps/el-gen/genesis_geth.py $tmp_dir/genesis-config.yaml > /data/metadata/genesis.json + python3 /apps/el-gen/genesis_chainspec.py $tmp_dir/genesis-config.yaml > /data/metadata/chainspec.json + python3 /apps/el-gen/genesis_besu.py $tmp_dir/genesis-config.yaml > /data/metadata/besu.json else echo "el genesis already exists. skipping generation..." fi @@ -45,7 +45,7 @@ gen_minimal_config() { ) for key in "${!replacements[@]}"; do - sed -i "s/$key:.*/$key: ${replacements[$key]}/" /data/custom_config_data/config.yaml + sed -i "s/$key:.*/$key: ${replacements[$key]}/" /data/metadata/config.yaml done } @@ -53,31 +53,29 @@ gen_cl_config(){ . /apps/el-gen/.venv/bin/activate set -x # Consensus layer: Check if genesis already exists - if ! [ -f "/data/custom_config_data/genesis.ssz" ]; then + if ! [ -f "/data/metadata/genesis.ssz" ]; then tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) - mkdir -p /data/custom_config_data - envsubst < /config/cl/config.yaml > /data/custom_config_data/config.yaml + mkdir -p /data/metadata + envsubst < /config/cl/config.yaml > /data/metadata/config.yaml envsubst < /config/cl/mnemonics.yaml > $tmp_dir/mnemonics.yaml # Conditionally override values if preset is "minimal" if [[ "$PRESET_BASE" == "minimal" ]]; then gen_minimal_config fi - cp $tmp_dir/mnemonics.yaml /data/custom_config_data/mnemonics.yaml + cp $tmp_dir/mnemonics.yaml /data/metadata/mnemonics.yaml # Create deposit_contract.txt and deploy_block.txt - grep DEPOSIT_CONTRACT_ADDRESS /data/custom_config_data/config.yaml | cut -d " " -f2 > /data/custom_config_data/deposit_contract.txt - echo $CL_EXEC_BLOCK > /data/custom_config_data/deploy_block.txt - echo $CL_EXEC_BLOCK > /data/custom_config_data/deposit_contract_block.txt - echo $BEACON_STATIC_ENR > /data/custom_config_data/bootstrap_nodes.txt - echo "- $BEACON_STATIC_ENR" > /data/custom_config_data/boot_enr.txt + grep DEPOSIT_CONTRACT_ADDRESS /data/metadata/config.yaml | cut -d " " -f2 > /data/metadata/deposit_contract.txt + echo $CL_EXEC_BLOCK > /data/metadata/deposit_contract_block.txt + echo $BEACON_STATIC_ENR > /data/metadata/bootstrap_nodes.txt # Envsubst mnemonics envsubst < /config/cl/mnemonics.yaml > $tmp_dir/mnemonics.yaml # Generate genesis genesis_args=( deneb - --config /data/custom_config_data/config.yaml + --config /data/metadata/config.yaml --mnemonics $tmp_dir/mnemonics.yaml - --tranches-dir /data/custom_config_data/tranches - --state-output /data/custom_config_data/genesis.ssz + --tranches-dir /data/metadata/tranches + --state-output /data/metadata/genesis.ssz --preset-phase0 $PRESET_BASE --preset-altair $PRESET_BASE --preset-bellatrix $PRESET_BASE @@ -92,7 +90,7 @@ gen_cl_config(){ elif [[ $SHADOW_FORK_RPC != "" ]]; then genesis_args+=(--shadow-fork-eth1-rpc=$SHADOW_FORK_RPC --eth1-config "") else - genesis_args+=(--eth1-config /data/custom_config_data/genesis.json) + genesis_args+=(--eth1-config /data/metadata/genesis.json) fi if ! [ -z "$CL_ADDITIONAL_VALIDATORS" ]; then if [[ $CL_ADDITIONAL_VALIDATORS = /* ]]; then @@ -111,15 +109,15 @@ gen_cl_config(){ --preset-bellatrix $PRESET_BASE --preset-capella $PRESET_BASE --preset-deneb $PRESET_BASE - /data/custom_config_data/genesis.ssz + /data/metadata/genesis.ssz ) /usr/local/bin/eth2-testnet-genesis "${genesis_args[@]}" - /usr/local/bin/zcli "${zcli_args[@]}" > /data/custom_config_data/parsedBeaconState.json + /usr/local/bin/zcli "${zcli_args[@]}" > /data/metadata/parsedBeaconState.json echo "Genesis args: ${genesis_args[@]}" - echo "Genesis block number: $(jq -r '.latest_execution_payload_header.block_number' /data/custom_config_data/parsedBeaconState.json)" - echo "Genesis block hash: $(jq -r '.latest_execution_payload_header.block_hash' /data/custom_config_data/parsedBeaconState.json)" - jq -r '.eth1_data.block_hash' /data/custom_config_data/parsedBeaconState.json | tr -d '\n' > /data/custom_config_data/deposit_contract_block_hash.txt - jq -r '.genesis_validators_root' /data/custom_config_data/parsedBeaconState.json | tr -d '\n' > /data/custom_config_data/genesis_validators_root.txt + echo "Genesis block number: $(jq -r '.latest_execution_payload_header.block_number' /data/metadata/parsedBeaconState.json)" + echo "Genesis block hash: $(jq -r '.latest_execution_payload_header.block_hash' /data/metadata/parsedBeaconState.json)" + jq -r '.eth1_data.block_hash' /data/metadata/parsedBeaconState.json | tr -d '\n' > /data/metadata/deposit_contract_block_hash.txt + jq -r '.genesis_validators_root' /data/metadata/parsedBeaconState.json | tr -d '\n' > /data/metadata/genesis_validators_root.txt else echo "cl genesis already exists. skipping generation..." fi From fd7d5b62b3e2930d9d43be6a68ee54eb739601fc Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Tue, 28 May 2024 16:31:35 +0200 Subject: [PATCH 2/7] add default env variables for everything --- config-example/values.env | 36 ------------------------------ config-example/values.env.template | 36 ++++++++++++++++++++++++++++++ entrypoint.sh | 1 + 3 files changed, 37 insertions(+), 36 deletions(-) delete mode 100644 config-example/values.env create mode 100644 config-example/values.env.template diff --git a/config-example/values.env b/config-example/values.env deleted file mode 100644 index 9d747c1..0000000 --- a/config-example/values.env +++ /dev/null @@ -1,36 +0,0 @@ -export PRESET_BASE="mainnet" -export CHAIN_ID="1337" -export DEPOSIT_CONTRACT_ADDRESS="0x6f22fFbC56eFF051aECF839396DD1eD9aD6BBA9D" -export EL_AND_CL_MNEMONIC="sleep moment list remain like wall lake industry canvas wonder ecology elite duck salad naive syrup frame brass utility club odor country obey pudding" -export CL_ADDITIONAL_VALIDATORS="" -export CL_EXEC_BLOCK="0" -export SLOT_DURATION_IN_SECONDS=12 -export DEPOSIT_CONTRACT_BLOCK="0x0000000000000000000000000000000000000000000000000000000000000000" -export NUMBER_OF_VALIDATORS=320 -export GENESIS_FORK_VERSION="0x10000000" -export ALTAIR_FORK_VERSION="0x20000000" -export BELLATRIX_FORK_VERSION="0x30000000" -export CAPELLA_FORK_VERSION="0x40000000" -export DENEB_FORK_VERSION="0x50000000" -export ELECTRA_FORK_VERSION="0x60000000" -export ELECTRA_FORK_EPOCH="2000" -export EIP7594_FORK_VERSION="0x70000000" -export EIP7594_FORK_EPOCH="99999" -export WITHDRAWAL_TYPE="0x00" -export WITHDRAWAL_ADDRESS=0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134 -export BEACON_STATIC_ENR="enr:-Iq4QJk4WqRkjsX5c2CXtOra6HnxN-BMXnWhmhEQO9Bn9iABTJGdjUOurM7Btj1ouKaFkvTRoju5vz2GPmVON2dffQKGAX53x8JigmlkgnY0gmlwhLKAlv6Jc2VjcDI1NmsxoQK6S-Cii_KmfFdUJL2TANL3ksaKUnNXvTCv1tLwXs0QgIN1ZHCCIyk" -#export SHADOW_FORK_RPC="http://docker.for.mac.localhost:8545" -#export SHADOW_FORK_FILE="/config/el/latest_block.json" -export GENESIS_TIMESTAMP=0 -export GENESIS_DELAY=60 -export GENESIS_GASLIMIT=25000000 -export MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT=8 -export CHURN_LIMIT_QUOTIENT=65536 -export EJECTION_BALANCE=16000000000 -export ETH1_FOLLOW_DISTANCE=2048 -export MIN_VALIDATOR_WITHDRAWABILITY_DELAY=256 -export SHARD_COMMITTEE_PERIOD=256 -export SAMPLES_PER_SLOT=8 -export CUSTODY_REQUIREMENT=1 -export DATA_COLUMN_SIDECAR_SUBNET_COUNT=32 -export TARGET_NUMBER_OF_PEERS=70 diff --git a/config-example/values.env.template b/config-example/values.env.template new file mode 100644 index 0000000..336b8a3 --- /dev/null +++ b/config-example/values.env.template @@ -0,0 +1,36 @@ +export PRESET_BASE="${PRESET_BASE:-mainnet}" +export CHAIN_ID="${CHAIN_ID:-1337}" +export DEPOSIT_CONTRACT_ADDRESS="${DEPOSIT_CONTRACT_ADDRESS:-0x4242424242424242424242424242424242424242}" +export EL_AND_CL_MNEMONIC="${EL_AND_CL_MNEMONIC:-sleep moment list remain like wall lake industry canvas wonder ecology elite duck salad naive syrup frame brass utility club odor country obey pudding}" +export CL_ADDITIONAL_VALIDATORS="${CL_ADDITIONAL_VALIDATORS:-}" +export CL_EXEC_BLOCK="${CL_EXEC_BLOCK:-0}" +export SLOT_DURATION_IN_SECONDS="${SLOT_DURATION_IN_SECONDS:-12}" +export DEPOSIT_CONTRACT_BLOCK="${DEPOSIT_CONTRACT_BLOCK:-0x0000000000000000000000000000000000000000000000000000000000000000}" +export NUMBER_OF_VALIDATORS="${NUMBER_OF_VALIDATORS:-320}" +export GENESIS_FORK_VERSION="${GENESIS_FORK_VERSION:-0x10000000}" +export ALTAIR_FORK_VERSION="${ALTAIR_FORK_VERSION:-0x20000000}" +export BELLATRIX_FORK_VERSION="${BELLATRIX_FORK_VERSION:-0x30000000}" +export CAPELLA_FORK_VERSION="${CAPELLA_FORK_VERSION:-0x40000000}" +export DENEB_FORK_VERSION="${DENEB_FORK_VERSION:-0x50000000}" +export ELECTRA_FORK_VERSION="${ELECTRA_FORK_VERSION:-0x60000000}" +export ELECTRA_FORK_EPOCH="${ELECTRA_FORK_EPOCH:-2000}" +export EIP7594_FORK_VERSION="${EIP7594_FORK_VERSION:-0x70000000}" +export EIP7594_FORK_EPOCH="${EIP7594_FORK_EPOCH:-99999}" +export WITHDRAWAL_TYPE="${WITHDRAWAL_TYPE:-0x00}" +export WITHDRAWAL_ADDRESS="${WITHDRAWAL_ADDRESS:-0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134}" +export BEACON_STATIC_ENR="${BEACON_STATIC_ENR:-enr:-Iq4QJk4WqRkjsX5c2CXtOra6HnxN-BMXnWhmhEQO9Bn9iABTJGdjUOurM7Btj1ouKaFkvTRoju5vz2GPmVON2dffQKGAX53x8JigmlkgnY0gmlwhLKAlv6Jc2VjcDI1NmsxoQK6S-Cii_KmfFdUJL2TANL3ksaKUnNXvTCv1tLwXs0QgIN1ZHCCIyk}" +export SHADOW_FORK_RPC="${SHADOW_FORK_RPC:-}" # http://docker.for.mac.localhost:8545 +export SHADOW_FORK_FILE="${SHADOW_FORK_FILE:-}" # /config/el/latest_block.json +export GENESIS_TIMESTAMP="${GENESIS_TIMESTAMP:-0}" +export GENESIS_DELAY="${GENESIS_DELAY:-60}" +export GENESIS_GASLIMIT="${GENESIS_GASLIMIT:-25000000}" +export MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT="${MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT:-8}" +export CHURN_LIMIT_QUOTIENT="${CHURN_LIMIT_QUOTIENT:-65536}" +export EJECTION_BALANCE="${EJECTION_BALANCE:-16000000000}" +export ETH1_FOLLOW_DISTANCE="${ETH1_FOLLOW_DISTANCE:-2048}" +export MIN_VALIDATOR_WITHDRAWABILITY_DELAY="${MIN_VALIDATOR_WITHDRAWABILITY_DELAY:-256}" +export SHARD_COMMITTEE_PERIOD="${SHARD_COMMITTEE_PERIOD:-256}" +export SAMPLES_PER_SLOT="${SAMPLES_PER_SLOT:-8}" +export CUSTODY_REQUIREMENT="${CUSTODY_REQUIREMENT:-1}" +export DATA_COLUMN_SIDECAR_SUBNET_COUNT="${DATA_COLUMN_SIDECAR_SUBNET_COUNT:-32}" +export TARGET_NUMBER_OF_PEERS="${TARGET_NUMBER_OF_PEERS:-70}" \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index bec31a3..5b784dd 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,5 @@ #!/bin/bash -e +eval "$(envsubst < /config/values.env.template)" source /config/values.env SERVER_ENABLED="${SERVER_ENABLED:-false}" SERVER_PORT="${SERVER_PORT:-8000}" From c99a9b85340bdb6b1e2a345989b16cd3a230373d Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Tue, 28 May 2024 16:39:41 +0200 Subject: [PATCH 3/7] add el premine and additional contracts --- config-example/values.env.template | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config-example/values.env.template b/config-example/values.env.template index 336b8a3..fa328be 100644 --- a/config-example/values.env.template +++ b/config-example/values.env.template @@ -33,4 +33,6 @@ export SHARD_COMMITTEE_PERIOD="${SHARD_COMMITTEE_PERIOD:-256}" export SAMPLES_PER_SLOT="${SAMPLES_PER_SLOT:-8}" export CUSTODY_REQUIREMENT="${CUSTODY_REQUIREMENT:-1}" export DATA_COLUMN_SIDECAR_SUBNET_COUNT="${DATA_COLUMN_SIDECAR_SUBNET_COUNT:-32}" -export TARGET_NUMBER_OF_PEERS="${TARGET_NUMBER_OF_PEERS:-70}" \ No newline at end of file +export TARGET_NUMBER_OF_PEERS="${TARGET_NUMBER_OF_PEERS:-70}" +export EL_PREMINE_ADDRS="${EL_PREMINE_ADDRS:-}" +export ADDITIONAL_PRELOADED_CONTRACTS="${ADDITIONAL_PRELOADED_CONTRACTS:-}" # '{"0x123463a4B065722E99115D6c222f267d9cABb524": {"balance": "1ETH","code": "0x123465","storage": {},"nonce": 0,"secretKey": "0x"}}' \ No newline at end of file From 54315b4eb47aa21e2495ac8c6077d4b81ffea9f2 Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Tue, 28 May 2024 16:49:51 +0200 Subject: [PATCH 4/7] rename to defaults.env --- config-example/{values.env.template => defaults.env} | 4 ++-- entrypoint.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename config-example/{values.env.template => defaults.env} (93%) diff --git a/config-example/values.env.template b/config-example/defaults.env similarity index 93% rename from config-example/values.env.template rename to config-example/defaults.env index fa328be..d3db174 100644 --- a/config-example/values.env.template +++ b/config-example/defaults.env @@ -34,5 +34,5 @@ export SAMPLES_PER_SLOT="${SAMPLES_PER_SLOT:-8}" export CUSTODY_REQUIREMENT="${CUSTODY_REQUIREMENT:-1}" export DATA_COLUMN_SIDECAR_SUBNET_COUNT="${DATA_COLUMN_SIDECAR_SUBNET_COUNT:-32}" export TARGET_NUMBER_OF_PEERS="${TARGET_NUMBER_OF_PEERS:-70}" -export EL_PREMINE_ADDRS="${EL_PREMINE_ADDRS:-}" -export ADDITIONAL_PRELOADED_CONTRACTS="${ADDITIONAL_PRELOADED_CONTRACTS:-}" # '{"0x123463a4B065722E99115D6c222f267d9cABb524": {"balance": "1ETH","code": "0x123465","storage": {},"nonce": 0,"secretKey": "0x"}}' \ No newline at end of file +export EL_PREMINE_ADDRS="${EL_PREMINE_ADDRS:-{}}" +export ADDITIONAL_PRELOADED_CONTRACTS="${ADDITIONAL_PRELOADED_CONTRACTS:-{}}" # '{"0x123463a4B065722E99115D6c222f267d9cABb524": {"balance": "1ETH","code": "0x123465","storage": {},"nonce": 0,"secretKey": "0x"}}' \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 5b784dd..2e99bad 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,5 @@ #!/bin/bash -e -eval "$(envsubst < /config/values.env.template)" +eval "$(envsubst < /config/defaults.env)" source /config/values.env SERVER_ENABLED="${SERVER_ENABLED:-false}" SERVER_PORT="${SERVER_PORT:-8000}" From f06229e4eb3ec1b13fab5b3079ab83c26c902c39 Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Tue, 28 May 2024 17:05:46 +0200 Subject: [PATCH 5/7] fix readme --- .gitignore | 3 ++- README.md | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 352e411..f71aaa2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ data/* .idea/ -_snapshot_eth_getBlockByNumber.json \ No newline at end of file +_snapshot_eth_getBlockByNumber.json +output/* \ No newline at end of file diff --git a/README.md b/README.md index a8ed143..2a1074b 100644 --- a/README.md +++ b/README.md @@ -12,17 +12,17 @@ mkdir output # Overwriting the config files and generating the EL and CL genesis docker run --rm -it -u $UID -v $PWD/output:/data \ - -v $PWD/config-example:/config \ + -v $PWD/config/values.env:/config/values.env \ ethpandaops/ethereum-genesis-generator:latest all # Just creating the EL genesis docker run --rm -it -u $UID -v $PWD/output:/data \ - -v $PWD/config-example:/config \ + -v $PWD/config/values.env:/config/values.env \ ethpandaops/ethereum-genesis-generator:latest el # Just creating the CL genesis docker run --rm -it -u $UID -v $PWD/output:/data \ - -v $PWD/config-example:/config \ + -v $PWD/config/values.env:/config/values.env \ ethpandaops/ethereum-genesis-generator:latest cl ``` ### Environment variables From ac2ca7ca9506ae719171ee9c11b15730941c4fba Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Tue, 28 May 2024 17:07:30 +0200 Subject: [PATCH 6/7] chnage to cat --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 2e99bad..ca2401a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,5 @@ #!/bin/bash -e -eval "$(envsubst < /config/defaults.env)" +eval "$(cat < /config/defaults.env)" source /config/values.env SERVER_ENABLED="${SERVER_ENABLED:-false}" SERVER_PORT="${SERVER_PORT:-8000}" From 92e6f5c67610b1c5e7ae0a546fdfc6172aa3eb70 Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Tue, 28 May 2024 17:21:32 +0200 Subject: [PATCH 7/7] Update entrypoint.sh --- entrypoint.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index ca2401a..5cc222b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,9 @@ #!/bin/bash -e eval "$(cat < /config/defaults.env)" -source /config/values.env +if [ -f /config/values.env ]; +then + source /config/values.env +fi SERVER_ENABLED="${SERVER_ENABLED:-false}" SERVER_PORT="${SERVER_PORT:-8000}" WITHDRAWAL_ADDRESS="${WITHDRAWAL_ADDRESS:-0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134}"