mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: integrate SignedTx AT into StaticFileProviderRW (#12764)
This commit is contained in:
3
Cargo.lock
generated
3
Cargo.lock
generated
@ -6456,6 +6456,7 @@ dependencies = [
|
|||||||
"reth-blockchain-tree",
|
"reth-blockchain-tree",
|
||||||
"reth-blockchain-tree-api",
|
"reth-blockchain-tree-api",
|
||||||
"reth-chainspec",
|
"reth-chainspec",
|
||||||
|
"reth-codecs",
|
||||||
"reth-config",
|
"reth-config",
|
||||||
"reth-consensus",
|
"reth-consensus",
|
||||||
"reth-db",
|
"reth-db",
|
||||||
@ -9159,8 +9160,10 @@ dependencies = [
|
|||||||
"assert_matches",
|
"assert_matches",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"rayon",
|
"rayon",
|
||||||
|
"reth-codecs",
|
||||||
"reth-db",
|
"reth-db",
|
||||||
"reth-db-api",
|
"reth-db-api",
|
||||||
|
"reth-primitives-traits",
|
||||||
"reth-provider",
|
"reth-provider",
|
||||||
"reth-prune-types",
|
"reth-prune-types",
|
||||||
"reth-stages",
|
"reth-stages",
|
||||||
|
|||||||
@ -1424,7 +1424,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn setup_genesis<
|
fn setup_genesis<
|
||||||
N: ProviderNodeTypes<Primitives: FullNodePrimitives<Block = reth_primitives::Block>>,
|
N: ProviderNodeTypes<Primitives: FullNodePrimitives<BlockBody = reth_primitives::BlockBody>>,
|
||||||
>(
|
>(
|
||||||
factory: &ProviderFactory<N>,
|
factory: &ProviderFactory<N>,
|
||||||
mut genesis: SealedBlock,
|
mut genesis: SealedBlock,
|
||||||
|
|||||||
@ -4,7 +4,7 @@ use alloy_primitives::{BlockHash, BlockNumber};
|
|||||||
use reth_consensus::Consensus;
|
use reth_consensus::Consensus;
|
||||||
use reth_db::{static_file::HeaderMask, tables};
|
use reth_db::{static_file::HeaderMask, tables};
|
||||||
use reth_db_api::{cursor::DbCursorRO, transaction::DbTx};
|
use reth_db_api::{cursor::DbCursorRO, transaction::DbTx};
|
||||||
use reth_node_types::{Block, FullNodePrimitives, NodeTypesWithDB};
|
use reth_node_types::{FullNodePrimitives, NodeTypesWithDB};
|
||||||
use reth_primitives::{BlockBody, StaticFileSegment};
|
use reth_primitives::{BlockBody, StaticFileSegment};
|
||||||
use reth_provider::{
|
use reth_provider::{
|
||||||
providers::ProviderNodeTypes, ChainStateBlockReader, ChainStateBlockWriter, ProviderFactory,
|
providers::ProviderNodeTypes, ChainStateBlockReader, ChainStateBlockWriter, ProviderFactory,
|
||||||
@ -15,11 +15,11 @@ use std::{collections::BTreeMap, sync::Arc};
|
|||||||
|
|
||||||
/// A helper trait with requirements for [`ProviderNodeTypes`] to be used within [`TreeExternals`].
|
/// A helper trait with requirements for [`ProviderNodeTypes`] to be used within [`TreeExternals`].
|
||||||
pub trait TreeNodeTypes:
|
pub trait TreeNodeTypes:
|
||||||
ProviderNodeTypes<Primitives: FullNodePrimitives<Block: Block<Body = BlockBody>>>
|
ProviderNodeTypes<Primitives: FullNodePrimitives<BlockBody = BlockBody>>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
impl<T> TreeNodeTypes for T where
|
impl<T> TreeNodeTypes for T where
|
||||||
T: ProviderNodeTypes<Primitives: FullNodePrimitives<Block: Block<Body = BlockBody>>>
|
T: ProviderNodeTypes<Primitives: FullNodePrimitives<BlockBody = BlockBody>>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -197,19 +197,11 @@ impl AccessRights {
|
|||||||
/// [`NodeTypes`](reth_node_builder::NodeTypes) in CLI.
|
/// [`NodeTypes`](reth_node_builder::NodeTypes) in CLI.
|
||||||
pub trait CliNodeTypes:
|
pub trait CliNodeTypes:
|
||||||
NodeTypesWithEngine
|
NodeTypesWithEngine
|
||||||
+ NodeTypesForProvider<
|
+ NodeTypesForProvider<Primitives: FullNodePrimitives<BlockBody = reth_primitives::BlockBody>>
|
||||||
Primitives: FullNodePrimitives<
|
|
||||||
Block: reth_node_api::Block<Body = reth_primitives::BlockBody>,
|
|
||||||
>,
|
|
||||||
>
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
impl<N> CliNodeTypes for N where
|
impl<N> CliNodeTypes for N where
|
||||||
N: NodeTypesWithEngine
|
N: NodeTypesWithEngine
|
||||||
+ NodeTypesForProvider<
|
+ NodeTypesForProvider<Primitives: FullNodePrimitives<BlockBody = reth_primitives::BlockBody>>
|
||||||
Primitives: FullNodePrimitives<
|
|
||||||
Block: reth_node_api::Block<Body = reth_primitives::BlockBody>,
|
|
||||||
>,
|
|
||||||
>
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,8 @@ workspace = true
|
|||||||
# reth
|
# reth
|
||||||
reth-ethereum-consensus.workspace = true
|
reth-ethereum-consensus.workspace = true
|
||||||
reth-blockchain-tree-api.workspace = true
|
reth-blockchain-tree-api.workspace = true
|
||||||
|
reth-codecs.workspace = true
|
||||||
|
reth-db-api.workspace = true
|
||||||
reth-primitives.workspace = true
|
reth-primitives.workspace = true
|
||||||
reth-stages-api.workspace = true
|
reth-stages-api.workspace = true
|
||||||
reth-errors.workspace = true
|
reth-errors.workspace = true
|
||||||
@ -80,6 +82,7 @@ assert_matches.workspace = true
|
|||||||
[features]
|
[features]
|
||||||
optimism = [
|
optimism = [
|
||||||
"reth-blockchain-tree/optimism",
|
"reth-blockchain-tree/optimism",
|
||||||
|
"reth-codecs/optimism",
|
||||||
"reth-chainspec",
|
"reth-chainspec",
|
||||||
"reth-db-api/optimism",
|
"reth-db-api/optimism",
|
||||||
"reth-db/optimism",
|
"reth-db/optimism",
|
||||||
|
|||||||
@ -6,8 +6,10 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use alloy_primitives::BlockNumber;
|
use alloy_primitives::BlockNumber;
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
|
use reth_codecs::Compact;
|
||||||
|
use reth_db_api::table::Value;
|
||||||
use reth_errors::RethResult;
|
use reth_errors::RethResult;
|
||||||
use reth_primitives::static_file::HighestStaticFiles;
|
use reth_primitives::{static_file::HighestStaticFiles, NodePrimitives};
|
||||||
use reth_provider::{
|
use reth_provider::{
|
||||||
BlockReader, ChainStateBlockReader, DatabaseProviderFactory, StageCheckpointReader,
|
BlockReader, ChainStateBlockReader, DatabaseProviderFactory, StageCheckpointReader,
|
||||||
StaticFileProviderFactory,
|
StaticFileProviderFactory,
|
||||||
@ -33,8 +35,9 @@ impl<Provider> StaticFileHook<Provider>
|
|||||||
where
|
where
|
||||||
Provider: StaticFileProviderFactory
|
Provider: StaticFileProviderFactory
|
||||||
+ DatabaseProviderFactory<
|
+ DatabaseProviderFactory<
|
||||||
Provider: StaticFileProviderFactory
|
Provider: StaticFileProviderFactory<
|
||||||
+ StageCheckpointReader
|
Primitives: NodePrimitives<SignedTx: Value + Compact>,
|
||||||
|
> + StageCheckpointReader
|
||||||
+ BlockReader
|
+ BlockReader
|
||||||
+ ChainStateBlockReader,
|
+ ChainStateBlockReader,
|
||||||
> + 'static,
|
> + 'static,
|
||||||
@ -148,8 +151,9 @@ impl<Provider> EngineHook for StaticFileHook<Provider>
|
|||||||
where
|
where
|
||||||
Provider: StaticFileProviderFactory
|
Provider: StaticFileProviderFactory
|
||||||
+ DatabaseProviderFactory<
|
+ DatabaseProviderFactory<
|
||||||
Provider: StaticFileProviderFactory
|
Provider: StaticFileProviderFactory<
|
||||||
+ StageCheckpointReader
|
Primitives: NodePrimitives<SignedTx: Value + Compact>,
|
||||||
|
> + StageCheckpointReader
|
||||||
+ BlockReader
|
+ BlockReader
|
||||||
+ ChainStateBlockReader,
|
+ ChainStateBlockReader,
|
||||||
> + 'static,
|
> + 'static,
|
||||||
|
|||||||
@ -2172,7 +2172,7 @@ mod tests {
|
|||||||
|
|
||||||
fn insert_blocks<
|
fn insert_blocks<
|
||||||
'a,
|
'a,
|
||||||
N: ProviderNodeTypes<Primitives: FullNodePrimitives<Block = reth_primitives::Block>>,
|
N: ProviderNodeTypes<Primitives: FullNodePrimitives<BlockBody = reth_primitives::BlockBody>>,
|
||||||
>(
|
>(
|
||||||
provider_factory: ProviderFactory<N>,
|
provider_factory: ProviderFactory<N>,
|
||||||
mut blocks: impl Iterator<Item = &'a SealedBlock>,
|
mut blocks: impl Iterator<Item = &'a SealedBlock>,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use alloy_eips::BlockNumHash;
|
|||||||
use reth_chain_state::ExecutedBlock;
|
use reth_chain_state::ExecutedBlock;
|
||||||
use reth_errors::ProviderError;
|
use reth_errors::ProviderError;
|
||||||
use reth_primitives::BlockBody;
|
use reth_primitives::BlockBody;
|
||||||
use reth_primitives_traits::{Block, FullNodePrimitives};
|
use reth_primitives_traits::FullNodePrimitives;
|
||||||
use reth_provider::{
|
use reth_provider::{
|
||||||
providers::ProviderNodeTypes, writer::UnifiedStorageWriter, BlockHashReader,
|
providers::ProviderNodeTypes, writer::UnifiedStorageWriter, BlockHashReader,
|
||||||
ChainStateBlockWriter, DatabaseProviderFactory, ProviderFactory, StaticFileProviderFactory,
|
ChainStateBlockWriter, DatabaseProviderFactory, ProviderFactory, StaticFileProviderFactory,
|
||||||
@ -21,11 +21,11 @@ use tracing::{debug, error};
|
|||||||
/// A helper trait with requirements for [`ProviderNodeTypes`] to be used within
|
/// A helper trait with requirements for [`ProviderNodeTypes`] to be used within
|
||||||
/// [`PersistenceService`].
|
/// [`PersistenceService`].
|
||||||
pub trait PersistenceNodeTypes:
|
pub trait PersistenceNodeTypes:
|
||||||
ProviderNodeTypes<Primitives: FullNodePrimitives<Block: Block<Body = BlockBody>>>
|
ProviderNodeTypes<Primitives: FullNodePrimitives<BlockBody = BlockBody>>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
impl<T> PersistenceNodeTypes for T where
|
impl<T> PersistenceNodeTypes for T where
|
||||||
T: ProviderNodeTypes<Primitives: FullNodePrimitives<Block: Block<Body = BlockBody>>>
|
T: ProviderNodeTypes<Primitives: FullNodePrimitives<BlockBody = BlockBody>>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
/// Writes parts of reth's in memory tree state to the database and static files.
|
/// Writes parts of reth's in memory tree state to the database and static files.
|
||||||
|
|||||||
@ -58,7 +58,7 @@ pub(crate) fn execute_block_and_commit_to_database<N>(
|
|||||||
block: &BlockWithSenders,
|
block: &BlockWithSenders,
|
||||||
) -> eyre::Result<BlockExecutionOutput<Receipt>>
|
) -> eyre::Result<BlockExecutionOutput<Receipt>>
|
||||||
where
|
where
|
||||||
N: ProviderNodeTypes<Primitives: FullNodePrimitives<Block = reth_primitives::Block>>,
|
N: ProviderNodeTypes<Primitives: FullNodePrimitives<BlockBody = reth_primitives::BlockBody>>,
|
||||||
{
|
{
|
||||||
let provider = provider_factory.provider()?;
|
let provider = provider_factory.provider()?;
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ pub(crate) fn blocks_and_execution_outputs<N>(
|
|||||||
key_pair: Keypair,
|
key_pair: Keypair,
|
||||||
) -> eyre::Result<Vec<(SealedBlockWithSenders, BlockExecutionOutput<Receipt>)>>
|
) -> eyre::Result<Vec<(SealedBlockWithSenders, BlockExecutionOutput<Receipt>)>>
|
||||||
where
|
where
|
||||||
N: ProviderNodeTypes<Primitives: FullNodePrimitives<Block = reth_primitives::Block>>,
|
N: ProviderNodeTypes<Primitives: FullNodePrimitives<BlockBody = reth_primitives::BlockBody>>,
|
||||||
{
|
{
|
||||||
let (block1, block2) = blocks(chain_spec.clone(), key_pair)?;
|
let (block1, block2) = blocks(chain_spec.clone(), key_pair)?;
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ pub(crate) fn blocks_and_execution_outcome<N>(
|
|||||||
) -> eyre::Result<(Vec<SealedBlockWithSenders>, ExecutionOutcome)>
|
) -> eyre::Result<(Vec<SealedBlockWithSenders>, ExecutionOutcome)>
|
||||||
where
|
where
|
||||||
N: ProviderNodeTypes,
|
N: ProviderNodeTypes,
|
||||||
N::Primitives: FullNodePrimitives<Block = reth_primitives::Block>,
|
N::Primitives: FullNodePrimitives<BlockBody = reth_primitives::BlockBody>,
|
||||||
{
|
{
|
||||||
let (block1, block2) = blocks(chain_spec.clone(), key_pair)?;
|
let (block1, block2) = blocks(chain_spec.clone(), key_pair)?;
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ use reth_exex::ExExManagerHandle;
|
|||||||
use reth_network_p2p::{
|
use reth_network_p2p::{
|
||||||
bodies::downloader::BodyDownloader, headers::downloader::HeaderDownloader, EthBlockClient,
|
bodies::downloader::BodyDownloader, headers::downloader::HeaderDownloader, EthBlockClient,
|
||||||
};
|
};
|
||||||
use reth_node_api::FullNodePrimitives;
|
use reth_node_api::{FullNodePrimitives, NodePrimitives};
|
||||||
use reth_provider::{providers::ProviderNodeTypes, ProviderFactory};
|
use reth_provider::{providers::ProviderNodeTypes, ProviderFactory};
|
||||||
use reth_stages::{prelude::DefaultStages, stages::ExecutionStage, Pipeline, StageSet};
|
use reth_stages::{prelude::DefaultStages, stages::ExecutionStage, Pipeline, StageSet};
|
||||||
use reth_static_file::StaticFileProducer;
|
use reth_static_file::StaticFileProducer;
|
||||||
@ -88,7 +88,7 @@ where
|
|||||||
N: ProviderNodeTypes,
|
N: ProviderNodeTypes,
|
||||||
H: HeaderDownloader<Header = alloy_consensus::Header> + 'static,
|
H: HeaderDownloader<Header = alloy_consensus::Header> + 'static,
|
||||||
B: BodyDownloader<
|
B: BodyDownloader<
|
||||||
Body = <<N::Primitives as FullNodePrimitives>::Block as reth_node_api::Block>::Body,
|
Body = <<N::Primitives as NodePrimitives>::Block as reth_node_api::Block>::Body,
|
||||||
> + 'static,
|
> + 'static,
|
||||||
Executor: BlockExecutorProvider,
|
Executor: BlockExecutorProvider,
|
||||||
N::Primitives: FullNodePrimitives<BlockBody = reth_primitives::BlockBody>,
|
N::Primitives: FullNodePrimitives<BlockBody = reth_primitives::BlockBody>,
|
||||||
|
|||||||
@ -14,14 +14,14 @@ pub mod tx_type;
|
|||||||
pub use tx_type::OpTxType;
|
pub use tx_type::OpTxType;
|
||||||
|
|
||||||
use alloy_consensus::Header;
|
use alloy_consensus::Header;
|
||||||
use reth_node_types::FullNodePrimitives;
|
use reth_node_types::NodePrimitives;
|
||||||
use reth_primitives::{Block, BlockBody, Receipt, TransactionSigned};
|
use reth_primitives::{Block, BlockBody, Receipt, TransactionSigned};
|
||||||
|
|
||||||
/// Optimism primitive types.
|
/// Optimism primitive types.
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||||
pub struct OpPrimitives;
|
pub struct OpPrimitives;
|
||||||
|
|
||||||
impl FullNodePrimitives for OpPrimitives {
|
impl NodePrimitives for OpPrimitives {
|
||||||
type Block = Block;
|
type Block = Block;
|
||||||
type BlockHeader = Header;
|
type BlockHeader = Header;
|
||||||
type BlockBody = BlockBody;
|
type BlockBody = BlockBody;
|
||||||
|
|||||||
@ -77,33 +77,45 @@ impl NodePrimitives for () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Helper trait that sets trait bounds on [`NodePrimitives`].
|
/// Helper trait that sets trait bounds on [`NodePrimitives`].
|
||||||
pub trait FullNodePrimitives:
|
pub trait FullNodePrimitives
|
||||||
Send + Sync + Unpin + Clone + Default + fmt::Debug + PartialEq + Eq + 'static
|
where
|
||||||
|
Self: NodePrimitives<
|
||||||
|
Block: FullBlock<Header = Self::BlockHeader, Body = Self::BlockBody>,
|
||||||
|
BlockHeader: FullBlockHeader,
|
||||||
|
BlockBody: FullBlockBody<Transaction = Self::SignedTx>,
|
||||||
|
SignedTx: FullSignedTx,
|
||||||
|
TxType: FullTxType,
|
||||||
|
Receipt: FullReceipt,
|
||||||
|
> + Send
|
||||||
|
+ Sync
|
||||||
|
+ Unpin
|
||||||
|
+ Clone
|
||||||
|
+ Default
|
||||||
|
+ fmt::Debug
|
||||||
|
+ PartialEq
|
||||||
|
+ Eq
|
||||||
|
+ 'static,
|
||||||
{
|
{
|
||||||
/// Block primitive.
|
|
||||||
type Block: FullBlock<Header = Self::BlockHeader, Body = Self::BlockBody>;
|
|
||||||
/// Block header primitive.
|
|
||||||
type BlockHeader: FullBlockHeader + 'static;
|
|
||||||
/// Block body primitive.
|
|
||||||
type BlockBody: FullBlockBody<Transaction = Self::SignedTx> + 'static;
|
|
||||||
/// Signed version of the transaction type.
|
|
||||||
type SignedTx: FullSignedTx;
|
|
||||||
/// Transaction envelope type ID.
|
|
||||||
type TxType: FullTxType;
|
|
||||||
/// A receipt.
|
|
||||||
type Receipt: FullReceipt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> NodePrimitives for T
|
impl<T> FullNodePrimitives for T where
|
||||||
where
|
T: NodePrimitives<
|
||||||
T: FullNodePrimitives,
|
Block: FullBlock<Header = Self::BlockHeader, Body = Self::BlockBody>,
|
||||||
|
BlockHeader: FullBlockHeader,
|
||||||
|
BlockBody: FullBlockBody<Transaction = Self::SignedTx>,
|
||||||
|
SignedTx: FullSignedTx,
|
||||||
|
TxType: FullTxType,
|
||||||
|
Receipt: FullReceipt,
|
||||||
|
> + Send
|
||||||
|
+ Sync
|
||||||
|
+ Unpin
|
||||||
|
+ Clone
|
||||||
|
+ Default
|
||||||
|
+ fmt::Debug
|
||||||
|
+ PartialEq
|
||||||
|
+ Eq
|
||||||
|
+ 'static
|
||||||
{
|
{
|
||||||
type Block = T::Block;
|
|
||||||
type BlockHeader = T::BlockHeader;
|
|
||||||
type BlockBody = T::BlockBody;
|
|
||||||
type SignedTx = T::SignedTx;
|
|
||||||
type TxType = T::TxType;
|
|
||||||
type Receipt = T::Receipt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper adapter type for accessing [`NodePrimitives`] receipt type.
|
/// Helper adapter type for accessing [`NodePrimitives`] receipt type.
|
||||||
|
|||||||
@ -79,7 +79,7 @@ pub mod serde_bincode_compat {
|
|||||||
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct EthPrimitives;
|
pub struct EthPrimitives;
|
||||||
|
|
||||||
impl reth_primitives_traits::FullNodePrimitives for EthPrimitives {
|
impl reth_primitives_traits::NodePrimitives for EthPrimitives {
|
||||||
type Block = crate::Block;
|
type Block = crate::Block;
|
||||||
type BlockHeader = alloy_consensus::Header;
|
type BlockHeader = alloy_consensus::Header;
|
||||||
type BlockBody = crate::BlockBody;
|
type BlockBody = crate::BlockBody;
|
||||||
|
|||||||
@ -63,7 +63,8 @@ impl AccountHashingStage {
|
|||||||
opts: SeedOpts,
|
opts: SeedOpts,
|
||||||
) -> Result<Vec<(alloy_primitives::Address, reth_primitives::Account)>, StageError>
|
) -> Result<Vec<(alloy_primitives::Address, reth_primitives::Account)>, StageError>
|
||||||
where
|
where
|
||||||
N::Primitives: reth_primitives_traits::FullNodePrimitives<Block = reth_primitives::Block>,
|
N::Primitives:
|
||||||
|
reth_primitives_traits::FullNodePrimitives<BlockBody = reth_primitives::BlockBody>,
|
||||||
{
|
{
|
||||||
use alloy_primitives::U256;
|
use alloy_primitives::U256;
|
||||||
use reth_db_api::models::AccountBeforeTx;
|
use reth_db_api::models::AccountBeforeTx;
|
||||||
|
|||||||
@ -13,12 +13,14 @@ workspace = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# reth
|
# reth
|
||||||
|
reth-codecs.workspace = true
|
||||||
reth-db.workspace = true
|
reth-db.workspace = true
|
||||||
reth-db-api.workspace = true
|
reth-db-api.workspace = true
|
||||||
reth-provider.workspace = true
|
reth-provider.workspace = true
|
||||||
reth-storage-errors.workspace = true
|
reth-storage-errors.workspace = true
|
||||||
reth-tokio-util.workspace = true
|
reth-tokio-util.workspace = true
|
||||||
reth-prune-types.workspace = true
|
reth-prune-types.workspace = true
|
||||||
|
reth-primitives-traits.workspace = true
|
||||||
reth-static-file-types.workspace = true
|
reth-static-file-types.workspace = true
|
||||||
reth-stages-types.workspace = true
|
reth-stages-types.workspace = true
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
use crate::segments::Segment;
|
use crate::segments::Segment;
|
||||||
use alloy_primitives::BlockNumber;
|
use alloy_primitives::BlockNumber;
|
||||||
use reth_db::tables;
|
use reth_codecs::Compact;
|
||||||
|
use reth_db::{table::Value, tables};
|
||||||
use reth_db_api::{cursor::DbCursorRO, transaction::DbTx};
|
use reth_db_api::{cursor::DbCursorRO, transaction::DbTx};
|
||||||
|
use reth_primitives_traits::NodePrimitives;
|
||||||
use reth_provider::{
|
use reth_provider::{
|
||||||
providers::StaticFileWriter, BlockReader, DBProvider, StaticFileProviderFactory,
|
providers::StaticFileWriter, BlockReader, DBProvider, StaticFileProviderFactory,
|
||||||
};
|
};
|
||||||
@ -13,8 +15,11 @@ use std::ops::RangeInclusive;
|
|||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct Transactions;
|
pub struct Transactions;
|
||||||
|
|
||||||
impl<Provider: StaticFileProviderFactory + DBProvider + BlockReader> Segment<Provider>
|
impl<Provider> Segment<Provider> for Transactions
|
||||||
for Transactions
|
where
|
||||||
|
Provider: StaticFileProviderFactory<Primitives: NodePrimitives<SignedTx: Value + Compact>>
|
||||||
|
+ DBProvider
|
||||||
|
+ BlockReader,
|
||||||
{
|
{
|
||||||
fn segment(&self) -> StaticFileSegment {
|
fn segment(&self) -> StaticFileSegment {
|
||||||
StaticFileSegment::Transactions
|
StaticFileSegment::Transactions
|
||||||
@ -38,8 +43,9 @@ impl<Provider: StaticFileProviderFactory + DBProvider + BlockReader> Segment<Pro
|
|||||||
.block_body_indices(block)?
|
.block_body_indices(block)?
|
||||||
.ok_or(ProviderError::BlockBodyIndicesNotFound(block))?;
|
.ok_or(ProviderError::BlockBodyIndicesNotFound(block))?;
|
||||||
|
|
||||||
let mut transactions_cursor =
|
let mut transactions_cursor = provider.tx_ref().cursor_read::<tables::Transactions<
|
||||||
provider.tx_ref().cursor_read::<tables::Transactions>()?;
|
<<Provider as StaticFileProviderFactory>::Primitives as NodePrimitives>::SignedTx,
|
||||||
|
>>()?;
|
||||||
let transactions_walker =
|
let transactions_walker =
|
||||||
transactions_cursor.walk_range(block_body_indices.tx_num_range())?;
|
transactions_cursor.walk_range(block_body_indices.tx_num_range())?;
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,9 @@ use crate::{segments, segments::Segment, StaticFileProducerEvent};
|
|||||||
use alloy_primitives::BlockNumber;
|
use alloy_primitives::BlockNumber;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
use reth_codecs::Compact;
|
||||||
|
use reth_db::table::Value;
|
||||||
|
use reth_primitives_traits::NodePrimitives;
|
||||||
use reth_provider::{
|
use reth_provider::{
|
||||||
providers::StaticFileWriter, BlockReader, ChainStateBlockReader, DBProvider,
|
providers::StaticFileWriter, BlockReader, ChainStateBlockReader, DBProvider,
|
||||||
DatabaseProviderFactory, StageCheckpointReader, StaticFileProviderFactory,
|
DatabaseProviderFactory, StageCheckpointReader, StaticFileProviderFactory,
|
||||||
@ -86,7 +89,10 @@ impl<Provider> StaticFileProducerInner<Provider>
|
|||||||
where
|
where
|
||||||
Provider: StaticFileProviderFactory
|
Provider: StaticFileProviderFactory
|
||||||
+ DatabaseProviderFactory<
|
+ DatabaseProviderFactory<
|
||||||
Provider: StaticFileProviderFactory + StageCheckpointReader + BlockReader,
|
Provider: StaticFileProviderFactory<
|
||||||
|
Primitives: NodePrimitives<SignedTx: Value + Compact>,
|
||||||
|
> + StageCheckpointReader
|
||||||
|
+ BlockReader,
|
||||||
>,
|
>,
|
||||||
{
|
{
|
||||||
/// Listen for events on the `static_file_producer`.
|
/// Listen for events on the `static_file_producer`.
|
||||||
|
|||||||
@ -889,8 +889,7 @@ mod tests {
|
|||||||
static_file_provider.latest_writer(StaticFileSegment::Transactions)?;
|
static_file_provider.latest_writer(StaticFileSegment::Transactions)?;
|
||||||
transactions_writer.increment_block(block.number)?;
|
transactions_writer.increment_block(block.number)?;
|
||||||
for tx in block.body.transactions() {
|
for tx in block.body.transactions() {
|
||||||
let tx: TransactionSignedNoHash = tx.clone().into();
|
transactions_writer.append_transaction(tx_num, tx)?;
|
||||||
transactions_writer.append_transaction(tx_num, &tx)?;
|
|
||||||
tx_num += 1;
|
tx_num += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -48,11 +48,11 @@ use reth_execution_types::{Chain, ExecutionOutcome};
|
|||||||
use reth_network_p2p::headers::downloader::SyncTarget;
|
use reth_network_p2p::headers::downloader::SyncTarget;
|
||||||
use reth_node_types::NodeTypes;
|
use reth_node_types::NodeTypes;
|
||||||
use reth_primitives::{
|
use reth_primitives::{
|
||||||
Account, Block, BlockBody, BlockWithSenders, Bytecode, GotExpected, Receipt, SealedBlock,
|
Account, Block, BlockBody, BlockWithSenders, Bytecode, GotExpected, NodePrimitives, Receipt,
|
||||||
SealedBlockWithSenders, SealedHeader, StaticFileSegment, StorageEntry, TransactionMeta,
|
SealedBlock, SealedBlockWithSenders, SealedHeader, StaticFileSegment, StorageEntry,
|
||||||
TransactionSigned, TransactionSignedNoHash,
|
TransactionMeta, TransactionSigned, TransactionSignedNoHash,
|
||||||
};
|
};
|
||||||
use reth_primitives_traits::{BlockBody as _, FullNodePrimitives, SignedTransaction};
|
use reth_primitives_traits::{BlockBody as _, SignedTransaction};
|
||||||
use reth_prune_types::{PruneCheckpoint, PruneModes, PruneSegment};
|
use reth_prune_types::{PruneCheckpoint, PruneModes, PruneSegment};
|
||||||
use reth_stages_types::{StageCheckpoint, StageId};
|
use reth_stages_types::{StageCheckpoint, StageId};
|
||||||
use reth_storage_api::{StateProvider, StorageChangeSetReader, TryIntoHistoricalStateProvider};
|
use reth_storage_api::{StateProvider, StorageChangeSetReader, TryIntoHistoricalStateProvider};
|
||||||
@ -2778,8 +2778,7 @@ impl<TX: DbTxMut + DbTx + 'static, N: ProviderNodeTypes + 'static> BlockExecutio
|
|||||||
impl<TX: DbTxMut + DbTx + 'static, N: ProviderNodeTypes + 'static> BlockWriter
|
impl<TX: DbTxMut + DbTx + 'static, N: ProviderNodeTypes + 'static> BlockWriter
|
||||||
for DatabaseProvider<TX, N>
|
for DatabaseProvider<TX, N>
|
||||||
{
|
{
|
||||||
type Body =
|
type Body = <<N::Primitives as NodePrimitives>::Block as reth_primitives_traits::Block>::Body;
|
||||||
<<N::Primitives as FullNodePrimitives>::Block as reth_primitives_traits::Block>::Body;
|
|
||||||
|
|
||||||
/// Inserts the block into the database, always modifying the following tables:
|
/// Inserts the block into the database, always modifying the following tables:
|
||||||
/// * [`CanonicalHeaders`](tables::CanonicalHeaders)
|
/// * [`CanonicalHeaders`](tables::CanonicalHeaders)
|
||||||
|
|||||||
@ -68,7 +68,7 @@ mod tests {
|
|||||||
use reth_db_api::transaction::DbTxMut;
|
use reth_db_api::transaction::DbTxMut;
|
||||||
use reth_primitives::{
|
use reth_primitives::{
|
||||||
static_file::{find_fixed_range, SegmentRangeInclusive, DEFAULT_BLOCKS_PER_STATIC_FILE},
|
static_file::{find_fixed_range, SegmentRangeInclusive, DEFAULT_BLOCKS_PER_STATIC_FILE},
|
||||||
Receipt, TransactionSignedNoHash,
|
EthPrimitives, Receipt, TransactionSigned,
|
||||||
};
|
};
|
||||||
use reth_storage_api::{ReceiptProvider, TransactionsProvider};
|
use reth_storage_api::{ReceiptProvider, TransactionsProvider};
|
||||||
use reth_testing_utils::generators::{self, random_header_range};
|
use reth_testing_utils::generators::{self, random_header_range};
|
||||||
@ -304,20 +304,20 @@ mod tests {
|
|||||||
/// * `10..=19`: no txs/receipts
|
/// * `10..=19`: no txs/receipts
|
||||||
/// * `20..=29`: only one tx/receipt
|
/// * `20..=29`: only one tx/receipt
|
||||||
fn setup_tx_based_scenario(
|
fn setup_tx_based_scenario(
|
||||||
sf_rw: &StaticFileProvider<()>,
|
sf_rw: &StaticFileProvider<EthPrimitives>,
|
||||||
segment: StaticFileSegment,
|
segment: StaticFileSegment,
|
||||||
blocks_per_file: u64,
|
blocks_per_file: u64,
|
||||||
) {
|
) {
|
||||||
fn setup_block_ranges(
|
fn setup_block_ranges(
|
||||||
writer: &mut StaticFileProviderRWRefMut<'_, ()>,
|
writer: &mut StaticFileProviderRWRefMut<'_, EthPrimitives>,
|
||||||
sf_rw: &StaticFileProvider<()>,
|
sf_rw: &StaticFileProvider<EthPrimitives>,
|
||||||
segment: StaticFileSegment,
|
segment: StaticFileSegment,
|
||||||
block_range: &Range<u64>,
|
block_range: &Range<u64>,
|
||||||
mut tx_count: u64,
|
mut tx_count: u64,
|
||||||
next_tx_num: &mut u64,
|
next_tx_num: &mut u64,
|
||||||
) {
|
) {
|
||||||
let mut receipt = Receipt::default();
|
let mut receipt = Receipt::default();
|
||||||
let mut tx = TransactionSignedNoHash::default();
|
let mut tx = TransactionSigned::default();
|
||||||
|
|
||||||
for block in block_range.clone() {
|
for block in block_range.clone() {
|
||||||
writer.increment_block(block).unwrap();
|
writer.increment_block(block).unwrap();
|
||||||
|
|||||||
@ -558,7 +558,10 @@ impl<N: NodePrimitives> StaticFileProviderRW<N> {
|
|||||||
/// empty blocks and this function wouldn't be called.
|
/// empty blocks and this function wouldn't be called.
|
||||||
///
|
///
|
||||||
/// Returns the current [`TxNumber`] as seen in the static file.
|
/// Returns the current [`TxNumber`] as seen in the static file.
|
||||||
pub fn append_transaction(&mut self, tx_num: TxNumber, tx: impl Compact) -> ProviderResult<()> {
|
pub fn append_transaction(&mut self, tx_num: TxNumber, tx: &N::SignedTx) -> ProviderResult<()>
|
||||||
|
where
|
||||||
|
N::SignedTx: Compact,
|
||||||
|
{
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
self.ensure_no_queued_prune()?;
|
self.ensure_no_queued_prune()?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user