Skip to content

feat: add bpos #40

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions crates/hardforks/src/hardfork/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ hardfork!(
Prague,
/// Osaka: <https://eips.ethereum.org/EIPS/eip-7607>
Osaka,
// BPOs: <https://eips.ethereum.org/EIPS/eip-7892>
/// BPO 1
Bpo1,
/// BPO 2
Bpo2,
/// BPO 3
Bpo3,
/// BPO 4
Bpo4,
/// BPO 5
Bpo5,
Comment on lines +52 to +62
Copy link
Member

Choose a reason for hiding this comment

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

these aren't useful as dedicated variants because they just are timestamp values that influence active blobparams

adding them as fork enums will cause a lot of friction and imo we can solve this differently because we only need these for forkid, imo we should track them as separate entries in the ChainHardforks struct and add a new classification for them,

struct Bpo {
  name, timestamp
}

that we then can use when we compute the forkid

}
);

Expand Down Expand Up @@ -579,6 +590,31 @@ pub trait EthereumHardforks {
fn is_paris_active_at_block(&self, block_number: u64) -> bool {
self.is_ethereum_fork_active_at_block(EthereumHardfork::Paris, block_number)
}

/// Convenience method to check if [`EthereumHardfork::Bpo1`] is active at a given timestamp.
fn is_bpo1_active_at_timestamp(&self, timestamp: u64) -> bool {
self.is_ethereum_fork_active_at_timestamp(EthereumHardfork::Bpo1, timestamp)
}

/// Convenience method to check if [`EthereumHardfork::Bpo2`] is active at a given timestamp.
fn is_bpo2_active_at_timestamp(&self, timestamp: u64) -> bool {
self.is_ethereum_fork_active_at_timestamp(EthereumHardfork::Bpo2, timestamp)
}

/// Convenience method to check if [`EthereumHardfork::Bpo3`] is active at a given timestamp.
fn is_bpo3_active_at_timestamp(&self, timestamp: u64) -> bool {
self.is_ethereum_fork_active_at_timestamp(EthereumHardfork::Bpo3, timestamp)
}

/// Convenience method to check if [`EthereumHardfork::Bpo4`] is active at a given timestamp.
fn is_bpo4_active_at_timestamp(&self, timestamp: u64) -> bool {
self.is_ethereum_fork_active_at_timestamp(EthereumHardfork::Bpo4, timestamp)
}

/// Convenience method to check if [`EthereumHardfork::Bpo5`] is active at a given timestamp.
fn is_bpo5_active_at_timestamp(&self, timestamp: u64) -> bool {
self.is_ethereum_fork_active_at_timestamp(EthereumHardfork::Bpo5, timestamp)
}
}

/// A type allowing to configure activation [`ForkCondition`]s for a given list of
Expand Down Expand Up @@ -654,6 +690,11 @@ mod tests {
"ShAnGhAI",
"CaNcUn",
"PrAguE",
"Bpo1",
"BPO2",
"bpo3",
"bPo4",
"bpO5",
];
let expected_hardforks = [
EthereumHardfork::Frontier,
Expand All @@ -674,6 +715,11 @@ mod tests {
EthereumHardfork::Shanghai,
EthereumHardfork::Cancun,
EthereumHardfork::Prague,
EthereumHardfork::Bpo1,
EthereumHardfork::Bpo2,
EthereumHardfork::Bpo3,
EthereumHardfork::Bpo4,
EthereumHardfork::Bpo5,
];

let hardforks: Vec<EthereumHardfork> =
Expand Down
2 changes: 1 addition & 1 deletion crates/op-hardforks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ impl Index<EthereumHardfork> for OpChainHardforks {
Shanghai => &self[Canyon],
Cancun => &self[Ecotone],
Prague => &self[Isthmus],
Osaka => panic!("index out of bounds"),
Osaka | Bpo1 | Bpo2 | Bpo3 | Bpo4 | Bpo5 => panic!("index out of bounds"),
}
}
}
Expand Down
Loading