Skip to content

Commit

Permalink
fix(exex): do not finalize WAL with a block higher than finalized hea…
Browse files Browse the repository at this point in the history
…der (#11420)
  • Loading branch information
shekhirin authored Oct 2, 2024
1 parent b44fff4 commit b66e4f5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions crates/exex/exex/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,17 @@ where
.collect::<Result<Vec<_>, _>>()?;
if exex_finished_heights.iter().all(|(_, _, is_canonical)| *is_canonical) {
// If there is a finalized header and all ExExs are on the canonical chain, finalize
// the WAL with the lowest finished height among all ExExes
// the WAL with either the lowest finished height among all ExExes, or finalized header
// – whichever is lower.
let lowest_finished_height = exex_finished_heights
.iter()
.copied()
.filter_map(|(_, num_hash, _)| num_hash)
.min_by_key(|num_hash| num_hash.number);
self.wal
.finalize(lowest_finished_height.expect("ExExManager has at least one ExEx"))?;
.chain([(finalized_header.num_hash())])
.min_by_key(|num_hash| num_hash.number)
.unwrap();

self.wal.finalize(lowest_finished_height)?;
} else {
let unfinalized_exexes = exex_finished_heights
.into_iter()
Expand Down

0 comments on commit b66e4f5

Please sign in to comment.