Skip to content

Commit

Permalink
answer comments
Browse files Browse the repository at this point in the history
Signed-off-by: Gregory Edison <[email protected]>
  • Loading branch information
greged93 committed Dec 10, 2024
1 parent a411b86 commit 2d78cc4
Show file tree
Hide file tree
Showing 6 changed files with 254 additions and 174 deletions.
41 changes: 41 additions & 0 deletions crates/scroll/chainspec/src/constants.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use crate::genesis::L1Config;
use alloy_primitives::{address, Address};

/// The transaction fee recipient on the L2.
pub const SCROLL_FEE_VAULT_ADDRESS: Address = address!("5300000000000000000000000000000000000005");

/// The L1 message queue address for Scroll mainnet.
/// <https://etherscan.io/address/0x0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B>.
pub const SCROLL_MAINNET_L1_MESSAGE_QUEUE_ADDRESS: Address =
address!("0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B");

/// The L1 proxy address for Scroll mainnet.
/// <https://etherscan.io/address/0xa13BAF47339d63B743e7Da8741db5456DAc1E556>.
pub const SCROLL_MAINNET_L1_PROXY_ADDRESS: Address =
address!("a13BAF47339d63B743e7Da8741db5456DAc1E556");

/// The L1 configuration for Scroll mainnet.
pub const SCROLL_MAINNET_L1_CONFIG: L1Config = L1Config {
l1_chain_id: 1,
l1_message_queue_address: SCROLL_MAINNET_L1_MESSAGE_QUEUE_ADDRESS,
scroll_chain_address: SCROLL_MAINNET_L1_PROXY_ADDRESS,
num_l1_messages_per_block: 10,
};

/// The L1 message queue address for Scroll sepolia.
/// <https://sepolia.etherscan.io/address/0xF0B2293F5D834eAe920c6974D50957A1732de763>.
pub const SCROLL_SEPOLIA_L1_MESSAGE_QUEUE_ADDRESS: Address =
address!("F0B2293F5D834eAe920c6974D50957A1732de763");

/// The L1 proxy address for Scroll sepolia.
/// <https://sepolia.etherscan.io/address/0x2D567EcE699Eabe5afCd141eDB7A4f2D0D6ce8a0>
pub const SCROLL_SEPOLIA_L1_PROXY_ADDRESS: Address =
address!("2D567EcE699Eabe5afCd141eDB7A4f2D0D6ce8a0");

