Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Blockchain by (12.7k points)

The following docker-compose.yml is used to start an Ethereum geth node, which needs to connect to a bootnode in order to access a private Ethereum network.

version: '2' 

    geth:

    image: ethereum/client-go:latest

    volumes:

        - ./node:/root/.ethereum

        - ./files/genesis.json:/root/genesis.json:ro

    ports:

        - "30303:30303"

        - "30303:30303/udp"

        - 8543:8545

    command: --rpc --rpcaddr 0.0.0.0 --networkid 13377331 --bootnodes="enode://692b8eda368ffc427fc1a047850557536a0ef0bfa3b66f998e03e8b83c3fd8f786e3c2b710a20e2e821a9eff34fc7b34ffa326a8a5fbcf3634b55b44596ada43@159.999.999.999:30303" --nodiscover

However, after running docker-compose up, we see that the chain configuration echoed is the default one, and not the config that the bootnode is using

Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: Engine: ethash}"

Question: Why is geth not connecting to the bootnode and not using the config that the bootnode has in its genesis.json?

docker-compose output:

geth_1  | WARN [07-15|00:48:33.310] Sanitizing cache to Go's GC limits       provided=1024 updated=666

geth_1  | INFO [07-15|00:48:33.310] Maximum peer count                       ETH=25 LES=0 total=25

geth_1  | INFO [07-15|00:48:33.317] Starting peer-to-peer node               instance=Geth/v1.8.13-unstable-2e0391ea/linux-amd64/go1.10.3

geth_1  | INFO [07-15|00:48:33.317] Allocated cache and file handles         database=/root/.ethereum/geth/chaindata cache=499 handles=1024

geth_1  | INFO [07-15|00:48:33.331] Writing default main-net genesis block 

geth_1  | INFO [07-15|00:48:33.632] Persisted trie from memory database      nodes=12356 size=1.88mB time=84.3549ms gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B

geth_1  | INFO [07-15|00:48:33.636] Initialised chain configuration          config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash}"

geth_1  | INFO [07-15|00:48:33.636] Disk storage enabled for ethash caches   dir=/root/.ethereum/geth/ethash count=3

geth_1  | INFO [07-15|00:48:33.636] Disk storage enabled for ethash DAGs     dir=/root/.ethash               count=2

geth_1  | INFO [07-15|00:48:33.636] Initialising Ethereum protocol           versions="[63 62]" network=1

geth_1  | INFO [07-15|00:48:33.637] Loaded most recent local header          number=0 hash=d4e567…cb8fa3 td=17179869184

geth_1  | INFO [07-15|00:48:33.637] Loaded most recent local full block      number=0 hash=d4e567…cb8fa3 td=17179869184

geth_1  | INFO [07-15|00:48:33.637] Loaded most recent local fast block      number=0 hash=d4e567…cb8fa3 td=17179869184

geth_1  | INFO [07-15|00:48:33.640] Regenerated local transaction journal    transactions=0 accounts=0

geth_1  | INFO [07-15|00:48:33.640] Starting P2P networking 

geth_1  | INFO [07-15|00:48:33.641] RLPx listener up                         self="enode://27175216e04387fb93e87a4069021b640fc6f87f985c86940e3297103a2b5e348bdecec4eea98af6ee2f106890fd28b49e1d983b6c5b8ce9ae1571c032bf2d5c@[::]:30303?discport=0"

geth_1  | INFO [07-15|00:48:33.644] IPC endpoint opened                      url=/root/.ethereum/geth.ipc

geth_1  | INFO [07-15|00:48:33.645] HTTP endpoint opened                     url=http://0.0.0.0:8545      cors= vhosts=localhost

genesis.json

{

    "config": {

    "chainId": 13377331,

    "homesteadBlock": 1,

    "eip150Block": 2,

    "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",

    "eip155Block": 3,

    "eip158Block": 3,

    "byzantiumBlock": 4,

    "clique": {

        "period": 15,

        "epoch": 30000

    }

    },

....

1 Answer

0 votes
by (29.5k points)

It seems that you are using default datadir instead of your private datadir initialized with genesis.json. As the result, geth started as a main network node by using default datadir

Initialize your geth datadir with genesis.json. For example:

geth --datadir path/to/custom/data/folder init genesis.json

Start your
geth by using the datadir and networkid. For example:

geth --datadir path/to/custom/data/folder --networkid 13377331

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...