From acfd3371b23aa37f859379d0f662e89c373a7450 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Thu, 2 May 2024 16:54:20 -0500 Subject: [PATCH] WIP: Back to v1.14 --- .../Dockerfile | 25 +++++++++++++++++++ .../build.sh | 8 ++++++ .../genesis/Makefile | 13 ++++++++++ .../genesis/accounts/import_keys.sh | 17 +++++++++++++ .../genesis/accounts/mnemonic_to_csv.py | 16 ++++++++++++ .../genesis/el/build_el.sh | 16 ++++++++++++ .../genesis/el/el-config.yaml | 17 +++++++++++++ 7 files changed, 112 insertions(+) create mode 100644 stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/Dockerfile create mode 100755 stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/build.sh create mode 100644 stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/Makefile create mode 100755 stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/accounts/import_keys.sh create mode 100644 stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/accounts/mnemonic_to_csv.py create mode 100755 stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/el/build_el.sh create mode 100644 stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/el/el-config.yaml diff --git a/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/Dockerfile b/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/Dockerfile new file mode 100644 index 0000000..870e8c9 --- /dev/null +++ b/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/Dockerfile @@ -0,0 +1,25 @@ +FROM ethpandaops/ethereum-genesis-generator:3.0.0 AS ethgen + +FROM golang:1.20-alpine as builder + +RUN apk add --no-cache python3 py3-pip make bash envsubst jq + +# Install ethereum-genesis-generator tools +COPY --from=ethgen /apps /apps +RUN cd /apps/el-gen && pip3 install --break-system-packages -r requirements.txt +RUN pip3 install --break-system-packages --upgrade "web3==v6.15.1" +RUN pip3 install --break-system-packages --upgrade "typing-extensions" + +# Install tool to generate initial block +RUN go install github.com/cerc-io/eth-dump-genblock@b29516740fc01cf1d1d623acbfd0e9a2b6440a96 + +# Build genesis config +COPY genesis /opt/genesis +RUN cd /opt/genesis && make genesis-el + +# Snag the genesis block info. +RUN eth-dump-genblock /opt/genesis/build/el/geth.json > /opt/genesis/build/el/genesis_block.json + +FROM alpine:latest + +COPY --from=builder /opt/genesis /opt/genesis diff --git a/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/build.sh b/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/build.sh new file mode 100755 index 0000000..2316b97 --- /dev/null +++ b/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/build.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# Build cerc/fixturenet-eth-genesis-postmerge + +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +docker build -t cerc/fixturenet-eth-genesis-postmerge:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} $SCRIPT_DIR diff --git a/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/Makefile b/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/Makefile new file mode 100644 index 0000000..a1eef57 --- /dev/null +++ b/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/Makefile @@ -0,0 +1,13 @@ +.PHONY: build +build: genesis + +.PHONY: genesis +genesis: genesis-el + +.PHONY: genesis-el +genesis-el: + cd el; ./build_el.sh + +.PHONY: clean +clean: + rm -rf build diff --git a/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/accounts/import_keys.sh b/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/accounts/import_keys.sh new file mode 100755 index 0000000..e8dce0e --- /dev/null +++ b/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/accounts/import_keys.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +ACCOUNT_PASSWORD=${ACCOUNT_PASSWORD:-secret1212} + +for line in `cat ../build/el/accounts.csv`; do + BIP44_PATH="`echo "$line" | cut -d',' -f1`" + ADDRESS="`echo "$line" | cut -d',' -f2`" + PRIVATE_KEY="`echo "$line" | cut -d',' -f3`" + + echo "$ACCOUNT_PASSWORD" > .pw.$$ + echo "$PRIVATE_KEY" | sed 's/0x//' > .key.$$ + + echo "" + echo "$ADDRESS" + geth account import --datadir=~/ethdata --password .pw.$$ .key.$$ + rm -f .pw.$$ .key.$$ +done diff --git a/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/accounts/mnemonic_to_csv.py b/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/accounts/mnemonic_to_csv.py new file mode 100644 index 0000000..1e6d10f --- /dev/null +++ b/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/accounts/mnemonic_to_csv.py @@ -0,0 +1,16 @@ +from web3.auto import w3 +import ruamel.yaml as yaml +import sys + +w3.eth.account.enable_unaudited_hdwallet_features() + +testnet_config_path = "genesis-config.yaml" +if len(sys.argv) > 1: + testnet_config_path = sys.argv[1] + +with open(testnet_config_path) as stream: + data = yaml.safe_load(stream) + +for key, value in data['el_premine'].items(): + acct = w3.eth.account.from_mnemonic(data['mnemonic'], account_path=key, passphrase='') + print("%s,%s,%s" % (key, acct.address, acct.key.hex())) diff --git a/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/el/build_el.sh b/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/el/build_el.sh new file mode 100755 index 0000000..d7a0ae1 --- /dev/null +++ b/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/el/build_el.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -e + +# See: https://github.com/skylenet/ethereum-genesis-generator/blob/master/entrypoint.sh + +rm -rf ../build/el +mkdir -p ../build/el + +tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) +envsubst < el-config.yaml > $tmp_dir/genesis-config.yaml + +python3 /apps/el-gen/genesis_geth.py $tmp_dir/genesis-config.yaml | \ + jq 'del(.config.pragueTime)' \ + > ../build/el/geth.json + +python3 ../accounts/mnemonic_to_csv.py $tmp_dir/genesis-config.yaml > ../build/el/accounts.csv diff --git a/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/el/el-config.yaml b/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/el/el-config.yaml new file mode 100644 index 0000000..a3bfb11 --- /dev/null +++ b/stack-orchestrator/container-build/cerc-fixturenet-eth-genesis-postmerge/genesis/el/el-config.yaml @@ -0,0 +1,17 @@ +mnemonic: "viable ketchup woman library opinion copy rhythm attend rose knock penalty practice photo bundle budget dentist enter round bind holiday useful arch danger lobster" +el_premine: + "m/44'/60'/0'/0/0": 10000000ETH + "m/44'/60'/0'/0/1": 10000000ETH + "m/44'/60'/0'/0/2": 10000000ETH + "m/44'/60'/0'/0/3": 10000000ETH + "m/44'/60'/0'/0/4": 10000000ETH + "m/44'/60'/0'/0/5": 10000000ETH +el_premine_addrs: {} +chain_id: 1212 +deposit_contract_address: "0x1212121212121212121212121212121212121212" +genesis_timestamp: 0 +genesis_delay: 0 +deneb_fork_epoch: 0 +# note: only needed as workaround https://github.com/ethpandaops/ethereum-genesis-generator/pull/105 +electra_fork_epoch: 0 +slot_duration_in_seconds: 3