Skip to content
Open
Changes from 1 commit
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
32 changes: 28 additions & 4 deletions crates/common/types/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ pub struct BlobSchedule {
pub bpo4: Option<ForkBlobSchedule>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub bpo5: Option<ForkBlobSchedule>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub amsterdam: Option<ForkBlobSchedule>,
}

impl Default for BlobSchedule {
Expand All @@ -151,6 +153,7 @@ impl Default for BlobSchedule {
bpo3: None,
bpo4: None,
bpo5: None,
amsterdam: None,
}
}
}
Expand Down Expand Up @@ -251,6 +254,8 @@ pub struct ChainConfig {
pub bpo4_time: Option<u64>,
pub bpo5_time: Option<u64>,

pub amsterdam_time: Option<u64>,

/// Amount of total difficulty reached by the network that triggers the consensus upgrade.
pub terminal_total_difficulty: Option<u128>,
/// Network has already passed the terminal total difficult
Expand Down Expand Up @@ -308,6 +313,7 @@ pub enum Fork {
BPO3 = 22,
BPO4 = 23,
BPO5 = 24,
Amsterdam = 25,
}

impl From<Fork> for &str {
Expand Down Expand Up @@ -338,11 +344,17 @@ impl From<Fork> for &str {
Fork::BPO3 => "BPO3",
Fork::BPO4 => "BPO4",
Fork::BPO5 => "BPO5",
Fork::Amsterdam => "Amsterdam",
}
}
}

impl ChainConfig {
pub fn is_amsterdam_activated(&self, block_timestamp: u64) -> bool {
self.amsterdam_time
.is_some_and(|time| time <= block_timestamp)
}
Comment on lines 353 to 356
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

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

The is_amsterdam_activated method is placed before is_bpo1_activated, breaking the chronological ordering convention used for other fork activation methods. The methods should follow the chronological fork order (oldest to newest) for consistency. Consider moving this method to after is_bpo5_activated to maintain the established pattern: Cancun → Shanghai → Prague → Osaka → BPO1-5 → Amsterdam.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

The existing code already had them out of order by placing BPO5 right above Osaka. The correct fix is reordering the BPOs, not placing Amsterdam after BPO5.


pub fn is_bpo1_activated(&self, block_timestamp: u64) -> bool {
self.bpo1_time.is_some_and(|time| time <= block_timestamp)
}
Expand Down Expand Up @@ -402,6 +414,7 @@ impl ChainConfig {
("Prague", self.prague_time),
("Verkle", self.verkle_time),
("Osaka", self.osaka_time),
("Amsterdam", self.amsterdam_time),
];

let active_forks: Vec<_> = post_merge_forks
Expand All @@ -421,7 +434,9 @@ impl ChainConfig {
}

pub fn get_fork(&self, block_timestamp: u64) -> Fork {
if self.is_bpo5_activated(block_timestamp) {
if self.is_amsterdam_activated(block_timestamp) {
Fork::Amsterdam
} else if self.is_bpo5_activated(block_timestamp) {
Fork::BPO5
} else if self.is_bpo4_activated(block_timestamp) {
Fork::BPO4
Expand All @@ -445,7 +460,9 @@ impl ChainConfig {
}

pub fn get_fork_blob_schedule(&self, block_timestamp: u64) -> Option<ForkBlobSchedule> {
if self.is_bpo5_activated(block_timestamp) {
if self.is_amsterdam_activated(block_timestamp) {
Some(self.blob_schedule.amsterdam.unwrap_or_default())
} else if self.is_bpo5_activated(block_timestamp) {
Some(self.blob_schedule.bpo5.unwrap_or_default())
} else if self.is_bpo4_activated(block_timestamp) {
Some(self.blob_schedule.bpo4.unwrap_or_default())
Expand All @@ -471,8 +488,10 @@ impl ChainConfig {
}

pub fn next_fork(&self, block_timestamp: u64) -> Option<Fork> {
let next = if self.is_bpo5_activated(block_timestamp) {
let next = if self.is_amsterdam_activated(block_timestamp) {
None
} else if self.is_bpo5_activated(block_timestamp) && self.amsterdam_time.is_some() {
Some(Fork::Amsterdam)
} else if self.is_bpo4_activated(block_timestamp) && self.bpo5_time.is_some() {
Some(Fork::BPO5)
} else if self.is_bpo3_activated(block_timestamp) && self.bpo4_time.is_some() {
Expand All @@ -499,7 +518,9 @@ impl ChainConfig {
}

pub fn get_last_scheduled_fork(&self) -> Fork {
if self.bpo5_time.is_some() {
if self.amsterdam_time.is_some() {
Fork::Amsterdam
} else if self.bpo5_time.is_some() {
Fork::BPO5
} else if self.bpo4_time.is_some() {
Fork::BPO4
Expand Down Expand Up @@ -530,6 +551,7 @@ impl ChainConfig {
Fork::BPO3 => self.bpo3_time,
Fork::BPO4 => self.bpo4_time,
Fork::BPO5 => self.bpo5_time,
Fork::Amsterdam => self.amsterdam_time,
Fork::Homestead => self.homestead_block,
Fork::DaoFork => self.dao_fork_block,
Fork::Byzantium => self.byzantium_block,
Expand Down Expand Up @@ -557,6 +579,7 @@ impl ChainConfig {
Fork::BPO3 => self.blob_schedule.bpo3,
Fork::BPO4 => self.blob_schedule.bpo4,
Fork::BPO5 => self.blob_schedule.bpo5,
Fork::Amsterdam => self.blob_schedule.amsterdam,
_ => None,
}
}
Expand Down Expand Up @@ -601,6 +624,7 @@ impl ChainConfig {
self.bpo3_time,
self.bpo4_time,
self.bpo5_time,
self.amsterdam_time,
self.verkle_time,
]
.into_iter()
Expand Down
Loading