Skip to content

Commit

Permalink
base stop height on rollup instead of sequencer
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanoroshiba authored and SuperFluffy committed Feb 4, 2025
1 parent 4ea3300 commit 66315e7
Show file tree
Hide file tree
Showing 13 changed files with 319 additions and 324 deletions.
18 changes: 10 additions & 8 deletions crates/astria-conductor/src/celestia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ impl RunningReader {
});

let reason = loop {
if self.has_reached_stop_height() {
if self.has_reached_stop_height()? {
break Ok("stop height reached");
}

Expand Down Expand Up @@ -449,13 +449,15 @@ impl RunningReader {

/// The stop height is reached if a) the next height to be forwarded would be greater
/// than the stop height, and b) there is no block currently in flight.
fn has_reached_stop_height(&self) -> bool {
self.rollup_state
.sequencer_stop_block_height()
.map_or(false, |stop_height| {
self.block_cache.next_height_to_pop() > stop_height.get()
})
&& self.enqueued_block.is_terminated()
fn has_reached_stop_height(&self) -> eyre::Result<bool> {
Ok(self
.rollup_state
.sequencer_stop_height()
.wrap_err("failed to obtain sequencer stop height")?
.map_or(false, |height| {
self.block_cache.next_height_to_pop() > height.get()
&& self.enqueued_block.is_terminated()
}))
}

#[instrument(skip_all)]
Expand Down
44 changes: 22 additions & 22 deletions crates/astria-conductor/src/conductor/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ fn should_restart_or_shutdown(
config: &Config,
status: &crate::executor::State,
) -> eyre::Result<RestartOrShutdown> {
let Some(sequencer_stop_height) = status.sequencer_stop_block_height() else {
let Some(rollup_stop_block_number) = status.rollup_stop_block_number() else {
return Err(eyre!(
"executor exited with a success value even though it was not configured to run with a \
stop height and even though it received no shutdown signal; this should not happen"
Expand All @@ -202,9 +202,9 @@ fn should_restart_or_shutdown(
config.execution_commit_level,
status.firm_number(),
status.firm_block_number_as_sequencer_height(),
status.rollup_start_block_height(),
status.sequencer_start_block_height(),
sequencer_stop_height,
status.rollup_start_block_number(),
status.sequencer_start_height(),
rollup_stop_block_number,
))
}
}
Expand All @@ -225,9 +225,9 @@ fn should_restart_or_shutdown(
config.execution_commit_level,
status.soft_number(),
status.soft_block_number_as_sequencer_height(),
status.rollup_start_block_height(),
status.sequencer_start_block_height(),
sequencer_stop_height,
status.rollup_start_block_number(),
status.sequencer_start_height(),
rollup_stop_block_number,
))
}
}
Expand Down Expand Up @@ -309,10 +309,10 @@ mod tests {
let rollup_id = RollupId::new([24; 32]);
GenesisInfo {
rollup_id: Some(rollup_id.to_raw()),
sequencer_start_block_height: 10,
sequencer_stop_block_height: 100,
sequencer_start_height: 10,
celestia_block_variance: 0,
rollup_start_block_height: 0,
rollup_start_block_number: 0,
rollup_stop_block_number: 90,
sequencer_chain_id: "test-sequencer-0".to_string(),
celestia_chain_id: "test-celestia-0".to_string(),
halt_at_stop_height: false,
Expand Down Expand Up @@ -358,9 +358,9 @@ mod tests {
},
&make_rollup_state(
GenesisInfo {
sequencer_start_block_height: 10,
sequencer_stop_block_height: 99,
rollup_start_block_height: 10,
sequencer_start_height: 10,
rollup_start_block_number: 10,
rollup_stop_block_number: 99,
halt_at_stop_height: false,
..make_genesis_info()
},
Expand Down Expand Up @@ -390,9 +390,9 @@ mod tests {
},
&make_rollup_state(
GenesisInfo {
sequencer_start_block_height: 10,
sequencer_stop_block_height: 99,
rollup_start_block_height: 10,
sequencer_start_height: 10,
rollup_start_block_number: 10,
rollup_stop_block_number: 99,
halt_at_stop_height: true,
..make_genesis_info()
},
Expand Down Expand Up @@ -425,9 +425,9 @@ mod tests {
},
&make_rollup_state(
GenesisInfo {
sequencer_start_block_height: 10,
sequencer_stop_block_height: 99,
rollup_start_block_height: 10,
sequencer_start_height: 10,
rollup_start_block_number: 10,
rollup_stop_block_number: 99,
halt_at_stop_height: false,
..make_genesis_info()
},
Expand Down Expand Up @@ -457,9 +457,9 @@ mod tests {
},
&make_rollup_state(
GenesisInfo {
sequencer_start_block_height: 10,
sequencer_stop_block_height: 99,
rollup_start_block_height: 10,
sequencer_start_height: 10,
rollup_start_block_number: 10,
rollup_stop_block_number: 99,
halt_at_stop_height: true,
..make_genesis_info()
},
Expand Down
30 changes: 16 additions & 14 deletions crates/astria-conductor/src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,20 +371,21 @@ impl Initialized {
std::cmp::Ordering::Equal => {}
}

let sequencer_start_height = self.state.sequencer_start_block_height();
let rollup_start_height = self.state.rollup_start_block_height();
let sequencer_start_height = self.state.sequencer_start_height();
let rollup_start_block_number = self.state.rollup_start_block_number();
let current_block_height = executable_block.height;
let Some(block_number) = state::map_sequencer_height_to_rollup_height(
sequencer_start_height,
rollup_start_height,
rollup_start_block_number,
current_block_height,
) else {
bail!(
"failed to map block height rollup number. This means the operation
`sequencer_height - sequencer_start_height + rollup_start_height` underflowed or \
was not a valid cometbft height. Sequencer height: `{current_block_height}`,
`sequencer_height - sequencer_start_height + rollup_start_block_number` \
underflowed or was not a valid cometbft height. Sequencer height: \
`{current_block_height}`,
sequencer start height: `{sequencer_start_height}`,
rollup start height: `{rollup_start_height}`"
rollup start height: `{rollup_start_block_number}`"
)
};

Expand Down Expand Up @@ -428,19 +429,20 @@ impl Initialized {
"expected block at sequencer height {expected_height}, but got {block_height}",
);

let sequencer_start_height = self.state.sequencer_start_block_height();
let rollup_start_height = self.state.rollup_start_block_height();
let sequencer_start_height = self.state.sequencer_start_height();
let rollup_start_block_number = self.state.rollup_start_block_number();
let Some(block_number) = state::map_sequencer_height_to_rollup_height(
sequencer_start_height,
rollup_start_height,
rollup_start_block_number,
block_height,
) else {
bail!(
"failed to map block height rollup number. This means the operation
`sequencer_height - sequencer_start_height + rollup_start_height` underflowed or \
was not a valid cometbft height. Sequencer block height: `{block_height}`,
`sequencer_height - sequencer_start_height + rollup_start_block_number` \
underflowed or was not a valid cometbft height. Sequencer block height: \
`{block_height}`,
sequencer start height: `{sequencer_start_height}`,
rollup start height: `{rollup_start_height}`"
rollup start height: `{rollup_start_block_number}`"
)
};

Expand Down Expand Up @@ -605,7 +607,7 @@ impl Initialized {
match task {
ReaderKind::Firm if self.config.is_with_firm() => {
match (
self.state.sequencer_stop_block_height().is_some(),
self.state.rollup_stop_block_number().is_some(),
self.state.has_firm_number_reached_stop_height(),
) {
(true, true) => {
Expand Down Expand Up @@ -640,7 +642,7 @@ impl Initialized {

ReaderKind::Soft if self.config.is_with_soft() => {
match (
self.state.sequencer_stop_block_height().is_some(),
self.state.rollup_stop_block_number().is_some(),
self.state.has_soft_number_reached_stop_height(),
) {
(true, true) => {
Expand Down
Loading

0 comments on commit 66315e7

Please sign in to comment.