Skip to content

Commit 2bb8d4c

Browse files
prestwichclaude
andcommitted
fix: address review feedback from Fraser999
- Delete unused ExtractableChainShim from blobber (RethChain replaces it) - Replace From<eyre::Report> with named RethHostError::notification() - Handle set_backfill_thresholds(None) by restoring defaults - Add blank line between module groups in host-reth lib.rs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 087ee7e commit 2bb8d4c

5 files changed

Lines changed: 18 additions & 51 deletions

File tree

crates/blobber/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mod error;
2424
pub use error::{BlobberError, BlobberResult};
2525

2626
mod shim;
27-
pub use shim::{ExtractableChainShim, RecoveredBlockShim};
27+
pub use shim::RecoveredBlockShim;
2828

2929
#[cfg(test)]
3030
mod test {

crates/blobber/src/shim.rs

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,12 @@
11
//! Shim and utilities for signet-sdk to reth conversions.
22
33
use alloy::consensus::Block;
4-
use reth::providers::Chain;
5-
use signet_extract::{BlockAndReceipts, Extractable, HasTxns};
4+
use signet_extract::HasTxns;
65
use signet_types::primitives::TransactionSigned;
76

87
/// A type alias for Reth's recovered block with a signed transaction.
98
type RethRecovered = reth::primitives::RecoveredBlock<Block<TransactionSigned>>;
109

11-
/// A shim around Reth's [`Chain`].
12-
#[derive(Debug)]
13-
#[repr(transparent)]
14-
pub struct ExtractableChainShim<'a> {
15-
/// The underlying Reth chain.
16-
chain: &'a Chain,
17-
}
18-
19-
impl<'a> ExtractableChainShim<'a> {
20-
/// Create a new shim around the given Reth chain.
21-
pub const fn new(chain: &'a Chain) -> Self {
22-
Self { chain }
23-
}
24-
25-
/// Get a reference to the underlying Reth chain.
26-
pub const fn chain(&self) -> &'a Chain {
27-
self.chain
28-
}
29-
}
30-
31-
impl<'a> Extractable for ExtractableChainShim<'a> {
32-
type Block = RecoveredBlockShim;
33-
type Receipt = reth::primitives::Receipt;
34-
35-
fn blocks_and_receipts(
36-
&self,
37-
) -> impl Iterator<Item = BlockAndReceipts<'_, Self::Block, Self::Receipt>> {
38-
self.chain.blocks_and_receipts().map(|(block, receipts)| {
39-
// SAFETY: `RecoveredBlockShim` is `#[repr(transparent)]` over a
40-
// single `RethRecovered` field, guaranteeing identical memory
41-
// layout. This makes the reference transmute sound.
42-
let block =
43-
unsafe { std::mem::transmute::<&'a RethRecovered, &RecoveredBlockShim>(block) };
44-
BlockAndReceipts { block, receipts }
45-
})
46-
}
47-
}
48-
4910
/// A shim for Reth's [`reth::primitives::RecoveredBlock`].
5011
#[derive(Debug)]
5112
#[repr(transparent)]

crates/host-reth/src/error.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ pub enum RethHostError {
1717
MissingHeader(u64),
1818
}
1919

20-
impl From<eyre::Report> for RethHostError {
21-
fn from(e: eyre::Report) -> Self {
20+
impl RethHostError {
21+
/// Wrap a notification stream error.
22+
pub fn notification(e: impl Into<Box<dyn core::error::Error + Send + Sync>>) -> Self {
2223
Self::Notification(e.into())
2324
}
2425
}

crates/host-reth/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
mod alias;
1515
pub use alias::{RethAliasOracle, RethAliasOracleFactory};
16+
1617
mod error;
1718
pub use error::RethHostError;
1819

crates/host-reth/src/notifier.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ where
112112
let notification = self.notifications.next().await?;
113113
let notification = match notification {
114114
Ok(n) => n,
115-
Err(e) => return Some(Err(e.into())),
115+
Err(e) => return Some(Err(RethHostError::notification(e))),
116116
};
117117

118118
// Read safe/finalized from the provider at notification time.
@@ -173,13 +173,17 @@ where
173173
}
174174

175175
fn set_backfill_thresholds(&mut self, max_blocks: Option<u64>) {
176-
if let Some(max_blocks) = max_blocks {
177-
self.notifications.set_backfill_thresholds(ExecutionStageThresholds {
178-
max_blocks: Some(max_blocks),
179-
..Default::default()
180-
});
181-
debug!(max_blocks, "configured backfill thresholds");
182-
}
176+
let thresholds = match max_blocks {
177+
Some(max_blocks) => {
178+
debug!(max_blocks, "configured backfill thresholds");
179+
ExecutionStageThresholds { max_blocks: Some(max_blocks), ..Default::default() }
180+
}
181+
None => {
182+
debug!("reset backfill thresholds to defaults");
183+
ExecutionStageThresholds::default()
184+
}
185+
};
186+
self.notifications.set_backfill_thresholds(thresholds);
183187
}
184188

185189
fn send_finished_height(&self, block_number: u64) -> Result<(), Self::Error> {

0 commit comments

Comments
 (0)