From e2218bea37aa455b4fd6602fe71a8fbe0974f12b Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Wed, 12 Jul 2023 11:19:43 +0300 Subject: [PATCH] fix(provider): update checkpoints only for known stages (#3624) --- crates/storage/provider/src/providers/database/provider.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/storage/provider/src/providers/database/provider.rs b/crates/storage/provider/src/providers/database/provider.rs index 2d494c40e2..597909db4c 100644 --- a/crates/storage/provider/src/providers/database/provider.rs +++ b/crates/storage/provider/src/providers/database/provider.rs @@ -1227,14 +1227,15 @@ impl<'this, TX: DbTxMut<'this>> StageCheckpointWriter for DatabaseProvider<'this ) -> Result<()> { // iterate over all existing stages in the table and update its progress. let mut cursor = self.tx.cursor_write::()?; - while let Some((stage_name, checkpoint)) = cursor.next()? { + for stage_id in StageId::ALL { + let (_, checkpoint) = cursor.seek_exact(stage_id.to_string())?.unwrap_or_default(); cursor.upsert( - stage_name, + stage_id.to_string(), StageCheckpoint { block_number, ..if drop_stage_checkpoint { Default::default() } else { checkpoint } }, - )? + )?; } Ok(())