/// The L1 configuration for Scroll sepolia.
pub const SCROLL_SEPOLIA_L1_CONFIG: L1Config = L1Config {
l1_chain_id: 11155111,
l1_message_queue_address: SCROLL_SEPOLIA_L1_MESSAGE_QUEUE_ADDRESS,
scroll_chain_address: SCROLL_SEPOLIA_L1_PROXY_ADDRESS,
num_l1_messages_per_block: 10,
};
27 changes: 7 additions & 20 deletions crates/scroll/chainspec/src/genesis.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! Scroll types for genesis data.
use crate::constants::{
SCROLL_FEE_VAULT_ADDRESS, SCROLL_MAINNET_L1_CONFIG, SCROLL_SEPOLIA_L1_CONFIG,
};
use alloy_primitives::{address, Address};
use alloy_serde::OtherFields;
use serde::de::Error;
Expand Down Expand Up @@ -80,15 +83,9 @@ pub struct L1Config {
pub l1_chain_id: u64,
/// The L1 contract address of the contract that handles the message queue targeting the Scroll
/// rollup.
///
/// Scroll mainnet l1 message queue address: <https://etherscan.io/address/0x0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B>.
/// Scroll sepolia l1 message queue address: <https://sepolia.etherscan.io/address/0xF0B2293F5D834eAe920c6974D50957A1732de763>.
pub l1_message_queue_address: Address,
/// The L1 contract address of the proxy contract which is responsible for Scroll rollup
/// settlement.
///
/// Scroll mainnet l1 chain proxy address: <https://etherscan.io/address/0xa13BAF47339d63B743e7Da8741db5456DAc1E556>.
/// Scroll sepolia l1 chain proxy address: <https://sepolia.etherscan.io/address/0x2D567EcE699Eabe5afCd141eDB7A4f2D0D6ce8a0>
pub scroll_chain_address: Address,
/// The maximum number of L1 messages to be consumed per L2 rollup block.
pub num_l1_messages_per_block: u64,
Expand Down Expand Up @@ -119,25 +116,15 @@ impl ScrollChainConfig {
/// Returns the [`ScrollChainConfig`] for Scroll Mainnet.
pub const fn mainnet() -> Self {
Self {
fee_vault_address: Some(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,
},
fee_vault_address: Some(SCROLL_FEE_VAULT_ADDRESS),
l1_config: SCROLL_MAINNET_L1_CONFIG,
}
}
/// Returns the [`ScrollChainConfig`] for Scroll Sepolia.
pub const fn sepolia() -> Self {
Self {
fee_vault_address: Some(address!("5300000000000000000000000000000000000005")),
l1_config: L1Config {
l1_chain_id: 11155111,
l1_message_queue_address: address!("F0B2293F5D834eAe920c6974D50957A1732de763"),
scroll_chain_address: address!("2D567EcE699Eabe5afCd141eDB7A4f2D0D6ce8a0"),
num_l1_messages_per_block: 10,
},
fee_vault_address: Some(SCROLL_FEE_VAULT_ADDRESS),
l1_config: SCROLL_SEPOLIA_L1_CONFIG,
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions crates/scroll/chainspec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ use std::sync::LazyLock;

extern crate alloc;

mod constants;
pub use constants::{
SCROLL_FEE_VAULT_ADDRESS, SCROLL_MAINNET_L1_CONFIG, SCROLL_MAINNET_L1_MESSAGE_QUEUE_ADDRESS,
SCROLL_MAINNET_L1_PROXY_ADDRESS, SCROLL_SEPOLIA_L1_CONFIG,
SCROLL_SEPOLIA_L1_MESSAGE_QUEUE_ADDRESS, SCROLL_SEPOLIA_L1_PROXY_ADDRESS,
};

mod dev;
pub use dev::SCROLL_DEV;

Expand Down
5 changes: 4 additions & 1 deletion crates/scroll/evm/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,13 @@ impl ConfigureEvmEnv for ScrollEvmConfig {

fn fill_block_env(&self, block_env: &mut BlockEnv, header: &Self::Header, after_merge: bool) {
block_env.number = U256::from(header.number);
block_env.coinbase = header.beneficiary;

if let Some(vault_address) = self.scroll_config.fee_vault_address {
block_env.coinbase = vault_address;
} else {
block_env.coinbase = header.beneficiary;
}

block_env.timestamp = U256::from(header.timestamp);
if after_merge {
block_env.prevrandao = Some(header.mix_hash);
Expand Down
15 changes: 1 addition & 14 deletions crates/scroll/evm/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ pub enum ScrollBlockExecutionError {
/// Error occurred at fork transition.
#[display("failed to apply fork: {_0}")]
Fork(ForkError),
/// Error occurred at L1 fee computation.
#[display("failed to compute l1 fee: {reason}")]
L1FeeComputation {
/// The reason for the fee computation error.
reason: &'static str,
},
}

impl From<ScrollBlockExecutionError> for BlockExecutionError {
Expand All @@ -21,18 +15,11 @@ impl From<ScrollBlockExecutionError> for BlockExecutionError {
}
}

impl ScrollBlockExecutionError {
/// Returns a [`ScrollBlockExecutionError`] with the `L1FeeComputation` variant.
pub const fn l1_fee(reason: &'static str) -> Self {
Self::L1FeeComputation { reason }
}
}

/// Scroll fork error.
#[derive(Debug, Display)]
pub enum ForkError {
/// Error occurred at Curie fork.
Curie,
Curie(String),
}

impl From<ForkError> for BlockExecutionError {
Expand Down
Loading

0 comments on commit 2d78cc4

Please sign in to comment.