besu
besu copied to clipboard
Allow private networks already using London fee market to use free gas
If you started (or hard-forked) a private network with the londonBlock fork without configuring the baseFeePerGas to zero at the time, then it's not possible to subsequently zero the base fee, meaning that you can't configure a free gas network.
Configuring the baseFeePerGas to zero is not yet documented and was only recently supported by this fix which works if you haven't yet upgraded to London (or are starting a new network).
~Note: related to https://github.com/hyperledger/besu/issues/4053~
Suggested solution (following a spike)
Introduce a zeroBaseFee config flag which wires up a ZeroBaseFeeMarket, an extension of LondonFeeMarket which returns 0 when computing the baseFee.
Genesis examples
To start a new free gas network on the latest fork:
{
"config": {
"grayGlacier": 0,
"zeroBaseFee": true,
...
}
Note, this replaces the only way to currently do this (although this way will still work for new networks):
{
"config": {
"grayGlacier": 0,
...
},
"baseFeePerGas": "0x0"
}
To upgrade an existing network to london (or beyond):
{
"config": {
"berlinBlock": 0,
"londonBlock": 999,
"zeroBaseFee": true,
...
}
To convert an existing london network to free gas:
{
"config": {
"londonBlock": 0,
"zeroBaseFee": true, # added at some block > 0
...
}
This would be a one-way operation: once you've set zeroBaseFee, you can't reset the base fee back to non-zero. There are complications around the block validation rules that lead to this simplification.
zeroBaseFee is preferred over baseFeePerGas because it is a config value rather than a genesis value. This means it can be set at any time by the node operator - even if london is already activated - thus allowing conversion of a non-zero base fee network into a zero base fee (free gas) network.
Using the transitions mechanism was evaluated and ruled out due to requiring significant effort without a clear advantage: we don't know if any users will ever need to flexibly set a non-zero base fee in the future.
This solution doesn't preclude adding a more flexible transition in the future.
Not using transitions does mean converting an existing network to free gas requires a synchronised restart, however I would expect this to be an exceptional scenario.
You still need to use min-gas-price=0 in conjunction with this for a free gas network.
Tasks
- [x] Add
zeroBaseFeeconfig for all consensus types - [x] Introduce ZeroBaseFeeMarket overriding computeBaseFee with 0
- [x] Wire ZeroBaseFeeMarket into MainnetProtocolSpecs.londonDefinition when
zeroBaseFeeset - [x] Fix BaseFeeMarketBlockHeaderGasPriceValidationRule to allow syncing to work
- [x] Test block creation, syncing, local/remote frontier/eip1559 transactions, all consensus mechanisms
- [x] Test BASEFEE opcode works
- [x] Test what happens to miner rewards (should still be paid tip, just no base fee is burned)
- [ ] Update Free Gas Network documentation
Ideally we would be able to configure a gas price at a block height (via a config transition)
I really like the idea of using a transition for this. It could add quite a big overhead because transitions are only supported for BFT, not Clique or ethash.
I think the current schema could use a bit of a tidy up 😄 something like
transitions : [{
block: 134,
changeSetting: something
}]
It'd be nice to get a place to configure all things bespoke (ie not testnet/mainnet) feels like we have a bunch of things in different places that could affect consensus, especially on private/internal test networks. min-gas-price and contractSizeLimit jump to mind, both can cause forks if configured differently. Currently the only way to guarantee that doesn't happen is to stop your network, change the setting then restart.