Skip to content

Commit

Permalink
docs(protocol): add comment for EIP-1559 (#16389)
Browse files Browse the repository at this point in the history
Co-authored-by: Brecht Devos <[email protected]>
  • Loading branch information
dantaik and Brechtpd authored Mar 11, 2024
1 parent d9dc4b6 commit 713bef3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/protocol/contracts/L2/Lib1559Math.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import "../thirdparty/solmate/LibFixedPointMath.sol";

/// @title Lib1559Math
/// @notice Implements e^(x) based bonding curve for EIP-1559
/// @dev See https://ethresear.ch/t/make-eip-1559-more-like-an-amm-curve/9082
/// @dev See https://ethresear.ch/t/make-eip-1559-more-like-an-amm-curve/9082 but some minor
/// difference as stated in docs/eip1559_on_l2.md.
/// @custom:security-contact [email protected]
library Lib1559Math {
error EIP1559_INVALID_PARAMS();
Expand Down
6 changes: 6 additions & 0 deletions packages/protocol/docs/eip1559_on_l2.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ It turns out the initial value of gasExcess doesn't really matter for the above
## Adjust the slope

To adjust the slope of the curve to satisfy $R == basefee(2T)/basefee(T)$, we simply need to choose $M$ and $b_0$. $b_0$ is simply to decide -- if we believe the cost of a L2 transaction is $1/n$ of the same L1 transaction, we simply use the current L1 base fee divided by $n$. Then we can simply tune $M$ to make sure $R == basefee(2T)/basefee(T)$ holds. This is very simply manually a try-and-adjust approach as shown in `Lib1559Math.t.sol`. The TaikoL1 contract will check if $R == basefee(2T)/basefee(T)$ holds but will not calculate $M$ for us.

## Implementation Difference

Our implementation computes the basefee prior to applying the gas used by the current block (indicated by the blue line in the image below), in contrast to Vitalik's concept, which calculates the average basefee by also taking into account the gas consumption of the current block (represented by the red line).

![Merkle Proof](./images/1559.png)
Binary file added packages/protocol/docs/images/1559.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 713bef3

Please sign in to comment.