2

I want to change the network_id of my private ethereum network setup with geth. It seems like I have to change it in genesis.json file and also have that id when I start geth.

But, to apply the change made in genesis.json I have to again do geth init and this will now start behaving as fresh network and I will loose my blocks. So is there any other way to change network_id?

1

this will now start behaving as fresh network and I will loose my blocks

If you have changed the chain ID in the genesis.json file, then the blocks from your old network won't be valid on the new network, so you will need to start again.

EIP-155 - which added replay attack protection - has this to say:

If block.number >= FORK_BLKNUM and CHAIN_ID is available, then when computing the hash of a transaction for the purposes of signing, instead of hashing only six rlp encoded elements (nonce, gasprice, startgas, to, value, data), you SHOULD hash nine rlp encoded elements (nonce, gasprice, startgas, to, value, data, chainid, 0, 0)

So any transactions on your original network will have been signed in the context of the original network's chain ID1. They will be invalid on your new chain, which has a different chain ID.

1 There's an important distinction between network ID and chain ID. See What is a chainID in Ethereum, how is it different than NetworkID, and how is it used?.

1
  • Thanks a lot for clarifying things. – NinjaMAN May 31 at 5:45

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.