mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(trie): parallel storage roots (#6903)
This commit is contained in:
@ -16,7 +16,7 @@ workspace = true
|
||||
reth-primitives.workspace = true
|
||||
reth-interfaces.workspace = true
|
||||
reth-db.workspace = true
|
||||
reth-trie.workspace = true
|
||||
reth-trie = { workspace = true, features = ["metrics"] }
|
||||
reth-nippy-jar.workspace = true
|
||||
reth-codecs.workspace = true
|
||||
reth-node-api.workspace = true
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
use crate::{BlockNumReader, DatabaseProviderFactory, DatabaseProviderRO, ProviderError};
|
||||
use reth_db::{cursor::DbCursorRO, database::Database, tables, transaction::DbTx};
|
||||
use reth_interfaces::provider::{ConsistentViewError, ProviderResult};
|
||||
use reth_interfaces::provider::ProviderResult;
|
||||
use reth_primitives::{GotExpected, B256};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
pub use reth_interfaces::provider::ConsistentViewError;
|
||||
|
||||
/// A consistent view over state in the database.
|
||||
///
|
||||
/// View gets initialized with the latest or provided tip.
|
||||
@ -14,6 +16,11 @@ use std::marker::PhantomData;
|
||||
///
|
||||
/// The view should only be used outside of staged-sync.
|
||||
/// Otherwise, any attempt to create a provider will result in [ConsistentViewError::Syncing].
|
||||
///
|
||||
/// When using the view, the consumer should either
|
||||
/// 1) have a failover for when the state changes and handle [ConsistentViewError::Inconsistent]
|
||||
/// appropriately.
|
||||
/// 2) be sure that the state does not change.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ConsistentDbView<DB, Provider> {
|
||||
database: PhantomData<DB>,
|
||||
@ -56,7 +63,7 @@ where
|
||||
|
||||
let tip = last_entry.map(|(_, hash)| hash);
|
||||
if self.tip != tip {
|
||||
return Err(ConsistentViewError::InconsistentView {
|
||||
return Err(ConsistentViewError::Inconsistent {
|
||||
tip: GotExpected { got: tip, expected: self.tip },
|
||||
})
|
||||
}
|
||||
|
||||
@ -5,10 +5,10 @@ use crate::{
|
||||
},
|
||||
to_range,
|
||||
traits::{BlockSource, ReceiptProvider},
|
||||
BlockHashReader, BlockNumReader, BlockReader, ChainSpecProvider, EvmEnvProvider,
|
||||
HeaderProvider, HeaderSyncGap, HeaderSyncGapProvider, HeaderSyncMode, ProviderError,
|
||||
PruneCheckpointReader, StageCheckpointReader, StateProviderBox, TransactionVariant,
|
||||
TransactionsProvider, WithdrawalsProvider,
|
||||
BlockHashReader, BlockNumReader, BlockReader, ChainSpecProvider, DatabaseProviderFactory,
|
||||
EvmEnvProvider, HeaderProvider, HeaderSyncGap, HeaderSyncGapProvider, HeaderSyncMode,
|
||||
ProviderError, PruneCheckpointReader, StageCheckpointReader, StateProviderBox,
|
||||
TransactionVariant, TransactionsProvider, WithdrawalsProvider,
|
||||
};
|
||||
use reth_db::{database::Database, init_db, models::StoredBlockBodyIndices, DatabaseEnv};
|
||||
use reth_interfaces::{provider::ProviderResult, RethError, RethResult};
|
||||
@ -208,6 +208,12 @@ impl<DB: Database> ProviderFactory<DB> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<DB: Database> DatabaseProviderFactory<DB> for ProviderFactory<DB> {
|
||||
fn database_provider_ro(&self) -> ProviderResult<DatabaseProviderRO<DB>> {
|
||||
self.provider()
|
||||
}
|
||||
}
|
||||
|
||||
impl<DB: Database> HeaderSyncGapProvider for ProviderFactory<DB> {
|
||||
fn sync_gap(
|
||||
&self,
|
||||
|
||||
@ -59,7 +59,7 @@ mod chain_info;
|
||||
use chain_info::ChainInfoTracker;
|
||||
|
||||
mod consistent_view;
|
||||
pub use consistent_view::ConsistentDbView;
|
||||
pub use consistent_view::{ConsistentDbView, ConsistentViewError};
|
||||
|
||||
/// The main type for interacting with the blockchain.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user