Skip to content
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

feat(protocol): reenable time as basefee calculation input #17867

Merged
merged 7 commits into from
Aug 6, 2024

Conversation

dantaik
Copy link
Contributor

@dantaik dantaik commented Jul 31, 2024

BEGIN_COMMIT_OVERRIDE
feat(protocol): revert removing time as input for L2 base fee calculation
feat(protocol): adjust gas excess once the gas target has changed
END_COMMIT_OVERRIDE


Here's an improved version of the PR description:

Background

Protocol changes for preconfirmation allow block proposers to select L2 block timestamps within a certain range. If base fee calculation uses a block's time (time since its parent block) as an input, it becomes susceptible to manipulation by the proposer. While the full impact of such manipulation is yet to be determined, it's prudent to address this issue.

We are considering two primary options:

Option 1: Remove block time from base fee calculation

This approach is currently implemented in the main branch prior to this PR. However, as noted by Brecht, this may introduce other issues. If removing the time input is acceptable, it would be logical to adopt the Ethereum client's default implementation for the EIP-1559 calculations. This is the goal of PR #17857.

Option 2: Retain block time as an input and accept potential base fee manipulation

This PR reintroduces block time as an input but does not implement measures to prevent manipulation.

An implementation detail

When two consecutive blocks have identical block times, no additional gas is issued for the second block, resulting in a slightly higher base fee for the second block compared to the first. This means that splitting a single block into two smaller ones (containing the same transactions) has different base fee implications. We could modify the code to ensure that the base fee remains consistent across multiple consecutive blocks with identical timestamps. However, I'm not convinced that this adjustment is necessary or beneficial.


I am currently undecided between these two options. Hope to learn more from the rest of the team...

@dantaik dantaik marked this pull request as ready for review July 31, 2024 04:29
Copy link

openzeppelin-code bot commented Jul 31, 2024

feat(protocol): reenable time as basefee calculation input

Generated at commit: 76444bf8a5a6906ecff3ecd9e740b0a262ebde24

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
2
2
0
8
42
54
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

dantaik and others added 2 commits August 6, 2024 11:31
…ustment in TaikoL2 (#17871)

Co-authored-by: dantaik <dantaik@users.noreply.github.com>
Co-authored-by: Brecht Devos <Brechtp.Devos@gmail.com>
@dantaik dantaik enabled auto-merge August 6, 2024 03:32
@dantaik
Copy link
Contributor Author

dantaik commented Aug 6, 2024

@Brechtpd @adaki2004 this PR is ready for another look.

Copy link
Contributor

@adaki2004 adaki2004 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this one.
Realistically in production it is more hard to manipulate this nr.2 one (even with preconfs) - tho possible to but the gain is less significant as you said. Perfect solution (sum up all the gas) would require extra work which does not worth the effort, given that the basefee shall be a small enough.

(In case of huge influx of traffic and demand, if a single preconfer is present, he/she can game this tho, but still not up to a level which is gameable now (main branch) imo.)

@dantaik dantaik added this pull request to the merge queue Aug 6, 2024
Merged via the queue into main with commit a1e217e Aug 6, 2024
5 checks passed
@dantaik dantaik deleted the bring_basefee_time_input_back branch August 6, 2024 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants