From 728b789aba9ed32f4ed22a0d1c37e70f370d2632 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 4 Sep 2024 16:52:50 +0530 Subject: [PATCH] Update instructions --- .../compose/docker-compose-eth.yml | 11 +--- stack-orchestrator/config/eth/run-cl.sh | 13 ++-- stack-orchestrator/config/eth/run-el.sh | 4 +- stack-orchestrator/stacks/eth/README.md | 66 +++++++++++++++++-- 4 files changed, 73 insertions(+), 21 deletions(-) diff --git a/stack-orchestrator/compose/docker-compose-eth.yml b/stack-orchestrator/compose/docker-compose-eth.yml index 0f5f135..8fc8ead 100644 --- a/stack-orchestrator/compose/docker-compose-eth.yml +++ b/stack-orchestrator/compose/docker-compose-eth.yml @@ -5,9 +5,9 @@ services: image: ethereum/client-go:alltools-v1.14.8 environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + ETH_DATADIR: "/root/.ethereum" CERC_NETWORK: ${CERC_NETWORK:-sepolia} CERC_ALLOW_UNPROTECTED_TXS: ${CERC_ALLOW_UNPROTECTED_TXS:-false} - CERC_ETH_DATADIR: ${CERC_ETH_DATADIR:-/root/.ethereum} CERC_GETH_VERBOSITY: ${CERC_GETH_VERBOSITY:-3} entrypoint: ["sh", "-c"] command: | @@ -35,8 +35,8 @@ services: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} ETH_ENDPOINT: "http://eth-geth:8545" EXECUTION_ENDPOINT: "http://eth-geth:8551" + LIGHTHOUSE_DATADIR: "/root/.lighthouse" CERC_NETWORK: ${CERC_NETWORK:-sepolia} - CERC_LIGHTHOUSE_DATADIR: ${CERC_LIGHTHOUSE_DATADIR:-/root/.lighthouse} CERC_CHECKPOINT_SYNC_URL: ${CERC_CHECKPOINT_SYNC_URL} CERC_DEBUG_LEVEL: ${CERC_DEBUG_LEVEL:-info} command: bash /root/scripts/run-cl.sh @@ -44,13 +44,6 @@ services: - eth_lighthouse_data:/root/.lighthouse - eth_secrets:/root/secrets - ../config/eth/run-cl.sh:/root/scripts/run-cl.sh - healthcheck: - # TODO: Update - test: ["CMD", "wget", "--tries=1", "--connect-timeout=1", "--quiet", "-O", "-", "http://localhost:8001/eth/v2/beacon/blocks/head"] - interval: 30s - timeout: 10s - retries: 10 - start_period: 30s ports: - "8001" diff --git a/stack-orchestrator/config/eth/run-cl.sh b/stack-orchestrator/config/eth/run-cl.sh index 294235b..fbf9974 100644 --- a/stack-orchestrator/config/eth/run-cl.sh +++ b/stack-orchestrator/config/eth/run-cl.sh @@ -8,9 +8,9 @@ fi echo "Using the following env:" echo "CERC_NETWORK: ${CERC_NETWORK}" -echo "CERC_LIGHTHOUSE_DATADIR: ${CERC_LIGHTHOUSE_DATADIR}" echo "CERC_CHECKPOINT_SYNC_URL: ${CERC_CHECKPOINT_SYNC_URL}" echo "CERC_DEBUG_LEVEL: ${CERC_DEBUG_LEVEL}" +echo "LIGHTHOUSE_DATADIR: ${LIGHTHOUSE_DATADIR}" echo "ETH_ENDPOINT: ${ETH_ENDPOINT}" echo "EXECUTION_ENDPOINT: ${EXECUTION_ENDPOINT}" @@ -24,16 +24,17 @@ cleanup() { } trap 'cleanup' SIGINT SIGTERM -# Create a JWT secret at shared path +# Create a JWT secret at shared path if not found jwtsecret_file_path=/root/secrets/jwtsecret -openssl rand -hex 32 | tr -d "\n" > $jwtsecret_file_path - -echo "Using the JWT secret generated at $jwtsecret_file_path" +if [ ! -f "$jwtsecret_file_path" ]; then + openssl rand -hex 32 | tr -d "\n" > $jwtsecret_file_path + echo "Generated JWT secret at $jwtsecret_file_path" +fi http_port=8001 lighthouse bn \ --network $CERC_NETWORK \ - --datadir $CERC_LIGHTHOUSE_DATADIR/$CERC_NETWORK \ + --datadir $LIGHTHOUSE_DATADIR/$CERC_NETWORK \ --execution-endpoint $EXECUTION_ENDPOINT \ --execution-jwt $jwtsecret_file_path \ --checkpoint-sync-url $CERC_CHECKPOINT_SYNC_URL \ diff --git a/stack-orchestrator/config/eth/run-el.sh b/stack-orchestrator/config/eth/run-el.sh index 9744ef4..bcd030b 100755 --- a/stack-orchestrator/config/eth/run-el.sh +++ b/stack-orchestrator/config/eth/run-el.sh @@ -8,8 +8,8 @@ fi echo "Using the following env:" echo "CERC_NETWORK: ${CERC_NETWORK}" echo "CERC_ALLOW_UNPROTECTED_TXS: ${CERC_ALLOW_UNPROTECTED_TXS}" -echo "CERC_ETH_DATADIR: ${CERC_ETH_DATADIR}" echo "CERC_GETH_VERBOSITY: ${CERC_GETH_VERBOSITY}" +echo "ETH_DATADIR: ${ETH_DATADIR}" # See https://linuxconfig.org/how-to-propagate-a-signal-to-child-processes-from-a-bash-script cleanup() { @@ -50,7 +50,7 @@ fi geth \ ${NETWORK_OPT} \ - --datadir="${CERC_ETH_DATADIR}" \ + --datadir="${ETH_DATADIR}" \ --authrpc.addr="0.0.0.0" \ --authrpc.vhosts="*" \ --authrpc.jwtsecret="$jwtsecret_file_path" \ diff --git a/stack-orchestrator/stacks/eth/README.md b/stack-orchestrator/stacks/eth/README.md index f7285f8..f8e3352 100644 --- a/stack-orchestrator/stacks/eth/README.md +++ b/stack-orchestrator/stacks/eth/README.md @@ -10,13 +10,27 @@ ## Create a deployment -* First, create a spec file for the deployment, which will map the stack's ports and volumes to the host: +* Create a spec file for the deployment, which will map the stack's ports and volumes to the host: ```bash laconic-so --stack ~/cerc/eth-stack/stack-orchestrator/stacks/eth deploy init --output eth-spec.yml ``` -* Once you've made any needed changes to the spec file, create a deployment from it: +* Edit `network` in the spec file to map container ports to host ports as required: + + ```yml + ... + network: + ports: + eth-geth: + - '8545:8545' + - '8546:8546' + - '6060:6060' + eth-lighthouse: + - '8001:8001' + ``` + +* Create a deployment from the spec file: ```bash laconic-so --stack ~/cerc/eth-stack/stack-orchestrator/stacks/eth deploy create --spec-file eth-spec.yml --deployment-dir eth-deployment @@ -26,8 +40,29 @@ ```bash # Optional - # Allow unprotected txs - CERC_ALLOW_UNPROTECTED_TXS=true + + # Network to run the ETH node for (default: sepolia) + # (one of mainnet, sepolia, holesky) + CERC_NETWORK= + + # Geth options (https://geth.ethereum.org/docs/fundamentals/command-line-options) + + # Allow unprotected txs (default: false) + CERC_ALLOW_UNPROTECTED_TXS= + + # Verbosity level (default: info) + CERC_GETH_VERBOSITY= + + # Lighthouse BN options (https://lighthouse-book.sigmaprime.io/help_bn.html) + + # Verbosity level (default: info) + CERC_DEBUG_LEVEL= + + # Required + + # Beacon node endpoint to use for checkpoint sync + # (https://eth-clients.github.io/checkpoint-sync-endpoints/) + CERC_CHECKPOINT_SYNC_URL= ``` ## Start @@ -38,6 +73,29 @@ laconic-so deployment --dir eth-deployment start ``` +## Check status + +* To list down and monitor the running containers: + + ```bash + # With status + docker ps -a + + # Follow logs for eth-geth container + laconic-so deployment --dir eth-deployment logs eth-geth -f + + # Follow logs for eth-lighthouse container + laconic-so deployment --dir eth-deployment logs eth-lighthouse -f + ``` + +* Once the node has caught up to head, make a request to get the latest block number: + + ```bash + curl -H "Content-Type: application/json" \ + --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \ + http://localhost:8545 + ``` + ## Clean up * To stop all services running in the background, while preserving chain data: