4

If I change the gaslimit in my genesis file does the network import the old blocks or only the new blocks? if it's yes how can I do it without modifying the genesis block ? I want to make the gaslimit higher without losting the old blocks

eth
  • 85,679
  • 53
  • 285
  • 406
sourh
  • 121
  • 4

2 Answers2

7

Don't change the genesis file, as it changes the dynamics of the blockchain. Geth 1.4 (develop branch) has a --targetgaslimit flag that will cause the miner to converge towards a specific number opposed to the hard coded value. 1.4 RC1 should be released this week if you don't want to use develop itself.

Péter Szilágyi
  • 10,436
  • 39
  • 42
  • Could you please explain why the dynamics of the blockchain changes with the gas limit? Is it because some previously valid transactions would become invalid with the gas change? Thx. – BokkyPooBah Apr 12 '16 at 15:56
  • 2
    Every block has a gas limit that's contained within the block itself. This limit can only change with a certain amount between blocks (prev limit/1024 to be precise). If the change is larger, the block is not accepted any more. – Péter Szilágyi Apr 13 '16 at 11:15
  • Out of curiosity, assuming we're starting a new private network disregarding the old blocks. Would you still recommend starting from the default gasLimit and why (as opposed to setting say Uint64Max)? – Peteris Jan 08 '20 at 12:43
5

Edit 13/04/2016: Péter Szilágyi provided a reason not to change the gas limit in the genesis file:

Every block has a gas limit that's contained within the block itself. This limit can only change with a certain amount between blocks (prev limit/1024 to be precise). If the change is larger, the block is not accepted any more.



I've just done some testing of your situation.

I get some strange results. Sometimes my blockchain is reset and mining starts again at block #1. Othertimes my blockchain is NOT reset and mining continues from where it was last at.

The is a geth command line parameter to import and export the blockchain data.

Export your current blockchain into a file using the export command:

geth {your other command line parameter options} export {filename}

Change your genesis file.

Import your exported blockchain back into the blockchain data directory using the import command:

geth {your other command line parameter options} import {filename}

If you want to be really sure that you don't reset your blockchain data, copy the whole data directory. In my case, when I start geth, I get the following information (I am using --datadir ~/Test/data1):

I0413 01:19:14.904877   23932 database.go:71] Alloted 16MB cache to /home/user/Test/data1/chaindata
I0413 01:19:14.914885   23932 database.go:71] Alloted 16MB cache to /home/user/Test/data1/dapp

Backup the whole /home/user/Test/data1 subdirectory by copying the whole structure into a backup area. Run your export and import operations. If this is not successful, restore your data subdirectory by copying back the whole structure from your backed up data.

BokkyPooBah
  • 40,274
  • 14
  • 123
  • 193