Skip to content

Commit

Permalink
fix(node-core): log stage progress only after the first stage run (#7319
Browse files Browse the repository at this point in the history
)
  • Loading branch information
shekhirin committed Mar 25, 2024
1 parent eed60d9 commit 28935da
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions crates/node-core/src/events/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ impl<DB> NodeState<DB> {
_ => Eta::default(),
},
checkpoint,
entities_checkpoint: match &self.current_stage {
Some(current_stage) if current_stage.stage_id == stage_id => {
current_stage.entities_checkpoint
}
_ => None,
},
target,
};

Expand All @@ -111,6 +117,12 @@ impl<DB> NodeState<DB> {
_ => Eta::default(),
},
checkpoint,
entities_checkpoint: match &self.current_stage {
Some(current_stage) if current_stage.stage_id == stage_id => {
current_stage.entities_checkpoint
}
_ => None,
},
target,
};

Expand Down Expand Up @@ -146,11 +158,13 @@ impl<DB> NodeState<DB> {

if let Some(current_stage) = self.current_stage.as_mut() {
current_stage.checkpoint = checkpoint;
current_stage.entities_checkpoint = checkpoint.entities();
current_stage.eta.update(stage_id, checkpoint);

let target = OptionalField(current_stage.target);
let stage_progress =
checkpoint.entities().and_then(|entities| entities.fmt_percentage());
let stage_progress = current_stage
.entities_checkpoint
.and_then(|entities| entities.fmt_percentage());
let stage_eta = current_stage.eta.fmt_for_stage(stage_id);

let message =
Expand Down Expand Up @@ -346,6 +360,10 @@ struct CurrentStage {
stage_id: StageId,
eta: Eta,
checkpoint: StageCheckpoint,
/// The entities checkpoint for reporting the progress. If `None`, then the progress is not
/// available, probably because the stage didn't finish running and didn't update its
/// checkpoint yet.
entities_checkpoint: Option<EntitiesCheckpoint>,
target: Option<BlockNumber>,
}

Expand Down Expand Up @@ -446,11 +464,11 @@ where
while this.info_interval.poll_tick(cx).is_ready() {
let freelist = OptionalField(this.state.freelist());

if let Some(CurrentStage { stage_id, eta, checkpoint, target }) =
if let Some(CurrentStage { stage_id, eta, checkpoint, entities_checkpoint, target }) =
&this.state.current_stage
{
let stage_progress =
checkpoint.entities().and_then(|entities| entities.fmt_percentage());
entities_checkpoint.and_then(|entities| entities.fmt_percentage());
let stage_eta = eta.fmt_for_stage(*stage_id);

match (stage_progress, stage_eta) {
Expand Down

0 comments on commit 28935da

Please sign in to comment.