mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: move eip1186 conversion helpers to reth-trie-common proofs (#12985)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -54,7 +54,6 @@ reth-provider = { workspace = true, features = ["test-utils"] }
|
||||
reth-payload-builder = { workspace = true, features = ["test-utils"] }
|
||||
reth-tokio-util.workspace = true
|
||||
reth-testing-utils.workspace = true
|
||||
|
||||
alloy-rlp.workspace = true
|
||||
|
||||
assert_matches.workspace = true
|
||||
@ -29,8 +29,9 @@ reth-execution-types.workspace = true
|
||||
reth-rpc-eth-types.workspace = true
|
||||
reth-rpc-server-types.workspace = true
|
||||
reth-network-api.workspace = true
|
||||
reth-trie.workspace = true
|
||||
reth-node-api.workspace = true
|
||||
reth-trie.workspace = true
|
||||
reth-trie-common = { workspace = true, features = ["eip1186"] }
|
||||
|
||||
# ethereum
|
||||
alloy-serde.workspace = true
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
//! Loads a pending block from database. Helper trait for `eth_` block, transaction, call and trace
|
||||
//! RPC methods.
|
||||
|
||||
use super::{EthApiSpec, LoadPendingBlock, SpawnBlocking};
|
||||
use crate::{EthApiTypes, FromEthApiError, RpcNodeCore, RpcNodeCoreExt};
|
||||
use alloy_consensus::{constants::KECCAK_EMPTY, Header};
|
||||
use alloy_eips::BlockId;
|
||||
use alloy_primitives::{Address, Bytes, B256, U256};
|
||||
@ -15,14 +16,9 @@ use reth_provider::{
|
||||
StateProviderFactory,
|
||||
};
|
||||
use reth_rpc_eth_types::{EthApiError, PendingBlockEnv, RpcInvalidTransactionError};
|
||||
use reth_rpc_types_compat::proof::from_primitive_account_proof;
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
use revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg, SpecId};
|
||||
|
||||
use crate::{EthApiTypes, FromEthApiError, RpcNodeCore, RpcNodeCoreExt};
|
||||
|
||||
use super::{EthApiSpec, LoadPendingBlock, SpawnBlocking};
|
||||
|
||||
/// Helper methods for `eth_` methods relating to state (accounts).
|
||||
pub trait EthState: LoadState + SpawnBlocking {
|
||||
/// Returns the maximum number of blocks into the past for generating state proofs.
|
||||
@ -122,7 +118,7 @@ pub trait EthState: LoadState + SpawnBlocking {
|
||||
let proof = state
|
||||
.proof(Default::default(), address, &storage_keys)
|
||||
.map_err(Self::Error::from_eth_err)?;
|
||||
Ok(from_primitive_account_proof(proof, keys))
|
||||
Ok(proof.into_eip1186_response(keys))
|
||||
})
|
||||
.await
|
||||
})
|
||||
|
||||
@ -20,16 +20,15 @@ pub mod node;
|
||||
pub mod pubsub;
|
||||
pub mod types;
|
||||
|
||||
pub use reth_rpc_eth_types::error::{
|
||||
AsEthApiError, FromEthApiError, FromEvmError, IntoEthApiError,
|
||||
};
|
||||
pub use reth_rpc_types_compat::TransactionCompat;
|
||||
|
||||
pub use bundle::{EthBundleApiServer, EthCallBundleApiServer};
|
||||
pub use core::{EthApiServer, FullEthApiServer};
|
||||
pub use filter::EthFilterApiServer;
|
||||
pub use node::{RpcNodeCore, RpcNodeCoreExt};
|
||||
pub use pubsub::EthPubSubApiServer;
|
||||
pub use reth_rpc_eth_types::error::{
|
||||
AsEthApiError, FromEthApiError, FromEvmError, IntoEthApiError,
|
||||
};
|
||||
pub use reth_rpc_types_compat::TransactionCompat;
|
||||
pub use types::{EthApiTypes, FullEthApiTypes, RpcBlock, RpcReceipt, RpcTransaction};
|
||||
|
||||
#[cfg(feature = "client")]
|
||||
@ -38,3 +37,5 @@ pub use bundle::{EthBundleApiClient, EthCallBundleApiClient};
|
||||
pub use core::EthApiClient;
|
||||
#[cfg(feature = "client")]
|
||||
pub use filter::EthFilterApiClient;
|
||||
|
||||
use reth_trie_common as _;
|
||||
|
||||
@ -14,10 +14,8 @@ workspace = true
|
||||
[dependencies]
|
||||
# reth
|
||||
reth-primitives.workspace = true
|
||||
reth-trie-common.workspace = true
|
||||
|
||||
# ethereum
|
||||
alloy-serde.workspace = true
|
||||
alloy-eips.workspace = true
|
||||
alloy-primitives.workspace = true
|
||||
alloy-rlp.workspace = true
|
||||
|
||||
@ -12,7 +12,5 @@
|
||||
|
||||
pub mod block;
|
||||
pub mod engine;
|
||||
pub mod proof;
|
||||
pub mod transaction;
|
||||
|
||||
pub use transaction::TransactionCompat;
|
||||
|
||||
@ -1,37 +0,0 @@
|
||||
//! Compatibility functions for rpc proof related types.
|
||||
|
||||
use alloy_rpc_types_eth::{EIP1186AccountProofResponse, EIP1186StorageProof};
|
||||
use alloy_serde::JsonStorageKey;
|
||||
use reth_trie_common::{AccountProof, StorageProof};
|
||||
|
||||
/// Creates a new rpc storage proof from a primitive storage proof type.
|
||||
pub fn from_primitive_storage_proof(
|
||||
proof: StorageProof,
|
||||
slot: JsonStorageKey,
|
||||
) -> EIP1186StorageProof {
|
||||
EIP1186StorageProof { key: slot, value: proof.value, proof: proof.proof }
|
||||
}
|
||||
|
||||
/// Creates a new rpc account proof from a primitive account proof type.
|
||||
pub fn from_primitive_account_proof(
|
||||
proof: AccountProof,
|
||||
slots: Vec<JsonStorageKey>,
|
||||
) -> EIP1186AccountProofResponse {
|
||||
let info = proof.info.unwrap_or_default();
|
||||
EIP1186AccountProofResponse {
|
||||
address: proof.address,
|
||||
balance: info.balance,
|
||||
code_hash: info.get_bytecode_hash(),
|
||||
nonce: info.nonce,
|
||||
storage_hash: proof.storage_root,
|
||||
account_proof: proof.proof,
|
||||
storage_proof: proof
|
||||
.storage_proofs
|
||||
.into_iter()
|
||||
.filter_map(|proof| {
|
||||
let input_slot = slots.iter().find(|s| s.as_b256() == proof.key)?;
|
||||
Some(from_primitive_storage_proof(proof, *input_slot))
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user