Skip to content

Commit

Permalink
fix: testnet configs
Browse files Browse the repository at this point in the history
  • Loading branch information
eenagy committed Jul 5, 2024
1 parent 13adca9 commit 0b8eb84
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 68 deletions.
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,20 @@ Open two terminals and execute the following commands:

Terminal 1:
```bash
bash run-a-client.sh --network <network> \
--consensus-client <consensus_client> \
--execution-client <execution_client> \
--run execution
bash run-a-client.sh --network <network> --cl <consensus_client>
```

Terminal 2:
```bash
bash run-a-client.sh --network <network> \
--consensus-client <consensus_client> \
--execution-client <execution_client> \
--run consensus
bash run-a-client.sh --network <network> --el <execution_client>
```

## Running a client pair with one script

This will run a node with the selected network and clients. Note this is intended as an example.

```bash
bash run-a-node.sh --network <network> \
--consensus-client <consensus_client> \
--execution-client <execution_client>
bash run-a-node.sh --network <network> --cl <consensus_client> --el <execution_client>
```

## Available Options
Expand Down
12 changes: 7 additions & 5 deletions network/testnet/testnet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
BASE_CONFIG_NETWORK=testnet
# PORT for EL and CL to communicate
BASE_CONFIG_ENGINE_API_PORT=8551
# URL for EL and CL to communicate
BASE_CONFIG_ENDPOINT_URL=http://localhost:$BASE_CONFIG_ENGINE_API_PORT
BASE_CONFIG_ENGINE_SCHEME=http
BASE_CONFIG_ENGINE_HOST=localhost
# DATADIR where CL and EL dirs will be placed
BASE_CONFIG_DATA_DIR=$HOME/nodes/$BASE_CONFIG_NETWORK/$EXECUTION_CLIENT-$CONSENSUS_CLIENT
BASE_CONFIG_DATA_DIR=$HOME/.run-a-node/$BASE_CONFIG_NETWORK
# URL for EL and CL to communicate
BASE_CONFIG_ENDPOINT_URL=$BASE_CONFIG_ENGINE_SCHEME://$BASE_CONFIG_ENGINE_HOST:$BASE_CONFIG_ENGINE_API_PORT
# JWT secrets file shared by CL and EL
BASE_CONFIG_SECRETS_FILE=$BASE_CONFIG_DATA_DIR/jwt.hex

Expand All @@ -15,7 +17,7 @@ BASE_CONFIG_SECRETS_FILE=$BASE_CONFIG_DATA_DIR/jwt.hex
BASE_CONFIG_CUSTOM_NETWORK_TESTNET_DIR=$BASE_CONFIG_DATA_DIR/testnet
BASE_CONFIG_CUSTOM_NETWORK_GENESIS_FILE=$BASE_CONFIG_CUSTOM_NETWORK_TESTNET_DIR/genesis.json
BASE_CONFIG_CUSTOM_NETWORK_GENESIS_STATE=$BASE_CONFIG_CUSTOM_NETWORK_TESTNET_DIR/genesis.ssz
BASE_CONFIG_CUSTOM_NETWORK_CHAINCONFIG=$BASE_CONFIG_CUSTOM_NETWORK_TESTNET_DIR/consensus/config.yml
BASE_CONFIG_CUSTOM_NETWORK_CHAINCONFIG=$BASE_CONFIG_CUSTOM_NETWORK_TESTNET_DIR/config.yaml

# FILLED IN BY SCRIPT, but custom network options (ephemery, testnet)
BASE_CONFIG_CUSTOM_NETWORK_BOOTNODES_ENR=
Expand All @@ -39,6 +41,6 @@ BASE_CONFIG_CL_P2P_PORT=

