Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(conductor)!: re-fetch genesis or stop at set height #1928

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a45206c
feat(conductor): restart or stop at set height
SuperFluffy Jan 22, 2025
d12ed9a
add necessary charts changes and smoke test, change stop height to be…
ethanoroshiba Jan 27, 2025
add58bc
revert range changes
ethanoroshiba Jan 27, 2025
c720931
update changelog, example config, test soft-first and firm-first scen…
ethanoroshiba Jan 28, 2025
4ea3300
fix typos
ethanoroshiba Jan 28, 2025
66315e7
base stop height on rollup instead of sequencer
ethanoroshiba Jan 30, 2025
42ae864
bring back executor tests, make test utils
ethanoroshiba Jan 30, 2025
c586b33
remove conductor_ prefix from tests, remove explicit sleep
SuperFluffy Feb 4, 2025
4eb7806
remove confusing test helper
SuperFluffy Feb 4, 2025
7b5b5fc
bump charts
SuperFluffy Feb 4, 2025
31caab9
rename last_height -> stop_height
SuperFluffy Feb 4, 2025
faa42af
remove tendermint ID from public API of execution genesis
SuperFluffy Feb 4, 2025
0be83ab
updated conductor, core changelogs
SuperFluffy Feb 4, 2025
50010e9
sequencer_end_height -> sequencer_stop_height
SuperFluffy Feb 4, 2025
6b9b54a
bump charts, format core changelog
ethanoroshiba Feb 4, 2025
373aaa0
rename halt_at_stop_height -> halt_at_rollup_stop_height
SuperFluffy Feb 4, 2025
98d04a8
fix proto formatting
SuperFluffy Feb 4, 2025
f5051d5
remove grpc mock changes after rebasing on main
SuperFluffy Feb 4, 2025
782ee12
fix evm restart test heights, add env vars back to non dev configmap
ethanoroshiba Feb 7, 2025
1e1668e
remove configmap values
ethanoroshiba Feb 7, 2025
b2af17c
Merge branch 'main' into superfluffy/forma-restart-logic
SuperFluffy Feb 10, 2025
8ade517
give evm rollup restart test its own just command
ethanoroshiba Feb 10, 2025
0bfd35f
fix rollup name in evm restart test dev values
ethanoroshiba Feb 10, 2025
3cee398
fix values
ethanoroshiba Feb 10, 2025
260e24c
fix geth genesis
ethanoroshiba Feb 10, 2025
dd16dc3
Fix evm restart test values, some verbiage changes for clarity
ethanoroshiba Feb 10, 2025
d8f2f3f
break proto changes into v2
ethanoroshiba Feb 10, 2025
ead3a9b
make start height the first execution height instead of one before
ethanoroshiba Feb 10, 2025
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
11 changes: 4 additions & 7 deletions charts/evm-rollup/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ genesis:
# for the genesis fork are provided, and additional forks can be added as needed.
forks:
launch:
# The block height to start the chain at, 0 for genesis
height: "0"
# Whether to halt the rollup chain at the given height. False for genesis
# The rollup number to start executing blocks at, lowest possible is 1
height: 1
# Whether to halt the rollup chain at the given height
halt: "false"
# Checksum of the snapshot to use upon restart
snapshotChecksum: ""
Expand All @@ -56,11 +56,8 @@ genesis:
chainId: ""
# The hrp for bech32m addresses, unlikely to be changed
addressPrefix: "astria"
# Block height to start syncing rollup from, lowest possible is 2
# Block height to start syncing rollup from (inclusive), lowest possible is 2
startHeight: ""
# Block height (on sequencer) to stop syncing rollup at, continuing to next configuration fork.
# A height of 0 indicates no stop height.
stopHeight: ""
celestia:
# The chain id of the celestia chain
chainId: ""
Expand Down
34 changes: 25 additions & 9 deletions crates/astria-conductor/src/executor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{

Check warning on line 1 in crates/astria-conductor/src/executor/mod.rs

View workflow job for this annotation

GitHub Actions / Code Freeze

Code Freeze in Effect - Bypassed

This file is under code freeze.
collections::HashMap,
time::Duration,
};
Expand Down Expand Up @@ -215,11 +215,14 @@
let (genesis_info, commitment_state) = tokio::try_join!(genesis_info, commitment_state)?;

let (state, _) = state::channel(
State::try_from_genesis_info_and_commitment_state(genesis_info, commitment_state)
.wrap_err(
"failed to construct initial state gensis and commitment info received from \
rollup",
)?,
State::try_from_genesis_info_and_commitment_state(
genesis_info,
commitment_state,
self.config.execution_commit_level,
)
.wrap_err(
"failed to construct initial state gensis and commitment info received from rollup",
)?,
);

