Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
georgehao committed Dec 4, 2024
1 parent 70abe38 commit 5aea8e8
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 62 deletions.
30 changes: 13 additions & 17 deletions crates/scroll/chainspec/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,23 @@ impl TryFrom<&OtherFields> for ScrollGenesisInfo {
#[serde(rename_all = "camelCase")]
pub struct L1Config {
/// l1 chain id
pub l1_chain_id: Option<u64>,
pub l1_chain_id: u64,
/// the l1 message queue address
pub l1_message_queue_address: Option<Address>,
pub l1_message_queue_address: Address,
// the l1 scroll proxy address
pub scroll_chain_address: Option<Address>,
pub scroll_chain_address: Address,
// the l1 message numbers of per block
pub num_l1_messages_per_block: Option<u64>,
pub num_l1_messages_per_block: u64,
}

/// The Scroll special chain specification.
#[derive(Default, Debug, Clone, Copy, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ScrollSpecialChainInfo {
/// the L2 tx fee vault address
pub fee_vault_address: Option<Address>,
pub fee_vault_address: Address,
/// the L1 special config
pub l1_config: Option<L1Config>,
pub l1_config: L1Config,
}

impl ScrollSpecialChainInfo {
Expand Down Expand Up @@ -165,17 +165,13 @@ mod tests {
darwin_v2_time: None,
}),
scroll_special_info: Some(ScrollSpecialChainInfo {
fee_vault_address: Some(address!("5300000000000000000000000000000000000005")),
l1_config: Some(L1Config {
l1_chain_id: Some(1),
l1_message_queue_address: Some(address!(
"0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B"
)),
scroll_chain_address: Some(address!(
"a13BAF47339d63B743e7Da8741db5456DAc1E556"
)),
num_l1_messages_per_block: Some(10),
}),
fee_vault_address: address!("5300000000000000000000000000000000000005"),
l1_config: L1Config {
l1_chain_id: 1,
l1_message_queue_address: address!("0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B"),
scroll_chain_address: address!("a13BAF47339d63B743e7Da8741db5456DAc1E556"),
num_l1_messages_per_block: 10,
},
}),
};
assert_eq!(chain_info, expected);
Expand Down
40 changes: 19 additions & 21 deletions crates/scroll/chainspec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@ impl ScrollGenesisInfo {
mod tests {
use crate::*;
use alloy_genesis::{ChainConfig, Genesis};
use reth_ethereum_forks::{EthereumHardfork, ForkHash, ForkId};
use reth_ethereum_forks::EthereumHardfork;
use reth_scroll_forks::ScrollHardfork;

#[test]
// #[test]
// fn scroll_mainnet_forkids() {
// let scroll_mainnet = ScrollChainSpecBuilder::scroll_mainnet().build();
// let _ =
Expand Down Expand Up @@ -453,25 +453,23 @@ mod tests {
// // <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()
)
}

#[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()
)
}

