Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions crates/rpc/rpc-eth-api/src/helpers/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,8 @@ pub trait LoadBlock:
async move {
if block_id.is_pending() {
// Pending block can be fetched directly without need for caching
if let Some(pending_block) = self
.provider()
.pending_block_with_senders()
.map_err(Self::Error::from_eth_err)?
if let Some(pending_block) =
self.provider().pending_block().map_err(Self::Error::from_eth_err)?
{
return Ok(Some(Arc::new(pending_block)));
}
Expand Down
4 changes: 1 addition & 3 deletions crates/rpc/rpc-eth-api/src/helpers/pending_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ pub trait LoadPendingBlock:
>,
Self::Error,
> {
if let Some(block) =
self.provider().pending_block_with_senders().map_err(Self::Error::from_eth_err)?
{
if let Some(block) = self.provider().pending_block().map_err(Self::Error::from_eth_err)? {
if let Some(receipts) = self
.provider()
.receipts_by_block(block.hash().into())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,7 @@ impl<N: ProviderNodeTypes> BlockReader for BlockchainProvider<N> {
self.consistent_provider()?.block(id)
}

fn pending_block(&self) -> ProviderResult<Option<SealedBlock<Self::Block>>> {
Ok(self.canonical_in_memory_state.pending_block())
}

fn pending_block_with_senders(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
fn pending_block(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
Ok(self.canonical_in_memory_state.pending_recovered_block())
}

Expand Down Expand Up @@ -1214,10 +1210,9 @@ mod tests {
});

// Assertions related to the pending block
assert_eq!(provider.pending_block()?, Some(block.clone()));

assert_eq!(
provider.pending_block_with_senders()?,
provider.pending_block()?,
Some(RecoveredBlock::new_sealed(block.clone(), block.senders().unwrap()))
);

Expand Down
6 changes: 1 addition & 5 deletions crates/storage/provider/src/providers/consistent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,11 +825,7 @@ impl<N: ProviderNodeTypes> BlockReader for ConsistentProvider<N> {
)
}

fn pending_block(&self) -> ProviderResult<Option<SealedBlock<Self::Block>>> {
Ok(self.canonical_in_memory_state.pending_block())
}

fn pending_block_with_senders(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
fn pending_block(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
Ok(self.canonical_in_memory_state.pending_recovered_block())
}

Expand Down
6 changes: 1 addition & 5 deletions crates/storage/provider/src/providers/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,10 @@ impl<N: ProviderNodeTypes> BlockReader for ProviderFactory<N> {
self.provider()?.block(id)
}

fn pending_block(&self) -> ProviderResult<Option<SealedBlock<Self::Block>>> {
fn pending_block(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
self.provider()?.pending_block()
}

fn pending_block_with_senders(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
self.provider()?.pending_block_with_senders()
}

fn pending_block_and_receipts(
&self,
) -> ProviderResult<Option<(SealedBlock<Self::Block>, Vec<Self::Receipt>)>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1191,12 +1191,7 @@ impl<TX: DbTx + 'static, N: NodeTypesForProvider> BlockReader for DatabaseProvid

Ok(None)
}

fn pending_block(&self) -> ProviderResult<Option<SealedBlock<Self::Block>>> {
Ok(None)
}

fn pending_block_with_senders(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
fn pending_block(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
Ok(None)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1644,12 +1644,7 @@ impl<N: FullNodePrimitives<SignedTx: Value, Receipt: Value, BlockHeader: Value>>
Err(ProviderError::UnsupportedProvider)
}

fn pending_block(&self) -> ProviderResult<Option<SealedBlock<Self::Block>>> {
// Required data not present in static_files
Err(ProviderError::UnsupportedProvider)
}

fn pending_block_with_senders(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
fn pending_block(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
// Required data not present in static_files
Err(ProviderError::UnsupportedProvider)
}
Expand Down
6 changes: 1 addition & 5 deletions crates/storage/provider/src/test_utils/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,11 +669,7 @@ impl<ChainSpec: EthChainSpec + Send + Sync + 'static> BlockReader
}
}

fn pending_block(&self) -> ProviderResult<Option<SealedBlock<Self::Block>>> {
Ok(None)
}

fn pending_block_with_senders(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
fn pending_block(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
Ok(None)
}

Expand Down
18 changes: 3 additions & 15 deletions crates/storage/storage-api/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,11 @@ pub trait BlockReader:
/// Returns `None` if block is not found.
fn block(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Self::Block>>;

/// Returns the pending block if available
///
/// Note: This returns a [`SealedBlock`] because it's expected that this is sealed by the
/// provider and the caller does not know the hash.
fn pending_block(&self) -> ProviderResult<Option<SealedBlock<Self::Block>>>;

/// Returns the pending block if available
///
/// Note: This returns a [`RecoveredBlock`] because it's expected that this is sealed by
/// the provider and the caller does not know the hash.
fn pending_block_with_senders(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>>;
fn pending_block(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>>;

/// Returns the pending block and receipts if available.
#[expect(clippy::type_complexity)]
Expand Down Expand Up @@ -166,12 +160,9 @@ impl<T: BlockReader> BlockReader for Arc<T> {
fn block(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Self::Block>> {
T::block(self, id)
}
fn pending_block(&self) -> ProviderResult<Option<SealedBlock<Self::Block>>> {
fn pending_block(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
T::pending_block(self)
}
fn pending_block_with_senders(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
T::pending_block_with_senders(self)
}
fn pending_block_and_receipts(
&self,
) -> ProviderResult<Option<(SealedBlock<Self::Block>, Vec<Self::Receipt>)>> {
Expand Down Expand Up @@ -227,12 +218,9 @@ impl<T: BlockReader> BlockReader for &T {
fn block(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Self::Block>> {
T::block(self, id)
}
fn pending_block(&self) -> ProviderResult<Option<SealedBlock<Self::Block>>> {
fn pending_block(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
T::pending_block(self)
}
fn pending_block_with_senders(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
T::pending_block_with_senders(self)
}
fn pending_block_and_receipts(
&self,
) -> ProviderResult<Option<(SealedBlock<Self::Block>, Vec<Self::Receipt>)>> {
Expand Down
6 changes: 1 addition & 5 deletions crates/storage/storage-api/src/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,7 @@ impl<C: Send + Sync, N: NodePrimitives> BlockReader for NoopProvider<C, N> {
Ok(None)
}

fn pending_block(&self) -> ProviderResult<Option<SealedBlock<Self::Block>>> {
Ok(None)
}

fn pending_block_with_senders(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
fn pending_block(&self) -> ProviderResult<Option<RecoveredBlock<Self::Block>>> {
Ok(None)
}

Expand Down
Loading