mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
primitives: use alloy MAINNET_GENESIS_HASH constant (#11848)
This commit is contained in:
5
Cargo.lock
generated
5
Cargo.lock
generated
@ -2857,6 +2857,7 @@ dependencies = [
|
|||||||
name = "example-manual-p2p"
|
name = "example-manual-p2p"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"alloy-consensus",
|
||||||
"eyre",
|
"eyre",
|
||||||
"futures",
|
"futures",
|
||||||
"reth-chainspec",
|
"reth-chainspec",
|
||||||
@ -6528,6 +6529,7 @@ name = "reth-chainspec"
|
|||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-chains",
|
"alloy-chains",
|
||||||
|
"alloy-consensus",
|
||||||
"alloy-eips",
|
"alloy-eips",
|
||||||
"alloy-genesis",
|
"alloy-genesis",
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
@ -6813,6 +6815,7 @@ dependencies = [
|
|||||||
name = "reth-db-common"
|
name = "reth-db-common"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"alloy-consensus",
|
||||||
"alloy-genesis",
|
"alloy-genesis",
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"boyer-moore-magiclen",
|
"boyer-moore-magiclen",
|
||||||
@ -7303,6 +7306,7 @@ name = "reth-ethereum-forks"
|
|||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-chains",
|
"alloy-chains",
|
||||||
|
"alloy-consensus",
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"alloy-rlp",
|
"alloy-rlp",
|
||||||
"arbitrary",
|
"arbitrary",
|
||||||
@ -7931,6 +7935,7 @@ dependencies = [
|
|||||||
name = "reth-node-ethereum"
|
name = "reth-node-ethereum"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"alloy-consensus",
|
||||||
"alloy-genesis",
|
"alloy-genesis",
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"eyre",
|
"eyre",
|
||||||
|
|||||||
@ -23,6 +23,7 @@ alloy-eips = { workspace = true, features = ["serde"] }
|
|||||||
alloy-genesis.workspace = true
|
alloy-genesis.workspace = true
|
||||||
alloy-primitives = { workspace = true, features = ["rand", "rlp"] }
|
alloy-primitives = { workspace = true, features = ["rand", "rlp"] }
|
||||||
alloy-trie.workspace = true
|
alloy-trie.workspace = true
|
||||||
|
alloy-consensus.workspace = true
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
auto_impl.workspace = true
|
auto_impl.workspace = true
|
||||||
|
|||||||
@ -7,6 +7,7 @@ use alloy_primitives::{address, b256, Address, BlockNumber, B256, U256};
|
|||||||
use alloy_trie::EMPTY_ROOT_HASH;
|
use alloy_trie::EMPTY_ROOT_HASH;
|
||||||
use derive_more::From;
|
use derive_more::From;
|
||||||
|
|
||||||
|
use alloy_consensus::constants::MAINNET_GENESIS_HASH;
|
||||||
use reth_ethereum_forks::{
|
use reth_ethereum_forks::{
|
||||||
ChainHardforks, DisplayHardforks, EthereumHardfork, EthereumHardforks, ForkCondition,
|
ChainHardforks, DisplayHardforks, EthereumHardfork, EthereumHardforks, ForkCondition,
|
||||||
ForkFilter, ForkFilterKey, ForkHash, ForkId, Hardfork, Hardforks, Head, DEV_HARDFORKS,
|
ForkFilter, ForkFilterKey, ForkHash, ForkId, Hardfork, Hardforks, Head, DEV_HARDFORKS,
|
||||||
@ -18,7 +19,7 @@ use reth_network_peers::{
|
|||||||
use reth_primitives_traits::{
|
use reth_primitives_traits::{
|
||||||
constants::{
|
constants::{
|
||||||
DEV_GENESIS_HASH, EIP1559_INITIAL_BASE_FEE, EMPTY_WITHDRAWALS, ETHEREUM_BLOCK_GAS_LIMIT,
|
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,
|
Header, SealedHeader,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -36,6 +36,7 @@ auto_impl.workspace = true
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
arbitrary = { workspace = true, features = ["derive"] }
|
arbitrary = { workspace = true, features = ["derive"] }
|
||||||
proptest.workspace = true
|
proptest.workspace = true
|
||||||
|
alloy-consensus.workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std", "serde", "rustc-hash"]
|
default = ["std", "serde", "rustc-hash"]
|
||||||
|
|||||||
@ -446,15 +446,12 @@ impl Cache {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use alloy_primitives::b256;
|
use alloy_consensus::constants::MAINNET_GENESIS_HASH;
|
||||||
|
|
||||||
const GENESIS_HASH: B256 =
|
|
||||||
b256!("d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3");
|
|
||||||
|
|
||||||
// EIP test vectors.
|
// EIP test vectors.
|
||||||
#[test]
|
#[test]
|
||||||
fn forkhash() {
|
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"));
|
assert_eq!(fork_hash.0, hex!("fc64ec04"));
|
||||||
|
|
||||||
fork_hash += 1_150_000u64;
|
fork_hash += 1_150_000u64;
|
||||||
@ -468,7 +465,7 @@ mod tests {
|
|||||||
fn compatibility_check() {
|
fn compatibility_check() {
|
||||||
let mut filter = ForkFilter::new(
|
let mut filter = ForkFilter::new(
|
||||||
Head { number: 0, ..Default::default() },
|
Head { number: 0, ..Default::default() },
|
||||||
GENESIS_HASH,
|
MAINNET_GENESIS_HASH,
|
||||||
0,
|
0,
|
||||||
vec![
|
vec![
|
||||||
ForkFilterKey::Block(1_150_000),
|
ForkFilterKey::Block(1_150_000),
|
||||||
@ -727,7 +724,7 @@ mod tests {
|
|||||||
|
|
||||||
let mut fork_filter = ForkFilter::new(
|
let mut fork_filter = ForkFilter::new(
|
||||||
Head { number: 0, ..Default::default() },
|
Head { number: 0, ..Default::default() },
|
||||||
GENESIS_HASH,
|
MAINNET_GENESIS_HASH,
|
||||||
0,
|
0,
|
||||||
vec![ForkFilterKey::Block(b1), ForkFilterKey::Block(b2)],
|
vec![ForkFilterKey::Block(b1), ForkFilterKey::Block(b2)],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -52,6 +52,7 @@ alloy-genesis.workspace = true
|
|||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
futures-util.workspace = true
|
futures-util.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
alloy-consensus.workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use alloy_consensus::constants::MAINNET_GENESIS_HASH;
|
||||||
use alloy_genesis::Genesis;
|
use alloy_genesis::Genesis;
|
||||||
use alloy_primitives::b256;
|
|
||||||
use reth::{
|
use reth::{
|
||||||
args::RpcServerArgs,
|
args::RpcServerArgs,
|
||||||
builder::{NodeBuilder, NodeConfig, NodeHandle},
|
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())
|
.submit_payload(blob_payload, blob_attr, PayloadStatusEnum::Valid, versioned_hashes.clone())
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let genesis_hash = b256!("d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3");
|
|
||||||
|
|
||||||
let (_, _) = tokio::join!(
|
let (_, _) = tokio::join!(
|
||||||
// send fcu with blob hash
|
// 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
|
// 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
|
// submit normal payload
|
||||||
|
|||||||
@ -138,10 +138,10 @@ impl Default for Status {
|
|||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```
|
/// ```
|
||||||
|
/// use alloy_consensus::constants::MAINNET_GENESIS_HASH;
|
||||||
/// use alloy_primitives::{B256, U256};
|
/// use alloy_primitives::{B256, U256};
|
||||||
/// use reth_chainspec::{Chain, EthereumHardfork, MAINNET};
|
/// use reth_chainspec::{Chain, EthereumHardfork, MAINNET};
|
||||||
/// use reth_eth_wire_types::{EthVersion, Status};
|
/// use reth_eth_wire_types::{EthVersion, Status};
|
||||||
/// use reth_primitives::MAINNET_GENESIS_HASH;
|
|
||||||
///
|
///
|
||||||
/// // this is just an example status message!
|
/// // this is just an example status message!
|
||||||
/// let status = Status::builder()
|
/// let status = Status::builder()
|
||||||
@ -216,6 +216,7 @@ impl StatusBuilder {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{EthVersion, Status};
|
use crate::{EthVersion, Status};
|
||||||
|
use alloy_consensus::constants::MAINNET_GENESIS_HASH;
|
||||||
use alloy_genesis::Genesis;
|
use alloy_genesis::Genesis;
|
||||||
use alloy_primitives::{hex, B256, U256};
|
use alloy_primitives::{hex, B256, U256};
|
||||||
use alloy_rlp::{Decodable, Encodable};
|
use alloy_rlp::{Decodable, Encodable};
|
||||||
@ -235,10 +236,7 @@ mod tests {
|
|||||||
"feb27336ca7923f8fab3bd617fcb6e75841538f71c1bcfc267d7838489d9e13d",
|
"feb27336ca7923f8fab3bd617fcb6e75841538f71c1bcfc267d7838489d9e13d",
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
genesis: B256::from_str(
|
genesis: MAINNET_GENESIS_HASH,
|
||||||
"d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
|
|
||||||
)
|
|
||||||
.unwrap(),
|
|
||||||
forkid: ForkId { hash: ForkHash([0xb7, 0x15, 0x07, 0x7d]), next: 0 },
|
forkid: ForkId { hash: ForkHash([0xb7, 0x15, 0x07, 0x7d]), next: 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -258,10 +256,7 @@ mod tests {
|
|||||||
"feb27336ca7923f8fab3bd617fcb6e75841538f71c1bcfc267d7838489d9e13d",
|
"feb27336ca7923f8fab3bd617fcb6e75841538f71c1bcfc267d7838489d9e13d",
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
genesis: B256::from_str(
|
genesis: MAINNET_GENESIS_HASH,
|
||||||
"d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
|
|
||||||
)
|
|
||||||
.unwrap(),
|
|
||||||
forkid: ForkId { hash: ForkHash([0xb7, 0x15, 0x07, 0x7d]), next: 0 },
|
forkid: ForkId { hash: ForkHash([0xb7, 0x15, 0x07, 0x7d]), next: 0 },
|
||||||
};
|
};
|
||||||
let status = Status::decode(&mut &data[..]).unwrap();
|
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.
|
/// Multiplier for converting ether to wei.
|
||||||
pub const ETH_TO_WEI: u128 = FINNEY_TO_WEI * 1000;
|
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`
|
/// Sepolia genesis hash: `0x25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9`
|
||||||
pub const SEPOLIA_GENESIS_HASH: B256 =
|
pub const SEPOLIA_GENESIS_HASH: B256 =
|
||||||
b256!("25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9");
|
b256!("25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9");
|
||||||
|
|||||||
@ -39,10 +39,7 @@ pub use block::{
|
|||||||
};
|
};
|
||||||
#[cfg(feature = "reth-codec")]
|
#[cfg(feature = "reth-codec")]
|
||||||
pub use compression::*;
|
pub use compression::*;
|
||||||
pub use constants::{
|
pub use constants::{DEV_GENESIS_HASH, HOLESKY_GENESIS_HASH, KECCAK_EMPTY, SEPOLIA_GENESIS_HASH};
|
||||||
DEV_GENESIS_HASH, HOLESKY_GENESIS_HASH, KECCAK_EMPTY, MAINNET_GENESIS_HASH,
|
|
||||||
SEPOLIA_GENESIS_HASH,
|
|
||||||
};
|
|
||||||
pub use receipt::{
|
pub use receipt::{
|
||||||
gas_spent_by_transactions, Receipt, ReceiptWithBloom, ReceiptWithBloomRef, Receipts,
|
gas_spent_by_transactions, Receipt, ReceiptWithBloom, ReceiptWithBloomRef, Receipts,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -42,6 +42,7 @@ tracing.workspace = true
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
reth-primitives-traits.workspace = true
|
reth-primitives-traits.workspace = true
|
||||||
reth-provider = { workspace = true, features = ["test-utils"] }
|
reth-provider = { workspace = true, features = ["test-utils"] }
|
||||||
|
alloy-consensus.workspace = true
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|||||||
@ -581,6 +581,7 @@ struct GenesisAccountWithAddress {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use alloy_consensus::constants::MAINNET_GENESIS_HASH;
|
||||||
use alloy_genesis::Genesis;
|
use alloy_genesis::Genesis;
|
||||||
use reth_chainspec::{Chain, ChainSpec, HOLESKY, MAINNET, SEPOLIA};
|
use reth_chainspec::{Chain, ChainSpec, HOLESKY, MAINNET, SEPOLIA};
|
||||||
use reth_db::DatabaseEnv;
|
use reth_db::DatabaseEnv;
|
||||||
@ -591,7 +592,7 @@ mod tests {
|
|||||||
transaction::DbTx,
|
transaction::DbTx,
|
||||||
Database,
|
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_primitives_traits::IntegerList;
|
||||||
use reth_provider::{
|
use reth_provider::{
|
||||||
test_utils::{create_test_provider_factory_with_chain_spec, MockNodeTypesWithDB},
|
test_utils::{create_test_provider_factory_with_chain_spec, MockNodeTypesWithDB},
|
||||||
|
|||||||
@ -14,6 +14,8 @@ reth-eth-wire.workspace = true
|
|||||||
reth-ecies.workspace = true
|
reth-ecies.workspace = true
|
||||||
reth-network-peers.workspace = true
|
reth-network-peers.workspace = true
|
||||||
|
|
||||||
|
alloy-consensus.workspace = true
|
||||||
|
|
||||||
secp256k1 = { workspace = true, features = ["global-context", "rand-std", "recovery"] }
|
secp256k1 = { workspace = true, features = ["global-context", "rand-std", "recovery"] }
|
||||||
|
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use alloy_consensus::constants::MAINNET_GENESIS_HASH;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use reth_chainspec::{Chain, MAINNET};
|
use reth_chainspec::{Chain, MAINNET};
|
||||||
use reth_discv4::{DiscoveryUpdate, Discv4, Discv4ConfigBuilder, DEFAULT_DISCOVERY_ADDRESS};
|
use reth_discv4::{DiscoveryUpdate, Discv4, Discv4ConfigBuilder, DEFAULT_DISCOVERY_ADDRESS};
|
||||||
@ -17,7 +18,7 @@ use reth_eth_wire::{
|
|||||||
};
|
};
|
||||||
use reth_network::config::rng_secret_key;
|
use reth_network::config::rng_secret_key;
|
||||||
use reth_network_peers::{mainnet_nodes, pk2id, NodeRecord};
|
use reth_network_peers::{mainnet_nodes, pk2id, NodeRecord};
|
||||||
use reth_primitives::{EthereumHardfork, Head, MAINNET_GENESIS_HASH};
|
use reth_primitives::{EthereumHardfork, Head};
|
||||||
use secp256k1::{SecretKey, SECP256K1};
|
use secp256k1::{SecretKey, SECP256K1};
|
||||||
use std::sync::LazyLock;
|
use std::sync::LazyLock;
|
||||||
use tokio::net::TcpStream;
|
use tokio::net::TcpStream;
|
||||||
|
|||||||
Reference in New Issue
Block a user