diff --git a/chain/chain/src/store.rs b/chain/chain/src/store.rs index 7221a222e68..48ca877888f 100644 --- a/chain/chain/src/store.rs +++ b/chain/chain/src/store.rs @@ -886,7 +886,7 @@ impl ChainStore { pub fn get_state_sync_dump_progress( &self, shard_id: ShardId, - ) -> Result, Error> { + ) -> Result { option_to_not_found( self.store .get_ser(DBCol::BlockMisc, &ChainStore::state_sync_dump_progress_key(shard_id)), @@ -902,7 +902,10 @@ impl ChainStore { ) -> Result<(), Error> { let mut store_update = self.store.store_update(); let key = ChainStore::state_sync_dump_progress_key(shard_id); - store_update.set_ser(DBCol::BlockMisc, &key, &value)?; + match value { + None => store_update.delete(DBCol::BlockMisc, &key), + Some(value) => store_update.set_ser(DBCol::BlockMisc, &key, &value)?, + } store_update.commit().map_err(|err| err.into()) } } diff --git a/nearcore/src/state_sync.rs b/nearcore/src/state_sync.rs index eeb356853aa..482d075fcd5 100644 --- a/nearcore/src/state_sync.rs +++ b/nearcore/src/state_sync.rs @@ -174,7 +174,7 @@ fn get_current_state( epoch_manager: Arc, ) -> Result, Error> { let was_last_epoch_dumped = match chain.store().get_state_sync_dump_progress(*shard_id) { - Ok(Some(StateSyncDumpProgress::AllDumped { epoch_id, .. })) => Some(epoch_id), + Ok(StateSyncDumpProgress::AllDumped { epoch_id, .. }) => Some(epoch_id), _ => None, }; @@ -338,11 +338,7 @@ async fn state_sync_dump( &shard_id, epoch_height, Some(state_part.len()), - num_parts - .checked_sub( - parts_to_dump.len().checked_add(1).unwrap() as u64, - ) - .unwrap(), + num_parts.checked_sub(parts_to_dump.len() as u64).unwrap(), num_parts, ); dumped_any_state_part = true; diff --git a/tools/state-viewer/src/scan_db.rs b/tools/state-viewer/src/scan_db.rs index 62b4cd57368..67e900cc461 100644 --- a/tools/state-viewer/src/scan_db.rs +++ b/tools/state-viewer/src/scan_db.rs @@ -231,7 +231,7 @@ fn format_block_misc_value<'a>(key: &'a [u8], value: &'a [u8]) -> Box::try_from_slice(value).unwrap()) } else if key.starts_with(near_store::STATE_SYNC_DUMP_KEY) { - Box::new(Option::::try_from_slice(value).unwrap()) + Box::new(StateSyncDumpProgress::try_from_slice(value).unwrap()) } else { Box::new(value) }