diff --git a/crates/exex/exex/src/manager.rs b/crates/exex/exex/src/manager.rs index e7c9a6504b..126622c26a 100644 --- a/crates/exex/exex/src/manager.rs +++ b/crates/exex/exex/src/manager.rs @@ -350,14 +350,17 @@ where .collect::, _>>()?; 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()