[Canyon Hard Fork] Change EIP 1559 Denominator with Canyon #98
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All codes referenced from
Description
For canyon, EIP 1559 denominator is updated from
50
to250
. Adding explicit timestamp parameter toCalcBaseFee
method. In some cases(for pending transactions, fee history)the base fee may not be accurate if the exact timestamp of the block is not known.Lets review why this change is needed. Referring EIP 1559 and current Linear EIP 1559 mechanics,
Let$T$ be the gas target, and $A$ be max base fee change denominator. Each block $B_{i}$ where $i$ is a block number has a base fee of $b_{i}$ and let $g_{i}$ be the total gas consumed in the block $B_{i}$ . Update rule for base fee:
In this PR, we are increasing the value of$A$ , the base fee change denominator. Therefore, fee update will be much more stable(not moving much). Users/Wallets will experience less failure of transactions because the fees got less volatile.
Testing
Unit tests added. In this PR, I will verify the values manually in this description. Here are the test cases:
params.InitialBaseFee == 1_000_000_000
T = parentGasTarget = parent.GasLimit / ElasticityMultiplier = 30_000_000 / 6 = 5_000_000
For {2,3,5,6}th sub task,
Before Canyon:
A = 50
1_000_000_000 * (1 + (1 / 50) * (5_000_000 - 5_000_000) / 5_000_000) == 1_000_000_000
1_000_000_000 * (1 + (1 / 50) * (4_000_000 - 5_000_000) / 5_000_000) == 996_000_000
Canyon:
A = 250
1_000_000_000 * (1 + (1 / 250) * (4_000_000 - 5_000_000) / 5_000_000) == 999_200_000
1_000_000_000 * (1 + (1 / 250) * (10_000_000 - 5_000_000) / 5_000_000) == 1_004_000_000
Misc