Run an RPC node with Docker
https://energyweb.atlassian.net/browse/DOI-1443
Work in progress
This document describes minimal setup to run an RPC node locally or on the server using Docker container run with docker-compose. This is solely for development purposes, it's not a production grade recommendation!
See OpenEthereum documentation for Docker:
https://openethereum.github.io/Docker
Prerequisites
docker
docker-compose
curl
Hardware Requirements
You need to meet OpenEthereum hardware requirements and have enough disk space to store database snapshots (which will grow in time).
https://docs.ethhub.io/using-ethereum/ethereum-clients/openethereum/
Multi-core CPU
4GB RAM
SSD drive and at least 150GB free space
A decent DSL connection is required
Set up
Verify that prerequisites are installed:
1
2
3
docker --version
docker-compose --version
curl --version
Create working directory
1
2
3
mkdir openethereum
cd openethereum
mkdir -p chain-data/chains
Create docker-compose.yaml file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
cat > docker-compose.yaml << 'EOF'
version: '3.8'
services:
openethereum:
image: openethereum/openethereum:v3.3.0-rc.11
restart: always
ports:
- 8545:8545
- 8546:8546
- 30303:30303
- 30303:30303/udp
command:
--jsonrpc-interface all --chain /config/chainspec.json
# Uncomment this if connecting local node to MetaMask
# --jsonrpc-cors chrome-extension://URL-OF-METAMASK
volumes:
- ./chain-data:/home/openethereum/.local/share/io.parity.ethereum/
- ./chainspec-volta.json:/config/chainspec.json:ro
# chainspec file should be changed if using EWC
# - ./chainspec-ewc.json:/config/chainspec.json:ro
EOF
Full specification for configuration options could be found there:
https://openethereum.github.io/Configuring-OpenEthereum
Download chainspec file
https://github.com/energywebfoundation/ewf-chainspec
Volta:
1
curl -L https://raw.githubusercontent.com/energywebfoundation/ewf-chainspec/master/Volta.json -o chainspec-volta.json
EWC:
1
curl -L https://raw.githubusercontent.com/energywebfoundation/ewf-chainspec/master/EnergyWebChain.json -o chainspec-ewc.json
Download database snapshot - this takes some time but will speed up synchronization process
Volta (depending on your internet connection ~1 hour download time for me):
1
curl -L -C - https://chain-download.energyweb.org/volta -o ./chain-data/chains/volta.tar
EWC (30 minutes download time for me):
1
curl -L -C - https://chain-download.energyweb.org/ewc -o ./chain-data/chains/energywebchain.tar
Unpack database snapshot
Volta:
1
sudo tar -xvf ./chain-data/chains/volta.tar -C ./chain-data/chains
EWC:
1
sudo tar -xvf ./chain-data/chains/energywebchain.tar -C ./chain-data/chains
Set permissions
1
sudo chmod -R 777 chain-data
Start containers
1
docker-compose up -d
Examine logs
1
docker-compose logs --tail 20 openethereum
Output should be similar to (sometimes it does not start immediately, wait some time):
1
2
3
4
5
6
7
8
9
10
11
openethereum_1 | 2021-11-03 15:26:22 UTC Starting OpenEthereum/v3.3.0-rc.11-stable/x86_64-linux-musl/rustc1.47.0
openethereum_1 | 2021-11-03 15:26:22 UTC Keys path /home/openethereum/.local/share/io.parity.ethereum/keys/Volta
openethereum_1 | 2021-11-03 15:26:22 UTC DB path /home/openethereum/.local/share/io.parity.ethereum/chains/Volta/db/d94a0a739a3e416a
openethereum_1 | 2021-11-03 15:26:22 UTC State DB configuration: fast
openethereum_1 | 2021-11-03 15:26:22 UTC Operating mode: active
openethereum_1 | 2021-11-03 15:26:22 UTC Not preparing block; cannot sign.
openethereum_1 | 2021-11-03 15:26:27 UTC Configured for Volta using AuthorityRound engine
openethereum_1 | 2021-11-03 15:26:32 UTC Error reading node table file: Error("EOF while parsing a value", line: 136, column: 13)
openethereum_1 | 2021-11-03 15:26:32 UTC Listening for new connections on 127.0.0.1:8546.
openethereum_1 | 2021-11-03 15:26:35 UTC Not preparing block; cannot sign.
openethereum_1 | 2021-11-03 15:26:37 UTC Public node URL: enode://fd35fd56944ed2150d019ab7f9c42e48c7dce5409af0c57b3f295fd083c04492c7b95d50bab89cc44e8650c3a5a877573c3e8b6a50b6c3553d07046330a86fe4@172.18.0.2:30303
You need to wait some time to connect to the network:
1
2021-11-03 15:33:42 UTC Syncing #14332274 0x2b0d...23c2 0.00 blk/s 0.0 tx/s 0.0 Mgas/s 0+ 0 Qed LI:#14332276 1/25 peers 72 KiB chain 0 bytes queue RPC: 0 conn, 0 req/s, 87 µs
Check db synchronization status:
https://openethereum.github.io/JSONRPC-eth-module
1
curl --data '{"method":"eth_syncing","params":[],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545
Output fill show current synchronization status:
1
{"jsonrpc":"2.0","result":{"currentBlock":"0xdab79f","highestBlock":"0xdac9d2","startingBlock":"0xdab172","warpChunksAmount":null,"warpChunksProcessed":null},"id":1}
It will take some time to get to the up-to-date state. When the synchronization is finished status would be:
1
{"jsonrpc":"2.0","result":false,"id":1}
Stop RPC node
Stop docker container:
1
docker-compose stop
Database is being saved in chain-data/chains
subdirectory. So the next time you launch RPC node with docker-compose up -d
it will start syncing from the latest state.