[Ethereum] Setting Block Gas Limit in private blockchain

gas-limitgenesisparityprivate-blockchain

In a private blockchain with Parity, what is the correct way to set the Block Gas Limit? When I go to "Transfer" and then specify an address in the "recipient" field, a red bar pops up that says:

the transaction execution will exceed the block gas limit

I don't know why the block gas limit is not the default! I am using my own chain spec file, but I copied these values from https://github.com/paritytech/parity/blob/master/ethcore/res/ethereum/foundation.json:

"gasLimit": "0x1388",

"minGasLimit": "0x1388",

The limit that the error is talking about appears to be 5000 (0x1388) because I get the error until I manually lower the gas (from 21000 default in the field) to 4999. But why is the limit set to 5000? Those two parameters don't have anything to do with the block gas limit, do they?

(And anyway, when I do lower the gas limit to anything below 5000, I I get this problem: Parity genesis file – How to set "minimal cost of the transaction" a.k.a. "Gtransaction" value?)

Really I just don't understand what I did to alter the Block Gas Limit. It should default to 21000, right? How did I manage to alter that?

Best Answer

In private network you can increase block gas limit by using gasLimit parameter in genesis file.

"gasLimit": "0x8000000",

gasLimit in genesis file:

A scalar value equal to the current chain-wide limit of Gas expenditure per block. High in our case to avoid being limited by this threshold during tests. Note: this does not indicate that we should not pay attention to the Gas consumption of our Contracts.

You can read about other genesis params from What does each genesis.json parameter mean?

PS: I have not tried increasing block gas limit but I guess this should work. Although you can increase block gas limit but you should not (ideally). If this is for testing purpose then it's alright. But If your smart contract consumes gas more than block gas limit, this is a concern. You could try splitting contract.

Related Topic