Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions crates/host-rpc/src/notifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,22 @@ where
}
WalkResult::Exhausted => {
let finalized = self.cached_finalized.ok_or(RpcHostError::NoFinalizedBlock)?;

// Restart from the block after our last delivered block, or
// finalized — whichever is lower — so we never skip blocks
// between the old chain_view tip and finalized.
let resume_from = self
.chain_view
.back()
.map(|(n, _)| n + 1)
.map_or(finalized, |next| next.min(finalized));

warn!(
buffer_capacity = self.buffer_capacity,
finalized, "walk exhausted buffer, resetting to backfill from finalized"
finalized, resume_from, "walk exhausted buffer, resetting to backfill"
);
self.chain_view.clear();
self.backfill_from = Some(finalized);
self.backfill_from = Some(resume_from);
self.last_tag_epoch = None;
crate::metrics::record_handle_new_head_duration(start.elapsed());
return Ok(None);
Expand Down
12 changes: 12 additions & 0 deletions crates/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,18 @@ where

let last_height = self.last_rollup_block()?;

// Detect gaps: if the first block to process is not contiguous with
// our last stored block, bail early so the notifier can re-backfill.
if let Some(first) = extracts.iter().find(|e| e.ru_height > last_height) {
let expected_next = last_height + 1;
eyre::ensure!(
first.ru_height == expected_next,
"notification gap: expected ru_height {expected_next}, got {}. \
Last stored block is {last_height}.",
first.ru_height,
);
}

let mut processed = false;
for block_extracts in extracts.iter().filter(|e| e.ru_height > last_height) {
// Constructed per-block: hardforks must be rechecked each block,
Expand Down