[Ethereum] Gas limit exceeded on private chain

gas-limitgo-ethereumprivate-blockchain

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.

Best Answer

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.

Related Topic