# validator related options shared between consensus client & validator
BASE_CONFIG_VALIDATOR_DATADIR=$BASE_CONFIG_DATA_DIR/validator
BASE_CONFIG_VALIDATOR_BEACON_RPC_PROVIDER=localhost:4000
BASE_CONFIG_VALIDATOR_BEACON_RPC_PROVIDER=BASE_CONFIG_ENGINE_HOST:4000
BASE_CONFIG_VALIDATOR_NUM_VALIDATORS=64
BASE_CONFIG_VALIDATOR_SHARED_FEE_RECEIPENT_ADDRESS=0x123463a4b065722e99115d6c222f267d9cabb524
78 changes: 37 additions & 41 deletions run-a-client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ create_secrets_file_if_not_exists() {

run_node_usage() {
echo "Usage: $0 [ --network mainnet|sepolia|ephemery|holesky|devnet ] \
[ --consensus-client lighthouse|lodestar|nimbus-eth2|prysm|teku ] \
[ --execution-client besu|erigon|geth|nethermind ] \
[ --run execution|consensus|validator ]"
[ --cl lighthouse|lodestar|nimbus-eth2|prysm|teku | --el besu|erigon|geth|nethermind ]"
exit 1
}

is_valid_option() {
local option="$1"
shift
Expand All @@ -60,29 +57,40 @@ run=
run_node_parse_options() {

local opts
opts=$(getopt -o '' -l "network:,consensus-client:,execution-client:,run:" -n "$0" -- "$@")
opts=$(getopt -o '' -l "network:,cl:,el:" -n "$0" -- "$@")
if [ $? != 0 ]; then
run_node_usage
fi

eval set -- "$opts"

local consensus_client_set=false
local execution_client_set=false

while true; do
case "$1" in
--network)
network="$2"
shift 2
;;
--consensus-client)
--cl)
if [ "$execution_client_set" = true ]; then
echo "Only one of consensus-client or execution-client is allowed."
run_node_usage
fi
consensus_client="$2"
consensus_client_set=true
run="consensus"
shift 2
;;
--execution-client)
--el)
if [ "$consensus_client_set" = true ]; then
echo "Only one of consensus-client or execution-client is allowed."
run_node_usage
fi
execution_client="$2"
shift 2
;;
--run)
run="$2"
execution_client_set=true
run="execution"
shift 2
;;
--)
Expand All @@ -100,18 +108,18 @@ run_node_parse_options() {
run_node_usage
fi

if [ -z "$consensus_client" ]; then
echo "Please provide a consensus-client value"
if [ "$consensus_client_set" = false ] && [ "$execution_client_set" = false ]; then
echo "Please provide either a consensus-client or an execution-client value"
run_node_usage
fi

if [ -z "$execution_client" ]; then
echo "Please provide an execution-client value"
if [ "$consensus_client_set" = true ] && ! is_valid_option "$consensus_client" "${VALID_CONSENSUS_CLIENTS[@]}"; then
echo "Invalid consensus client: $consensus_client"
run_node_usage
fi

if [ -z "$run" ]; then
echo "Please provide a run value"
if [ "$execution_client_set" = true ] && ! is_valid_option "$execution_client" "${VALID_EXECUTION_CLIENTS[@]}"; then
echo "Invalid execution client: $execution_client"
run_node_usage
fi

Expand All @@ -120,36 +128,19 @@ run_node_parse_options() {
run_node_usage
fi

if ! is_valid_option "$consensus_client" "${VALID_CONSENSUS_CLIENTS[@]}"; then
echo "Invalid consensus client: $consensus_client"
run_node_usage
fi

if ! is_valid_option "$execution_client" "${VALID_EXECUTION_CLIENTS[@]}"; then
echo "Invalid execution client: $execution_client"
run_node_usage
echo "Network: $network"
if [ "$consensus_client_set" = true ]; then
echo "Consensus Client: $consensus_client"
fi

if ! is_valid_option "$run" "${VALID_RUN_OPTIONS[@]}"; then
echo "Invalid run option: $run"
run_node_usage
if [ "$execution_client_set" = true ]; then
echo "Execution Client: $execution_client"
fi

echo "Network: $network"
echo "Consensus Client: $consensus_client"
echo "Execution Client: $execution_client"
echo "Running Client: $run"
}

run_node_parse_options "$@"

latest_execution_client_version=${LATEST_CLIENTS["$execution_client"]}
latest_consensus_client_version=${LATEST_CLIENTS["$consensus_client"]}

EXECUTION_CLIENT=$execution_client
CONSENSUS_CLIENT=$consensus_client
EXECUTION_CLIENT_VERSION=$latest_execution_client_version
CONSENSUS_CLIENT_VERSION=$latest_consensus_client_version

script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
set -a
Expand All @@ -160,11 +151,10 @@ create_data_dir_if_not_exists "$BASE_CONFIG_DATA_DIR"
create_secrets_file_if_not_exists "$BASE_CONFIG_SECRETS_FILE"

if [[ "$network" == "ephemery" ]] || [[ "$network" == "testnet" ]]; then
source "$script_dir/handle_ephemery.sh"
source "$script_dir/handle_$network.sh"
fi



shared_run="$run"
additional_confs=""
sub_dir=""
Expand All @@ -173,10 +163,16 @@ latest_client_version=
if [ "$run" == "execution" ]; then
client_name="$execution_client"
sub_dir="el"
latest_execution_client_version=${LATEST_CLIENTS["$execution_client"]}
EXECUTION_CLIENT=$execution_client
EXECUTION_CLIENT_VERSION=$latest_execution_client_version
latest_client_version=$latest_execution_client_version
elif [ "$run" == "consensus" ]; then
client_name="$consensus_client"
sub_dir="cl"
CONSENSUS_CLIENT=$consensus_client
latest_consensus_client_version=${LATEST_CLIENTS["$consensus_client"]}
CONSENSUS_CLIENT_VERSION=$latest_consensus_client_version
latest_client_version=$latest_consensus_client_version
fi

Expand Down
22 changes: 11 additions & 11 deletions run-a-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ kill_previous_processes() {
}

usage() {
echo "Usage: $0 --network <network> --consensus-client <consensus_client> --execution-client <execution_client> --with-validator"
echo "Usage: $0 --network <network> --cl <consensus_client> --el <execution_client> --with-validator"
exit 1
}

Expand All @@ -32,8 +32,8 @@ with_monitoring=
while [[ "$#" -gt 0 ]]; do
case $1 in
--network) network="$2"; shift ;;
--consensus-client) consensus_client="$2"; shift ;;
--execution-client) execution_client="$2"; shift ;;
--cl) consensus_client="$2"; shift ;;
--el) execution_client="$2"; shift ;;
--with-validator) with_validator=true; shift ;;
*) echo "Unknown parameter passed: $1"; usage ;;
esac
Expand All @@ -56,24 +56,24 @@ kill_previous_processes
chmod +x run-a-client.sh

