-
Notifications
You must be signed in to change notification settings - Fork 605
feat: EIP-7840 #1828
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
Merged
Merged
feat: EIP-7840 #1828
Changes from all commits
Commits
Show all changes
7 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 hidden or 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 hidden or 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 hidden or 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,68 @@ | ||
| //! Contains constants and utility functions for [EIP-7840](https://github.com/ethereum/EIPs/tree/master/EIPS/eip-7840.md) | ||
|
|
||
| use crate::{eip4844, eip7691}; | ||
|
|
||
| /// A single item of `blobSchedule` defined in EIP-7840. | ||
| #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] | ||
| pub struct BlobScheduleItem { | ||
| /// Target blob count for the block. | ||
| #[cfg_attr(feature = "serde", serde(rename = "target"))] | ||
| pub target_blob_count: u64, | ||
| /// Max blob count for the block. | ||
| #[cfg_attr(feature = "serde", serde(rename = "max"))] | ||
| pub max_blob_count: u64, | ||
| } | ||
|
|
||
| /// Configuration for the blob-related calculations. | ||
| #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| pub struct BlobParams { | ||
| /// Target blob count for the block. | ||
| pub target_blob_count: u64, | ||
| /// Max blob count for the block. | ||
| pub max_blob_count: u64, | ||
| /// Update fraction for excess blob gas calculation. | ||
| pub update_fraction: u128, | ||
| /// Minimum gas price for a data blob. | ||
| pub min_blob_fee: u128, | ||
| } | ||
|
|
||
| impl BlobParams { | ||
| /// Returns [`BlobParams`] configuration activated with Cancun hardfork. | ||
| pub const fn cancun() -> Self { | ||
| Self { | ||
| target_blob_count: eip4844::TARGET_BLOBS_PER_BLOCK, | ||
| max_blob_count: eip4844::MAX_BLOBS_PER_BLOCK as u64, | ||
| update_fraction: eip4844::BLOB_GASPRICE_UPDATE_FRACTION, | ||
| min_blob_fee: eip4844::BLOB_TX_MIN_BLOB_GASPRICE, | ||
| } | ||
| } | ||
|
|
||
| /// Returns [`BlobParams`] configuration activated with Prague hardfork. | ||
| pub const fn prague() -> Self { | ||
| Self { | ||
| target_blob_count: eip7691::TARGET_BLOBS_PER_BLOCK_ELECTRA, | ||
| max_blob_count: eip7691::MAX_BLOBS_PER_BLOCK_ELECTRA, | ||
| update_fraction: eip7691::BLOB_GASPRICE_UPDATE_FRACTION_PECTRA, | ||
| min_blob_fee: eip4844::BLOB_TX_MIN_BLOB_GASPRICE, | ||
| } | ||
| } | ||
|
|
||
| /// Calculates the `excess_blob_gas` value for the next block based on the current block | ||
| /// `excess_blob_gas` and `blob_gas_used`. | ||
| #[inline] | ||
| pub const fn next_block_excess_blob_gas( | ||
| &self, | ||
| excess_blob_gas: u64, | ||
| blob_gas_used: u64, | ||
| ) -> u64 { | ||
| (excess_blob_gas + blob_gas_used) | ||
| .saturating_sub(eip4844::DATA_GAS_PER_BLOB * self.target_blob_count) | ||
| } | ||
|
|
||
| /// Calculates the blob fee for block based on its `excess_blob_gas`. | ||
| #[inline] | ||
| pub const fn calc_blob_fee(&self, excess_blob_gas: u64) -> u128 { | ||
| eip4844::fake_exponential(self.min_blob_fee, excess_blob_gas as u128, self.update_fraction) | ||
| } | ||
| } |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -45,3 +45,5 @@ pub mod eip7685; | |
| pub mod eip7691; | ||
|
|
||
| pub mod eip7702; | ||
|
|
||
| pub mod eip7840; | ||
This file contains hidden or 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 hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.