// #[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()
// )
// }
//
// #[test]
// fn latest_scroll_mainnet_fork_id_with_builder() {
// let scroll_mainnet = ScrollChainSpecBuilder::scroll_mainnet().build();
// assert_eq!(
// ForkId { hash: ForkHash([0xbc, 0x38, 0xf9, 0xca]), next: 0 },
// scroll_mainnet.latest_fork_id()
// )
// }
#[test]
fn is_bernoulli_active() {
let scroll_mainnet = ScrollChainSpecBuilder::scroll_mainnet().build();
Expand Down
40 changes: 16 additions & 24 deletions crates/scroll/hardforks/src/hardfork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ hardfork!(
/// When building a list of hardforks for a chain, it's still expected to mix with
/// [`EthereumHardfork`].
ScrollHardfork {
/// EIP150 HF block (nil = no fork)
EIP150Block,
/// EIP155 HF block
EIP155Block,
/// EIP158 HF block
EIP158Block,
/// Archimedes switch block (nil = no fork, 0 = already on archimedes)
Archimedes,
/// Bernoulli: <https://scroll.io/blog/blobs-are-here-scrolls-bernoulli-upgrade>.
Expand Down Expand Up @@ -69,6 +63,8 @@ impl ScrollHardfork {
fork,
|fork| match fork {
EthereumHardfork::Homestead |
EthereumHardfork::Tangerine |
EthereumHardfork::SpuriousDragon |
EthereumHardfork::Byzantium |
EthereumHardfork::Constantinople |
EthereumHardfork::Petersburg |
Expand All @@ -79,9 +75,7 @@ impl ScrollHardfork {
_ => None,
},
|fork| match fork {
Self::EIP150Block | Self::EIP155Block | Self::EIP158Block | Self::Archimedes => {
Some(0)
}
Self::Archimedes => Some(0),
Self::Bernoulli => Some(3747132),
Self::Curie => Some(4740239),
Self::Darwin => Some(6075509),
Expand All @@ -96,6 +90,8 @@ impl ScrollHardfork {
fork,
|fork| match fork {
EthereumHardfork::Homestead |
EthereumHardfork::Tangerine |
EthereumHardfork::SpuriousDragon |
EthereumHardfork::Byzantium |
EthereumHardfork::Constantinople |
EthereumHardfork::Petersburg |
Expand All @@ -106,9 +102,7 @@ impl ScrollHardfork {
_ => None,
},
|fork| match fork {
Self::EIP150Block | Self::EIP155Block | Self::EIP158Block | Self::Archimedes => {
Some(0)
}
Self::Archimedes => Some(0),
Self::Bernoulli => Some(3747132),
Self::Curie => Some(4740239),
Self::Darwin => Some(6075509),
Expand All @@ -123,6 +117,8 @@ impl ScrollHardfork {
fork,
|fork| match fork {
EthereumHardfork::Homestead |
EthereumHardfork::Tangerine |
EthereumHardfork::SpuriousDragon |
EthereumHardfork::Byzantium |
EthereumHardfork::Constantinople |
EthereumHardfork::Petersburg |
Expand All @@ -133,9 +129,7 @@ impl ScrollHardfork {
_ => None,
},
|fork| match fork {
Self::EIP150Block | Self::EIP155Block | Self::EIP158Block | Self::Archimedes => {
Some(0)
}
Self::Archimedes => Some(0),
Self::Bernoulli => Some(1713175866),
Self::Curie => Some(1718616171),
Self::Darwin => Some(1723622400),
Expand All @@ -150,6 +144,8 @@ impl ScrollHardfork {
fork,
|fork| match fork {
EthereumHardfork::Homestead |
EthereumHardfork::Tangerine |
EthereumHardfork::SpuriousDragon |
EthereumHardfork::Byzantium |
EthereumHardfork::Constantinople |
EthereumHardfork::Petersburg |
Expand All @@ -160,9 +156,7 @@ impl ScrollHardfork {
_ => None,
},
|fork| match fork {
Self::EIP150Block | Self::EIP155Block | Self::EIP158Block | Self::Archimedes => {
Some(0)
}
Self::Archimedes => Some(0),
Self::Bernoulli => Some(1714358352),
Self::Curie => Some(1719994277),
Self::Darwin => Some(1724227200),
Expand All @@ -176,9 +170,8 @@ impl ScrollHardfork {
ChainHardforks::new(vec![
(EthereumHardfork::Homestead.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::Dao.boxed(), ForkCondition::Never),
(Self::EIP150Block.boxed(), ForkCondition::Block(0)),
(Self::EIP155Block.boxed(), ForkCondition::Block(0)),
(Self::EIP158Block.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::Tangerine.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::SpuriousDragon.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::Byzantium.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::Constantinople.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::Petersburg.boxed(), ForkCondition::Block(0)),
Expand All @@ -200,9 +193,8 @@ impl ScrollHardfork {
pub fn scroll_sepolia() -> ChainHardforks {
ChainHardforks::new(vec![
(EthereumHardfork::Homestead.boxed(), ForkCondition::Block(0)),
(Self::EIP150Block.boxed(), ForkCondition::Block(0)),
(Self::EIP155Block.boxed(), ForkCondition::Block(0)),
(Self::EIP158Block.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::Tangerine.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::SpuriousDragon.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::Byzantium.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::Constantinople.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::Petersburg.boxed(), ForkCondition::Block(0)),
Expand Down

0 comments on commit 5aea8e8

Please sign in to comment.