0

I am trying to add a peer Geth node on the same machine using the link https://github.com/ethereum/go-ethereum/wiki/Setting-up-private-network-or-local-cluster However, getting chainId which is wrong.

I have the following folder structure:

  1. Blockchain

    • datadirone
    • datadirtwo
    • logs
    • myGenesis.json

myGenesis.json has following code:

{
  "config": {
  "chainId": 192,
  "homesteadBlock": 0,
  "eip155Block": 0,
  "eip158Block": 0,
  "byzantiumBlock": 0
},
"difficulty": "400",
"gasLimit": "2000000",
"alloc": {
    "<account>":{
         "balance":"1000"
 }
}}

I created my first node using command:

geth --datadir="./datadirone" -verbosity 6 --ipcdisable --port 30301 --rpcport 8101 console 2>> ./logs/01.log

In the response , I could see proper chainId as 192.

However, when I create the second geth node using command:

geth --datadir="./datadirtwo" -verbosity 6 --ipcdisable --port 30302 --rpcport 8102 console 2>> ./logs/02.log

It starts but with wrong chainid as 1.

What am I missing ?

2
  • how did you get chainid of the second node? – sp4c3 Jan 31 '19 at 10:37
  • After the node starts, have diverted all logs to a file and I see this line there, which shows the chainId Persisted trie from memory database nodes=12356 size=1.88mB time=84.315382ms gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B INFO [01-31|15:27:45.550] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash}" – Twinkle Shine Feb 1 '19 at 3:33
2

Did you run geth --datadir="$DATADIR_PATH" init genesis.json on both nodes?
And also try to put --networkid 192 on the start command

1
  • It solved my problem. Thanks @waytosay 1. I had not run init genesis.json. So, first ran it. 2. Then added networkId . I got the same chainId. – Twinkle Shine Feb 1 '19 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.