# Run execution client
nohup run-a-client.sh --network "$network" --consensus-client "$consensus_client" --execution-client "$execution_client" --run execution $OP_ARGS > $LOGS_DIR/execution.log 2>&1 &
nohup run-a-client.sh --network "$network" --consensus-client "$consensus_client" --execution-client "$execution_client" $OP_ARGS > $LOGS_DIR/execution.log 2>&1 &
EL_CLIENT_PID=$!
echo "Execution client started with PID $EL_CLIENT_PID"
echo "$EL_CLIENT_PID" >> "$PID_FILE"

# Run consensus client
nohup run-a-client.sh --network "$network" --consensus-client "$consensus_client" --execution-client "$execution_client" --run consensus $OP_ARGS > $LOGS_DIR/consensus.log 2>&1 &
nohup run-a-client.sh --network "$network" --consensus-client "$consensus_client" --execution-client "$execution_client" $OP_ARGS > $LOGS_DIR/consensus.log 2>&1 &
CL_CLIENT_PID=$!
echo "Consensus client started with PID $CL_CLIENT_PID"
echo "$CL_CLIENT_PID" >> "$PID_FILE"

# Run the client with validator if specified
if [ "$with_validator" == "true" ]; then
nohup run-a-client.sh --network "$network" --consensus-client "$consensus_client" --execution-client "$execution_client" --run validator $OP_ARGS > $LOGS_DIR/validator.log 2>&1 &
VALIDATOR_CLIENT_PID=$!
echo "validator client started with PID $VALIDATOR_CLIENT_PID"
echo "$VALIDATOR_CLIENT_PID" >> "$PID_FILE"
fi
# if [ "$with_validator" == "true" ]; then
# nohup run-a-client.sh --network "$network" --consensus-client "$consensus_client" --execution-client "$execution_client" --run validator $OP_ARGS > $LOGS_DIR/validator.log 2>&1 &
# VALIDATOR_CLIENT_PID=$!
# echo "validator client started with PID $VALIDATOR_CLIENT_PID"
# echo "$VALIDATOR_CLIENT_PID" >> "$PID_FILE"
# fi

sleep 1

Expand Down

0 comments on commit 0b8eb84

Please sign in to comment.