fix(engine, pruner): prune poll logic, history indices (#4043)

This commit is contained in:
Alexey Shekhirin
2023-08-03 15:54:16 +01:00
committed by GitHub
parent 8d0aa64ab8
commit f917d49fb4
4 changed files with 161 additions and 150 deletions

View File

@ -51,6 +51,18 @@ impl ForkchoiceStateTracker {
self.latest_status().map(|s| s.is_valid()).unwrap_or(false)
}
/// Returns whether the latest received FCU is syncing: [ForkchoiceStatus::Syncing]
#[allow(unused)]
pub(crate) fn is_latest_syncing(&self) -> bool {
self.latest_status().map(|s| s.is_syncing()).unwrap_or(false)
}
/// Returns whether the latest received FCU is syncing: [ForkchoiceStatus::Invalid]
#[allow(unused)]
pub(crate) fn is_latest_invalid(&self) -> bool {
self.latest_status().map(|s| s.is_invalid()).unwrap_or(false)
}
/// Returns the last valid head hash.
#[allow(unused)]
pub(crate) fn last_valid_head(&self) -> Option<H256> {
@ -98,6 +110,10 @@ impl ForkchoiceStatus {
matches!(self, ForkchoiceStatus::Valid)
}
pub(crate) fn is_invalid(&self) -> bool {
matches!(self, ForkchoiceStatus::Invalid)
}
pub(crate) fn is_syncing(&self) -> bool {
matches!(self, ForkchoiceStatus::Syncing)
}

View File

@ -1715,12 +1715,13 @@ where
// Poll prune controller if all conditions are met:
// 1. Pipeline is idle
// 2. Pruning is running and we need to prioritize checking its events OR no engine and
// sync messages are pending and we may start pruning
// 3. Latest FCU status is VALID
// 2. Either of two:
// 1. Pruning is running and we need to prioritize checking its events
// 2. Both engine and sync messages are pending AND latest FCU status is not INVALID,
// so we may start pruning
if this.sync.is_pipeline_idle() &&
(this.is_prune_active() || is_pending) &&
this.forkchoice_state_tracker.is_latest_valid()
(this.is_prune_active() ||
is_pending && !this.forkchoice_state_tracker.is_latest_invalid())
{
if let Some(ref mut prune) = this.prune {
match prune.poll(cx, this.blockchain.canonical_tip().number) {