Skip to content

Commit 797d440

Browse files
authored
feat: schedule Galileo on Scroll Sepolia (#364)
1 parent 857624c commit 797d440

File tree

6 files changed

+96
-12
lines changed

6 files changed

+96
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl ScrollHardfork {
5454
(Self::Euclid, ForkCondition::Timestamp(1741680000)),
5555
(Self::EuclidV2, ForkCondition::Timestamp(1741852800)),
5656
(Self::Feynman, ForkCondition::Timestamp(1753167600)),
57-
(Self::Galileo, ForkCondition::Timestamp(u64::MAX)),
57+
(Self::Galileo, ForkCondition::Timestamp(1764054000)),
5858
]
5959
}
6060
}

crates/scroll/chainspec/src/lib.rs

Lines changed: 89 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,20 @@ impl ScrollChainSpecBuilder {
174174
self
175175
}
176176

177+
/// Enable `Feynman` at genesis
178+
pub fn feynman_activated(mut self) -> Self {
179+
self = self.euclid_v2_activated();
180+
self.inner = self.inner.with_fork(ScrollHardfork::Feynman, ForkCondition::Timestamp(0));
181+
self
182+
}
183+
184+
/// Enable `Galileo` at genesis
185+
pub fn galileo_activated(mut self) -> Self {
186+
self = self.feynman_activated();
187+
self.inner = self.inner.with_fork(ScrollHardfork::Galileo, ForkCondition::Timestamp(0));
188+
self
189+
}
190+
177191
/// Build the resulting [`ScrollChainSpec`].
178192
///
179193
/// # Panics
@@ -520,34 +534,42 @@ mod tests {
520534
Head { number: 0, ..Default::default() },
521535
ForkId { hash: ForkHash([0xea, 0x6b, 0x56, 0xca]), next: 5220340 },
522536
),
537+
// Bernoulli
523538
(
524539
Head { number: 5220340, ..Default::default() },
525540
ForkId { hash: ForkHash([0xee, 0x46, 0xae, 0x2a]), next: 7096836 },
526541
),
542+
// Curie
527543
(
528544
Head { number: 7096836, ..Default::default() },
529545
ForkId { hash: ForkHash([0x18, 0xd3, 0xc8, 0xd9]), next: 1724227200 },
530546
),
547+
// Darwin
531548
(
532549
Head { number: 7096836, timestamp: 1724227200, ..Default::default() },
533550
ForkId { hash: ForkHash([0xcc, 0xeb, 0x09, 0xb0]), next: 1725264000 },
534551
),
552+
// DarwinV2
535553
(
536554
Head { number: 7096836, timestamp: 1725264000, ..Default::default() },
537555
ForkId { hash: ForkHash([0x21, 0xa2, 0x07, 0x54]), next: 1744815600 },
538556
),
557+
// Euclid
539558
(
540559
Head { number: 7096836, timestamp: 1744815600, ..Default::default() },
541560
ForkId { hash: ForkHash([0xca, 0xc5, 0x80, 0xca]), next: 1745305200 },
542561
),
562+
// EuclidV2
543563
(
544564
Head { number: 7096836, timestamp: 1745305200, ..Default::default() },
545565
ForkId { hash: ForkHash([0x0e, 0xcf, 0xb2, 0x31]), next: 1755576000 },
546566
),
567+
// Feynman
547568
(
548569
Head { number: 7096836, timestamp: 1755576000, ..Default::default() },
549570
ForkId { hash: ForkHash([0x38, 0x0f, 0x78, 0x5d]), next: u64::MAX },
550571
),
572+
// Galileo
551573
(
552574
Head { number: 7096836, timestamp: u64::MAX, ..Default::default() },
553575
ForkId { hash: ForkHash([0x50, 0xe7, 0xe6, 0xd5]), next: 0 },
@@ -558,19 +580,54 @@ mod tests {
558580

559581
#[test]
560582
fn scroll_mainnet_forkids() {
583+
// To maintain compatibility with l2geth, we need to ignore time-based forks in the ForkID.
584+
561585
let cases = [
562586
(
563587
Head { number: 0, ..Default::default() },
564588
ForkId { hash: ForkHash([0xea, 0x6b, 0x56, 0xca]), next: 5220340 },
565589
),
590+
// Bernoulli
566591
(
567592
Head { number: 5220340, ..Default::default() },
568593
ForkId { hash: ForkHash([0xee, 0x46, 0xae, 0x2a]), next: 7096836 },
569594
),
595+
// Curie
570596
(
571597
Head { number: 7096836, ..Default::default() },
572598
ForkId { hash: ForkHash([0x18, 0xd3, 0xc8, 0xd9]), next: 0 },
573599
),
600+
// Note: The following time-based forks are ignored in the ForkID calculation.
601+
// Darwin
602+
(
603+
Head { number: 7096836, timestamp: 1724227200, ..Default::default() },
604+
ForkId { hash: ForkHash([0x18, 0xd3, 0xc8, 0xd9]), next: 0 },
605+
),
606+
// DarwinV2
607+
(
608+
Head { number: 7096836, timestamp: 1725264000, ..Default::default() },
609+
ForkId { hash: ForkHash([0x18, 0xd3, 0xc8, 0xd9]), next: 0 },
610+
),
611+
// Euclid
612+
(
613+
Head { number: 7096836, timestamp: 1744815600, ..Default::default() },
614+
ForkId { hash: ForkHash([0x18, 0xd3, 0xc8, 0xd9]), next: 0 },
615+
),
616+
// EuclidV2
617+
(
618+
Head { number: 7096836, timestamp: 1745305200, ..Default::default() },
619+
ForkId { hash: ForkHash([0x18, 0xd3, 0xc8, 0xd9]), next: 0 },
620+
),
621+
// Feynman
622+
(
623+
Head { number: 7096836, timestamp: 1755576000, ..Default::default() },
624+
ForkId { hash: ForkHash([0x18, 0xd3, 0xc8, 0xd9]), next: 0 },
625+
),
626+
// Galileo
627+
(
628+
Head { number: 7096836, timestamp: u64::MAX, ..Default::default() },
629+
ForkId { hash: ForkHash([0x18, 0xd3, 0xc8, 0xd9]), next: 0 },
630+
),
574631
];
575632

576633
for (block, expected_id) in cases {
@@ -612,37 +669,45 @@ mod tests {
612669
Head { number: 0, ..Default::default() },
613670
ForkId { hash: ForkHash([0x25, 0xfa, 0xe4, 0x54]), next: 3747132 },
614671
),
672+
// Bernoulli
615673
(
616674
Head { number: 3747132, ..Default::default() },
617675
ForkId { hash: ForkHash([0xda, 0x76, 0xc2, 0x2d]), next: 4740239 },
618676
),
677+
// Curie
619678
(
620679
Head { number: 4740239, ..Default::default() },
621680
ForkId { hash: ForkHash([0x9f, 0xb4, 0x75, 0xf1]), next: 1723622400 },
622681
),
682+
// Darwin
623683
(
624684
Head { number: 4740239, timestamp: 1723622400, ..Default::default() },
625685
ForkId { hash: ForkHash([0xe9, 0x26, 0xd4, 0x9b]), next: 1724832000 },
626686
),
687+
// DarwinV2
627688
(
628689
Head { number: 4740239, timestamp: 1724832000, ..Default::default() },
629690
ForkId { hash: ForkHash([0x69, 0xf3, 0x7e, 0xde]), next: 1741680000 },
630691
),
692+
// Euclid
631693
(
632694
Head { number: 4740239, timestamp: 1741680000, ..Default::default() },
633695
ForkId { hash: ForkHash([0xf7, 0xac, 0x7e, 0xfc]), next: 1741852800 },
634696
),
697+
// EuclidV2
635698
(
636699
Head { number: 4740239, timestamp: 1741852800, ..Default::default() },
637700
ForkId { hash: ForkHash([0x51, 0x7e, 0x0f, 0x1c]), next: 1753167600 },
638701
),
702+
// Feynman
639703
(
640704
Head { number: 4740239, timestamp: 1753167600, ..Default::default() },
641-
ForkId { hash: ForkHash([0x19, 0xbb, 0x92, 0xc6]), next: u64::MAX },
705+
ForkId { hash: ForkHash([0x19, 0xbb, 0x92, 0xc6]), next: 1764054000 },
642706
),
707+
// Galileo
643708
(
644-
Head { number: 4740239, timestamp: u64::MAX, ..Default::default() },
645-
ForkId { hash: ForkHash([0xf8, 0x27, 0xe0, 0xfc]), next: 0 },
709+
Head { number: 4740239, timestamp: 1764054000, ..Default::default() },
710+
ForkId { hash: ForkHash([0xe8, 0xc2, 0x20, 0x80]), next: 0 },
646711
),
647712
],
648713
);
@@ -664,6 +729,10 @@ mod tests {
664729
"curieBlock": 20,
665730
"darwinTime": 30,
666731
"darwinV2Time": 31,
732+
"euclidTime": 32,
733+
"euclidV2Time": 33,
734+
"feynmanTime": 34,
735+
"galileoTime": 35,
667736
"scroll": {
668737
"feeVaultAddress": "0x5300000000000000000000000000000000000005",
669738
"maxTxPayloadBytesPerBlock": 122880,
@@ -688,6 +757,15 @@ mod tests {
688757
assert_eq!(actual_darwin_timestamp, Some(serde_json::Value::from(30)).as_ref());
689758
let actual_darwin_v2_timestamp = genesis.config.extra_fields.get("darwinV2Time");
690759
assert_eq!(actual_darwin_v2_timestamp, Some(serde_json::Value::from(31)).as_ref());
760+
let actual_euclid_timestamp = genesis.config.extra_fields.get("euclidTime");
761+
assert_eq!(actual_euclid_timestamp, Some(serde_json::Value::from(32)).as_ref());
762+
let actual_euclid_v2_timestamp = genesis.config.extra_fields.get("euclidV2Time");
763+
assert_eq!(actual_euclid_v2_timestamp, Some(serde_json::Value::from(33)).as_ref());
764+
let actual_feynman_timestamp = genesis.config.extra_fields.get("feynmanTime");
765+
assert_eq!(actual_feynman_timestamp, Some(serde_json::Value::from(34)).as_ref());
766+
let actual_galileo_timestamp = genesis.config.extra_fields.get("galileoTime");
767+
assert_eq!(actual_galileo_timestamp, Some(serde_json::Value::from(35)).as_ref());
768+
691769
let scroll_object = genesis.config.extra_fields.get("scroll").unwrap();
692770
assert_eq!(
693771
scroll_object,
@@ -711,11 +789,19 @@ mod tests {
711789
assert!(!chain_spec.is_fork_active_at_block(ScrollHardfork::Curie, 0));
712790
assert!(!chain_spec.is_fork_active_at_timestamp(ScrollHardfork::Darwin, 0));
713791
assert!(!chain_spec.is_fork_active_at_timestamp(ScrollHardfork::DarwinV2, 0));
792+
assert!(!chain_spec.is_fork_active_at_timestamp(ScrollHardfork::Euclid, 0));
793+
assert!(!chain_spec.is_fork_active_at_timestamp(ScrollHardfork::EuclidV2, 0));
794+
assert!(!chain_spec.is_fork_active_at_timestamp(ScrollHardfork::Feynman, 0));
795+
assert!(!chain_spec.is_fork_active_at_timestamp(ScrollHardfork::Galileo, 0));
714796

715797
assert!(chain_spec.is_fork_active_at_block(ScrollHardfork::Bernoulli, 10));
716798
assert!(chain_spec.is_fork_active_at_block(ScrollHardfork::Curie, 20));
717799
assert!(chain_spec.is_fork_active_at_timestamp(ScrollHardfork::Darwin, 30));
718800
assert!(chain_spec.is_fork_active_at_timestamp(ScrollHardfork::DarwinV2, 31));
801+
assert!(chain_spec.is_fork_active_at_timestamp(ScrollHardfork::Euclid, 32));
802+
assert!(chain_spec.is_fork_active_at_timestamp(ScrollHardfork::EuclidV2, 33));
803+
assert!(chain_spec.is_fork_active_at_timestamp(ScrollHardfork::Feynman, 34));
804+
assert!(chain_spec.is_fork_active_at_timestamp(ScrollHardfork::Galileo, 35));
719805
}
720806

721807
#[test]

crates/scroll/chainspec/src/scroll.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{
66
};
77
use alloc::{sync::Arc, vec};
88

9-
use alloy_chains::{Chain, NamedChain};
9+
use alloy_chains::Chain;
1010
use reth_chainspec::{BaseFeeParamsKind, ChainSpec, Hardfork};
1111
use reth_primitives_traits::SealedHeader;
1212
use reth_scroll_forks::SCROLL_MAINNET_HARDFORKS;
@@ -18,8 +18,7 @@ pub static SCROLL_MAINNET: LazyLock<Arc<ScrollChainSpec>> = LazyLock::new(|| {
1818
.expect("Can't deserialize Scroll Mainnet genesis json");
1919
ScrollChainSpec {
2020
inner: ChainSpec {
21-
// TODO(scroll): migrate to Chain::scroll() (introduced in https://github.com/alloy-rs/chains/pull/112) when alloy-chains is bumped to version 0.1.48
22-
chain: Chain::from_named(NamedChain::Scroll),
21+
chain: Chain::scroll_mainnet(),
2322
genesis_header: SealedHeader::new(
2423
make_genesis_header(&genesis),
2524
SCROLL_MAINNET_GENESIS_HASH,

crates/scroll/chainspec/src/scroll_sepolia.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{
66
};
77
use alloc::{sync::Arc, vec};
88

9-
use alloy_chains::{Chain, NamedChain};
9+
use alloy_chains::Chain;
1010
use reth_chainspec::{BaseFeeParamsKind, ChainSpec, Hardfork};
1111
use reth_primitives_traits::SealedHeader;
1212
use reth_scroll_forks::SCROLL_SEPOLIA_HARDFORKS;
@@ -18,8 +18,7 @@ pub static SCROLL_SEPOLIA: LazyLock<Arc<ScrollChainSpec>> = LazyLock::new(|| {
1818
.expect("Can't deserialize Scroll Sepolia genesis json");
1919
ScrollChainSpec {
2020
inner: ChainSpec {
21-
// TODO(scroll): migrate to Chain::scroll_sepolia() (introduced in https://github.com/alloy-rs/chains/pull/112) when alloy-chains is bumped to version 0.1.48
22-
chain: Chain::from_named(NamedChain::ScrollSepolia),
21+
chain: Chain::scroll_sepolia(),
2322
genesis_header: SealedHeader::new(
2423
make_genesis_header(&genesis),
2524
SCROLL_SEPOLIA_GENESIS_HASH,

crates/scroll/hardforks/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub static SCROLL_SEPOLIA_HARDFORKS: LazyLock<ChainHardforks> = LazyLock::new(||
6565
(ScrollHardfork::Euclid.boxed(), ForkCondition::Timestamp(1741680000)),
6666
(ScrollHardfork::EuclidV2.boxed(), ForkCondition::Timestamp(1741852800)),
6767
(ScrollHardfork::Feynman.boxed(), ForkCondition::Timestamp(1753167600)),
68-
(ScrollHardfork::Galileo.boxed(), ForkCondition::Timestamp(u64::MAX)),
68+
(ScrollHardfork::Galileo.boxed(), ForkCondition::Timestamp(1764054000)),
6969
])
7070
});
7171

crates/scroll/node/src/test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub async fn setup(
3131
reth_e2e_test_utils::setup_engine(
3232
num_nodes,
3333
Arc::new(
34-
ScrollChainSpecBuilder::scroll_mainnet().genesis(genesis).euclid_v2_activated().build(
34+
ScrollChainSpecBuilder::scroll_mainnet().genesis(genesis).galileo_activated().build(
3535
ScrollChainConfig {
3636
max_tx_payload_bytes_per_block: 120 * 1024,
3737
..Default::default()

0 commit comments

Comments
 (0)