self.metrics
Expand Down Expand Up @@ -544,14 +547,27 @@
OnlySoft,
ToSame,
};
let (firm, soft, celestia_height) = match update {
OnlyFirm(firm, celestia_height) => (firm, self.state.soft(), celestia_height),

use crate::config::CommitLevel;
let (firm, soft, celestia_height, commit_level) = match update {
OnlyFirm(firm, celestia_height) => (
firm,
self.state.soft(),
celestia_height,
CommitLevel::FirmOnly,
),
OnlySoft(soft) => (
self.state.firm(),
soft,
self.state.celestia_base_block_height(),
CommitLevel::SoftOnly,
),
ToSame(block, celestia_height) => (
block.clone(),
block,
celestia_height,
CommitLevel::SoftAndFirm,
),
ToSame(block, celestia_height) => (block.clone(), block, celestia_height),
};
let commitment_state = CommitmentState::builder()
.firm(firm)
Expand All @@ -572,7 +588,7 @@
"updated commitment state",
);
self.state
.try_update_commitment_state(new_state)
.try_update_commitment_state(new_state, commit_level)
.wrap_err("failed updating internal state tracking rollup state; invalid?")?;
Ok(())
}
Expand Down
42 changes: 28 additions & 14 deletions crates/astria-conductor/src/executor/state.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! After being created the state must be primed with [`State::init`] before any of

Check warning on line 1 in crates/astria-conductor/src/executor/state.rs

View workflow job for this annotation

GitHub Actions / Code Freeze

Code Freeze in Effect - Bypassed

