fix: also update persisted height after backfill run (#9894)

This commit is contained in:
Matthias Seitz
2024-07-30 12:38:40 +02:00
committed by GitHub
parent cd430121dd
commit 3a088a9ec7

View File

@@ -622,7 +622,10 @@ where
self.canonical_in_memory_state.clear_state();
if let Ok(Some(new_head)) = self.provider.sealed_header(backfill_height) {
// update the tracked chain height, after backfill sync both the canonical height and
// persisted height are the same
self.state.tree_state.set_canonical_head(new_head.num_hash());
self.persistence_state.finish(new_head.hash(), new_head.number);
}
// check if we need to run backfill again by comparing the most recent finalized height to
@@ -1632,7 +1635,7 @@ pub struct PersistenceState {
rx: Option<oneshot::Receiver<B256>>,
/// The last persisted block number.
///
/// A `None` value means no persistence task has been completed yet
/// This tracks the chain height that is persisted on disk
last_persisted_block_number: u64,
}
@@ -1650,6 +1653,7 @@ impl PersistenceState {
/// Sets state for a finished persistence task.
fn finish(&mut self, last_persisted_block_hash: B256, last_persisted_block_number: u64) {
trace!(target: "engine", block= %last_persisted_block_number, hash=%last_persisted_block_hash, "updating persistence state");
self.rx = None;
self.last_persisted_block_number = last_persisted_block_number;
self.last_persisted_block_hash = last_persisted_block_hash;