Add a stack to run an Ethereum node #1
32
stack-orchestrator/compose/docker-compose-eth.yml
Normal file
32
stack-orchestrator/compose/docker-compose-eth.yml
Normal file
@ -0,0 +1,32 @@
|
||||
services:
|
||||
eth-geth:
|
||||
restart: on-failure
|
||||
hostname: eth-geth
|
||||
environment:
|
||||
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
||||
CERC_NETWORK: ${CERC_NETWORK:-sepolia}
|
||||
CERC_ALLOW_UNPROTECTED_TXS: ${CERC_ALLOW_UNPROTECTED_TXS:-false}
|
||||
CERC_ETH_DATADIR: ${CERC_ETH_DATADIR:-/root/ethdata}
|
||||
CERC_GETH_VERBOSITY: ${CERC_GETH_VERBOSITY:-3}
|
||||
env_file:
|
||||
- ../config/eth/params.env
|
||||
image: ethereum/client-go:alltools-v1.14.8
|
||||
entrypoint: ["sh", "-c"]
|
||||
command: |
|
||||
"/scripts/run-el.sh"
|
||||
volumes:
|
||||
- eth_geth_data:/root/ethdata
|
||||
- ../config/eth/run-el.sh:/scripts/run-el.sh
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-v", "localhost", "8545"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
start_period: 3s
|
||||
ports:
|
||||
- "8545"
|
||||
- "8546"
|
||||
- "6060"
|
||||
|
||||
volumes:
|
||||
eth_geth_data:
|
3
stack-orchestrator/config/eth/params.env
Normal file
3
stack-orchestrator/config/eth/params.env
Normal file
@ -0,0 +1,3 @@
|
||||
# JWT shared by geth and lighthouse for authentication
|
||||
# TODO: Generate using openssl
|
||||
JWT="0x6cdcac3501046a08e186730dd8bd136cfaf0fdc1fc955f6e15ad3068c0ff2af0"
|
68
stack-orchestrator/config/eth/run-el.sh
Executable file
68
stack-orchestrator/config/eth/run-el.sh
Executable file
@ -0,0 +1,68 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
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}"
|
||||
|
||||
# See https://linuxconfig.org/how-to-propagate-a-signal-to-child-processes-from-a-bash-script
|
||||
cleanup() {
|
||||
echo "Signal received, cleaning up..."
|
||||
|
||||
# Kill the child process first (CERC_REMOTE_DEBUG=true uses dlv which starts geth as a child process)
|
||||
pkill -P ${geth_pid}
|
||||
sleep 2
|
||||
kill $(jobs -p)
|
||||
|
||||
wait
|
||||
echo "Done"
|
||||
}
|
||||
trap 'cleanup' SIGINT SIGTERM
|
||||
|
||||
# Store the JWT secret
|
||||
jwtsecret_file_path=/opt/jwtsecret
|
||||
echo -n "$JWT" > $jwtsecret_file_path
|
||||
|
||||
NETWORK_OPT=""
|
||||
if [ "$CERC_NETWORK" = "sepolia" ] || [ "$CERC_NETWORK" = "holesky" ] || [ "$CERC_NETWORK" = "mainnet" ]; then
|
||||
NETWORK_OPT="--${CERC_NETWORK}"
|
||||
else
|
||||
NETWORK_OPT="--networkid ${CERC_NETWORK}"
|
||||
fi
|
||||
|
||||
OTHER_OPTS=""
|
||||
if [ "$CERC_ALLOW_UNPROTECTED_TXS" == "true" ]; then
|
||||
# Allow for unprotected (non EIP155) txs to be submitted via RPC
|
||||
OTHER_OPTS="--rpc.allow-unprotected-txs"
|
||||
fi
|
||||
|
||||
geth \
|
||||
${NETWORK_OPT} \
|
||||
--datadir="${CERC_ETH_DATADIR}" \
|
||||
--authrpc.addr="0.0.0.0" \
|
||||
--authrpc.vhosts="*" \
|
||||
--authrpc.jwtsecret="$jwtsecret_file_path" \
|
||||
--http \
|
||||
--http.addr="0.0.0.0" \
|
||||
--http.vhosts="*" \
|
||||
--http.api="${CERC_GETH_HTTP_APIS:-eth,web3,net,admin,personal,debug}" \
|
||||
--http.corsdomain="*" \
|
||||
--ws \
|
||||
--ws.addr="0.0.0.0" \
|
||||
--ws.origins="*" \
|
||||
--ws.api="${CERC_GETH_WS_APIS:-eth,web3,net,admin,personal,debug}" \
|
||||
--state.scheme hash \
|
||||
--gcmode archive \
|
||||
--syncmode=full \
|
||||
--metrics \
|
||||
--metrics.addr="0.0.0.0" \
|
||||
--verbosity=${CERC_GETH_VERBOSITY} \
|
||||
${OTHER_OPTS} \
|
||||
&
|
||||
|
||||
geth_pid=$!
|
||||
wait $geth_pid
|
56
stack-orchestrator/stacks/eth/README.md
Normal file
56
stack-orchestrator/stacks/eth/README.md
Normal file
@ -0,0 +1,56 @@
|
||||
# eth
|
||||
|
||||
## Setup
|
||||
|
||||
* Clone the stack repo:
|
||||
|
||||
```bash
|
||||
laconic-so fetch-stack git.vdb.to/cerc-io/eth-stack
|
||||
```
|
||||
|
||||
## Create a deployment
|
||||
|
||||
* First, 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:
|
||||
|
||||
```bash
|
||||
laconic-so --stack ~/cerc/eth-stack/stack-orchestrator/stacks/eth deploy create --spec-file eth-spec.yml --deployment-dir eth-deployment
|
||||
```
|
||||
|
||||
* Inside the `eth-deployment` deployment directory, open `config.env` file and set following env variables:
|
||||
|
||||
```bash
|
||||
# Optional
|
||||
# Allow unprotected txs
|
||||
CERC_ALLOW_UNPROTECTED_TXS=true
|
||||
```
|
||||
|
||||
## Start
|
||||
|
||||
* Start the deployment:
|
||||
|
||||
```bash
|
||||
laconic-so deployment --dir eth-deployment start
|
||||
```
|
||||
|
||||
## Clean up
|
||||
|
||||
* To stop all services running in the background, while preserving chain data:
|
||||
|
||||
```bash
|
||||
laconic-so deployment --dir eth-deployment stop
|
||||
```
|
||||
|
||||
* To stop all services and also delete chain data:
|
||||
|
||||
```bash
|
||||
laconic-so deployment --dir eth-deployment stop --delete-volumes
|
||||
|
||||
# Remove the deployment dir
|
||||
sudo rm -rf eth-deployment
|
||||
```
|
7
stack-orchestrator/stacks/eth/stack.yml
Normal file
7
stack-orchestrator/stacks/eth/stack.yml
Normal file
@ -0,0 +1,7 @@
|
||||
version: "1.0"
|
||||
name: eth
|
||||
description: "ETH stack"
|
||||
repos:
|
||||
containers:
|
||||
pods:
|
||||
- eth
|
Loading…
Reference in New Issue
Block a user