This file is under code freeze.
//! the other methods can be used. Otherwise, they will panic.
//!
//! The inner state must not be unset after having been set.
Expand Down Expand Up @@ -191,10 +191,15 @@
pub(super) fn try_update_commitment_state(
&mut self,
commitment_state: CommitmentState,
commit_level: crate::config::CommitLevel,
) -> Result<(), InvalidState> {
let genesis_info = self.genesis_info();
let _ = map_firm_to_sequencer_height(&genesis_info, &commitment_state)?;
let _ = map_soft_to_sequencer_height(&genesis_info, &commitment_state)?;
if commit_level.is_with_firm() {
let _ = map_firm_to_sequencer_height(&genesis_info, &commitment_state)?;
}
if commit_level.is_with_soft() {
let _ = map_soft_to_sequencer_height(&genesis_info, &commitment_state)?;
}
self.inner.send_modify(move |state| {
state.set_commitment_state(commitment_state);
});
Expand Down Expand Up @@ -280,9 +285,14 @@
pub(crate) fn try_from_genesis_info_and_commitment_state(
genesis_info: GenesisInfo,
commitment_state: CommitmentState,
commit_level: crate::config::CommitLevel,
) -> Result<Self, InvalidState> {
let _ = map_firm_to_sequencer_height(&genesis_info, &commitment_state)?;
let _ = map_soft_to_sequencer_height(&genesis_info, &commitment_state)?;
if commit_level.is_with_firm() {
let _ = map_firm_to_sequencer_height(&genesis_info, &commitment_state)?;
}
if commit_level.is_with_soft() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition is wrong. Soft must update with firm in lock-step even if soft is not set.

let _ = map_soft_to_sequencer_height(&genesis_info, &commitment_state)?;
}
Ok(State {
commitment_state,
genesis_info,
Expand Down Expand Up @@ -402,18 +412,22 @@
/// Maps a rollup height to a sequencer height.
///
/// Returns error if `sequencer_start_height + (rollup_number - rollup_start_block_number)`
/// overflows `u32::MAX`.
/// is out of range of `u32` or if `rollup_start_block_number` is more than 1 greater than
/// `rollup_number`.
fn map_rollup_number_to_sequencer_height(
sequencer_start_height: u64,
rollup_start_block_number: u64,
rollup_number: u32,
) -> Result<SequencerHeight, &'static str> {
let delta = u64::from(rollup_number)
.checked_sub(rollup_start_block_number)
.ok_or("rollup start height exceeds rollup number")?;
let rollup_number = u64::from(rollup_number);
if rollup_start_block_number > (rollup_number.checked_add(1).ok_or("overflows u64::MAX")?) {
return Err("rollup start height exceeds rollup number + 1");
}
let sequencer_height = sequencer_start_height
.checked_add(delta)
.ok_or("overflows u64::MAX")?;
.checked_add(rollup_number)
.ok_or("overflows u64::MAX")?
.checked_sub(rollup_start_block_number)
.ok_or("(sequencer height + rollup number - rollup start height) is negative")?;
sequencer_height
.try_into()
.map_err(|_| "overflows u32::MAX, the maximum cometbft height")
Expand Down Expand Up @@ -456,7 +470,7 @@
fn next_firm_sequencer_height_is_correct() {
let (_, rx) = make_channel();
assert_eq!(
SequencerHeight::from(12u32),
SequencerHeight::from(11u32),
rx.next_expected_firm_sequencer_height(),
);
}
Expand All @@ -465,7 +479,7 @@
fn next_soft_sequencer_height_is_correct() {
let (_, rx) = make_channel();
assert_eq!(
SequencerHeight::from(13u32),
SequencerHeight::from(12u32),
rx.next_expected_soft_sequencer_height(),
);
}
Expand All @@ -490,8 +504,8 @@

#[should_panic = "rollup start height exceeds rollup number"]
#[test]
fn is_error_if_rollup_start_exceeds_current_number() {
map_rollup_number_to_sequencer_height(10, 10, 9).unwrap();
fn is_error_if_rollup_start_exceeds_current_number_plus_one() {
map_rollup_number_to_sequencer_height(10, 11, 9).unwrap();
}

#[test]
Expand Down
8 changes: 6 additions & 2 deletions crates/astria-conductor/src/executor/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use astria_core::{

Check warning on line 1 in crates/astria-conductor/src/executor/tests.rs

View workflow job for this annotation

GitHub Actions / Code Freeze

Code Freeze in Effect - Bypassed

This file is under code freeze.
self,
execution::v2::{
Block,
Expand Down Expand Up @@ -53,8 +53,12 @@
base_celestia_height: 1,
})
.unwrap();
let state =
State::try_from_genesis_info_and_commitment_state(genesis_info, commitment_state).unwrap();
let state = State::try_from_genesis_info_and_commitment_state(
genesis_info,
commitment_state,
crate::config::CommitLevel::SoftAndFirm,
)
.unwrap();
super::state::channel(state)
}

Expand Down
9 changes: 7 additions & 2 deletions crates/astria-conductor/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub(crate) fn make_genesis_info() -> GenesisInfo {
rollup_id: Some(rollup_id.to_raw()),
sequencer_start_height: 10,
celestia_block_variance: 0,
rollup_start_block_number: 0,
rollup_start_block_number: 1,
rollup_stop_block_number: 90,
sequencer_chain_id: "test-sequencer-0".to_string(),
celestia_chain_id: "test-celestia-0".to_string(),
Expand All @@ -57,5 +57,10 @@ pub(crate) fn make_rollup_state(
let genesis_info = astria_core::execution::v2::GenesisInfo::try_from_raw(genesis_info).unwrap();
let commitment_state =
astria_core::execution::v2::CommitmentState::try_from_raw(commitment_state).unwrap();
State::try_from_genesis_info_and_commitment_state(genesis_info, commitment_state).unwrap()
State::try_from_genesis_info_and_commitment_state(
genesis_info,
commitment_state,
crate::config::CommitLevel::SoftAndFirm,
)
.unwrap()
}
28 changes: 14 additions & 14 deletions crates/astria-conductor/tests/blackbox/firm_only.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ async fn simple() {

mount_get_genesis_info!(
test_conductor,
sequencer_start_height: 1,
sequencer_start_height: 3,
celestia_block_variance: 10,
rollup_start_block_number: 0,
rollup_start_block_number: 2,
rollup_stop_block_number: 9,
);

Expand Down Expand Up @@ -137,9 +137,9 @@ async fn submits_two_heights_in_succession() {

mount_get_genesis_info!(
test_conductor,
sequencer_start_height: 1,
sequencer_start_height: 3,
celestia_block_variance: 10,
rollup_start_block_number: 0,
rollup_start_block_number: 2,
rollup_stop_block_number: 9,
);

Expand Down Expand Up @@ -251,9 +251,9 @@ async fn skips_already_executed_heights() {

mount_get_genesis_info!(
test_conductor,
sequencer_start_height: 1,
sequencer_start_height: 3,
celestia_block_variance: 10,
rollup_start_block_number: 0,
rollup_start_block_number: 2,
rollup_stop_block_number: 9,
);

Expand Down Expand Up @@ -337,9 +337,9 @@ async fn fetch_from_later_celestia_height() {

mount_get_genesis_info!(
test_conductor,
sequencer_start_height: 1,
sequencer_start_height: 3,
celestia_block_variance: 10,
rollup_start_block_number: 0,
rollup_start_block_number: 2,
rollup_stop_block_number: 9,
);

Expand Down Expand Up @@ -455,9 +455,9 @@ async fn exits_on_celestia_chain_id_mismatch() {
matcher::message_type::<GetGenesisInfoRequest>(),
)
.respond_with(GrpcResponse::constant_response(
genesis_info!(sequencer_start_height: 1,
genesis_info!(sequencer_start_height: 3,
celestia_block_variance: 10,
rollup_start_block_number: 0,
rollup_start_block_number: 2,
rollup_stop_block_number: 9
),
))
Expand Down Expand Up @@ -548,9 +548,9 @@ async fn restarts_after_reaching_stop_block_height() {

mount_get_genesis_info!(
test_conductor,
sequencer_start_height: 1,
sequencer_start_height: 3,
celestia_block_variance: 10,
rollup_start_block_number: 0,
rollup_start_block_number: 2,
rollup_stop_block_number: 2,
up_to_n_times: 1, // Only respond once, since updated information is needed after restart.
);
Expand Down Expand Up @@ -635,9 +635,9 @@ async fn restarts_after_reaching_stop_block_height() {
// Mount new genesis info and commitment state with updated heights
mount_get_genesis_info!(
test_conductor,
sequencer_start_height: 2,
sequencer_start_height: 4,
celestia_block_variance: 10,
rollup_start_block_number: 1,
rollup_start_block_number: 3,
rollup_stop_block_number: 9,
);

Expand Down
Loading
Loading