4

I am able to hard fork my private chain into first Constantinople and than to Istanbul, please see the answer for it.

My approach is:

  • I have updated geth to its highest version
  • I have kept the go-ethereum/params/config.go file as it is
  • I have updated the genesis.json file by adding "constantinopleBlock": 2862930, "petersburgBlock": 2862930, and "istanbulBlock": 3831182. Block numbers are selected based on my chain.
  • I have removed the chain. sudo rm -rf chaindata lightchaindata
  • Initialized my chain by started it with geth init
  • Finally, I have started my chain, which started to sync from 0th block

I have tried this without removing the chain but it did not work. So from scratch since genesis block should be updated, I am syncing the chain from 0th, block which is very uniefficient.

[Q] I was wondering is it possible to hard fork a private network without resyncing chain from the 0th block? This approach is inefficient to sync few GB all over again for all the nodes on the network.

  • Maybe you can check how other hard forks happened (like the eth dao one ?) But, I am sure you know that, a blockchain is not supposed to have fork. – Florian Castelain Jan 2 at 9:34
  • I am not sure but as I understand, by doing hard fork it only sets the new EVM version from the specified block number. In other words, the pre-Istanbul network will be terminated. If a network participant fails to meet the Istanbul requirements, then his/her computer will be unable to validate transactions and will therefore lose the ability to take part in Ethereum’s operations after the upgrade. Its not like Ethereum dao where fork occurs. – alper Jan 2 at 10:25
  • I believe you don't have to delete anything or run geth init. Just update the genesis file with the milestones, restart your node and that's it. If the other nodes do the same your network will keep going. I haven't tested it so I'm not proposing it as an answer but I think it's this simple. – David Ammouial Jan 3 at 1:56
  • I was thinking the same and first tried the way you said, but it didn't work, please see the comments on the answer link I shared. Basically geth starts as: Istanbul <Nil> that's the way I was able to check it. – alper Jan 3 at 7:28
2

Anything in config section of genesis is applied directly onto the geth regardless of the blocks it may have already in its chain. So, if the chain is up to lets say block 1000, you can enable new hard forks such as constantinople or istanbul by setting your constantinopleBlock to 1100 and then istanbulBlock to 1200 and it will work.

That said, some caveats:

  • hard forks fail forward only, so if you set constantinople to block 1100, then reached that block and then set it in genesis to be 900, the change will be rejected (or rather, when you run geth config, it will not be applied)
  • geth node has to be brought down, geth init with new genesis needs to be allied, and the node will need to go back up for change to take effect
  • all other nodes in your private chain must apply the same genesis before the set blocks are reached or these nodes will fail out of the chain
| improve this answer | |
  • I have tried that as well where I have set let's say istanbulBlock to 100 ahead block number and still after 100 blocks passed, when I restarted geth, still Istanbull shows up as Nil. I have first made this change on my signer nodes, that increments the blocks. – alper Jan 4 at 10:29
  • Is this just istanbul? or any block trigger? what version of geth? – fixanoid Jan 5 at 2:10
  • geth is v1.9.9-stable, I was having same issue for Constantinople as well – alper Jan 5 at 10:56
  • 1
    Hi alper, this may be a good issue to bring up on go-ethereum github as the steps you've followed are correct. – fixanoid Jan 7 at 15:26
  • On your first example, assume I set hardFork, Istanbul, to 1100 when the chain is on block 1000. geth will start as Istanbul <Nil>. Afterwards when chain is on 1200, when I restart the chan, geth still shows up as Istanbul <Nil> – alper Jan 7 at 15:58

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.