qol: purge goerli (#9310)

This commit is contained in:
Roman Krasiuk
2024-07-05 03:38:58 -07:00
committed by GitHub
parent 21a9dfc9ec
commit 26b7b9720c
37 changed files with 52 additions and 368 deletions

2
book/cli/reth.md vendored
View File

@ -28,7 +28,7 @@ Options:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -18,7 +18,7 @@ Options:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

2
book/cli/reth/db.md vendored
View File

@ -56,7 +56,7 @@ Datadir:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -20,7 +20,7 @@ Options:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -12,7 +12,7 @@ Options:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -44,7 +44,7 @@ Datadir:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -44,7 +44,7 @@ Datadir:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -44,7 +44,7 @@ Datadir:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -15,7 +15,7 @@ Options:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -20,7 +20,7 @@ Options:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -44,7 +44,7 @@ Datadir:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -16,7 +16,7 @@ Options:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -44,7 +44,7 @@ Datadir:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -19,7 +19,7 @@ Options:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -44,7 +44,7 @@ Datadir:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -51,7 +51,7 @@ Datadir:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -44,7 +44,7 @@ Datadir:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -49,7 +49,7 @@ Datadir:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -16,7 +16,7 @@ Options:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -16,7 +16,7 @@ Options:
Possible values are either a built-in chain or the path to a chain specification file.
Built-in chains:
mainnet, sepolia, goerli, holesky, dev
mainnet, sepolia, holesky, dev
[default: mainnet]

View File

@ -13,7 +13,7 @@ pub use alloy_chains::{Chain, ChainKind, NamedChain};
pub use info::ChainInfo;
pub use spec::{
BaseFeeParams, BaseFeeParamsKind, ChainSpec, ChainSpecBuilder, DepositContract,
ForkBaseFeeParams, DEV, GOERLI, HOLESKY, MAINNET, SEPOLIA,
ForkBaseFeeParams, DEV, HOLESKY, MAINNET, SEPOLIA,
};
#[cfg(feature = "optimism")]
pub use spec::{BASE_MAINNET, BASE_SEPOLIA, OP_MAINNET, OP_SEPOLIA};
@ -50,8 +50,8 @@ mod tests {
#[test]
fn test_named_id() {
let chain = Chain::from_named(NamedChain::Goerli);
assert_eq!(chain.id(), 5);
let chain = Chain::from_named(NamedChain::Holesky);
assert_eq!(chain.id(), 17000);
}
#[test]
@ -77,9 +77,9 @@ mod tests {
#[test]
fn test_into_u256() {
let chain = Chain::from_named(NamedChain::Goerli);
let chain = Chain::from_named(NamedChain::Holesky);
let n: U256 = U256::from(chain.id());
let expected = U256::from(5);
let expected = U256::from(17000);
assert_eq!(n, expected);
}

View File

@ -29,8 +29,8 @@ pub use alloy_eips::eip1559::BaseFeeParams;
#[cfg(feature = "optimism")]
use reth_ethereum_forks::OptimismHardfork;
use reth_network_peers::{
base_nodes, base_testnet_nodes, goerli_nodes, holesky_nodes, mainnet_nodes, op_nodes,
op_testnet_nodes, sepolia_nodes,
base_nodes, base_testnet_nodes, holesky_nodes, mainnet_nodes, op_nodes, op_testnet_nodes,
sepolia_nodes,
};
/// The Ethereum mainnet spec
@ -60,30 +60,6 @@ pub static MAINNET: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
.into()
});
/// The Goerli spec
pub static GOERLI: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
ChainSpec {
chain: Chain::goerli(),
genesis: serde_json::from_str(include_str!("../res/genesis/goerli.json"))
.expect("Can't deserialize Goerli genesis json"),
genesis_hash: Some(b256!(
"bf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a"
)),
// <https://goerli.etherscan.io/block/7382818>
paris_block_and_final_difficulty: Some((7382818, U256::from(10_790_000))),
hardforks: EthereumHardfork::goerli().into(),
// https://goerli.etherscan.io/tx/0xa3c07dc59bfdb1bfc2d50920fed2ef2c1c4e0a09fe2325dbc14e07702f965a78
deposit_contract: Some(DepositContract::new(
address!("ff50ed3d0ec03ac01d4c79aad74928bff48a7b2b"),
4367322,
b256!("649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"),
)),
base_fee_params: BaseFeeParamsKind::Constant(BaseFeeParams::ethereum()),
prune_delete_limit: 1700,
}
.into()
});
/// The Sepolia spec
pub static SEPOLIA: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
ChainSpec {
@ -709,7 +685,6 @@ impl ChainSpec {
let chain = self.chain;
match chain.try_into().ok()? {
C::Mainnet => Some(mainnet_nodes()),
C::Goerli => Some(goerli_nodes()),
C::Sepolia => Some(sepolia_nodes()),
C::Holesky => Some(holesky_nodes()),
C::Base => Some(base_nodes()),
@ -1443,63 +1418,6 @@ Post-merge hard forks (timestamp based):
);
}
#[test]
fn goerli_hardfork_fork_ids() {
test_hardfork_fork_ids(
&GOERLI,
&[
(
EthereumHardfork::Frontier,
ForkId { hash: ForkHash([0xa3, 0xf5, 0xab, 0x08]), next: 1561651 },
),
(
EthereumHardfork::Homestead,
ForkId { hash: ForkHash([0xa3, 0xf5, 0xab, 0x08]), next: 1561651 },
),
(
EthereumHardfork::Tangerine,
ForkId { hash: ForkHash([0xa3, 0xf5, 0xab, 0x08]), next: 1561651 },
),
(
EthereumHardfork::SpuriousDragon,
ForkId { hash: ForkHash([0xa3, 0xf5, 0xab, 0x08]), next: 1561651 },
),
(
EthereumHardfork::Byzantium,
ForkId { hash: ForkHash([0xa3, 0xf5, 0xab, 0x08]), next: 1561651 },
),
(
EthereumHardfork::Constantinople,
ForkId { hash: ForkHash([0xa3, 0xf5, 0xab, 0x08]), next: 1561651 },
),
(
EthereumHardfork::Petersburg,
ForkId { hash: ForkHash([0xa3, 0xf5, 0xab, 0x08]), next: 1561651 },
),
(
EthereumHardfork::Istanbul,
ForkId { hash: ForkHash([0xc2, 0x5e, 0xfa, 0x5c]), next: 4460644 },
),
(
EthereumHardfork::Berlin,
ForkId { hash: ForkHash([0x75, 0x7a, 0x1c, 0x47]), next: 5062605 },
),
(
EthereumHardfork::London,
ForkId { hash: ForkHash([0xb8, 0xc6, 0x29, 0x9d]), next: 1678832736 },
),
(
EthereumHardfork::Shanghai,
ForkId { hash: ForkHash([0xf9, 0x84, 0x3a, 0xbf]), next: 1705473120 },
),
(
EthereumHardfork::Cancun,
ForkId { hash: ForkHash([0x70, 0xcc, 0x14, 0xe2]), next: 0 },
),
],
);
}
#[test]
fn sepolia_hardfork_fork_ids() {
test_hardfork_fork_ids(
@ -1675,63 +1593,6 @@ Post-merge hard forks (timestamp based):
)
}
#[test]
fn goerli_forkids() {
test_fork_ids(
&GOERLI,
&[
(
Head { number: 0, ..Default::default() },
ForkId { hash: ForkHash([0xa3, 0xf5, 0xab, 0x08]), next: 1561651 },
),
(
Head { number: 1561650, ..Default::default() },
ForkId { hash: ForkHash([0xa3, 0xf5, 0xab, 0x08]), next: 1561651 },
),
(
Head { number: 1561651, ..Default::default() },
ForkId { hash: ForkHash([0xc2, 0x5e, 0xfa, 0x5c]), next: 4460644 },
),
(
Head { number: 4460643, ..Default::default() },
ForkId { hash: ForkHash([0xc2, 0x5e, 0xfa, 0x5c]), next: 4460644 },
),
(
Head { number: 4460644, ..Default::default() },
ForkId { hash: ForkHash([0x75, 0x7a, 0x1c, 0x47]), next: 5062605 },
),
(
Head { number: 5062605, ..Default::default() },
ForkId { hash: ForkHash([0xb8, 0xc6, 0x29, 0x9d]), next: 1678832736 },
),
(
Head { number: 6000000, timestamp: 1678832735, ..Default::default() },
ForkId { hash: ForkHash([0xb8, 0xc6, 0x29, 0x9d]), next: 1678832736 },
),
// First Shanghai block
(
Head { number: 6000001, timestamp: 1678832736, ..Default::default() },
ForkId { hash: ForkHash([0xf9, 0x84, 0x3a, 0xbf]), next: 1705473120 },
),
// Future Shanghai block
(
Head { number: 6500002, timestamp: 1678832736, ..Default::default() },
ForkId { hash: ForkHash([0xf9, 0x84, 0x3a, 0xbf]), next: 1705473120 },
),
// First Cancun block
(
Head { number: 6500003, timestamp: 1705473120, ..Default::default() },
ForkId { hash: ForkHash([0x70, 0xcc, 0x14, 0xe2]), next: 0 },
),
// Future Cancun block
(
Head { number: 6500003, timestamp: 2705473120, ..Default::default() },
ForkId { hash: ForkHash([0x70, 0xcc, 0x14, 0xe2]), next: 0 },
),
],
);
}
#[test]
fn sepolia_forkids() {
test_fork_ids(

View File

@ -1,4 +1,4 @@
use reth_chainspec::{Chain, ChainSpec, EthereumHardfork};
use reth_chainspec::{ChainSpec, EthereumHardfork};
use reth_primitives::{constants::ETH_TO_WEI, BlockNumber, U256};
/// Calculates the base block reward.
@ -26,9 +26,7 @@ pub fn base_block_reward(
block_difficulty: U256,
total_difficulty: U256,
) -> Option<u128> {
if chain_spec.fork(EthereumHardfork::Paris).active_at_ttd(total_difficulty, block_difficulty) ||
chain_spec.chain == Chain::goerli()
{
if chain_spec.fork(EthereumHardfork::Paris).active_at_ttd(total_difficulty, block_difficulty) {
None
} else {
Some(base_block_reward_pre_merge(chain_spec, block_number))

View File

@ -358,29 +358,6 @@ impl EthereumHardfork {
]
}
/// Ethereum goerli list of hardforks.
pub const fn goerli() -> [(Self, ForkCondition); 14] {
[
(Self::Frontier, ForkCondition::Block(0)),
(Self::Homestead, ForkCondition::Block(0)),
(Self::Dao, ForkCondition::Block(0)),
(Self::Tangerine, ForkCondition::Block(0)),
(Self::SpuriousDragon, ForkCondition::Block(0)),
(Self::Byzantium, ForkCondition::Block(0)),
(Self::Constantinople, ForkCondition::Block(0)),
(Self::Petersburg, ForkCondition::Block(0)),
(Self::Istanbul, ForkCondition::Block(1561651)),
(Self::Berlin, ForkCondition::Block(4460644)),
(Self::London, ForkCondition::Block(5062605)),
(
Self::Paris,
ForkCondition::TTD { fork_block: None, total_difficulty: uint!(10_790_000_U256) },
),
(Self::Shanghai, ForkCondition::Timestamp(1678832736)),
(Self::Cancun, ForkCondition::Timestamp(1705473120)),
]
}
/// Ethereum sepolia list of hardforks.
pub const fn sepolia() -> [(Self, ForkCondition); 15] {
[

View File

@ -8,7 +8,7 @@
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
use reth_chainspec::{Chain, ChainSpec, EthereumHardfork, EthereumHardforks};
use reth_chainspec::{ChainSpec, EthereumHardfork, EthereumHardforks};
use reth_consensus::{Consensus, ConsensusError, PostExecutionInput};
use reth_consensus_common::validation::{
validate_4844_header_standalone, validate_against_parent_4844,
@ -198,10 +198,9 @@ impl Consensus for EthBeaconConsensus {
})
}
// Goerli and early OP exception:
// * If the network is goerli pre-merge, ignore the extradata check, since we do not
// support clique. Same goes for OP blocks below Bedrock.
if self.chain_spec.chain != Chain::goerli() && !self.chain_spec.is_optimism() {
// Early OP exception:
// * If the network is pre-Bedrock OP, ignore the extradata check.
if !self.chain_spec.is_optimism() {
validate_header_extradata(header)?;
}
}

View File

@ -15,9 +15,7 @@ extern crate alloc;
use core::ops::Deref;
use reth_chainspec::ChainSpec;
use reth_primitives::{
header::block_coinbase, Address, Header, TransactionSigned, TransactionSignedEcRecovered, U256,
};
use reth_primitives::{Address, Header, TransactionSigned, TransactionSignedEcRecovered, U256};
use revm::{inspector_handle_register, Database, Evm, EvmBuilder, GetInspector};
use revm_primitives::{
BlockEnv, Bytes, CfgEnvWithHandlerCfg, Env, EnvWithHandlerCfg, SpecId, TxEnv,
@ -139,27 +137,9 @@ pub trait ConfigureEvmEnv: Send + Sync + Unpin + Clone + 'static {
);
/// Fill [`BlockEnv`] field according to the chain spec and given header
fn fill_block_env(
&self,
block_env: &mut BlockEnv,
chain_spec: &ChainSpec,
header: &Header,
after_merge: bool,
) {
let coinbase = block_coinbase(chain_spec, header, after_merge);
self.fill_block_env_with_coinbase(block_env, header, after_merge, coinbase);
}
/// Fill block environment with coinbase.
fn fill_block_env_with_coinbase(
&self,
block_env: &mut BlockEnv,
header: &Header,
after_merge: bool,
coinbase: Address,
) {
fn fill_block_env(&self, block_env: &mut BlockEnv, header: &Header, after_merge: bool) {
block_env.number = U256::from(header.number);
block_env.coinbase = coinbase;
block_env.coinbase = header.beneficiary;
block_env.timestamp = U256::from(header.timestamp);
if after_merge {
block_env.prevrandao = Some(header.mix_hash);
@ -189,11 +169,6 @@ pub trait ConfigureEvmEnv: Send + Sync + Unpin + Clone + 'static {
) {
self.fill_cfg_env(cfg, chain_spec, header, total_difficulty);
let after_merge = cfg.handler_cfg.spec_id >= SpecId::MERGE;
self.fill_block_env_with_coinbase(
block_env,
header,
after_merge,
block_coinbase(chain_spec, header, after_merge),
);
self.fill_block_env(block_env, header, after_merge);
}
}

View File

@ -17,22 +17,6 @@ pub static SEPOLIA_BOOTNODES : [&str; 5] = [
"enode://9e9492e2e8836114cc75f5b929784f4f46c324ad01daf87d956f98b3b6c5fcba95524d6e5cf9861dc96a2c8a171ea7105bb554a197455058de185fa870970c7c@138.68.123.152:30303", // sepolia-bootnode-1-ams3
];
/// Görli Bootnodes
pub static GOERLI_BOOTNODES : [&str; 7] = [
// Upstream bootnodes
"enode://011f758e6552d105183b1761c5e2dea0111bc20fd5f6422bc7f91e0fabbec9a6595caf6239b37feb773dddd3f87240d99d859431891e4a642cf2a0a9e6cbb98a@51.141.78.53:30303",
"enode://176b9417f511d05b6b2cf3e34b756cf0a7096b3094572a8f6ef4cdcb9d1f9d00683bf0f83347eebdf3b81c3521c2332086d9592802230bf528eaf606a1d9677b@13.93.54.137:30303",
"enode://46add44b9f13965f7b9875ac6b85f016f341012d84f975377573800a863526f4da19ae2c620ec73d11591fa9510e992ecc03ad0751f53cc02f7c7ed6d55c7291@94.237.54.114:30313",
"enode://b5948a2d3e9d486c4d75bf32713221c2bd6cf86463302339299bd227dc2e276cd5a1c7ca4f43a0e9122fe9af884efed563bd2a1fd28661f3b5f5ad7bf1de5949@18.218.250.66:30303",
// Ethereum Foundation bootnode
"enode://a61215641fb8714a373c80edbfa0ea8878243193f57c96eeb44d0bc019ef295abd4e044fd619bfc4c59731a73fb79afe84e9ab6da0c743ceb479cbb6d263fa91@3.11.147.67:30303",
// Goerli Initiative bootnodes
"enode://d4f764a48ec2a8ecf883735776fdefe0a3949eb0ca476bd7bc8d0954a9defe8fea15ae5da7d40b5d2d59ce9524a99daedadf6da6283fca492cc80b53689fb3b3@46.4.99.122:32109",
"enode://d2b720352e8216c9efc470091aa91ddafc53e222b32780f505c817ceef69e01d5b0b0797b69db254c586f493872352f5a022b4d8479a00fc92ec55f9ad46a27e@88.99.70.182:30303",
];
/// Ethereum Foundation Holesky Bootnodes
pub static HOLESKY_BOOTNODES : [&str; 2] = [
"enode://ac906289e4b7f12df423d654c5a962b6ebe5b3a74cc9e06292a85221f9a64a6f1cfdd6b714ed6dacef51578f92b34c60ee91e9ede9c7f8fadc4d347326d95e2b@146.190.13.128:30303",

View File

@ -13,11 +13,6 @@ pub fn mainnet_nodes() -> Vec<NodeRecord> {
parse_nodes(&MAINNET_BOOTNODES[..])
}
/// Returns parsed goerli nodes
pub fn goerli_nodes() -> Vec<NodeRecord> {
parse_nodes(&GOERLI_BOOTNODES[..])
}
/// Returns parsed sepolia nodes
pub fn sepolia_nodes() -> Vec<NodeRecord> {
parse_nodes(&SEPOLIA_BOOTNODES[..])

View File

@ -11,14 +11,14 @@ use reth_chainspec::DEV;
use reth_chainspec::{BASE_MAINNET, BASE_SEPOLIA, OP_MAINNET, OP_SEPOLIA};
#[cfg(not(feature = "optimism"))]
use reth_chainspec::{GOERLI, HOLESKY, MAINNET, SEPOLIA};
use reth_chainspec::{HOLESKY, MAINNET, SEPOLIA};
#[cfg(feature = "optimism")]
/// Chains supported by op-reth. First value should be used as the default.
pub const SUPPORTED_CHAINS: &[&str] = &["optimism", "optimism-sepolia", "base", "base-sepolia"];
#[cfg(not(feature = "optimism"))]
/// Chains supported by reth. First value should be used as the default.
pub const SUPPORTED_CHAINS: &[&str] = &["mainnet", "sepolia", "goerli", "holesky", "dev"];
pub const SUPPORTED_CHAINS: &[&str] = &["mainnet", "sepolia", "holesky", "dev"];
/// The help info for the --chain flag
pub fn chain_help() -> String {
@ -34,8 +34,6 @@ pub fn chain_value_parser(s: &str) -> eyre::Result<Arc<ChainSpec>, eyre::Error>
#[cfg(not(feature = "optimism"))]
"mainnet" => MAINNET.clone(),
#[cfg(not(feature = "optimism"))]
"goerli" => GOERLI.clone(),
#[cfg(not(feature = "optimism"))]
"sepolia" => SEPOLIA.clone(),
#[cfg(not(feature = "optimism"))]
"holesky" => HOLESKY.clone(),

View File

@ -259,10 +259,10 @@ impl<D> From<PathBuf> for MaybePlatformPath<D> {
/// Wrapper type around `PlatformPath` that includes a `Chain`, used for separating reth data for
/// different networks.
///
/// If the chain is either mainnet, goerli, or sepolia, then the path will be:
/// If the chain is either mainnet, sepolia, or holesky, then the path will be:
/// * mainnet: `<DIR>/mainnet`
/// * goerli: `<DIR>/goerli`
/// * sepolia: `<DIR>/sepolia`
/// * holesky: `<DIR>/holesky`
///
/// Otherwise, the path will be dependent on the chain ID:
/// * `<DIR>/<CHAIN_ID>`
@ -383,10 +383,6 @@ mod tests {
#[test]
fn test_maybe_testnet_datadir_path() {
let path = MaybePlatformPath::<DataDirPath>::default();
let path = path.unwrap_or_chain_default(Chain::goerli(), DatadirArgs::default());
assert!(path.as_ref().ends_with("reth/goerli"), "{path:?}");
let path = MaybePlatformPath::<DataDirPath>::default();
let path = path.unwrap_or_chain_default(Chain::holesky(), DatadirArgs::default());
assert!(path.as_ref().ends_with("reth/holesky"), "{path:?}");

View File

@ -104,10 +104,6 @@ pub const ETH_TO_WEI: u128 = FINNEY_TO_WEI * 1000;
pub const MAINNET_GENESIS_HASH: B256 =
b256!("d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3");
/// Goerli genesis hash: `0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a`
pub const GOERLI_GENESIS_HASH: B256 =
b256!("bf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a");
/// Sepolia genesis hash: `0x25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9`
pub const SEPOLIA_GENESIS_HASH: B256 =
b256!("25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9");

View File

@ -18,8 +18,8 @@ reth-codecs.workspace = true
reth-ethereum-forks.workspace = true
reth-static-file-types.workspace = true
reth-trie-common.workspace = true
reth-chainspec.workspace = true
revm-primitives = { workspace = true, features = ["serde"] }
reth-chainspec = { workspace = true, optional = true }
# ethereum
alloy-primitives = { workspace = true, features = ["rand", "rlp"] }
@ -57,6 +57,7 @@ proptest = { workspace = true, optional = true }
# eth
reth-primitives-traits = { workspace = true, features = ["arbitrary"] }
revm-primitives = { workspace = true, features = ["arbitrary"] }
reth-chainspec.workspace = true
nybbles = { workspace = true, features = ["arbitrary"] }
alloy-trie = { workspace = true, features = ["arbitrary"] }
alloy-eips = { workspace = true, features = ["arbitrary"] }
@ -88,7 +89,7 @@ asm-keccak = ["alloy-primitives/asm-keccak"]
arbitrary = [
"reth-primitives-traits/arbitrary",
"revm-primitives/arbitrary",
"reth-chainspec/arbitrary",
"reth-chainspec?/arbitrary",
"reth-ethereum-forks/arbitrary",
"nybbles/arbitrary",
"alloy-trie/arbitrary",

View File

@ -1,71 +1,12 @@
//! Header types.
use crate::{recover_signer_unchecked, Address, Bytes};
use alloy_rlp::{Decodable, Encodable};
use bytes::BufMut;
use reth_chainspec::{Chain, ChainSpec};
use reth_codecs::derive_arbitrary;
use serde::{Deserialize, Serialize};
pub use reth_primitives_traits::{Header, HeaderError, SealedHeader};
/// Return the coinbase address for the given header and chain spec.
pub fn block_coinbase(chain_spec: &ChainSpec, header: &Header, after_merge: bool) -> Address {
// Clique consensus fills the EXTRA_SEAL (last 65 bytes) of the extra data with the
// signer's signature.
//
// On the genesis block, the extra data is filled with zeros, so we should not attempt to
// recover the signer on the genesis block.
//
// From EIP-225:
//
// * `EXTRA_SEAL`: Fixed number of extra-data suffix bytes reserved for signer seal.
// * 65 bytes fixed as signatures are based on the standard `secp256k1` curve.
// * Filled with zeros on genesis block.
if chain_spec.chain == Chain::goerli() && !after_merge && header.number > 0 {
recover_header_signer(header).unwrap_or_else(|err| {
panic!(
"Failed to recover goerli Clique Consensus signer from header ({}, {}) using extradata {}: {:?}",
header.number, header.hash_slow(), header.extra_data, err
)
})
} else {
header.beneficiary
}
}
/// Error type for recovering Clique signer from a header.
#[derive(Debug, thiserror_no_std::Error)]
pub enum CliqueSignerRecoveryError {
/// Header extradata is too short.
#[error("Invalid extra data length")]
InvalidExtraData,
/// Recovery failed.
#[error("Invalid signature: {0}")]
InvalidSignature(#[from] secp256k1::Error),
}
/// Recover the account from signed header per clique consensus rules.
pub fn recover_header_signer(header: &Header) -> Result<Address, CliqueSignerRecoveryError> {
let extra_data_len = header.extra_data.len();
// Fixed number of extra-data suffix bytes reserved for signer signature.
// 65 bytes fixed as signatures are based on the standard secp256k1 curve.
// Filled with zeros on genesis block.
let signature_start_byte = extra_data_len - 65;
let signature: [u8; 65] = header.extra_data[signature_start_byte..]
.try_into()
.map_err(|_| CliqueSignerRecoveryError::InvalidExtraData)?;
let seal_hash = {
let mut header_to_seal = header.clone();
header_to_seal.extra_data = Bytes::from(header.extra_data[..signature_start_byte].to_vec());
header_to_seal.hash_slow()
};
// TODO: this is currently unchecked recovery, does this need to be checked w.r.t EIP-2?
recover_signer_unchecked(&signature, &seal_hash.0)
.map_err(CliqueSignerRecoveryError::InvalidSignature)
}
/// Represents the direction for a headers request depending on the `reverse` field of the request.
/// > The response must contain a number of block headers, of rising number when reverse is 0,
/// > falling when 1
@ -147,9 +88,7 @@ impl From<HeadersDirection> for bool {
#[cfg(test)]
mod tests {
use super::*;
use crate::{
address, b256, bloom, bytes, hex, Address, Bytes, Header, HeadersDirection, B256, U256,
};
use crate::{address, b256, bloom, bytes, hex, Address, Bytes, B256, U256};
use alloy_rlp::{Decodable, Encodable};
use std::str::FromStr;
@ -413,13 +352,4 @@ mod tests {
Header::decode(&mut data.as_slice())
.expect_err("blob_gas_used size should make this header decoding fail");
}
#[test]
fn test_recover_genesis_goerli_signer() {
// just ensures that `block_coinbase` does not panic on the genesis block
let chain_spec = reth_chainspec::GOERLI.clone();
let header = chain_spec.genesis_header();
let block_coinbase = block_coinbase(&chain_spec, &header, false);
assert_eq!(block_coinbase, header.beneficiary);
}
}

View File

@ -43,8 +43,8 @@ pub use block::{
#[cfg(feature = "zstd-codec")]
pub use compression::*;
pub use constants::{
DEV_GENESIS_HASH, EMPTY_OMMER_ROOT_HASH, GOERLI_GENESIS_HASH, HOLESKY_GENESIS_HASH,
KECCAK_EMPTY, MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH,
DEV_GENESIS_HASH, EMPTY_OMMER_ROOT_HASH, HOLESKY_GENESIS_HASH, KECCAK_EMPTY,
MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH,
};
pub use genesis::{ChainConfig, Genesis, GenesisAccount};
pub use header::{Header, HeadersDirection, SealedHeader};

View File

@ -140,7 +140,7 @@ mod tests {
use alloy_genesis::GenesisAccount;
use alloy_primitives::{b256, Address, LogData};
use alloy_rlp::Decodable;
use reth_chainspec::{GOERLI, HOLESKY, MAINNET, SEPOLIA};
use reth_chainspec::{HOLESKY, MAINNET, SEPOLIA};
use reth_trie_common::root::{state_root_ref_unhashed, state_root_unhashed};
use std::collections::HashMap;
@ -535,14 +535,6 @@ mod tests {
"mainnet state root mismatch"
);
let expected_goerli_state_root =
b256!("5d6cded585e73c4e322c30c2f782a336316f17dd85a4863b9d838d2d4b8b3008");
let calculated_goerli_state_root = state_root_ref_unhashed(&GOERLI.genesis.alloc);
assert_eq!(
expected_goerli_state_root, calculated_goerli_state_root,
"goerli state root mismatch"
);
let expected_sepolia_state_root =
b256!("5eb6e371a698b8d68f665192350ffcecbbbf322916f4b51bd79bb6887da3f494");
let calculated_sepolia_state_root = state_root_ref_unhashed(&SEPOLIA.genesis.alloc);

View File

@ -4,9 +4,7 @@
use futures::Future;
use reth_evm::ConfigureEvmEnv;
use reth_primitives::{Address, BlockId, Bytes, Header, B256, U256};
use reth_provider::{
BlockIdReader, ChainSpecProvider, StateProvider, StateProviderBox, StateProviderFactory,
};
use reth_provider::{BlockIdReader, StateProvider, StateProviderBox, StateProviderFactory};
use reth_rpc_eth_types::{
EthApiError, EthResult, EthStateCache, PendingBlockEnv, RpcInvalidTransactionError,
};
@ -207,12 +205,7 @@ pub trait LoadState {
let (cfg, mut block_env, _) = self.evm_env_at(header.parent_hash.into()).await?;
let after_merge = cfg.handler_cfg.spec_id >= SpecId::MERGE;
self.evm_config().fill_block_env(
&mut block_env,
&LoadPendingBlock::provider(self).chain_spec(),
header,
after_merge,
);
self.evm_config().fill_block_env(&mut block_env, header, after_merge);
Ok((cfg, block_env))
}

View File

@ -521,7 +521,7 @@ struct GenesisAccountWithAddress {
mod tests {
use super::*;
use alloy_genesis::Genesis;
use reth_chainspec::{Chain, GOERLI, HOLESKY, MAINNET, SEPOLIA};
use reth_chainspec::{Chain, HOLESKY, MAINNET, SEPOLIA};
use reth_db::DatabaseEnv;
use reth_db_api::{
cursor::DbCursorRO,
@ -529,9 +529,7 @@ mod tests {
table::{Table, TableRow},
transaction::DbTx,
};
use reth_primitives::{
GOERLI_GENESIS_HASH, HOLESKY_GENESIS_HASH, MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH,
};
use reth_primitives::{HOLESKY_GENESIS_HASH, MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH};
use reth_primitives_traits::IntegerList;
use reth_provider::test_utils::create_test_provider_factory_with_chain_spec;
@ -554,15 +552,6 @@ mod tests {
assert_eq!(genesis_hash, MAINNET_GENESIS_HASH);
}
#[test]
fn success_init_genesis_goerli() {
let genesis_hash =
init_genesis(create_test_provider_factory_with_chain_spec(GOERLI.clone())).unwrap();
// actual, expected
assert_eq!(genesis_hash, GOERLI_GENESIS_HASH);
}
#[test]
fn success_init_genesis_sepolia() {
let genesis_hash =