Skip to content

Commit

Permalink
fix: use generic receipt in StaticFileProducer (paradigmxyz#13324)
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr authored Dec 11, 2024
1 parent c553b1e commit 328d493
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
12 changes: 10 additions & 2 deletions crates/consensus/beacon/src/engine/hooks/static_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ where
Provider: StaticFileProviderFactory
+ DatabaseProviderFactory<
Provider: StaticFileProviderFactory<
Primitives: NodePrimitives<SignedTx: Value + Compact, BlockHeader: Value + Compact>,
Primitives: NodePrimitives<
SignedTx: Value + Compact,
BlockHeader: Value + Compact,
Receipt: Value + Compact,
>,
> + StageCheckpointReader
+ BlockReader
+ ChainStateBlockReader,
Expand Down Expand Up @@ -152,7 +156,11 @@ where
Provider: StaticFileProviderFactory
+ DatabaseProviderFactory<
Provider: StaticFileProviderFactory<
Primitives: NodePrimitives<SignedTx: Value + Compact, BlockHeader: Value + Compact>,
Primitives: NodePrimitives<
SignedTx: Value + Compact,
BlockHeader: Value + Compact,
Receipt: Value + Compact,
>,
> + StageCheckpointReader
+ BlockReader
+ ChainStateBlockReader,
Expand Down
16 changes: 12 additions & 4 deletions crates/static-file/static-file/src/segments/receipts.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::segments::Segment;
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_primitives_traits::NodePrimitives;
use reth_provider::{
providers::StaticFileWriter, BlockReader, DBProvider, StaticFileProviderFactory,
};
Expand All @@ -13,8 +15,11 @@ use std::ops::RangeInclusive;
#[derive(Debug, Default)]
pub struct Receipts;

impl<Provider: StaticFileProviderFactory + DBProvider + BlockReader> Segment<Provider>
for Receipts
impl<Provider> Segment<Provider> for Receipts
where
Provider: StaticFileProviderFactory<Primitives: NodePrimitives<Receipt: Value + Compact>>
+ DBProvider
+ BlockReader,
{
fn segment(&self) -> StaticFileSegment {
StaticFileSegment::Receipts
Expand All @@ -36,7 +41,10 @@ impl<Provider: StaticFileProviderFactory + DBProvider + BlockReader> Segment<Pro
.block_body_indices(block)?
.ok_or(ProviderError::BlockBodyIndicesNotFound(block))?;

let mut receipts_cursor = provider.tx_ref().cursor_read::<tables::Receipts>()?;
let mut receipts_cursor = provider
.tx_ref()
.cursor_read::<tables::Receipts<<Provider::Primitives as NodePrimitives>::Receipt>>(
)?;
let receipts_walker = receipts_cursor.walk_range(block_body_indices.tx_num_range())?;

static_file_writer.append_receipts(
Expand Down
6 changes: 5 additions & 1 deletion crates/static-file/static-file/src/static_file_producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ where
Provider: StaticFileProviderFactory
+ DatabaseProviderFactory<
Provider: StaticFileProviderFactory<
Primitives: NodePrimitives<SignedTx: Value + Compact, BlockHeader: Value + Compact>,
Primitives: NodePrimitives<
SignedTx: Value + Compact,
BlockHeader: Value + Compact,
Receipt: Value + Compact,
>,
> + StageCheckpointReader
+ BlockReader,
>,
Expand Down
5 changes: 3 additions & 2 deletions crates/storage/provider/src/providers/static_file/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use reth_nippy_jar::{NippyJar, NippyJarError, NippyJarWriter};
use reth_node_types::NodePrimitives;
use reth_primitives::{
static_file::{SegmentHeader, SegmentRangeInclusive},
Receipt, StaticFileSegment,
StaticFileSegment,
};
use reth_storage_errors::provider::{ProviderError, ProviderResult};
use std::{
Expand Down Expand Up @@ -615,7 +615,8 @@ impl<N: NodePrimitives> StaticFileProviderRW<N> {
pub fn append_receipts<I, R>(&mut self, receipts: I) -> ProviderResult<Option<TxNumber>>
where
I: Iterator<Item = Result<(TxNumber, R), ProviderError>>,
R: Borrow<Receipt>,
R: Borrow<N::Receipt>,
N::Receipt: Compact,
{
debug_assert!(self.writer.user_header().segment() == StaticFileSegment::Receipts);

Expand Down

0 comments on commit 328d493

Please sign in to comment.