Skip to content

Commit 3c9ea7d

Browse files
committed
handle finalized head in reconciliation
1 parent 328b9e9 commit 3c9ea7d

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

crates/chain-orchestrator/src/consolidation.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ pub(crate) async fn reconcile_batch<L2P: Provider<Scroll>>(
3838

3939
// The block matches the derived attributes and the block is below or equal to the
4040
// safe current safe head.
41-
if attributes.block_number <= fcs.safe_block_info().number {
41+
if attributes.block_number <= fcs.finalized_block_info().number ||
42+
attributes.block_number <= fcs.safe_block_info().number
43+
{
4244
Ok::<_, ChainOrchestratorError>(BlockConsolidationAction::Skip(block_info))
4345
} else {
4446
// The block matches the derived attributes, no action is needed.
45-
Ok::<_, ChainOrchestratorError>(BlockConsolidationAction::UpdateSafeHead(
46-
block_info,
47-
))
47+
Ok::<_, ChainOrchestratorError>(BlockConsolidationAction::UpdateFcs(block_info))
4848
}
4949
} else {
5050
// The block does not match the derived attributes, a reorg is needed.
@@ -81,7 +81,7 @@ impl BatchReconciliationResult {
8181
for next in &self.actions {
8282
if let Some(last) = actions.last_mut() {
8383
match (last, next) {
84-
(last, next) if last.is_update_safe_head() && next.is_update_safe_head() => {
84+
(last, next) if last.is_update_fcs() && next.is_update_fcs() => {
8585
*last = next.clone();
8686
}
8787
_ => {
@@ -128,8 +128,8 @@ pub(crate) struct AggregatedBatchConsolidationActions {
128128
/// An action that must be performed on the L2 chain to consolidate a block.
129129
#[derive(Debug, Clone)]
130130
pub(crate) enum BlockConsolidationAction {
131-
/// Update the safe head to the given block.
132-
UpdateSafeHead(L2BlockInfoWithL1Messages),
131+
/// Update the fcs to the given block.
132+
UpdateFcs(L2BlockInfoWithL1Messages),
133133
/// The derived attributes match the L2 chain and the safe head is already at or beyond the
134134
/// block, so no action is needed.
135135
Skip(L2BlockInfoWithL1Messages),
@@ -138,9 +138,9 @@ pub(crate) enum BlockConsolidationAction {
138138
}
139139

140140
impl BlockConsolidationAction {
141-
/// Returns true if the action is to update the safe head.
142-
pub(crate) const fn is_update_safe_head(&self) -> bool {
143-
matches!(self, Self::UpdateSafeHead(_))
141+
/// Returns true if the action is to update the fcs.
142+
pub(crate) const fn is_update_fcs(&self) -> bool {
143+
matches!(self, Self::UpdateFcs(_))
144144
}
145145

146146
/// Returns true if the action is to skip the block.
@@ -157,7 +157,7 @@ impl BlockConsolidationAction {
157157
/// skip, returns None for reorg.
158158
pub(crate) fn into_block_info(self) -> Option<L2BlockInfoWithL1Messages> {
159159
match self {
160-
Self::UpdateSafeHead(info) | Self::Skip(info) => Some(info),
160+
Self::UpdateFcs(info) | Self::Skip(info) => Some(info),
161161
Self::Reorg(_attrs) => None,
162162
}
163163
}
@@ -166,7 +166,7 @@ impl BlockConsolidationAction {
166166
impl std::fmt::Display for BlockConsolidationAction {
167167
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
168168
match self {
169-
Self::UpdateSafeHead(info) => {
169+
Self::UpdateFcs(info) => {
170170
write!(f, "UpdateSafeHead to block {}", info.block_info.number)
171171
}
172172
Self::Skip(info) => write!(f, "Skip block {}", info.block_info.number),

crates/chain-orchestrator/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ impl<
454454
BlockConsolidationAction::Skip(_) => {
455455
unreachable!("Skip actions have been filtered out in aggregation")
456456
}
457-
BlockConsolidationAction::UpdateSafeHead(block_info) => {
457+
BlockConsolidationAction::UpdateFcs(block_info) => {
458458
tracing::info!(target: "scroll::chain_orchestrator", ?block_info, "Updating safe head to consolidated block");
459459
let finalized_block_info = batch_reconciliation_result
460460
.target_status

0 commit comments

Comments
 (0)