mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(no_std): Add no_std support for reth-storage-api (#14187)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -34,3 +34,16 @@ alloy-consensus.workspace = true
|
||||
alloy-rpc-types-engine.workspace = true
|
||||
|
||||
auto_impl.workspace = true
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"reth-chainspec/std",
|
||||
"alloy-consensus/std",
|
||||
"alloy-eips/std",
|
||||
"alloy-primitives/std",
|
||||
"alloy-rpc-types-engine/std",
|
||||
"reth-primitives/std",
|
||||
"reth-primitives-traits/std",
|
||||
"revm/std",
|
||||
]
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
use alloc::{
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
vec::Vec,
|
||||
};
|
||||
use alloy_primitives::{Address, BlockNumber};
|
||||
use auto_impl::auto_impl;
|
||||
use core::ops::{RangeBounds, RangeInclusive};
|
||||
use reth_db_models::AccountBeforeTx;
|
||||
use reth_primitives_traits::Account;
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use std::{
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
ops::{RangeBounds, RangeInclusive},
|
||||
};
|
||||
|
||||
/// Account reader
|
||||
#[auto_impl(&, Arc, Box)]
|
||||
|
||||
@ -2,11 +2,12 @@ use crate::{
|
||||
BlockBodyIndicesProvider, BlockNumReader, HeaderProvider, OmmersProvider, ReceiptProvider,
|
||||
ReceiptProviderIdExt, TransactionVariant, TransactionsProvider, WithdrawalsProvider,
|
||||
};
|
||||
use alloc::{sync::Arc, vec::Vec};
|
||||
use alloy_eips::{BlockHashOrNumber, BlockId, BlockNumberOrTag};
|
||||
use alloy_primitives::{BlockNumber, B256};
|
||||
use core::ops::RangeInclusive;
|
||||
use reth_primitives::{RecoveredBlock, SealedBlock, SealedHeader};
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
/// A helper enum that represents the origin of the requested block.
|
||||
///
|
||||
@ -153,7 +154,7 @@ pub trait BlockReader:
|
||||
) -> ProviderResult<Vec<RecoveredBlock<Self::Block>>>;
|
||||
}
|
||||
|
||||
impl<T: BlockReader> BlockReader for std::sync::Arc<T> {
|
||||
impl<T: BlockReader> BlockReader for Arc<T> {
|
||||
type Block = T::Block;
|
||||
|
||||
fn find_block_by_hash(
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use alloc::vec::Vec;
|
||||
use alloy_eips::BlockHashOrNumber;
|
||||
use alloy_primitives::{BlockNumber, B256};
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
use alloc::vec::Vec;
|
||||
use alloy_primitives::BlockNumber;
|
||||
use core::ops::RangeInclusive;
|
||||
use reth_db_models::StoredBlockBodyIndices;
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
/// Client trait for fetching block body indices related data.
|
||||
#[auto_impl::auto_impl(&, Arc)]
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
use crate::{DBProvider, OmmersProvider, StorageLocation};
|
||||
use alloc::vec::Vec;
|
||||
use alloy_consensus::Header;
|
||||
use alloy_primitives::BlockNumber;
|
||||
use core::marker::PhantomData;
|
||||
use reth_chainspec::{ChainSpecProvider, EthereumHardforks};
|
||||
use reth_db::{
|
||||
cursor::{DbCursorRO, DbCursorRW},
|
||||
@ -83,7 +85,7 @@ impl<T, Provider, Primitives: FullNodePrimitives> ChainStorageReader<Provider, P
|
||||
|
||||
/// Ethereum storage implementation.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct EthStorage<T = TransactionSigned, H = Header>(std::marker::PhantomData<(T, H)>);
|
||||
pub struct EthStorage<T = TransactionSigned, H = Header>(PhantomData<(T, H)>);
|
||||
|
||||
impl<T, H> Default for EthStorage<T, H> {
|
||||
fn default() -> Self {
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
use alloy_rpc_types_engine::ForkchoiceState;
|
||||
use reth_primitives_traits::SealedHeader;
|
||||
use std::time::Instant;
|
||||
|
||||
/// A type that can track updates related to fork choice updates.
|
||||
pub trait CanonChainTracker: Send + Sync {
|
||||
@ -12,14 +11,16 @@ pub trait CanonChainTracker: Send + Sync {
|
||||
|
||||
/// Returns the last time a fork choice update was received from the CL
|
||||
/// ([`CanonChainTracker::on_forkchoice_update_received`])
|
||||
fn last_received_update_timestamp(&self) -> Option<Instant>;
|
||||
#[cfg(feature = "std")]
|
||||
fn last_received_update_timestamp(&self) -> Option<std::time::Instant>;
|
||||
|
||||
/// Notify the tracker about a transition configuration exchange.
|
||||
fn on_transition_configuration_exchanged(&self);
|
||||
|
||||
/// Returns the last time a transition configuration was exchanged with the CL
|
||||
/// ([`CanonChainTracker::on_transition_configuration_exchanged`])
|
||||
fn last_exchanged_transition_configuration_timestamp(&self) -> Option<Instant>;
|
||||
#[cfg(feature = "std")]
|
||||
fn last_exchanged_transition_configuration_timestamp(&self) -> Option<std::time::Instant>;
|
||||
|
||||
/// Sets the canonical head of the chain.
|
||||
fn set_canonical_head(&self, header: SealedHeader<Self::Header>);
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec::Vec;
|
||||
use core::ops::{Bound, RangeBounds};
|
||||
use reth_db_api::{
|
||||
common::KeyValue,
|
||||
cursor::DbCursorRO,
|
||||
@ -8,7 +10,6 @@ use reth_db_api::{
|
||||
};
|
||||
use reth_prune_types::PruneModes;
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use std::ops::{Bound, RangeBounds};
|
||||
|
||||
/// Database provider.
|
||||
pub trait DBProvider: Send + Sync + Sized + 'static {
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
use alloc::collections::{BTreeMap, BTreeSet};
|
||||
use alloy_primitives::{map::HashMap, Address, BlockNumber, B256};
|
||||
use auto_impl::auto_impl;
|
||||
use core::ops::{RangeBounds, RangeInclusive};
|
||||
use reth_db::models::{AccountBeforeTx, BlockNumberAddress};
|
||||
use reth_primitives::{Account, StorageEntry};
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use std::{
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
ops::{RangeBounds, RangeInclusive},
|
||||
};
|
||||
|
||||
/// Hashing Writer
|
||||
#[auto_impl(&, Arc, Box)]
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use alloc::vec::Vec;
|
||||
use alloy_eips::BlockHashOrNumber;
|
||||
use alloy_primitives::{BlockHash, BlockNumber, U256};
|
||||
use core::ops::RangeBounds;
|
||||
use reth_primitives_traits::{BlockHeader, SealedHeader};
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use std::ops::RangeBounds;
|
||||
|
||||
/// A helper type alias to access [`HeaderProvider::Header`].
|
||||
pub type ProviderHeader<P> = <P as HeaderProvider>::Header;
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
use alloy_primitives::{Address, BlockNumber, B256};
|
||||
use auto_impl::auto_impl;
|
||||
use core::ops::{RangeBounds, RangeInclusive};
|
||||
use reth_db::models::{AccountBeforeTx, BlockNumberAddress};
|
||||
use reth_primitives_traits::StorageEntry;
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use std::ops::{RangeBounds, RangeInclusive};
|
||||
|
||||
/// History Writer
|
||||
#[auto_impl(&, Arc, Box)]
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
//!
|
||||
//! This module is scheduled for removal in the future.
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use alloy_eips::BlockNumHash;
|
||||
use alloy_primitives::{BlockHash, BlockNumber};
|
||||
use auto_impl::auto_impl;
|
||||
|
||||
@ -7,6 +7,9 @@
|
||||
)]
|
||||
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
// Re-export used error types.
|
||||
pub use reth_storage_errors as errors;
|
||||
|
||||
@ -8,12 +8,17 @@ use crate::{
|
||||
StateProviderBox, StateProviderFactory, StateRootProvider, StorageRootProvider,
|
||||
TransactionVariant, TransactionsProvider, WithdrawalsProvider,
|
||||
};
|
||||
use alloc::{boxed::Box, string::String, sync::Arc, vec::Vec};
|
||||
use alloy_consensus::transaction::TransactionMeta;
|
||||
use alloy_eips::{eip4895::Withdrawals, BlockHashOrNumber, BlockId, BlockNumberOrTag};
|
||||
use alloy_primitives::{
|
||||
map::{B256HashMap, HashMap},
|
||||
Address, BlockHash, BlockNumber, Bytes, StorageKey, StorageValue, TxHash, TxNumber, B256, U256,
|
||||
};
|
||||
use core::{
|
||||
marker::PhantomData,
|
||||
ops::{RangeBounds, RangeInclusive},
|
||||
};
|
||||
use reth_chainspec::{ChainInfo, ChainSpecProvider, EthChainSpec, MAINNET};
|
||||
use reth_db_models::{AccountBeforeTx, StoredBlockBodyIndices};
|
||||
use reth_primitives::{EthPrimitives, RecoveredBlock, SealedBlock};
|
||||
@ -25,11 +30,6 @@ use reth_trie::{
|
||||
updates::TrieUpdates, AccountProof, HashedPostState, HashedStorage, MultiProof,
|
||||
MultiProofTargets, TrieInput,
|
||||
};
|
||||
use std::{
|
||||
marker::PhantomData,
|
||||
ops::{RangeBounds, RangeInclusive},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
/// Supports various api interfaces for testing purposes.
|
||||
#[derive(Debug)]
|
||||
@ -83,7 +83,7 @@ impl<ChainSpec: Send + Sync, N: Send + Sync> BlockHashReader for NoopProvider<Ch
|
||||
_start: BlockNumber,
|
||||
_end: BlockNumber,
|
||||
) -> ProviderResult<Vec<B256>> {
|
||||
Ok(vec![])
|
||||
Ok(Vec::new())
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,21 +196,21 @@ impl<C: Send + Sync, N: NodePrimitives> BlockReader for NoopProvider<C, N> {
|
||||
}
|
||||
|
||||
fn block_range(&self, _range: RangeInclusive<BlockNumber>) -> ProviderResult<Vec<Self::Block>> {
|
||||
Ok(vec![])
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
fn block_with_senders_range(
|
||||
&self,
|
||||
_range: RangeInclusive<BlockNumber>,
|
||||
) -> ProviderResult<Vec<RecoveredBlock<Self::Block>>> {
|
||||
Ok(vec![])
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
fn sealed_block_with_senders_range(
|
||||
&self,
|
||||
_range: RangeInclusive<BlockNumber>,
|
||||
) -> ProviderResult<Vec<RecoveredBlock<Self::Block>>> {
|
||||
Ok(vec![])
|
||||
Ok(Vec::new())
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,7 +302,7 @@ impl<C: Send + Sync, N: NodePrimitives> ReceiptProvider for NoopProvider<C, N> {
|
||||
&self,
|
||||
_range: impl RangeBounds<TxNumber>,
|
||||
) -> ProviderResult<Vec<Self::Receipt>> {
|
||||
Ok(vec![])
|
||||
Ok(Vec::new())
|
||||
}
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ impl<C: Send + Sync, N: NodePrimitives> HeaderProvider for NoopProvider<C, N> {
|
||||
&self,
|
||||
_range: impl RangeBounds<BlockNumber>,
|
||||
) -> ProviderResult<Vec<Self::Header>> {
|
||||
Ok(vec![])
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
fn sealed_header(
|
||||
@ -346,7 +346,7 @@ impl<C: Send + Sync, N: NodePrimitives> HeaderProvider for NoopProvider<C, N> {
|
||||
_range: impl RangeBounds<BlockNumber>,
|
||||
_predicate: impl FnMut(&SealedHeader<Self::Header>) -> bool,
|
||||
) -> ProviderResult<Vec<SealedHeader<Self::Header>>> {
|
||||
Ok(vec![])
|
||||
Ok(Vec::new())
|
||||
}
|
||||
}
|
||||
|
||||
@ -572,6 +572,6 @@ impl<C: Send + Sync, N: Send + Sync> BlockBodyIndicesProvider for NoopProvider<C
|
||||
&self,
|
||||
_range: RangeInclusive<BlockNumber>,
|
||||
) -> ProviderResult<Vec<StoredBlockBodyIndices>> {
|
||||
Ok(vec![])
|
||||
Ok(Vec::new())
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
use crate::HeaderProvider;
|
||||
use alloc::{sync::Arc, vec::Vec};
|
||||
use alloy_eips::BlockHashOrNumber;
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
|
||||
@ -10,7 +11,7 @@ pub trait OmmersProvider: HeaderProvider + Send + Sync {
|
||||
fn ommers(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Vec<Self::Header>>>;
|
||||
}
|
||||
|
||||
impl<T: OmmersProvider> OmmersProvider for std::sync::Arc<T> {
|
||||
impl<T: OmmersProvider> OmmersProvider for Arc<T> {
|
||||
fn ommers(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Vec<Self::Header>>> {
|
||||
T::ommers(self, id)
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use alloc::vec::Vec;
|
||||
use reth_prune_types::{PruneCheckpoint, PruneSegment};
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
use crate::BlockIdReader;
|
||||
use alloc::vec::Vec;
|
||||
use alloy_eips::{BlockHashOrNumber, BlockId, BlockNumberOrTag};
|
||||
use alloy_primitives::{TxHash, TxNumber};
|
||||
use core::ops::RangeBounds;
|
||||
use reth_primitives_traits::Receipt;
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use std::ops::RangeBounds;
|
||||
|
||||
/// A helper type alias to access [`ReceiptProvider::Receipt`].
|
||||
pub type ProviderReceipt<P> = <P as ReceiptProvider>::Receipt;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use alloc::{string::String, vec::Vec};
|
||||
use alloy_primitives::BlockNumber;
|
||||
use reth_stages_types::{StageCheckpoint, StageId};
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
|
||||
@ -2,6 +2,7 @@ use super::{
|
||||
AccountReader, BlockHashReader, BlockIdReader, StateProofProvider, StateRootProvider,
|
||||
StorageRootProvider,
|
||||
};
|
||||
use alloc::boxed::Box;
|
||||
use alloy_consensus::constants::KECCAK_EMPTY;
|
||||
use alloy_eips::{BlockId, BlockNumberOrTag};
|
||||
use alloy_primitives::{Address, BlockHash, BlockNumber, StorageKey, StorageValue, B256, U256};
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
use alloc::{
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
vec::Vec,
|
||||
};
|
||||
use alloy_primitives::{Address, BlockNumber, B256};
|
||||
use core::ops::RangeInclusive;
|
||||
use reth_db_api::models::BlockNumberAddress;
|
||||
use reth_primitives_traits::StorageEntry;
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use std::{
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
ops::RangeInclusive,
|
||||
};
|
||||
|
||||
/// Storage reader
|
||||
#[auto_impl::auto_impl(&, Arc, Box)]
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use crate::{BlockNumReader, BlockReader};
|
||||
use alloc::vec::Vec;
|
||||
use alloy_consensus::transaction::TransactionMeta;
|
||||
use alloy_eips::BlockHashOrNumber;
|
||||
use alloy_primitives::{Address, BlockNumber, TxHash, TxNumber};
|
||||
use core::ops::{Range, RangeBounds, RangeInclusive};
|
||||
use reth_primitives_traits::SignedTransaction;
|
||||
use reth_storage_errors::provider::{ProviderError, ProviderResult};
|
||||
use std::ops::{Range, RangeBounds, RangeInclusive};
|
||||
|
||||
/// Enum to control transaction hash inclusion.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user