mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix(cli): consistent max block across pipeline and engine (#3510)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -36,7 +36,9 @@ use reth_interfaces::{
|
||||
};
|
||||
use reth_network::{error::NetworkError, NetworkConfig, NetworkHandle, NetworkManager};
|
||||
use reth_network_api::NetworkInfo;
|
||||
use reth_primitives::{stage::StageId, BlockHashOrNumber, ChainSpec, Head, SealedHeader, H256};
|
||||
use reth_primitives::{
|
||||
stage::StageId, BlockHashOrNumber, BlockNumber, ChainSpec, Head, SealedHeader, H256,
|
||||
};
|
||||
use reth_provider::{
|
||||
BlockHashReader, BlockReader, CanonStateSubscriptions, HeaderProvider, ProviderFactory,
|
||||
StageCheckpointReader,
|
||||
@ -281,6 +283,14 @@ impl Command {
|
||||
let metrics_listener = MetricsListener::new(metrics_rx);
|
||||
ctx.task_executor.spawn_critical("metrics listener task", metrics_listener);
|
||||
|
||||
let max_block = if let Some(block) = self.debug.max_block {
|
||||
Some(block)
|
||||
} else if let Some(tip) = self.debug.tip {
|
||||
Some(self.lookup_or_fetch_tip(&db, &network_client, tip).await?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
// Configure the pipeline
|
||||
let (mut pipeline, client) = if self.auto_mine {
|
||||
let (_, client, mut task) = AutoSealBuilder::new(
|
||||
@ -300,6 +310,7 @@ impl Command {
|
||||
db.clone(),
|
||||
&ctx.task_executor,
|
||||
metrics_tx,
|
||||
max_block,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@ -318,6 +329,7 @@ impl Command {
|
||||
db.clone(),
|
||||
&ctx.task_executor,
|
||||
metrics_tx,
|
||||
max_block,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@ -346,7 +358,7 @@ impl Command {
|
||||
blockchain_db.clone(),
|
||||
Box::new(ctx.task_executor.clone()),
|
||||
Box::new(network.clone()),
|
||||
self.debug.max_block,
|
||||
max_block,
|
||||
self.debug.continuous,
|
||||
payload_builder.clone(),
|
||||
initial_target,
|
||||
@ -422,6 +434,7 @@ impl Command {
|
||||
}
|
||||
|
||||
/// Constructs a [Pipeline] that's wired to the network
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn build_networked_pipeline<DB, Client>(
|
||||
&self,
|
||||
config: &mut Config,
|
||||
@ -430,19 +443,12 @@ impl Command {
|
||||
db: DB,
|
||||
task_executor: &TaskExecutor,
|
||||
metrics_tx: MetricEventsSender,
|
||||
max_block: Option<BlockNumber>,
|
||||
) -> eyre::Result<Pipeline<DB>>
|
||||
where
|
||||
DB: Database + Unpin + Clone + 'static,
|
||||
Client: HeadersClient + BodiesClient + Clone + 'static,
|
||||
{
|
||||
let max_block = if let Some(block) = self.debug.max_block {
|
||||
Some(block)
|
||||
} else if let Some(tip) = self.debug.tip {
|
||||
Some(self.lookup_or_fetch_tip(&db, &client, tip).await?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
// building network downloaders using the fetch client
|
||||
let header_downloader = ReverseHeadersDownloaderBuilder::from(config.stages.headers)
|
||||
.build(client.clone(), Arc::clone(&consensus))
|
||||
|
||||
Reference in New Issue
Block a user