-
Notifications
You must be signed in to change notification settings - Fork 126
fix(l2): Fix EIP-4844 blob fee bump to use percentage scale #5415
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
base: main
Are you sure you want to change the base?
fix(l2): Fix EIP-4844 blob fee bump to use percentage scale #5415
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a critical bug in the EIP-4844 blob fee bump calculation that was causing blob transaction fees to decrease instead of increase during retries. The fix aligns the blob fee bump formula with the existing EIP-1559 fee bump strategy.
- Corrects the
max_fee_per_blob_gasbump formula to multiply by(100 + bump_percentage)/100instead of the incorrect division-based calculation - Ensures consistency across all fee bump operations (EIP-1559 and EIP-4844)
- Prevents underpriced blob transaction retries that would violate replacement rules
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if let Some(max_fee_per_blob_gas) = &mut tx.max_fee_per_blob_gas { | ||
| let factor = 1 + (bump_percentage / 100) * 10; | ||
| let factor = 100 + bump_percentage; | ||
| *max_fee_per_blob_gas = max_fee_per_blob_gas | ||
| .saturating_mul(U256::from(factor)) | ||
| .div(10); | ||
| .div(100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep the same semantics without the integer truncation issue what you actually need is:
| if let Some(max_fee_per_blob_gas) = &mut tx.max_fee_per_blob_gas { | |
| let factor = 1 + (bump_percentage / 100) * 10; | |
| let factor = 100 + bump_percentage; | |
| *max_fee_per_blob_gas = max_fee_per_blob_gas | |
| .saturating_mul(U256::from(factor)) | |
| .div(10); | |
| .div(100); | |
| if let Some(max_fee_per_blob_gas) = &mut tx.max_fee_per_blob_gas { | |
| let factor = 100 + bump_percentage * 10; | |
| *max_fee_per_blob_gas = max_fee_per_blob_gas | |
| .saturating_mul(U256::from(factor)) | |
| .div(1000); |
I don't know why the magic multiply and divide by 10 was there, but if there was a reason you'll want to keep it.
Motivation
The bump formula max_fee_per_blob_gas in crates/l2/sdk/src/sdk.rs::bump_gas_generic_tx() is incorrect and decreases the value instead of increasing it.
Description
Adjust the bump logic for EIP-4844 max_fee_per_blob_gas in bump_gas_generic_tx() to increase by (100 + bump_percentage)/100, mirroring the existing EIP-1559 fee bump strategy. The previous implementation used a factor with integer division and an extra division by 10, which effectively reduced the blob fee (e.g., with bump_percentage=30 it divided by 10) and conflicted with replacement rules and inclusion probabilities for blob transactions. This change aligns behavior with how max_fee_per_gas and max_priority_fee_per_gas are bumped, respects client-side clamping via maximum_allowed_max_fee_per_blob_gas, and prevents underpriced retries for blob transactions.