Skip to content

Commit 414c692

Browse files
authored
feat: add hardfork Galileo (#354)
* chore: add hardfork galileo * fmt * fix: test after new hardfork added * fix: tests for hardfork
1 parent a0ffcb5 commit 414c692

File tree

5 files changed

+46
-8
lines changed

5 files changed

+46
-8
lines changed

crates/scroll/alloy/hardforks/src/hardfork.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ hardfork!(
2121
/// EuclidV2 <https://docs.scroll.io/en/technology/overview/scroll-upgrades/euclid-upgrade/>
2222
EuclidV2,
2323
/// Feynman <https://docs.scroll.io/en/technology/overview/scroll-upgrades/feynman-upgrade/>
24-
Feynman
24+
Feynman,
25+
/// Galileo <https://docs.scroll.io/en/technology/overview/scroll-upgrades/galileo-upgrade/>
26+
Galileo,
2527
}
2628
);
2729

2830
impl ScrollHardfork {
2931
/// Scroll mainnet list of hardforks.
30-
pub const fn scroll_mainnet() -> [(Self, ForkCondition); 8] {
32+
pub const fn scroll_mainnet() -> [(Self, ForkCondition); 9] {
3133
[
3234
(Self::Archimedes, ForkCondition::Block(0)),
3335
(Self::Bernoulli, ForkCondition::Block(5220340)),
@@ -37,11 +39,12 @@ impl ScrollHardfork {
3739
(Self::Euclid, ForkCondition::Timestamp(1744815600)),
3840
(Self::EuclidV2, ForkCondition::Timestamp(1745305200)),
3941
(Self::Feynman, ForkCondition::Timestamp(1755576000)),
42+
(Self::Galileo, ForkCondition::Timestamp(u64::MAX)),
4043
]
4144
}
4245

4346
/// Scroll sepolia list of hardforks.
44-
pub const fn scroll_sepolia() -> [(Self, ForkCondition); 8] {
47+
pub const fn scroll_sepolia() -> [(Self, ForkCondition); 9] {
4548
[
4649
(Self::Archimedes, ForkCondition::Block(0)),
4750
(Self::Bernoulli, ForkCondition::Block(3747132)),
@@ -51,6 +54,7 @@ impl ScrollHardfork {
5154
(Self::Euclid, ForkCondition::Timestamp(1741680000)),
5255
(Self::EuclidV2, ForkCondition::Timestamp(1741852800)),
5356
(Self::Feynman, ForkCondition::Timestamp(1753167600)),
57+
(Self::Galileo, ForkCondition::Timestamp(u64::MAX)),
5458
]
5559
}
5660
}
@@ -62,8 +66,16 @@ mod tests {
6266

6367
#[test]
6468
fn check_scroll_hardfork_from_str() {
65-
let hardfork_str =
66-
["BernOulLi", "CUrie", "DaRwIn", "DaRwInV2", "EUcliD", "eUClidv2", "FEYnmaN"];
69+
let hardfork_str = [
70+
"BernOulLi",
71+
"CUrie",
72+
"DaRwIn",
73+
"DaRwInV2",
74+
"EUcliD",
75+
"eUClidv2",
76+
"FEYnmaN",
77+
"gaLiLEo",
78+
];
6779
let expected_hardforks = [
6880
ScrollHardfork::Bernoulli,
6981
ScrollHardfork::Curie,
@@ -72,6 +84,7 @@ mod tests {
7284
ScrollHardfork::Euclid,
7385
ScrollHardfork::EuclidV2,
7486
ScrollHardfork::Feynman,
87+
ScrollHardfork::Galileo,
7588
];
7689

7790
let hardforks: Vec<ScrollHardfork> =

crates/scroll/alloy/hardforks/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ pub trait ScrollHardforks: EthereumHardforks {
5252
fn is_feynman_active_at_timestamp(&self, timestamp: u64) -> bool {
5353
self.scroll_fork_activation(ScrollHardfork::Feynman).active_at_timestamp(timestamp)
5454
}
55+
56+
/// Returns `true` if [`Galileo`](ScrollHardfork::Galileo) is active at given block timestamp.
57+
fn is_galileo_active_at_timestamp(&self, timestamp: u64) -> bool {
58+
self.scroll_fork_activation(ScrollHardfork::Galileo).active_at_timestamp(timestamp)
59+
}
5560
}
5661

5762
/// A type allowing to configure activation [`ForkCondition`]s for a given list of

crates/scroll/chainspec/src/genesis.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ pub struct ScrollHardforkInfo {
6969
pub euclid_v2_time: Option<u64>,
7070
/// feynman hardfork timestamp
7171
pub feynman_time: Option<u64>,
72+
/// galileo hardfork timestamp
73+
pub galileo_time: Option<u64>,
7274
}
7375

7476
impl ScrollHardforkInfo {
@@ -187,7 +189,8 @@ mod tests {
187189
"curieBlock": 12,
188190
"darwinTime": 0,
189191
"euclidTime": 11,
190-
"feynmanTime": 100
192+
"feynmanTime": 100,
193+
"galileoTime": 110
191194
}
192195
"#;
193196

@@ -205,6 +208,7 @@ mod tests {
205208
euclid_time: Some(11),
206209
euclid_v2_time: None,
207210
feynman_time: Some(100),
211+
galileo_time: Some(110),
208212
}
209213
);
210214
}
@@ -219,6 +223,7 @@ mod tests {
219223
"darwinTime": 0,
220224
"euclidTime": 11,
221225
"feynmanTime": 100,
226+
"galileoTime": 110,
222227
"scroll": {
223228
"feeVaultAddress": "0x5300000000000000000000000000000000000005",
224229
"maxTxPayloadBytesPerBlock": 122880,
@@ -247,6 +252,7 @@ mod tests {
247252
euclid_time: Some(11),
248253
euclid_v2_time: None,
249254
feynman_time: Some(100),
255+
galileo_time: Some(110),
250256
}),
251257
scroll_chain_config: ScrollChainConfig {
252258
fee_vault_address: Some(address!("5300000000000000000000000000000000000005")),

crates/scroll/chainspec/src/lib.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ impl From<Genesis> for ScrollChainSpec {
431431
(ScrollHardfork::Euclid.boxed(), hard_fork_info.euclid_time),
432432
(ScrollHardfork::EuclidV2.boxed(), hard_fork_info.euclid_v2_time),
433433
(ScrollHardfork::Feynman.boxed(), hard_fork_info.feynman_time),
434+
(ScrollHardfork::Galileo.boxed(), hard_fork_info.galileo_time),
434435
];
435436

436437
let mut time_hardforks = time_hardfork_opts
@@ -545,7 +546,11 @@ mod tests {
545546
),
546547
(
547548
Head { number: 7096836, timestamp: 1755576000, ..Default::default() },
548-
ForkId { hash: ForkHash([0x38, 0x0f, 0x78, 0x5d]), next: 0 },
549+
ForkId { hash: ForkHash([0x38, 0x0f, 0x78, 0x5d]), next: u64::MAX },
550+
),
551+
(
552+
Head { number: 7096836, timestamp: u64::MAX, ..Default::default() },
553+
ForkId { hash: ForkHash([0x50, 0xe7, 0xe6, 0xd5]), next: 0 },
549554
),
550555
],
551556
);
@@ -633,7 +638,11 @@ mod tests {
633638
),
634639
(
635640
Head { number: 4740239, timestamp: 1753167600, ..Default::default() },
636-
ForkId { hash: ForkHash([0x19, 0xbb, 0x92, 0xc6]), next: 0 },
641+
ForkId { hash: ForkHash([0x19, 0xbb, 0x92, 0xc6]), next: u64::MAX },
642+
),
643+
(
644+
Head { number: 4740239, timestamp: u64::MAX, ..Default::default() },
645+
ForkId { hash: ForkHash([0xf8, 0x27, 0xe0, 0xfc]), next: 0 },
637646
),
638647
],
639648
);
@@ -734,6 +743,7 @@ mod tests {
734743
(String::from("darwinTime"), 0.into()),
735744
(String::from("darwinV2Time"), 0.into()),
736745
(String::from("feynmanTime"), 0.into()),
746+
(String::from("galileoTime"), 0.into()),
737747
(
738748
String::from("scroll"),
739749
serde_json::json!({
@@ -777,6 +787,7 @@ mod tests {
777787
ScrollHardfork::Darwin.boxed(),
778788
ScrollHardfork::DarwinV2.boxed(),
779789
ScrollHardfork::Feynman.boxed(),
790+
ScrollHardfork::Galileo.boxed(),
780791
];
781792

782793
assert!(expected_hardforks

crates/scroll/hardforks/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub static SCROLL_MAINNET_HARDFORKS: LazyLock<ChainHardforks> = LazyLock::new(||
4040
(ScrollHardfork::Euclid.boxed(), ForkCondition::Timestamp(1744815600)),
4141
(ScrollHardfork::EuclidV2.boxed(), ForkCondition::Timestamp(1745305200)),
4242
(ScrollHardfork::Feynman.boxed(), ForkCondition::Timestamp(1755576000)),
43+
(ScrollHardfork::Galileo.boxed(), ForkCondition::Timestamp(u64::MAX)),
4344
])
4445
});
4546

@@ -64,6 +65,7 @@ pub static SCROLL_SEPOLIA_HARDFORKS: LazyLock<ChainHardforks> = LazyLock::new(||
6465
(ScrollHardfork::Euclid.boxed(), ForkCondition::Timestamp(1741680000)),
6566
(ScrollHardfork::EuclidV2.boxed(), ForkCondition::Timestamp(1741852800)),
6667
(ScrollHardfork::Feynman.boxed(), ForkCondition::Timestamp(1753167600)),
68+
(ScrollHardfork::Galileo.boxed(), ForkCondition::Timestamp(u64::MAX)),
6769
])
6870
});
6971

@@ -88,5 +90,6 @@ pub static DEV_HARDFORKS: LazyLock<ChainHardforks> = LazyLock::new(|| {
8890
(ScrollHardfork::Euclid.boxed(), ForkCondition::Timestamp(0)),
8991
(ScrollHardfork::EuclidV2.boxed(), ForkCondition::Timestamp(0)),
9092
(ScrollHardfork::Feynman.boxed(), ForkCondition::Timestamp(0)),
93+
(ScrollHardfork::Galileo.boxed(), ForkCondition::Timestamp(0)),
9194
])
9295
});

0 commit comments

Comments
 (0)