-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove gas_target from block structure #3552
Conversation
I also started on something similar. This is what I had so far: diff --git a/EIPS/eip-1559.md b/EIPS/eip-1559.md
index e8559ef..34a1c53 100644
--- a/EIPS/eip-1559.md
+++ b/EIPS/eip-1559.md
@@ -16,7 +16,7 @@ A transaction pricing mechanism that includes fixed-per-block network fee that i
## Abstract
We introduce a new [EIP-2718](./eip-2718.md) transaction type, with the format `0x02 || rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, access_list, signatureYParity, signatureR, signatureS])`.
-There is a base fee per gas in protocol, which can move up or down each block according to a formula which is a function of gas used in parent block and gas target (formerly known as gas limit) of parent block.
+There is a base fee per gas in protocol, which can move up or down each block according to a formula which is a function of gas used in parent block and gas target (half the gas limit) of parent block.
The algorithm results in the base fee per gas increasing when blocks are above the gas target, and decreasing when blocks are below the gas target.
The base fee per gas is burned.
Transactions specify the maximum fee per gas they are willing to give to miners to incentivize them to include their transaction (aka: priority fee).
@@ -133,7 +133,7 @@ class Block:
logs_bloom: int = 0
difficulty: int = 0
number: int = 0
- gas_target: int = 0 # note the name change to gas_target from gas_limit
+ gas_limit: int = 0
gas_used: int = 0
timestamp: int = 0
extra_data: bytes = bytes()
@@ -157,15 +157,16 @@ class World(ABC):
def validate_block(self, block: Block) -> None:
parent_base_fee_per_gas = self.parent(block).base_fee_per_gas
parent_gas_used = self.parent(block).gas_used
- parent_gas_target = self.parent(block).gas_target
+ parent_gas_target = self.parent(block).gas_limit // ELASTICITY_MULTIPLIER
transactions = self.transactions(block)
+ gas_target = block.gas_limit // ELASTICITY_MULTIPLIER
# check if the block used too much gas
- assert block.gas_used <= block.gas_target * ELASTICITY_MULTIPLIER, 'invalid block: too much gas used'
+ assert block.gas_used <= block.gas_limit, 'invalid block: too much gas used'
# check if the block changed the gas target too much
- assert block.gas_target <= parent_gas_target + parent_gas_target // 1024, 'invalid block: gas target increased too much'
- assert block.gas_target >= parent_gas_target - parent_gas_target // 1024, 'invalid block: gas target decreased too much'
+ assert gas_target <= parent_gas_target + parent_gas_target // 1024, 'invalid block: gas target increased too much'
+ assert gas_target >= parent_gas_target - parent_gas_target // 1024, 'invalid block: gas target decreased too much'
# check if the base fee is correct
if parent_gas_used == parent_gas_target:
|
It looks like the changes are fairly small. One thing I just noticed, though, is that the reference implementation doesn't mention how to act on the switch-over between non-1559 and 1559, where the |
This is a good point. I've updated to avoid this. |
4b132db
to
de139a7
Compare
de139a7
to
93d047c
Compare
Would this reduce capacity by 2x once the EIP turns on and before miners get around to voting the gaslimit up to 25m? Is that an issue? |
Before merging this into the spec, one open question would be how to do the miner side gas control of things - if in any way - so they don't start pushing the limit down once the fork passes. Currently Geth has two flags to control the miner's gas behavior:
Essentially On mainnet, Geth miners I'd assume are running with Come the 1559 fork, with this gasLimit proposal we'll see a jump from 15M gas to 30M gas on the fork block. This will make all Geth miners realize they're over their allowance and start voting the limit back down to 15M (or the semantic |
* remove gas_target from block structure * missed block.gas_target * avoid undue gas_target halving on 1559 fork block * fix spelling error
Per @karalabe's document and proposal, this PR will remove the notion of
gasTarget
in the block structure. It will revert to the current status quo ofgasLimit
. ThegasTarget
will continue to be an integral part of EIP-1559, but it will be computed each block with the formulagasLimit // ELASTICITY_MULTIPLIER
. On the fork block, the gas target will be interpreted as the parent block's gas limit to avoid unduly halving the gas target.