-
Notifications
You must be signed in to change notification settings - Fork 236
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: EIP-7742 #1600
Open
klkvr
wants to merge
5
commits into
main
Choose a base branch
from
klkvr/eip7742
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+288
−24
Open
feat: EIP-7742 #1600
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//! Contains constants and utility functions for [EIP-7742](https://eips.ethereum.org/EIPS/eip-7742) | ||
|
||
use crate::eip4844::{fake_exponential, BLOB_TX_MIN_BLOB_GASPRICE, DATA_GAS_PER_BLOB}; | ||
|
||
/// Controls the update rate of the blob base fee based on `target_blobs_per_block`. | ||
pub const BLOB_BASE_FEE_UPDATE_FRACTION_PER_TARGET_BLOB: u64 = 1112825; | ||
|
||
/// Calculates the `excess_blob_gas` from the parent header's `blob_gas_used`, `excess_blob_gas` and | ||
/// `target_blobs_per_block`. | ||
/// | ||
/// Similar to [crate::eip4844::calc_excess_blob_gas], but derives the target blob gas from | ||
/// `parent_target_blobs_per_block`. | ||
#[inline] | ||
pub const fn calc_excess_blob_gas( | ||
parent_excess_blob_gas: u64, | ||
parent_blob_gas_used: u64, | ||
parent_target_blobs_per_block: u64, | ||
) -> u64 { | ||
(parent_excess_blob_gas + parent_blob_gas_used) | ||
.saturating_sub(DATA_GAS_PER_BLOB * parent_target_blobs_per_block) | ||
} | ||
|
||
/// Calculates the blob gas price from the header's excess blob gas field. | ||
/// | ||
/// Similar to [crate::eip4844::calc_blob_gasprice], but adjusts the update rate based on | ||
/// `target_blobs_per_block`. | ||
#[inline] | ||
pub fn calc_blob_gasprice(excess_blob_gas: u64, target_blobs_per_block: u64) -> u128 { | ||
let update_fraction = BLOB_BASE_FEE_UPDATE_FRACTION_PER_TARGET_BLOB * target_blobs_per_block; | ||
fake_exponential(BLOB_TX_MIN_BLOB_GASPRICE, excess_blob_gas as u128, update_fraction as u128) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,5 @@ pub mod eip7251; | |
pub mod eip7685; | ||
|
||
pub mod eip7702; | ||
|
||
pub mod eip7742; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
I'm a bit concerned that this will be easy to misuse if the functions have the same name, but since this takes an additional param this is okay imo