mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 00:58:11 -05:00
primitives: use alloy MAINNET_GENESIS_HASH constant (#11848)
This commit is contained in:
@@ -23,6 +23,7 @@ alloy-eips = { workspace = true, features = ["serde"] }
|
||||
alloy-genesis.workspace = true
|
||||
alloy-primitives = { workspace = true, features = ["rand", "rlp"] }
|
||||
alloy-trie.workspace = true
|
||||
alloy-consensus.workspace = true
|
||||
|
||||
# misc
|
||||
auto_impl.workspace = true
|
||||
|
||||
@@ -7,6 +7,7 @@ use alloy_primitives::{address, b256, Address, BlockNumber, B256, U256};
|
||||
use alloy_trie::EMPTY_ROOT_HASH;
|
||||
use derive_more::From;
|
||||
|
||||
use alloy_consensus::constants::MAINNET_GENESIS_HASH;
|
||||
use reth_ethereum_forks::{
|
||||
ChainHardforks, DisplayHardforks, EthereumHardfork, EthereumHardforks, ForkCondition,
|
||||
ForkFilter, ForkFilterKey, ForkHash, ForkId, Hardfork, Hardforks, Head, DEV_HARDFORKS,
|
||||
@@ -18,7 +19,7 @@ use reth_network_peers::{
|
||||
use reth_primitives_traits::{
|
||||
constants::{
|
||||
DEV_GENESIS_HASH, EIP1559_INITIAL_BASE_FEE, EMPTY_WITHDRAWALS, ETHEREUM_BLOCK_GAS_LIMIT,
|
||||
HOLESKY_GENESIS_HASH, MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH,
|
||||
HOLESKY_GENESIS_HASH, SEPOLIA_GENESIS_HASH,
|
||||
},
|
||||
Header, SealedHeader,
|
||||
};
|
||||
|
||||
@@ -36,6 +36,7 @@ auto_impl.workspace = true
|
||||
[dev-dependencies]
|
||||
arbitrary = { workspace = true, features = ["derive"] }
|
||||
proptest.workspace = true
|
||||
alloy-consensus.workspace = true
|
||||
|
||||
[features]
|
||||
default = ["std", "serde", "rustc-hash"]
|
||||
|
||||
@@ -446,15 +446,12 @@ impl Cache {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use alloy_primitives::b256;
|
||||
|
||||
const GENESIS_HASH: B256 =
|
||||
b256!("d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3");
|
||||
use alloy_consensus::constants::MAINNET_GENESIS_HASH;
|
||||
|
||||
// EIP test vectors.
|
||||
#[test]
|
||||
fn forkhash() {
|
||||
let mut fork_hash = ForkHash::from(GENESIS_HASH);
|
||||
let mut fork_hash = ForkHash::from(MAINNET_GENESIS_HASH);
|
||||
assert_eq!(fork_hash.0, hex!("fc64ec04"));
|
||||
|
||||
fork_hash += 1_150_000u64;
|
||||
@@ -468,7 +465,7 @@ mod tests {
|
||||
fn compatibility_check() {
|
||||
let mut filter = ForkFilter::new(
|
||||
Head { number: 0, ..Default::default() },
|
||||
GENESIS_HASH,
|
||||
MAINNET_GENESIS_HASH,
|
||||
0,
|
||||
vec![
|
||||
ForkFilterKey::Block(1_150_000),
|
||||
@@ -727,7 +724,7 @@ mod tests {
|
||||
|
||||
let mut fork_filter = ForkFilter::new(
|
||||
Head { number: 0, ..Default::default() },
|
||||
GENESIS_HASH,
|
||||
MAINNET_GENESIS_HASH,
|
||||
0,
|
||||
vec![ForkFilterKey::Block(b1), ForkFilterKey::Block(b2)],
|
||||
);
|
||||
|
||||
@@ -52,6 +52,7 @@ alloy-genesis.workspace = true
|
||||
tokio.workspace = true
|
||||
futures-util.workspace = true
|
||||
serde_json.workspace = true
|
||||
alloy-consensus.workspace = true
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use alloy_consensus::constants::MAINNET_GENESIS_HASH;
|
||||
use alloy_genesis::Genesis;
|
||||
use alloy_primitives::b256;
|
||||
use reth::{
|
||||
args::RpcServerArgs,
|
||||
builder::{NodeBuilder, NodeConfig, NodeHandle},
|
||||
@@ -75,13 +75,11 @@ async fn can_handle_blobs() -> eyre::Result<()> {
|
||||
.submit_payload(blob_payload, blob_attr, PayloadStatusEnum::Valid, versioned_hashes.clone())
|
||||
.await?;
|
||||
|
||||
let genesis_hash = b256!("d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3");
|
||||
|
||||
let (_, _) = tokio::join!(
|
||||
// send fcu with blob hash
|
||||
node.engine_api.update_forkchoice(genesis_hash, blob_block_hash),
|
||||
node.engine_api.update_forkchoice(MAINNET_GENESIS_HASH, blob_block_hash),
|
||||
// send fcu with normal hash
|
||||
node.engine_api.update_forkchoice(genesis_hash, payload.block().hash())
|
||||
node.engine_api.update_forkchoice(MAINNET_GENESIS_HASH, payload.block().hash())
|
||||
);
|
||||
|
||||
// submit normal payload
|
||||
|
||||
@@ -138,10 +138,10 @@ impl Default for Status {
|
||||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// use alloy_consensus::constants::MAINNET_GENESIS_HASH;
|
||||
/// use alloy_primitives::{B256, U256};
|
||||
/// use reth_chainspec::{Chain, EthereumHardfork, MAINNET};
|
||||
/// use reth_eth_wire_types::{EthVersion, Status};
|
||||
/// use reth_primitives::MAINNET_GENESIS_HASH;
|
||||
///
|
||||
/// // this is just an example status message!
|
||||
/// let status = Status::builder()
|
||||
@@ -216,6 +216,7 @@ impl StatusBuilder {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{EthVersion, Status};
|
||||
use alloy_consensus::constants::MAINNET_GENESIS_HASH;
|
||||
use alloy_genesis::Genesis;
|
||||
use alloy_primitives::{hex, B256, U256};
|
||||
use alloy_rlp::{Decodable, Encodable};
|
||||
@@ -235,10 +236,7 @@ mod tests {
|
||||
"feb27336ca7923f8fab3bd617fcb6e75841538f71c1bcfc267d7838489d9e13d",
|
||||
)
|
||||
.unwrap(),
|
||||
genesis: B256::from_str(
|
||||
"d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
|
||||
)
|
||||
.unwrap(),
|
||||
genesis: MAINNET_GENESIS_HASH,
|
||||
forkid: ForkId { hash: ForkHash([0xb7, 0x15, 0x07, 0x7d]), next: 0 },
|
||||
};
|
||||
|
||||
@@ -258,10 +256,7 @@ mod tests {
|
||||
"feb27336ca7923f8fab3bd617fcb6e75841538f71c1bcfc267d7838489d9e13d",
|
||||
)
|
||||
.unwrap(),
|
||||
genesis: B256::from_str(
|
||||
"d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
|
||||
)
|
||||
.unwrap(),
|
||||
genesis: MAINNET_GENESIS_HASH,
|
||||
forkid: ForkId { hash: ForkHash([0xb7, 0x15, 0x07, 0x7d]), next: 0 },
|
||||
};
|
||||
let status = Status::decode(&mut &data[..]).unwrap();
|
||||
|
||||
@@ -98,11 +98,6 @@ pub const FINNEY_TO_WEI: u128 = (GWEI_TO_WEI as u128) * 1_000_000;
|
||||
/// Multiplier for converting ether to wei.
|
||||
pub const ETH_TO_WEI: u128 = FINNEY_TO_WEI * 1000;
|
||||
|
||||
/// The Ethereum mainnet genesis hash:
|
||||
/// `0x0d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3`
|
||||
pub const MAINNET_GENESIS_HASH: B256 =
|
||||
b256!("d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3");
|
||||
|
||||
/// Sepolia genesis hash: `0x25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9`
|
||||
pub const SEPOLIA_GENESIS_HASH: B256 =
|
||||
b256!("25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9");
|
||||
|
||||
@@ -39,10 +39,7 @@ pub use block::{
|
||||
};
|
||||
#[cfg(feature = "reth-codec")]
|
||||
pub use compression::*;
|
||||
pub use constants::{
|
||||
DEV_GENESIS_HASH, HOLESKY_GENESIS_HASH, KECCAK_EMPTY, MAINNET_GENESIS_HASH,
|
||||
SEPOLIA_GENESIS_HASH,
|
||||
};
|
||||
pub use constants::{DEV_GENESIS_HASH, HOLESKY_GENESIS_HASH, KECCAK_EMPTY, SEPOLIA_GENESIS_HASH};
|
||||
pub use receipt::{
|
||||
gas_spent_by_transactions, Receipt, ReceiptWithBloom, ReceiptWithBloomRef, Receipts,
|
||||
};
|
||||
|
||||
@@ -42,6 +42,7 @@ tracing.workspace = true
|
||||
[dev-dependencies]
|
||||
reth-primitives-traits.workspace = true
|
||||
reth-provider = { workspace = true, features = ["test-utils"] }
|
||||
alloy-consensus.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -581,6 +581,7 @@ struct GenesisAccountWithAddress {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use alloy_consensus::constants::MAINNET_GENESIS_HASH;
|
||||
use alloy_genesis::Genesis;
|
||||
use reth_chainspec::{Chain, ChainSpec, HOLESKY, MAINNET, SEPOLIA};
|
||||
use reth_db::DatabaseEnv;
|
||||
@@ -591,7 +592,7 @@ mod tests {
|
||||
transaction::DbTx,
|
||||
Database,
|
||||
};
|
||||
use reth_primitives::{HOLESKY_GENESIS_HASH, MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH};
|
||||
use reth_primitives::{HOLESKY_GENESIS_HASH, SEPOLIA_GENESIS_HASH};
|
||||
use reth_primitives_traits::IntegerList;
|
||||
use reth_provider::{
|
||||
test_utils::{create_test_provider_factory_with_chain_spec, MockNodeTypesWithDB},
|
||||
|
||||
Reference in New Issue
Block a user