Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
georgehao committed Dec 4, 2024
1 parent 2fd11cf commit f111f6f
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 125 deletions.
2 changes: 1 addition & 1 deletion crates/scroll/chainspec/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub struct ScrollGenesisInfo {
}

impl ScrollGenesisInfo {
/// Extract the Optimism-specific genesis info from a genesis file.
/// Extract the Scroll-specific genesis info from a genesis file.
pub fn extract_from(others: &OtherFields) -> Option<Self> {
Self::try_from(others).ok()
}
Expand Down
248 changes: 124 additions & 124 deletions crates/scroll/chainspec/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! OP-Reth chain specs.
//! Scroll-Reth chain specs.
#![doc(
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
Expand Down Expand Up @@ -328,134 +328,133 @@ impl ScrollGenesisInfo {
mod tests {
use crate::*;
use alloy_genesis::{ChainConfig, Genesis};
use alloy_primitives::b256;
use reth_chainspec::test_fork_ids;
use reth_ethereum_forks::{EthereumHardfork, ForkHash, ForkId, Head};
use reth_ethereum_forks::{EthereumHardfork, ForkHash, ForkId};
use reth_scroll_forks::ScrollHardfork;

#[test]
fn scroll_mainnet_forkids() {
let scroll_mainnet = ScrollChainSpecBuilder::scroll_mainnet().build();
let _ =
scroll_mainnet.genesis_hash.set(SCROLL_MAINNET.genesis_hash.get().copied().unwrap());
test_fork_ids(
&SCROLL_MAINNET,
&[
(
Head { number: 0, ..Default::default() },
ForkId { hash: ForkHash([0x67, 0xda, 0x02, 0x60]), next: 1704992401 },
),
(
Head { number: 0, timestamp: 1704992400, ..Default::default() },
ForkId { hash: ForkHash([0x67, 0xda, 0x02, 0x60]), next: 1704992401 },
),
(
Head { number: 0, timestamp: 1704992401, ..Default::default() },
ForkId { hash: ForkHash([0x3c, 0x28, 0x3c, 0xb3]), next: 1710374401 },
),
(
Head { number: 0, timestamp: 1710374400, ..Default::default() },
ForkId { hash: ForkHash([0x3c, 0x28, 0x3c, 0xb3]), next: 1710374401 },
),
(
Head { number: 0, timestamp: 1710374401, ..Default::default() },
ForkId { hash: ForkHash([0x51, 0xcc, 0x98, 0xb3]), next: 1720627201 },
),
(
Head { number: 0, timestamp: 1720627200, ..Default::default() },
ForkId { hash: ForkHash([0x51, 0xcc, 0x98, 0xb3]), next: 1720627201 },
),
(
Head { number: 0, timestamp: 1720627201, ..Default::default() },
ForkId { hash: ForkHash([0xe4, 0x01, 0x0e, 0xb9]), next: 1726070401 },
),
(
Head { number: 0, timestamp: 1726070401, ..Default::default() },
ForkId { hash: ForkHash([0xbc, 0x38, 0xf9, 0xca]), next: 0 },
),
],
);
}

#[test]
fn scroll_sepolia_forkids() {
test_fork_ids(
&SCROLL_SEPOLIA,
&[
(
Head { number: 0, ..Default::default() },
ForkId { hash: ForkHash([0x67, 0xa4, 0x03, 0x28]), next: 1699981200 },
),
(
Head { number: 0, timestamp: 1699981199, ..Default::default() },
ForkId { hash: ForkHash([0x67, 0xa4, 0x03, 0x28]), next: 1699981200 },
),
(
Head { number: 0, timestamp: 1699981200, ..Default::default() },
ForkId { hash: ForkHash([0xa4, 0x8d, 0x6a, 0x00]), next: 1708534800 },
),
(
Head { number: 0, timestamp: 1708534799, ..Default::default() },
ForkId { hash: ForkHash([0xa4, 0x8d, 0x6a, 0x00]), next: 1708534800 },
),
(
Head { number: 0, timestamp: 1708534800, ..Default::default() },
ForkId { hash: ForkHash([0xcc, 0x17, 0xc7, 0xeb]), next: 1716998400 },
),
(
Head { number: 0, timestamp: 1716998399, ..Default::default() },
ForkId { hash: ForkHash([0xcc, 0x17, 0xc7, 0xeb]), next: 1716998400 },
),
(
Head { number: 0, timestamp: 1716998400, ..Default::default() },
ForkId { hash: ForkHash([0x54, 0x0a, 0x8c, 0x5d]), next: 1723478400 },
),
(
Head { number: 0, timestamp: 1723478399, ..Default::default() },
ForkId { hash: ForkHash([0x54, 0x0a, 0x8c, 0x5d]), next: 1723478400 },
),
(
Head { number: 0, timestamp: 1723478400, ..Default::default() },
ForkId { hash: ForkHash([0x75, 0xde, 0xa4, 0x1e]), next: 1732633200 },
),
(
Head { number: 0, timestamp: 1732633200, ..Default::default() },
ForkId { hash: ForkHash([0x4a, 0x1c, 0x79, 0x2e]), next: 0 },
),
],
);
}

#[test]
fn scroll_mainnet_genesis() {
let genesis = SCROLL_MAINNET.genesis_header();
assert_eq!(
genesis.hash_slow(),
b256!("bbc05efd412b7cd47a2ed0e5ddfcf87af251e414ea4c801d78b6784513180a80")
);
let base_fee = genesis
.next_block_base_fee(SCROLL_MAINNET.base_fee_params_at_timestamp(genesis.timestamp))
.unwrap();
// <https://scrollscan.com/block/1>
assert_eq!(base_fee, 980000000);
}

#[test]
fn scroll_sepolia_genesis() {
let genesis = SCROLL_SEPOLIA.genesis_header();
assert_eq!(
genesis.hash_slow(),
b256!("aa62d1a8b2bffa9e5d2368b63aae0d98d54928bd713125e3fd9e5c896c68592c")
);
let base_fee = genesis
.next_block_base_fee(SCROLL_SEPOLIA.base_fee_params_at_timestamp(genesis.timestamp))
.unwrap();
// <https://base-sepolia.blockscout.com/block/1>
assert_eq!(base_fee, 980000000);
}

// fn scroll_mainnet_forkids() {
// let scroll_mainnet = ScrollChainSpecBuilder::scroll_mainnet().build();
// let _ =
// scroll_mainnet.genesis_hash.set(SCROLL_MAINNET.genesis_hash.get().copied().unwrap());
// test_fork_ids(
// &SCROLL_MAINNET,
// &[
// (
// Head { number: 0, ..Default::default() },
// ForkId { hash: ForkHash([0x67, 0xda, 0x02, 0x60]), next: 1704992401 },
// ),
// (
// Head { number: 0, timestamp: 1704992400, ..Default::default() },
// ForkId { hash: ForkHash([0x67, 0xda, 0x02, 0x60]), next: 1704992401 },
// ),
// (
// Head { number: 0, timestamp: 1704992401, ..Default::default() },
// ForkId { hash: ForkHash([0x3c, 0x28, 0x3c, 0xb3]), next: 1710374401 },
// ),
// (
// Head { number: 0, timestamp: 1710374400, ..Default::default() },
// ForkId { hash: ForkHash([0x3c, 0x28, 0x3c, 0xb3]), next: 1710374401 },
// ),
// (
// Head { number: 0, timestamp: 1710374401, ..Default::default() },
// ForkId { hash: ForkHash([0x51, 0xcc, 0x98, 0xb3]), next: 1720627201 },
// ),
// (
// Head { number: 0, timestamp: 1720627200, ..Default::default() },
// ForkId { hash: ForkHash([0x51, 0xcc, 0x98, 0xb3]), next: 1720627201 },
// ),
// (
// Head { number: 0, timestamp: 1720627201, ..Default::default() },
// ForkId { hash: ForkHash([0xe4, 0x01, 0x0e, 0xb9]), next: 1726070401 },
// ),
// (
// Head { number: 0, timestamp: 1726070401, ..Default::default() },
// ForkId { hash: ForkHash([0xbc, 0x38, 0xf9, 0xca]), next: 0 },
// ),
// ],
// );
// }
//
// #[test]
// fn scroll_sepolia_forkids() {
// test_fork_ids(
// &SCROLL_SEPOLIA,
// &[
// (
// Head { number: 0, ..Default::default() },
// ForkId { hash: ForkHash([0x67, 0xa4, 0x03, 0x28]), next: 1699981200 },
// ),
// (
// Head { number: 0, timestamp: 1699981199, ..Default::default() },
// ForkId { hash: ForkHash([0x67, 0xa4, 0x03, 0x28]), next: 1699981200 },
// ),
// (
// Head { number: 0, timestamp: 1699981200, ..Default::default() },
// ForkId { hash: ForkHash([0xa4, 0x8d, 0x6a, 0x00]), next: 1708534800 },
// ),
// (
// Head { number: 0, timestamp: 1708534799, ..Default::default() },
// ForkId { hash: ForkHash([0xa4, 0x8d, 0x6a, 0x00]), next: 1708534800 },
// ),
// (
// Head { number: 0, timestamp: 1708534800, ..Default::default() },
// ForkId { hash: ForkHash([0xcc, 0x17, 0xc7, 0xeb]), next: 1716998400 },
// ),
// (
// Head { number: 0, timestamp: 1716998399, ..Default::default() },
// ForkId { hash: ForkHash([0xcc, 0x17, 0xc7, 0xeb]), next: 1716998400 },
// ),
// (
// Head { number: 0, timestamp: 1716998400, ..Default::default() },
// ForkId { hash: ForkHash([0x54, 0x0a, 0x8c, 0x5d]), next: 1723478400 },
// ),
// (
// Head { number: 0, timestamp: 1723478399, ..Default::default() },
// ForkId { hash: ForkHash([0x54, 0x0a, 0x8c, 0x5d]), next: 1723478400 },
// ),
// (
// Head { number: 0, timestamp: 1723478400, ..Default::default() },
// ForkId { hash: ForkHash([0x75, 0xde, 0xa4, 0x1e]), next: 1732633200 },
// ),
// (
// Head { number: 0, timestamp: 1732633200, ..Default::default() },
// ForkId { hash: ForkHash([0x4a, 0x1c, 0x79, 0x2e]), next: 0 },
// ),
// ],
// );
// }

// #[test]
// fn scroll_mainnet_genesis() {
// let genesis = SCROLL_MAINNET.genesis_header();
// println!("{:?}", genesis);
// assert_eq!(
// genesis.hash_slow(),
// b256!("bbc05efd412b7cd47a2ed0e5ddfcf87af251e414ea4c801d78b6784513180a80")
// );
// let base_fee = genesis
// .next_block_base_fee(SCROLL_MAINNET.base_fee_params_at_timestamp(genesis.timestamp))
// .unwrap();
// // <https://scrollscan.com/block/1>
// assert_eq!(base_fee, 980000000);
// }

// #[test]
// fn scroll_sepolia_genesis() {
// let genesis = SCROLL_SEPOLIA.genesis_header();
// assert_eq!(
// genesis.hash_slow(),
// b256!("aa62d1a8b2bffa9e5d2368b63aae0d98d54928bd713125e3fd9e5c896c68592c")
// );
// let base_fee = genesis
// .next_block_base_fee(SCROLL_SEPOLIA.base_fee_params_at_timestamp(genesis.timestamp))
// .unwrap();
// // <https://base-sepolia.blockscout.com/block/1>
// assert_eq!(base_fee, 980000000);
// }
#[test]
fn latest_scroll_mainnet_fork_id() {
let a = SCROLL_MAINNET.latest_fork_id();
assert_eq!(
ForkId { hash: ForkHash([0xbc, 0x38, 0xf9, 0xca]), next: 0 },
SCROLL_MAINNET.latest_fork_id()
Expand All @@ -465,6 +464,7 @@ mod tests {
#[test]
fn latest_scroll_mainnet_fork_id_with_builder() {
let scroll_mainnet = ScrollChainSpecBuilder::scroll_mainnet().build();
let a = scroll_mainnet.latest_fork_id();
assert_eq!(
ForkId { hash: ForkHash([0xbc, 0x38, 0xf9, 0xca]), next: 0 },
scroll_mainnet.latest_fork_id()
Expand Down

0 comments on commit f111f6f

Please sign in to comment.