mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat(rpc): enable eth_getProof (#5071)
This commit is contained in:
@ -3,7 +3,7 @@ use crate::{
|
||||
StateProvider, StateRootProvider,
|
||||
};
|
||||
use reth_interfaces::{provider::ProviderError, RethResult};
|
||||
use reth_primitives::{Account, Address, BlockNumber, Bytecode, Bytes, B256};
|
||||
use reth_primitives::{trie::AccountProof, Account, Address, BlockNumber, Bytecode, B256};
|
||||
|
||||
/// A state provider that either resolves to data in a wrapped [`crate::BundleStateWithReceipts`],
|
||||
/// or an underlying state provider.
|
||||
@ -92,11 +92,7 @@ impl<SP: StateProvider, BSDP: BundleStateDataProvider> StateProvider
|
||||
self.state_provider.bytecode_by_hash(code_hash)
|
||||
}
|
||||
|
||||
fn proof(
|
||||
&self,
|
||||
_address: Address,
|
||||
_keys: &[B256],
|
||||
) -> RethResult<(Vec<Bytes>, B256, Vec<Vec<Bytes>>)> {
|
||||
fn proof(&self, _address: Address, _keys: &[B256]) -> RethResult<AccountProof> {
|
||||
Err(ProviderError::StateRootNotAvailableForHistoricalBlock.into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ use reth_db::{
|
||||
};
|
||||
use reth_interfaces::RethResult;
|
||||
use reth_primitives::{
|
||||
Account, Address, BlockNumber, Bytecode, Bytes, StorageKey, StorageValue, B256,
|
||||
trie::AccountProof, Account, Address, BlockNumber, Bytecode, StorageKey, StorageValue, B256,
|
||||
};
|
||||
|
||||
/// State provider for a given block number which takes a tx reference.
|
||||
@ -240,11 +240,7 @@ impl<'b, TX: DbTx> StateProvider for HistoricalStateProviderRef<'b, TX> {
|
||||
}
|
||||
|
||||
/// Get account and storage proofs.
|
||||
fn proof(
|
||||
&self,
|
||||
_address: Address,
|
||||
_keys: &[B256],
|
||||
) -> RethResult<(Vec<Bytes>, B256, Vec<Vec<Bytes>>)> {
|
||||
fn proof(&self, _address: Address, _keys: &[B256]) -> RethResult<AccountProof> {
|
||||
Err(ProviderError::StateRootNotAvailableForHistoricalBlock.into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,8 @@ use reth_db::{
|
||||
};
|
||||
use reth_interfaces::{provider::ProviderError, RethError, RethResult};
|
||||
use reth_primitives::{
|
||||
keccak256, Account, Address, BlockNumber, Bytecode, Bytes, StorageKey, StorageValue, B256,
|
||||
keccak256, trie::AccountProof, Account, Address, BlockNumber, Bytecode, StorageKey,
|
||||
StorageValue, B256,
|
||||
};
|
||||
|
||||
/// State provider over latest state that takes tx reference.
|
||||
@ -84,11 +85,7 @@ impl<'b, TX: DbTx> StateProvider for LatestStateProviderRef<'b, TX> {
|
||||
self.db.get::<tables::Bytecodes>(code_hash).map_err(Into::into)
|
||||
}
|
||||
|
||||
fn proof(
|
||||
&self,
|
||||
address: Address,
|
||||
_keys: &[B256],
|
||||
) -> RethResult<(Vec<Bytes>, B256, Vec<Vec<Bytes>>)> {
|
||||
fn proof(&self, address: Address, _keys: &[B256]) -> RethResult<AccountProof> {
|
||||
let _hashed_address = keccak256(address);
|
||||
let _root = self
|
||||
.db
|
||||
|
||||
@ -42,7 +42,7 @@ macro_rules! delegate_provider_impls {
|
||||
}
|
||||
StateProvider $(where [$($generics)*])?{
|
||||
fn storage(&self, account: reth_primitives::Address, storage_key: reth_primitives::StorageKey) -> reth_interfaces::RethResult<Option<reth_primitives::StorageValue>>;
|
||||
fn proof(&self, address: reth_primitives::Address, keys: &[reth_primitives::B256]) -> reth_interfaces::RethResult<(Vec<reth_primitives::Bytes>, reth_primitives::B256, Vec<Vec<reth_primitives::Bytes>>)>;
|
||||
fn proof(&self, address: reth_primitives::Address, keys: &[reth_primitives::B256]) -> reth_interfaces::RethResult<reth_primitives::trie::AccountProof>;
|
||||
fn bytecode_by_hash(&self, code_hash: reth_primitives::B256) -> reth_interfaces::RethResult<Option<reth_primitives::Bytecode>>;
|
||||
}
|
||||
);
|
||||
|
||||
@ -10,9 +10,9 @@ use parking_lot::Mutex;
|
||||
use reth_db::models::StoredBlockBodyIndices;
|
||||
use reth_interfaces::{provider::ProviderError, RethResult};
|
||||
use reth_primitives::{
|
||||
keccak256, Account, Address, Block, BlockHash, BlockHashOrNumber, BlockId, BlockNumber,
|
||||
BlockWithSenders, Bytecode, Bytes, ChainInfo, ChainSpec, Header, Receipt, SealedBlock,
|
||||
SealedHeader, StorageKey, StorageValue, TransactionMeta, TransactionSigned,
|
||||
keccak256, trie::AccountProof, Account, Address, Block, BlockHash, BlockHashOrNumber, BlockId,
|
||||
BlockNumber, BlockWithSenders, Bytecode, Bytes, ChainInfo, ChainSpec, Header, Receipt,
|
||||
SealedBlock, SealedHeader, StorageKey, StorageValue, TransactionMeta, TransactionSigned,
|
||||
TransactionSignedNoHash, TxHash, TxNumber, B256, U256,
|
||||
};
|
||||
use revm::primitives::{BlockEnv, CfgEnv};
|
||||
@ -507,11 +507,7 @@ impl StateProvider for MockEthProvider {
|
||||
}))
|
||||
}
|
||||
|
||||
fn proof(
|
||||
&self,
|
||||
_address: Address,
|
||||
_keys: &[B256],
|
||||
) -> RethResult<(Vec<Bytes>, B256, Vec<Vec<Bytes>>)> {
|
||||
fn proof(&self, _address: Address, _keys: &[B256]) -> RethResult<AccountProof> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,10 +10,11 @@ use reth_db::models::{AccountBeforeTx, StoredBlockBodyIndices};
|
||||
use reth_interfaces::RethResult;
|
||||
use reth_primitives::{
|
||||
stage::{StageCheckpoint, StageId},
|
||||
Account, Address, Block, BlockHash, BlockHashOrNumber, BlockId, BlockNumber, Bytecode, Bytes,
|
||||
trie::AccountProof,
|
||||
Account, Address, Block, BlockHash, BlockHashOrNumber, BlockId, BlockNumber, Bytecode,
|
||||
ChainInfo, ChainSpec, Header, PruneCheckpoint, PruneSegment, Receipt, SealedBlock,
|
||||
SealedHeader, StorageKey, StorageValue, TransactionMeta, TransactionSigned,
|
||||
TransactionSignedNoHash, TxHash, TxNumber, B256, KECCAK_EMPTY, MAINNET, U256,
|
||||
TransactionSignedNoHash, TxHash, TxNumber, B256, MAINNET, U256,
|
||||
};
|
||||
use revm::primitives::{BlockEnv, CfgEnv};
|
||||
use std::{
|
||||
@ -278,12 +279,8 @@ impl StateProvider for NoopProvider {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn proof(
|
||||
&self,
|
||||
_address: Address,
|
||||
_keys: &[B256],
|
||||
) -> RethResult<(Vec<Bytes>, B256, Vec<Vec<Bytes>>)> {
|
||||
Ok((vec![], KECCAK_EMPTY, vec![]))
|
||||
fn proof(&self, _address: Address, _keys: &[B256]) -> RethResult<AccountProof> {
|
||||
Ok(AccountProof::default())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,8 +3,8 @@ use crate::{BlockHashReader, BlockIdReader, BundleStateWithReceipts};
|
||||
use auto_impl::auto_impl;
|
||||
use reth_interfaces::{provider::ProviderError, RethResult};
|
||||
use reth_primitives::{
|
||||
Address, BlockHash, BlockId, BlockNumHash, BlockNumber, BlockNumberOrTag, Bytecode, Bytes,
|
||||
StorageKey, StorageValue, B256, KECCAK_EMPTY, U256,
|
||||
trie::AccountProof, Address, BlockHash, BlockId, BlockNumHash, BlockNumber, BlockNumberOrTag,
|
||||
Bytecode, StorageKey, StorageValue, B256, KECCAK_EMPTY, U256,
|
||||
};
|
||||
|
||||
/// Type alias of boxed [StateProvider].
|
||||
@ -24,11 +24,7 @@ pub trait StateProvider: BlockHashReader + AccountReader + StateRootProvider + S
|
||||
fn bytecode_by_hash(&self, code_hash: B256) -> RethResult<Option<Bytecode>>;
|
||||
|
||||
/// Get account and storage proofs.
|
||||
fn proof(
|
||||
&self,
|
||||
address: Address,
|
||||
keys: &[B256],
|
||||
) -> RethResult<(Vec<Bytes>, B256, Vec<Vec<Bytes>>)>;
|
||||
fn proof(&self, address: Address, keys: &[B256]) -> RethResult<AccountProof>;
|
||||
|
||||
/// Get account code by its address.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user