mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(primitives): add _HASH suffix for constants hashes (#5175)
This commit is contained in:
@ -228,7 +228,7 @@ mod tests {
|
||||
};
|
||||
use reth_primitives::{
|
||||
Address, Chain, ForkTimestamps, Genesis, GenesisAccount, IntegerList, GOERLI,
|
||||
GOERLI_GENESIS, MAINNET, MAINNET_GENESIS, SEPOLIA, SEPOLIA_GENESIS,
|
||||
GOERLI_GENESIS_HASH, MAINNET, MAINNET_GENESIS_HASH, SEPOLIA, SEPOLIA_GENESIS_HASH,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
@ -249,7 +249,7 @@ mod tests {
|
||||
let genesis_hash = init_genesis(db, MAINNET.clone()).unwrap();
|
||||
|
||||
// actual, expected
|
||||
assert_eq!(genesis_hash, MAINNET_GENESIS);
|
||||
assert_eq!(genesis_hash, MAINNET_GENESIS_HASH);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -258,7 +258,7 @@ mod tests {
|
||||
let genesis_hash = init_genesis(db, GOERLI.clone()).unwrap();
|
||||
|
||||
// actual, expected
|
||||
assert_eq!(genesis_hash, GOERLI_GENESIS);
|
||||
assert_eq!(genesis_hash, GOERLI_GENESIS_HASH);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -267,7 +267,7 @@ mod tests {
|
||||
let genesis_hash = init_genesis(db, SEPOLIA.clone()).unwrap();
|
||||
|
||||
// actual, expected
|
||||
assert_eq!(genesis_hash, SEPOLIA_GENESIS);
|
||||
assert_eq!(genesis_hash, SEPOLIA_GENESIS_HASH);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -281,8 +281,8 @@ mod tests {
|
||||
assert_eq!(
|
||||
genesis_hash.unwrap_err(),
|
||||
InitDatabaseError::GenesisHashMismatch {
|
||||
chainspec_hash: MAINNET_GENESIS,
|
||||
database_hash: SEPOLIA_GENESIS
|
||||
chainspec_hash: MAINNET_GENESIS_HASH,
|
||||
database_hash: SEPOLIA_GENESIS_HASH
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@ -24,8 +24,8 @@ use reth_interfaces::{
|
||||
use reth_primitives::{
|
||||
constants::{EMPTY_RECEIPTS, EMPTY_TRANSACTIONS, ETHEREUM_BLOCK_GAS_LIMIT},
|
||||
proofs, Address, Block, BlockBody, BlockHash, BlockHashOrNumber, BlockNumber, Bloom, ChainSpec,
|
||||
Header, ReceiptWithBloom, SealedBlock, SealedHeader, TransactionSigned, B256, EMPTY_OMMER_ROOT,
|
||||
U256,
|
||||
Header, ReceiptWithBloom, SealedBlock, SealedHeader, TransactionSigned, B256,
|
||||
EMPTY_OMMER_ROOT_HASH, U256,
|
||||
};
|
||||
use reth_provider::{
|
||||
BlockExecutor, BlockReaderIdExt, BundleStateWithReceipts, CanonStateNotificationSender,
|
||||
@ -262,7 +262,7 @@ impl StorageInner {
|
||||
|
||||
let mut header = Header {
|
||||
parent_hash: self.best_hash,
|
||||
ommers_hash: EMPTY_OMMER_ROOT,
|
||||
ommers_hash: EMPTY_OMMER_ROOT_HASH,
|
||||
beneficiary: Default::default(),
|
||||
state_root: Default::default(),
|
||||
transactions_root: Default::default(),
|
||||
|
||||
@ -3,7 +3,7 @@ use reth_consensus_common::validation;
|
||||
use reth_interfaces::consensus::{Consensus, ConsensusError};
|
||||
use reth_primitives::{
|
||||
constants::{ALLOWED_FUTURE_BLOCK_TIME_SECONDS, MAXIMUM_EXTRA_DATA_SIZE},
|
||||
Chain, ChainSpec, Hardfork, Header, SealedBlock, SealedHeader, EMPTY_OMMER_ROOT, U256,
|
||||
Chain, ChainSpec, Hardfork, Header, SealedBlock, SealedHeader, EMPTY_OMMER_ROOT_HASH, U256,
|
||||
};
|
||||
use std::{sync::Arc, time::SystemTime};
|
||||
|
||||
@ -55,7 +55,7 @@ impl Consensus for BeaconConsensus {
|
||||
return Err(ConsensusError::TheMergeNonceIsNotZero)
|
||||
}
|
||||
|
||||
if header.ommers_hash != EMPTY_OMMER_ROOT {
|
||||
if header.ommers_hash != EMPTY_OMMER_ROOT_HASH {
|
||||
return Err(ConsensusError::TheMergeOmmerRootIsNotEmpty)
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ use reth_primitives::{Chain, ForkId, PeerId, B256, U256};
|
||||
/// # Example
|
||||
/// ```
|
||||
/// use reth_eth_wire::EthVersion;
|
||||
/// use reth_primitives::{Chain, U256, B256, MAINNET_GENESIS, MAINNET, Hardfork};
|
||||
/// use reth_primitives::{Chain, U256, B256, MAINNET_GENESIS_HASH, MAINNET, Hardfork};
|
||||
/// use reth_eth_wire::types::Status;
|
||||
///
|
||||
/// // this is just an example status message!
|
||||
@ -19,8 +19,8 @@ use reth_primitives::{Chain, ForkId, PeerId, B256, U256};
|
||||
/// .version(EthVersion::Eth66.into())
|
||||
/// .chain(Chain::mainnet())
|
||||
/// .total_difficulty(U256::from(100))
|
||||
/// .blockhash(B256::from(MAINNET_GENESIS))
|
||||
/// .genesis(B256::from(MAINNET_GENESIS))
|
||||
/// .blockhash(B256::from(MAINNET_GENESIS_HASH))
|
||||
/// .genesis(B256::from(MAINNET_GENESIS_HASH))
|
||||
/// .forkid(Hardfork::Paris.fork_id(&MAINNET).unwrap())
|
||||
/// .build();
|
||||
///
|
||||
@ -30,8 +30,8 @@ use reth_primitives::{Chain, ForkId, PeerId, B256, U256};
|
||||
/// version: EthVersion::Eth66.into(),
|
||||
/// chain: Chain::mainnet(),
|
||||
/// total_difficulty: U256::from(100),
|
||||
/// blockhash: B256::from(MAINNET_GENESIS),
|
||||
/// genesis: B256::from(MAINNET_GENESIS),
|
||||
/// blockhash: B256::from(MAINNET_GENESIS_HASH),
|
||||
/// genesis: B256::from(MAINNET_GENESIS_HASH),
|
||||
/// forkid: Hardfork::Paris.fork_id(&MAINNET).unwrap(),
|
||||
/// }
|
||||
/// );
|
||||
|
||||
@ -28,7 +28,7 @@ use reth_primitives::{
|
||||
proofs,
|
||||
revm::{compat::into_reth_log, env::tx_env_with_recovered},
|
||||
Block, BlockNumberOrTag, Bytes, ChainSpec, Header, IntoRecoveredTransaction, Receipt, Receipts,
|
||||
SealedBlock, Withdrawal, B256, EMPTY_OMMER_ROOT, U256,
|
||||
SealedBlock, Withdrawal, B256, EMPTY_OMMER_ROOT_HASH, U256,
|
||||
};
|
||||
use reth_provider::{BlockReaderIdExt, BlockSource, BundleStateWithReceipts, StateProviderFactory};
|
||||
use reth_revm::{
|
||||
@ -865,7 +865,7 @@ where
|
||||
|
||||
let header = Header {
|
||||
parent_hash: parent_block.hash,
|
||||
ommers_hash: EMPTY_OMMER_ROOT,
|
||||
ommers_hash: EMPTY_OMMER_ROOT_HASH,
|
||||
beneficiary: initialized_block_env.coinbase,
|
||||
state_root,
|
||||
transactions_root,
|
||||
@ -953,7 +953,7 @@ where
|
||||
|
||||
let header = Header {
|
||||
parent_hash: parent_block.hash,
|
||||
ommers_hash: EMPTY_OMMER_ROOT,
|
||||
ommers_hash: EMPTY_OMMER_ROOT_HASH,
|
||||
beneficiary: initialized_block_env.coinbase,
|
||||
state_root,
|
||||
transactions_root: EMPTY_TRANSACTIONS,
|
||||
|
||||
@ -7,7 +7,7 @@ use crate::{
|
||||
header::Head,
|
||||
proofs::genesis_state_root,
|
||||
Address, BlockNumber, Chain, ForkFilter, ForkHash, ForkId, Genesis, Hardfork, Header,
|
||||
SealedHeader, B256, EMPTY_OMMER_ROOT, U256,
|
||||
SealedHeader, B256, EMPTY_OMMER_ROOT_HASH, U256,
|
||||
};
|
||||
use once_cell::sync::Lazy;
|
||||
use revm_primitives::{address, b256};
|
||||
@ -370,7 +370,7 @@ impl ChainSpec {
|
||||
parent_hash: B256::ZERO,
|
||||
number: 0,
|
||||
transactions_root: EMPTY_TRANSACTIONS,
|
||||
ommers_hash: EMPTY_OMMER_ROOT,
|
||||
ommers_hash: EMPTY_OMMER_ROOT_HASH,
|
||||
receipts_root: EMPTY_RECEIPTS,
|
||||
logs_bloom: Default::default(),
|
||||
gas_limit: self.genesis.gas_limit,
|
||||
|
||||
@ -73,23 +73,23 @@ pub const ETH_TO_WEI: u128 = FINNEY_TO_WEI * 1000;
|
||||
pub const MGAS_TO_GAS: u64 = 1_000_000u64;
|
||||
|
||||
/// The Ethereum mainnet genesis hash.
|
||||
pub const MAINNET_GENESIS: B256 =
|
||||
pub const MAINNET_GENESIS_HASH: B256 =
|
||||
b256!("d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3");
|
||||
|
||||
/// Goerli genesis hash.
|
||||
pub const GOERLI_GENESIS: B256 =
|
||||
pub const GOERLI_GENESIS_HASH: B256 =
|
||||
b256!("bf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a");
|
||||
|
||||
/// Sepolia genesis hash.
|
||||
pub const SEPOLIA_GENESIS: B256 =
|
||||
pub const SEPOLIA_GENESIS_HASH: B256 =
|
||||
b256!("25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9");
|
||||
|
||||
/// Holesky genesis hash.
|
||||
pub const HOLESKY_GENESIS: B256 =
|
||||
pub const HOLESKY_GENESIS_HASH: B256 =
|
||||
b256!("ff9006519a8ce843ac9c28549d24211420b546e12ce2d170c77a8cca7964f23d");
|
||||
|
||||
/// Testnet genesis hash.
|
||||
pub const DEV_GENESIS: B256 =
|
||||
pub const DEV_GENESIS_HASH: B256 =
|
||||
b256!("2f980576711e3617a5e4d83dd539548ec0f7792007d505a3d2e9674833af2d7c");
|
||||
|
||||
/// Keccak256 over empty array.
|
||||
@ -97,7 +97,7 @@ pub const KECCAK_EMPTY: B256 =
|
||||
b256!("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
|
||||
|
||||
/// Ommer root of empty list.
|
||||
pub const EMPTY_OMMER_ROOT: B256 =
|
||||
pub const EMPTY_OMMER_ROOT_HASH: B256 =
|
||||
b256!("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347");
|
||||
|
||||
/// Root hash of an empty trie.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
basefee::calculate_next_block_base_fee,
|
||||
constants::{EMPTY_OMMER_ROOT, EMPTY_ROOT_HASH},
|
||||
constants::{EMPTY_OMMER_ROOT_HASH, EMPTY_ROOT_HASH},
|
||||
eip4844::{calc_blob_gasprice, calculate_excess_blob_gas},
|
||||
keccak256, Address, BaseFeeParams, BlockBodyRoots, BlockHash, BlockNumHash, BlockNumber, Bloom,
|
||||
Bytes, B256, B64, U256,
|
||||
@ -115,7 +115,7 @@ impl Default for Header {
|
||||
fn default() -> Self {
|
||||
Header {
|
||||
parent_hash: Default::default(),
|
||||
ommers_hash: EMPTY_OMMER_ROOT,
|
||||
ommers_hash: EMPTY_OMMER_ROOT_HASH,
|
||||
beneficiary: Default::default(),
|
||||
state_root: EMPTY_ROOT_HASH,
|
||||
transactions_root: EMPTY_ROOT_HASH,
|
||||
@ -164,7 +164,7 @@ impl Header {
|
||||
|
||||
/// Check if the ommers hash equals to empty hash list.
|
||||
pub fn ommers_hash_is_empty(&self) -> bool {
|
||||
self.ommers_hash == EMPTY_OMMER_ROOT
|
||||
self.ommers_hash == EMPTY_OMMER_ROOT_HASH
|
||||
}
|
||||
|
||||
/// Check if the transaction root equals to empty root.
|
||||
|
||||
@ -61,8 +61,8 @@ pub use chain::{
|
||||
};
|
||||
pub use compression::*;
|
||||
pub use constants::{
|
||||
DEV_GENESIS, EMPTY_OMMER_ROOT, GOERLI_GENESIS, HOLESKY_GENESIS, KECCAK_EMPTY, MAINNET_GENESIS,
|
||||
SEPOLIA_GENESIS,
|
||||
DEV_GENESIS_HASH, EMPTY_OMMER_ROOT_HASH, GOERLI_GENESIS_HASH, HOLESKY_GENESIS_HASH,
|
||||
KECCAK_EMPTY, MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH,
|
||||
};
|
||||
pub use eip4844::{calculate_excess_blob_gas, kzg_to_versioned_hash};
|
||||
pub use forkid::{ForkFilter, ForkHash, ForkId, ForkTransition, ValidationError};
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//! Helper function for calculating Merkle proofs and hashes.
|
||||
|
||||
use crate::{
|
||||
constants::EMPTY_OMMER_ROOT,
|
||||
constants::EMPTY_OMMER_ROOT_HASH,
|
||||
keccak256,
|
||||
trie::{HashBuilder, Nibbles},
|
||||
Address, GenesisAccount, Header, ReceiptWithBloom, ReceiptWithBloomRef, TransactionSigned,
|
||||
@ -89,7 +89,7 @@ where
|
||||
pub fn calculate_ommers_root(ommers: &[Header]) -> B256 {
|
||||
// Check if `ommers` list is empty
|
||||
if ommers.is_empty() {
|
||||
return EMPTY_OMMER_ROOT
|
||||
return EMPTY_OMMER_ROOT_HASH
|
||||
}
|
||||
// RLP Encode
|
||||
let mut ommers_rlp = Vec::new();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//! Standalone Conversion Functions for Handling Different Versions of Execution Payloads in
|
||||
//! Ethereum's Engine
|
||||
use reth_primitives::{
|
||||
constants::{EMPTY_OMMER_ROOT, MAXIMUM_EXTRA_DATA_SIZE, MIN_PROTOCOL_BASE_FEE_U256},
|
||||
constants::{EMPTY_OMMER_ROOT_HASH, MAXIMUM_EXTRA_DATA_SIZE, MIN_PROTOCOL_BASE_FEE_U256},
|
||||
proofs::{self},
|
||||
Block, Header, SealedBlock, TransactionSigned, UintTryTo, Withdrawal, B256, U256, U64,
|
||||
};
|
||||
@ -51,7 +51,7 @@ pub fn try_payload_v1_to_block(payload: ExecutionPayloadV1) -> Result<Block, Pay
|
||||
parent_beacon_block_root: None,
|
||||
extra_data: payload.extra_data,
|
||||
// Defaults
|
||||
ommers_hash: EMPTY_OMMER_ROOT,
|
||||
ommers_hash: EMPTY_OMMER_ROOT_HASH,
|
||||
difficulty: Default::default(),
|
||||
nonce: Default::default(),
|
||||
};
|
||||
|
||||
@ -7,7 +7,7 @@ use reth_primitives::{
|
||||
proofs,
|
||||
revm::{compat::into_reth_log, env::tx_env_with_recovered},
|
||||
Block, BlockId, BlockNumberOrTag, ChainSpec, Header, IntoRecoveredTransaction, Receipt,
|
||||
Receipts, SealedBlock, SealedHeader, B256, EMPTY_OMMER_ROOT, U256,
|
||||
Receipts, SealedBlock, SealedHeader, B256, EMPTY_OMMER_ROOT_HASH, U256,
|
||||
};
|
||||
use reth_provider::{BundleStateWithReceipts, ChainSpecProvider, StateProviderFactory};
|
||||
use reth_revm::{
|
||||
@ -212,7 +212,7 @@ impl PendingBlockEnv {
|
||||
|
||||
let header = Header {
|
||||
parent_hash,
|
||||
ommers_hash: EMPTY_OMMER_ROOT,
|
||||
ommers_hash: EMPTY_OMMER_ROOT_HASH,
|
||||
beneficiary: block_env.coinbase,
|
||||
state_root,
|
||||
transactions_root,
|
||||
|
||||
@ -16,7 +16,9 @@ use reth_eth_wire::{
|
||||
EthMessage, EthStream, HelloMessage, P2PStream, Status, UnauthedEthStream, UnauthedP2PStream,
|
||||
};
|
||||
use reth_network::config::rng_secret_key;
|
||||
use reth_primitives::{mainnet_nodes, Chain, Hardfork, Head, NodeRecord, MAINNET, MAINNET_GENESIS};
|
||||
use reth_primitives::{
|
||||
mainnet_nodes, Chain, Hardfork, Head, NodeRecord, MAINNET, MAINNET_GENESIS_HASH,
|
||||
};
|
||||
use secp256k1::{SecretKey, SECP256K1};
|
||||
use tokio::net::TcpStream;
|
||||
|
||||
@ -99,7 +101,7 @@ async fn handshake_eth(p2p_stream: AuthedP2PStream) -> eyre::Result<(AuthedEthSt
|
||||
|
||||
let status = Status::builder()
|
||||
.chain(Chain::mainnet())
|
||||
.genesis(MAINNET_GENESIS)
|
||||
.genesis(MAINNET_GENESIS_HASH)
|
||||
.forkid(Hardfork::Shanghai.fork_id(&MAINNET).unwrap())
|
||||
.build();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user