7

I am currently running a private ethereum chain with 2 nodes. My coinbase address on the main node has plenty of ether so I went to make a transaction but got the error "Gas Limit exceeded". I noticed that the gas limit was set to 5000 which is too low to make a transaction so I went to the customised genesis.json file and increased the limit to "0xC350" or 50000. Despite this the limit only moved to 5003. I have no idea why it does this and I have replaced the figure with other bigger numbers yet it only ever manages to get to 5003 instead of the default 5000. Any help would be much appreciated.

Here is my Genesis.json file:

{
"nonce": "0x0000000000000042",
"timestamp": "0x0",
"parentHash":      "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x0",
"gasLimit": "0xC350",
"difficulty": "0x400",
"mixhash":"0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333",
"alloc":
{ 
"0xcf117e46aa225864ed1d0dd7e99b8b006abe3410":
{ "balance": "10000000000000000000000000" } 
}

}

I am using Geth.

q9f
  • 32,913
  • 47
  • 156
  • 395
James
  • 341
  • 2
  • 12

1 Answers1

4

Don't change the genesis file, as it changes the dynamics of the blockchain. Geth has a --targetgaslimit flag that will cause the miner to converge towards a specific number opposed to the hard coded value.

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.

Make sure that you not only set --targetgaslimit but also to start mining --mine your private network. This will slowly move the block gas limit towards the target gas limit specified and you will see how the gas limit increases each block.

Also note, the target gas limit flag was introduced in geth 1.4.x, so make sure you have a very recent client.

See also this excellent answer on Ethereum Stack Exchange.

q9f
  • 32,913
  • 47
  • 156
  • 395
  • Are you aware that I am running a private chain and not the main net ethereum blockchain? Does this still apply to private local chains? Thanks – James Jun 29 '16 at 06:50
  • Yes, set --targetgaslimit to 500000 and start mining your private network and you will see how the gas limit increases each block. – q9f Jun 29 '16 at 06:51
  • Still won't change for some reason... – James Jun 29 '16 at 07:30
  • Which geth version? Are you mining? – q9f Jun 29 '16 at 07:34
  • 1.5.0. I even erased the blockchain, started over and mined but the limit is still 5000. Cheers – James Jun 30 '16 at 05:14
  • Hey @James have you solved this problem? I'm in exact same situation – KwahuNashoba Oct 02 '18 at 19:47
  • I deleted all and reconfigured everything again and it worked. Thing is that my gasLimit was 5003 (regardless of starting node with --targetgaslimit) and I guess it is because of dynamic gas limit calculation the nodes use so they decreased it because of network inactivity – KwahuNashoba Oct 02 '18 at 21:52