forked from cerc-io/stack-orchestrator
Refactor for shiv package
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
FROM sigp/lcli:v3.2.1 AS lcli
|
||||
FROM skylenet/ethereum-genesis-generator@sha256:210353ce7c898686bc5092f16c61220a76d357f51eff9c451e9ad1b9ad03d4d3 AS ethgen
|
||||
FROM cerc/fixturenet-eth-geth:local AS fnetgeth
|
||||
|
||||
FROM cerc/lighthouse:local
|
||||
|
||||
# cerc/lighthouse is based on Ubuntu
|
||||
RUN apt-get update && apt-get -y upgrade && apt-get install -y --no-install-recommends \
|
||||
libssl-dev ca-certificates \
|
||||
curl socat iproute2 telnet wget jq \
|
||||
build-essential python3 python3-dev python3-pip gettext-base \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY genesis /opt/testnet
|
||||
COPY run-cl.sh /opt/testnet/run.sh
|
||||
|
||||
COPY --from=lcli /usr/local/bin/lcli /usr/local/bin/lcli
|
||||
COPY --from=ethgen /usr/local/bin/eth2-testnet-genesis /usr/local/bin/eth2-testnet-genesis
|
||||
COPY --from=ethgen /usr/local/bin/eth2-val-tools /usr/local/bin/eth2-val-tools
|
||||
COPY --from=ethgen /apps /apps
|
||||
COPY --from=fnetgeth /opt/testnet/el /opt/testnet/el
|
||||
COPY --from=fnetgeth /opt/testnet/build/el /opt/testnet/build/el
|
||||
|
||||
RUN cd /opt/testnet && make genesis-cl
|
||||
|
||||
# Work around some bugs in lcli where the default path is always used.
|
||||
RUN mkdir -p /root/.lighthouse && cd /root/.lighthouse && ln -s /opt/testnet/build/cl/testnet
|
||||
|
||||
ENTRYPOINT ["/opt/testnet/run.sh"]
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/fixturenet-eth-lighthouse
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker build -t cerc/fixturenet-eth-lighthouse:local -f ${SCRIPT_DIR}/Dockerfile $SCRIPT_DIR
|
||||
@@ -0,0 +1,13 @@
|
||||
.PHONY: build
|
||||
build: genesis
|
||||
|
||||
.PHONY: genesis
|
||||
genesis: genesis-cl
|
||||
|
||||
.PHONY: genesis-cl
|
||||
genesis-cl:
|
||||
cd cl; ./build_cl.sh
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf build
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# See: https://github.com/sigp/lighthouse/blob/stable/scripts/local_testnet/beacon_node.sh
|
||||
#
|
||||
# Starts a beacon node based upon a genesis state created by `./setup.sh`.
|
||||
#
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
source ./vars.env
|
||||
|
||||
SUBSCRIBE_ALL_SUBNETS=
|
||||
DEBUG_LEVEL=${DEBUG_LEVEL:-debug}
|
||||
|
||||
# Get positional arguments
|
||||
data_dir=$DATADIR/node_${NODE_NUMBER}
|
||||
network_port=9001
|
||||
http_port=8001
|
||||
authrpc_port=8551
|
||||
|
||||
exec lighthouse \
|
||||
--debug-level $DEBUG_LEVEL \
|
||||
bn \
|
||||
$SUBSCRIBE_ALL_SUBNETS \
|
||||
--boot-nodes "$ENR" \
|
||||
--datadir $data_dir \
|
||||
--testnet-dir $TESTNET_DIR \
|
||||
--enable-private-discovery \
|
||||
--staking \
|
||||
--enr-address $ENR_IP \
|
||||
--enr-udp-port $network_port \
|
||||
--enr-tcp-port $network_port \
|
||||
--port $network_port \
|
||||
--http-address 0.0.0.0 \
|
||||
--http-port $http_port \
|
||||
--disable-packet-filter \
|
||||
--execution-endpoint $EXECUTION_ENDPOINT \
|
||||
--execution-jwt $JWTSECRET \
|
||||
--terminal-total-difficulty-override $ETH1_TTD \
|
||||
--suggested-fee-recipient $SUGGESTED_FEE_RECIPIENT \
|
||||
--target-peers $((BN_COUNT - 1))
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# See: https://github.com/sigp/lighthouse/blob/stable/scripts/local_testnet/bootnode.sh
|
||||
#
|
||||
# Starts a bootnode from the generated enr.
|
||||
#
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
source ./vars.env
|
||||
|
||||
DEBUG_LEVEL=${1:-info}
|
||||
|
||||
echo "Starting bootnode"
|
||||
|
||||
if [ ! -f "$DATADIR/bootnode/enr.dat" ]; then
|
||||
echo "Generating bootnode enr"
|
||||
lcli \
|
||||
generate-bootnode-enr \
|
||||
--ip $ENR_IP \
|
||||
--udp-port $BOOTNODE_PORT \
|
||||
--tcp-port $BOOTNODE_PORT \
|
||||
--genesis-fork-version $GENESIS_FORK_VERSION \
|
||||
--output-dir $DATADIR/bootnode
|
||||
|
||||
bootnode_enr=`cat $DATADIR/bootnode/enr.dat`
|
||||
echo "- $bootnode_enr" > $TESTNET_DIR/boot_enr.yaml
|
||||
|
||||
echo "Generated bootnode enr and written to $TESTNET_DIR/boot_enr.yaml"
|
||||
fi
|
||||
|
||||
exec lighthouse boot_node \
|
||||
--testnet-dir $TESTNET_DIR \
|
||||
--port $BOOTNODE_PORT \
|
||||
--listen-address 0.0.0.0 \
|
||||
--disable-packet-filter \
|
||||
--network-dir $DATADIR/bootnode \
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Deploys the deposit contract and makes deposits for $VALIDATOR_COUNT insecure deterministic validators.
|
||||
# Produces a testnet specification and a genesis state where the genesis time
|
||||
# is now + $GENESIS_DELAY.
|
||||
#
|
||||
# Generates datadirs for multiple validator keys according to the
|
||||
# $VALIDATOR_COUNT and $BN_COUNT variables.
|
||||
#
|
||||
|
||||
set -o nounset -o errexit -o pipefail
|
||||
|
||||
source ./vars.env
|
||||
|
||||
rm -rf $DATADIR
|
||||
mkdir -p $DATADIR
|
||||
|
||||
NOW=`date +%s`
|
||||
GENESIS_TIME=`expr $NOW + $GENESIS_DELAY`
|
||||
|
||||
echo "Creating testnet ..."
|
||||
echo "(Note: errors of the form 'WARN: Scrypt parameters are too weak...' below can be safely ignored)"
|
||||
lcli \
|
||||
new-testnet \
|
||||
--spec $SPEC_PRESET \
|
||||
--deposit-contract-address $ETH1_DEPOSIT_CONTRACT_ADDRESS \
|
||||
--testnet-dir $TESTNET_DIR \
|
||||
--min-genesis-active-validator-count $GENESIS_VALIDATOR_COUNT \
|
||||
--min-genesis-time $GENESIS_TIME \
|
||||
--genesis-delay $GENESIS_DELAY \
|
||||
--genesis-fork-version $GENESIS_FORK_VERSION \
|
||||
--altair-fork-epoch $ALTAIR_FORK_EPOCH \
|
||||
--merge-fork-epoch $MERGE_FORK_EPOCH \
|
||||
--eth1-id $ETH1_CHAIN_ID \
|
||||
--eth1-follow-distance 1 \
|
||||
--seconds-per-slot $SECONDS_PER_SLOT \
|
||||
--seconds-per-eth1-block $SECONDS_PER_ETH1_BLOCK \
|
||||
--force
|
||||
|
||||
echo Specification generated at $TESTNET_DIR.
|
||||
echo "Generating $VALIDATOR_COUNT validators concurrently... (this may take a while)"
|
||||
|
||||
lcli \
|
||||
insecure-validators \
|
||||
--count $VALIDATOR_COUNT \
|
||||
--base-dir $DATADIR \
|
||||
--node-count $BN_COUNT
|
||||
|
||||
echo Validators generated with keystore passwords at $DATADIR.
|
||||
echo "Building genesis state... (this might take a while)"
|
||||
|
||||
lcli \
|
||||
interop-genesis \
|
||||
--spec $SPEC_PRESET \
|
||||
--genesis-time $GENESIS_TIME \
|
||||
--testnet-dir $TESTNET_DIR \
|
||||
$GENESIS_VALIDATOR_COUNT
|
||||
|
||||
echo Created genesis state in $TESTNET_DIR
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
LIGHTHOUSE_BASE_URL=http://localhost:8001
|
||||
|
||||
result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.data.message.body.execution_payload.block_number'`
|
||||
if [ ! -z "$result" ] && [ $result -gt 0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exit 1
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# See: https://github.com/sigp/lighthouse/blob/stable/scripts/local_testnet/reset_genesis_time.sh
|
||||
#
|
||||
# Resets the beacon state genesis time to now.
|
||||
#
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
source ./vars.env
|
||||
|
||||
NOW=${1:-`date +%s`}
|
||||
|
||||
lcli \
|
||||
change-genesis-time \
|
||||
$TESTNET_DIR/genesis.ssz \
|
||||
$NOW
|
||||
|
||||
echo "Reset genesis time to now ($NOW)"
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# See: https://github.com/sigp/lighthouse/blob/stable/scripts/local_testnet/validator_client.sh
|
||||
#
|
||||
# Usage: ./validator_client.sh <DATADIR> <BEACON-NODE-HTTP> <OPTIONAL-DEBUG-LEVEL>
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
source ./vars.env
|
||||
|
||||
DEBUG_LEVEL=info
|
||||
|
||||
BUILDER_PROPOSALS=
|
||||
|
||||
# Get options
|
||||
while getopts "pd:" flag; do
|
||||
case "${flag}" in
|
||||
p) BUILDER_PROPOSALS="--builder-proposals";;
|
||||
d) DEBUG_LEVEL=${OPTARG};;
|
||||
esac
|
||||
done
|
||||
|
||||
exec lighthouse \
|
||||
--debug-level $DEBUG_LEVEL \
|
||||
vc \
|
||||
$BUILDER_PROPOSALS \
|
||||
--validators-dir $DATADIR/node_$NODE_NUMBER/validators \
|
||||
--secrets-dir $DATADIR/node_$NODE_NUMBER/secrets \
|
||||
--testnet-dir $TESTNET_DIR \
|
||||
--init-slashing-protection \
|
||||
--beacon-nodes http://localhost:8001 \
|
||||
--suggested-fee-recipient $SUGGESTED_FEE_RECIPIENT \
|
||||
$VC_ARGS
|
||||
@@ -0,0 +1,54 @@
|
||||
# Base directories for the validator keys and secrets
|
||||
DATADIR=${DATADIR:-../build/cl}
|
||||
|
||||
# Directory for the eth2 config
|
||||
TESTNET_DIR=${TESTNET_DIR:-$DATADIR/testnet}
|
||||
JWTSECRET=${JWTSECRET:-$DATADIR/jwtsecret}
|
||||
ENR=${ENR:="SET_AT_RUNTIME"}
|
||||
ENR_IP=`ip addr | grep inet | grep -v '127.0.0.1' | sort | head -1 | awk '{print $2}' | cut -d '/' -f1`
|
||||
|
||||
GENESIS_FORK_VERSION=${GENESIS_FORK_VERSION:-0x12121212}
|
||||
|
||||
VALIDATOR_COUNT=${VALIDATOR_COUNT:-80}
|
||||
GENESIS_VALIDATOR_COUNT=${GENESIS_VALIDATOR_COUNT:-80}
|
||||
|
||||
# Number of beacon_node instances that you intend to run
|
||||
BN_COUNT=${BN_COUNT:-2}
|
||||
|
||||
# Number of validator clients
|
||||
VC_COUNT=${VC_COUNT:-$BN_COUNT}
|
||||
|
||||
# Number of seconds to delay to start genesis block.
|
||||
# If started by a script this can be 0, if starting by hand
|
||||
# use something like 180.
|
||||
GENESIS_DELAY=${GENESIS_DELAY:-0}
|
||||
|
||||
# Port for P2P communication with bootnode
|
||||
BOOTNODE_PORT=${BOOTNODE_PORT:-4242}
|
||||
|
||||
# Hard fork configuration
|
||||
ALTAIR_FORK_EPOCH=${ALTAIR_FORK_EPOCH:-0}
|
||||
MERGE_FORK_EPOCH=${MERGE_FORK_EPOCH:-0}
|
||||
|
||||
# Spec version (mainnet or minimal)
|
||||
SPEC_PRESET=${SPEC_PRESET:-mainnet}
|
||||
|
||||
# Seconds per Eth2 slot
|
||||
SECONDS_PER_SLOT=${SECONDS_PER_SLOT:-3}
|
||||
|
||||
# Seconds per Eth1 block
|
||||
SECONDS_PER_ETH1_BLOCK=${SECONDS_PER_ETH1_BLOCK:-1}
|
||||
|
||||
# Command line arguments for validator client
|
||||
VC_ARGS=${VC_ARGS:-""}
|
||||
|
||||
EXECUTION_ENDPOINT=${EXECUTION_ENDPOINT:-http://localhost:8551}
|
||||
|
||||
ETH1_GENESIS_JSON=${ETH1_GENESIS_JSON:-"../build/el/geth.json"}
|
||||
ETH1_CONFIG_YAML=${ETH1_CONFIG_YAML:-"../el/el-config.yaml"}
|
||||
|
||||
ETH1_CHAIN_ID=${ETH1_CHAIN_ID:-`cat $ETH1_GENESIS_JSON | jq -r '.config.chainId'`}
|
||||
ETH1_TTD=${ETH1_TTD:-`cat $ETH1_GENESIS_JSON | jq -r '.config.terminalTotalDifficulty'`}
|
||||
ETH1_DEPOSIT_CONTRACT_ADDRESS=${ETH1_DEPOSIT_CONTRACT_ADDRESS:-`cat $ETH1_CONFIG_YAML | grep 'deposit_contract_address' | awk '{ print $2 }' | sed 's/"//g'`}
|
||||
ETH1_DEPOSIT_CONTRACT_BLOCK=${ETH1_DEPOSIT_CONTRACT_BLOCK:-0x0}
|
||||
SUGGESTED_FEE_RECIPIENT=`cat ../build/el/accounts.csv | head -1 | cut -d',' -f2`
|
||||
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "true" == "$RUN_BOOTNODE" ]; then
|
||||
cd /opt/testnet/build/cl
|
||||
python3 -m http.server 3000 &
|
||||
|
||||
|
||||
cd /opt/testnet/cl
|
||||
./bootnode.sh 2>&1 | tee /var/log/lighthouse_bootnode.log
|
||||
else
|
||||
while [ 1 -eq 1 ]; do
|
||||
echo "Waiting on geth ..."
|
||||
sleep 5
|
||||
result=`wget --no-check-certificate --quiet \
|
||||
-O - \
|
||||
--method POST \
|
||||
--timeout=0 \
|
||||
--header 'Content-Type: application/json' \
|
||||
--body-data '{ "jsonrpc": "2.0", "id": 1, "method": "eth_blockNumber", "params": [] }' "${ETH1_ENDPOINT:-localhost:8545}" | jq -r '.result'`
|
||||
if [ ! -z "$result" ] && [ "null" != "$result" ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
cd /opt/testnet/cl
|
||||
|
||||
if [ -z "$LIGHTHOUSE_GENESIS_STATE_URL" ]; then
|
||||
./reset_genesis_time.sh
|
||||
else
|
||||
while [ 1 -eq 1 ]; do
|
||||
echo "Waiting on Genesis time ..."
|
||||
sleep 5
|
||||
result=`wget --no-check-certificate --quiet -O - --timeout=0 $LIGHTHOUSE_GENESIS_STATE_URL | jq -r '.data.genesis_time'`
|
||||
if [ ! -z "$result" ]; then
|
||||
./reset_genesis_time.sh $result
|
||||
break;
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ ! -z "$ENR_URL" ]; then
|
||||
while [ 1 -eq 1 ]; do
|
||||
echo "Waiting on ENR for boot node..."
|
||||
sleep 5
|
||||
result=`wget --no-check-certificate --quiet -O - --timeout=0 $ENR_URL`
|
||||
if [ ! -z "$result" ]; then
|
||||
export ENR="$result"
|
||||
break;
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
export JWTSECRET="/opt/testnet/build/cl/jwtsecret"
|
||||
echo -n "$JWT" > $JWTSECRET
|
||||
|
||||
./beacon_node.sh 2>&1 | tee /var/log/lighthouse_bn.log &
|
||||
lpid=$!
|
||||
./validator_client.sh 2>&1 | tee /var/log/lighthouse_vc.log &
|
||||
vpid=$!
|
||||
|
||||
wait $lpid $vpid
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
|
||||
STATUSES=("geth to generate DAG" "beacon phase0" "beacon altair" "beacon bellatrix pre-merge" "beacon bellatrix merge")
|
||||
STATUS=0
|
||||
|
||||
|
||||
LIGHTHOUSE_BASE_URL=${LIGHTHOUSE_BASE_URL}
|
||||
GETH_BASE_URL=${GETH_BASE_URL}
|
||||
|
||||
if [ -z "$LIGHTHOUSE_BASE_URL" ]; then
|
||||
LIGHTHOUSE_PORT=`docker ps -f "name=fixturenet-eth-lighthouse-1-1" --format "{{.Ports}}" | head -1 | cut -d':' -f2 | cut -d'-' -f1`
|
||||
LIGHTHOUSE_BASE_URL="http://localhost:${LIGHTHOUSE_PORT}"
|
||||
fi
|
||||
|
||||
if [ -z "$GETH_BASE_URL" ]; then
|
||||
GETH_PORT=`docker ps -f "name=fixturenet-eth-geth-1-1" --format "{{.Ports}}" | head -1 | cut -d':' -f2 | cut -d'-' -f1`
|
||||
GETH_BASE_URL="http://localhost:${GETH_PORT}"
|
||||
fi
|
||||
|
||||
function inc_status() {
|
||||
echo " DONE!"
|
||||
STATUS=$((STATUS + 1))
|
||||
if [ $STATUS -lt ${#STATUSES[@]} ]; then
|
||||
echo -n "Waiting for ${STATUSES[$STATUS]}..."
|
||||
fi
|
||||
}
|
||||
|
||||
echo -n "Waiting for ${STATUSES[$STATUS]}..."
|
||||
while [ $STATUS -lt ${#STATUSES[@]} ]; do
|
||||
sleep 1
|
||||
echo -n "."
|
||||
case $STATUS in
|
||||
0)
|
||||
result=`wget --no-check-certificate --quiet -O - --method POST --header 'Content-Type: application/json' \
|
||||
--body-data '{ "jsonrpc": "2.0", "id": 1, "method": "eth_getBlockByNumber", "params": ["0x3", false] }' $GETH_BASE_URL | jq -r '.result'`
|
||||
if [ ! -z "$result" ] && [ "null" != "$result" ]; then
|
||||
inc_status
|
||||
fi
|
||||
;;
|
||||
1)
|
||||
result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.data.message.slot'`
|
||||
if [ ! -z "$result" ] && [ $result -gt 0 ]; then
|
||||
inc_status
|
||||
fi
|
||||
;;
|
||||
2)
|
||||
result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.version'`
|
||||
if [ ! -z "$result" ] && ([ "$result" == "altair" ] || [ "$result" == "bellatrix" ]); then
|
||||
inc_status
|
||||
fi
|
||||
;;
|
||||
3)
|
||||
result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.version'`
|
||||
if [ ! -z "$result" ] && [ "$result" == "bellatrix" ]; then
|
||||
inc_status
|
||||
fi
|
||||
;;
|
||||
4)
|
||||
result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.data.message.body.execution_payload.block_number'`
|
||||
if [ ! -z "$result" ] && [ $result -gt 0 ]; then
|
||||
inc_status
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
Reference in New Issue
Block a user