mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix(storage): invalid stage checkpoints on unwind (#3029)
This commit is contained in:
@ -511,7 +511,7 @@ where
|
||||
self.calculate_history_indices(first_number..=last_block_number)?;
|
||||
|
||||
// Update pipeline progress
|
||||
self.update_pipeline_stages(new_tip_number)?;
|
||||
self.update_pipeline_stages(new_tip_number, false)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -1009,7 +1009,7 @@ where
|
||||
|
||||
// Update pipeline progress
|
||||
if let Some(fork_number) = unwind_to {
|
||||
self.update_pipeline_stages(fork_number)?;
|
||||
self.update_pipeline_stages(fork_number, true)?;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1021,12 +1021,18 @@ where
|
||||
pub fn update_pipeline_stages(
|
||||
&self,
|
||||
block_number: BlockNumber,
|
||||
drop_stage_checkpoint: bool,
|
||||
) -> Result<(), TransactionError> {
|
||||
// iterate over all existing stages in the table and update its progress.
|
||||
let mut cursor = self.cursor_write::<tables::SyncStage>()?;
|
||||
while let Some((stage_name, checkpoint)) = cursor.next()? {
|
||||
// TODO(alexey): do we want to invalidate stage-specific checkpoint data?
|
||||
cursor.upsert(stage_name, StageCheckpoint { block_number, ..checkpoint })?
|
||||
cursor.upsert(
|
||||
stage_name,
|
||||
StageCheckpoint {
|
||||
block_number,
|
||||
..if drop_stage_checkpoint { Default::default() } else { checkpoint }
|
||||
},
|
||||
)?
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user