fix: respect --debug.terminate --debug.max-block (#11710)

This commit is contained in:
Matthias Seitz
2024-10-14 11:46:00 +02:00
committed by GitHub
parent d2233fcc0d
commit 7c2c3a6a5c
2 changed files with 16 additions and 0 deletions

View File

@ -806,6 +806,15 @@ where
Ok(initial_target) Ok(initial_target)
} }
/// Returns true if the node should terminate after the initial backfill run.
///
/// This is the case if any of these configs are set:
/// `--debug.max-block`
/// `--debug.terminate`
pub const fn terminate_after_initial_backfill(&self) -> bool {
self.node_config().debug.terminate || self.node_config().debug.max_block.is_some()
}
/// Check if the pipeline is consistent (all stages have the checkpoint block numbers no less /// Check if the pipeline is consistent (all stages have the checkpoint block numbers no less
/// than the checkpoint of the first stage). /// than the checkpoint of the first stage).
/// ///

View File

@ -334,6 +334,8 @@ where
.fuse(); .fuse();
let chainspec = ctx.chain_spec(); let chainspec = ctx.chain_spec();
let (exit, rx) = oneshot::channel(); let (exit, rx) = oneshot::channel();
let terminate_after_backfill = ctx.terminate_after_initial_backfill();
info!(target: "reth::cli", "Starting consensus engine"); info!(target: "reth::cli", "Starting consensus engine");
ctx.task_executor().spawn_critical("consensus engine", async move { ctx.task_executor().spawn_critical("consensus engine", async move {
if let Some(initial_target) = initial_target { if let Some(initial_target) = initial_target {
@ -357,6 +359,11 @@ where
debug!(target: "reth::cli", "Event: {event}"); debug!(target: "reth::cli", "Event: {event}");
match event { match event {
ChainEvent::BackfillSyncFinished => { ChainEvent::BackfillSyncFinished => {
if terminate_after_backfill {
debug!(target: "reth::cli", "Terminating after initial backfill");
break
}
network_handle.update_sync_state(SyncState::Idle); network_handle.update_sync_state(SyncState::Idle);
} }
ChainEvent::BackfillSyncStarted => { ChainEvent::BackfillSyncStarted => {