Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 31 additions & 2 deletions crates/scroll/chainspec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)]

use alloc::{boxed::Box, vec::Vec};
use alloc::{boxed::Box, vec, vec::Vec};
use alloy_chains::Chain;
use alloy_consensus::Header;
use alloy_genesis::Genesis;
use alloy_primitives::{B256, U256};
use derive_more::{Constructor, Deref, From, Into};
use reth_chainspec::{
BaseFeeParams, ChainSpec, ChainSpecBuilder, DepositContract, EthChainSpec,
BaseFeeParams, BaseFeeParamsKind, ChainSpec, ChainSpecBuilder, DepositContract, EthChainSpec,
EthereumCapabilities, EthereumHardforks, ForkFilter, ForkId, Hardforks, Head,
};
use reth_ethereum_forks::{
ChainHardforks, EthereumHardfork, ForkCondition, ForkFilterKey, ForkHash, Hardfork,
};
use reth_network_peers::NodeRecord;
use reth_primitives_traits::SealedHeader;
use scroll_alloy_hardforks::{ScrollHardfork, ScrollHardforks};

use alloy_eips::eip7840::BlobParams;
Expand Down Expand Up @@ -184,6 +185,34 @@ impl ScrollChainSpecBuilder {
}
}

// Used by the CLI for custom genesis files.
impl ScrollChainSpec {
/// Build from a custom `Genesis`, ensuring:
/// - `genesis_header` has `base_fee_per_gas` (0 if Feynman@genesis)
/// - `base_fee_params` switch to Scroll defaults at Feynman
pub fn from_custom_genesis(genesis: Genesis) -> Self {
// Use the existing From<Genesis> as the base.
let mut spec: Self = genesis.into();

// Determine whether Feynman is active at genesis.
let feynman_active_at_genesis =
spec.is_feynman_active_at_timestamp(spec.inner.genesis.timestamp);

// Ensure the genesis header has a base fee when required.
let mut header = make_genesis_header(&spec.inner.genesis);
if header.base_fee_per_gas.is_none() && feynman_active_at_genesis {
header.base_fee_per_gas = Some(0);
}
spec.inner.genesis_header = SealedHeader::new_unhashed(header);

// Use Scroll's EIP-1559 params from Feynman onwards.
spec.inner.base_fee_params = BaseFeeParamsKind::Variable(
vec![(ScrollHardfork::Feynman.boxed(), SCROLL_BASE_FEE_PARAMS_FEYNMAN)].into(),
);
spec
}
}

/// Returns the chain configuration.
#[auto_impl::auto_impl(Arc)]
pub trait ChainConfig {
Expand Down
2 changes: 1 addition & 1 deletion crates/scroll/cli/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl ChainSpecParser for ScrollChainSpecParser {
"dev" => SCROLL_DEV.clone(),
"scroll-mainnet" => SCROLL_MAINNET.clone(),
"scroll-sepolia" => SCROLL_SEPOLIA.clone(),
_ => Arc::new(parse_genesis(s)?.into()),
_ => Arc::new(ScrollChainSpec::from_custom_genesis(parse_genesis(s)?)),
})
}
}
1 change: 0 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ exceptions = [
# TODO: decide on MPL-2.0 handling
# These dependencies are grandfathered in https://github.com/paradigmxyz/reth/pull/6980
{ allow = ["MPL-2.0"], name = "option-ext" },
{ allow = ["MPL-2.0"], name = "webpki-root-certs" },
]

# Skip the poseidon-bn254, bn254 and zktrie crates for license verification. We should at some point publish a license for them.
Expand Down
Loading