Skip to content

Commit 05aaabf

Browse files
committed
fix: answer comments
1 parent 8496196 commit 05aaabf

File tree

7 files changed

+16
-22
lines changed

7 files changed

+16
-22
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/rollup/src/network.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use reth_rpc_builder::config::RethRpcServerConfig;
1010
use reth_scroll_chainspec::ScrollChainSpec;
1111
use reth_scroll_primitives::ScrollPrimitives;
1212
use reth_transaction_pool::{PoolTransaction, TransactionPool};
13-
use rollup_node_indexer::Indexer;
1413
use rollup_node_manager::{PoAConsensus, RollupNodeManager};
1514
use rollup_node_providers::{beacon_provider, DatabaseL1MessageProvider, OnlineL1Provider};
1615
use rollup_node_watcher::L1Watcher;
@@ -120,9 +119,6 @@ where
120119
// Wrap the database in an Arc
121120
let db = Arc::new(db);
122121

123-
// Spawn the indexer
124-
let indexer = Indexer::new(db.clone());
125-
126122
// Spawn the L1Watcher
127123
let l1_provider_args = self.config.l1_provider_args;
128124
let l1_notification_rx = if let Some(l1_rpc_url) = l1_provider_args.l1_rpc_url {
@@ -153,8 +149,8 @@ where
153149
scroll_network_manager,
154150
engine,
155151
l1_provider,
152+
db,
156153
l1_notification_rx,
157-
indexer,
158154
ForkchoiceState::genesis(
159155
ctx.config().chain.chain.try_into().expect("must be a named chain"),
160156
),

crates/derivation-pipeline/src/lib.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,7 @@ where
8686

8787
/// Handles the next batch index in the batch index queue, pushing the future in the pipeline
8888
/// futures.
89-
fn handle_next_batch<
90-
F: FnMut(&mut FuturesOrdered<DerivationPipelineFuture>, DerivationPipelineFuture),
91-
>(
92-
&mut self,
93-
mut queue_fut: F,
94-
) {
89+
fn handle_next_batch(&mut self) -> Option<DerivationPipelineFuture> {
9590
let database = self.database.clone();
9691
let provider = self.l1_provider.clone();
9792

@@ -105,8 +100,9 @@ where
105100

106101
derive(batch, provider).await.map_err(|err| (index, err))
107102
});
108-
queue_fut(&mut self.pipeline_futures, fut);
103+
return Some(fut);
109104
}
105+
None
110106
}
111107
}
112108

@@ -133,7 +129,9 @@ where
133129

134130
// if the futures can still grow, handle the next batch.
135131
if this.pipeline_futures.len() < MAX_CONCURRENT_DERIVATION_PIPELINE_FUTS {
136-
this.handle_next_batch(|queue, fut| queue.push_back(fut));
132+
if let Some(fut) = this.handle_next_batch() {
133+
this.pipeline_futures.push_back(fut)
134+
}
137135
}
138136

139137
// poll the futures and handle result.
@@ -147,7 +145,9 @@ where
147145
tracing::error!(target: "scroll::node::derivation_pipeline", ?index, ?err, "failed to derive payload attributes for batch");
148146
// retry polling the same batch index.
149147
this.batch_index_queue.push_front(index);
150-
this.handle_next_batch(|queue, fut| queue.push_front(fut));
148+
if let Some(fut) = this.handle_next_batch() {
149+
this.pipeline_futures.push_front(fut)
150+
}
151151
}
152152
}
153153
}

crates/indexer/src/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ impl Indexer {
3535
Self { database, pending_futures: Default::default() }
3636
}
3737

38-
/// Returns a reference to the database used by the indexer.
39-
pub fn database(&self) -> Arc<Database> {
40-
self.database.clone()
41-
}
42-
4338
/// Handles an event from the L1.
4439
pub fn handle_l1_notification(&mut self, event: L1Notification) {
4540
let fut =

crates/node/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ reth-scroll-primitives.workspace = true
2323

2424
# scroll
2525
scroll-alloy-rpc-types-engine.workspace = true
26+
scroll-db.workspace = true
2627
scroll-derivation-pipeline.workspace = true
2728
scroll-engine.workspace = true
2829
scroll-network.workspace = true

crates/node/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ mod consensus;
3939
use consensus::Consensus;
4040
use rollup_node_primitives::BlockInfo;
4141
use rollup_node_providers::{ExecutionPayloadProvider, L1Provider};
42+
use scroll_db::Database;
4243
use scroll_derivation_pipeline::DerivationPipeline;
4344

4445
/// The size of the event channel.
@@ -121,13 +122,13 @@ where
121122
network: NetworkManager,
122123
engine: EngineDriver<EC, P>,
123124
l1_provider: L1P,
125+
database: Arc<Database>,
124126
l1_notification_rx: Option<Receiver<Arc<L1Notification>>>,
125-
indexer: Indexer,
126127
forkchoice_state: ForkchoiceState,
127128
consensus: C,
128129
new_block_rx: Option<UnboundedReceiver<NewBlockWithPeer>>,
129130
) -> Self {
130-
let database = indexer.database();
131+
let indexer = Indexer::new(database.clone());
131132
let derivation_pipeline = DerivationPipeline::new(l1_provider, database);
132133
Self {
133134
network,

crates/providers/src/l1/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<L1P, BP> OnlineL1Provider<L1P, BP>
5151
where
5252
BP: BeaconProvider,
5353
{
54-
/// Returns a new [`OnlineBeaconClient`] from the provided [`OnlineBeaconClient`], blob capacity
54+
/// Returns a new [`OnlineL1Provider`] from the provided [`BeaconProvider`], blob capacity
5555
/// and [`L1MessageProvider`].
5656
pub async fn new(beacon_provider: BP, blob_capacity: usize, l1_message_provider: L1P) -> Self {
5757
let cache = Arc::new(Mutex::new(LruCache::new(

0 commit comments

Comments
 (0)