primitives: use alloy KECCAK_EMPTY constant (#11851)

This commit is contained in:
Thomas Coratger
2024-10-18 10:25:22 +02:00
committed by GitHub
parent dfcaad4608
commit 0c70f6bd35
9 changed files with 14 additions and 11 deletions

1
Cargo.lock generated
View File

@ -9002,6 +9002,7 @@ dependencies = [
name = "reth-storage-api"
version = "1.1.0"
dependencies = [
"alloy-consensus",
"alloy-eips",
"alloy-primitives",
"auto_impl",

View File

@ -194,13 +194,14 @@ impl ConfigureEvm for EthEvmConfig {
#[cfg(test)]
mod tests {
use super::*;
use alloy_consensus::constants::KECCAK_EMPTY;
use alloy_genesis::Genesis;
use alloy_primitives::{B256, U256};
use reth_chainspec::{Chain, ChainSpec, MAINNET};
use reth_evm::execute::ProviderError;
use reth_primitives::{
revm_primitives::{BlockEnv, CfgEnv, SpecId},
Header, KECCAK_EMPTY,
Header,
};
use reth_revm::{
db::{CacheDB, EmptyDBTyped},

View File

@ -208,6 +208,7 @@ impl ConfigureEvm for OptimismEvmConfig {
#[cfg(test)]
mod tests {
use super::*;
use alloy_consensus::constants::KECCAK_EMPTY;
use alloy_genesis::Genesis;
use alloy_primitives::{B256, U256};
use reth_chainspec::ChainSpec;
@ -216,7 +217,7 @@ mod tests {
use reth_optimism_chainspec::BASE_MAINNET;
use reth_primitives::{
revm_primitives::{BlockEnv, CfgEnv, SpecId},
Header, Receipt, Receipts, SealedBlockWithSenders, TxType, KECCAK_EMPTY,
Header, Receipt, Receipts, SealedBlockWithSenders, TxType,
};
use reth_revm::{
db::{CacheDB, EmptyDBTyped},

View File

@ -106,10 +106,6 @@ pub const SEPOLIA_GENESIS_HASH: B256 =
pub const HOLESKY_GENESIS_HASH: B256 =
b256!("b5f7f912443c940f21fd611f12828d75b534364ed9e95ca4e307729a4661bde4");
/// Keccak256 over empty array: `0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470`
pub const KECCAK_EMPTY: B256 =
b256!("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
/// From address from Optimism system txs: `0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001`
pub const OP_SYSTEM_TX_FROM_ADDR: Address = address!("deaddeaddeaddeaddeaddeaddeaddeaddead0001");

View File

@ -39,7 +39,7 @@ pub use block::{
};
#[cfg(feature = "reth-codec")]
pub use compression::*;
pub use constants::{HOLESKY_GENESIS_HASH, KECCAK_EMPTY, SEPOLIA_GENESIS_HASH};
pub use constants::{HOLESKY_GENESIS_HASH, SEPOLIA_GENESIS_HASH};
pub use receipt::{
gas_spent_by_transactions, Receipt, ReceiptWithBloom, ReceiptWithBloomRef, Receipts,
};

View File

@ -1,13 +1,14 @@
//! Loads a pending block from database. Helper trait for `eth_` block, transaction, call and trace
//! RPC methods.
use alloy_consensus::constants::KECCAK_EMPTY;
use alloy_primitives::{Address, Bytes, B256, U256};
use alloy_rpc_types::{serde_helpers::JsonStorageKey, Account, EIP1186AccountProofResponse};
use futures::Future;
use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_errors::RethError;
use reth_evm::ConfigureEvmEnv;
use reth_primitives::{BlockId, Header, KECCAK_EMPTY};
use reth_primitives::{BlockId, Header};
use reth_provider::{
BlockIdReader, BlockNumReader, ChainSpecProvider, StateProvider, StateProviderBox,
StateProviderFactory,

View File

@ -26,5 +26,6 @@ reth-trie.workspace = true
# ethereum
alloy-eips.workspace = true
alloy-primitives.workspace = true
alloy-consensus.workspace = true
auto_impl.workspace = true

View File

@ -2,11 +2,12 @@ use super::{
AccountReader, BlockHashReader, BlockIdReader, StateProofProvider, StateRootProvider,
StorageRootProvider,
};
use alloy_consensus::constants::KECCAK_EMPTY;
use alloy_eips::{BlockId, BlockNumHash, BlockNumberOrTag};
use alloy_primitives::{Address, BlockHash, BlockNumber, StorageKey, StorageValue, B256, U256};
use auto_impl::auto_impl;
use reth_execution_types::ExecutionOutcome;
use reth_primitives::{Bytecode, KECCAK_EMPTY};
use reth_primitives::Bytecode;
use reth_storage_errors::provider::{ProviderError, ProviderResult};
/// Type alias of boxed [`StateProvider`].

View File

@ -1,6 +1,7 @@
//! Merkle trie proofs.
use crate::{Nibbles, TrieAccount};
use alloy_consensus::constants::KECCAK_EMPTY;
use alloy_primitives::{keccak256, Address, Bytes, B256, U256};
use alloy_rlp::{encode_fixed_size, Decodable, EMPTY_STRING_CODE};
use alloy_trie::{
@ -9,13 +10,13 @@ use alloy_trie::{
EMPTY_ROOT_HASH,
};
use itertools::Itertools;
use reth_primitives_traits::{constants::KECCAK_EMPTY, Account};
use reth_primitives_traits::Account;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
/// The state multiproof of target accounts and multiproofs of their storage tries.
/// Multiproof is effectively a state subtrie that only contains the nodes
/// in the paths of target accounts.
/// in the paths of target accounts.
#[derive(Clone, Default, Debug)]
pub struct MultiProof {
/// State trie multiproof for requested accounts.