Skip to content

Commit

Permalink
add preliminary to GenesisInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanoroshiba committed Jan 6, 2025
1 parent 483aa39 commit 680d984
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 3 deletions.
1 change: 1 addition & 0 deletions crates/astria-conductor/src/executor/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ mod tests {
rollup_start_block_height: 0,
sequencer_chain_id: "test-sequencer-0".to_string(),
celestia_chain_id: "test-celestia-0".to_string(),
halt_at_stop_height: false,
})
.unwrap()
}
Expand Down
1 change: 1 addition & 0 deletions crates/astria-conductor/src/executor/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ fn make_state(
rollup_start_block_height: 1,
sequencer_chain_id: "test_sequencer-0".to_string(),
celestia_chain_id: "test_celestia-0".to_string(),
halt_at_stop_height: false,
})
.unwrap();
let commitment_state = CommitmentState::try_from_raw(raw::CommitmentState {
Expand Down
43 changes: 42 additions & 1 deletion crates/astria-conductor/tests/blackbox/helpers/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,23 @@ macro_rules! genesis_info {
$start_height:expr,sequencer_stop_block_height:
$stop_height:expr,celestia_block_variance:
$variance:expr,rollup_start_block_height:
$rollup_start_block_height:expr $(,)?
$rollup_start_block_height:expr,
) => {
genesis_info!(
sequencer_start_block_height: $start_height,
sequencer_stop_block_height: $stop_height,
celestia_block_variance: $variance,
rollup_start_block_height: $rollup_start_block_height,
halt_at_stop_height: false,
)
};
(
sequencer_start_block_height:
$start_height:expr,sequencer_stop_block_height:
$stop_height:expr,celestia_block_variance:
$variance:expr,rollup_start_block_height:
$rollup_start_block_height:expr,
halt_at_stop_height: $halt_at_stop_height:expr $(,)?
) => {
::astria_core::generated::astria::execution::v1::GenesisInfo {
rollup_id: Some($crate::ROLLUP_ID.to_raw()),
Expand All @@ -108,6 +124,7 @@ macro_rules! genesis_info {
rollup_start_block_height: $rollup_start_block_height,
sequencer_chain_id: $crate::SEQUENCER_CHAIN_ID.to_string(),
celestia_chain_id: $crate::helpers::CELESTIA_CHAIN_ID.to_string(),
halt_at_stop_height: $halt_at_stop_height,
}
};
}
Expand Down Expand Up @@ -397,15 +414,39 @@ macro_rules! mount_get_genesis_info {
rollup_start_block_height: $rollup_start_block_height:expr,
up_to_n_times: $up_to_n_times:expr
$(,)?
) => {
mount_get_genesis_info!(
$test_env,
sequencer_start_block_height: $start_height,
sequencer_stop_block_height: $stop_height,
celestia_block_variance: $variance,
rollup_start_block_height: $rollup_start_block_height,
up_to_n_times: $up_to_n_times,
halt_at_stop_height: false,
expected_calls: 1,
)
};
(
$test_env:ident,
sequencer_start_block_height: $start_height:expr,
sequencer_stop_block_height: $stop_height:expr,
celestia_block_variance: $variance:expr,
rollup_start_block_height: $rollup_start_block_height:expr,
up_to_n_times: $up_to_n_times:expr,
halt_at_stop_height: $halt_at_stop_height:expr,
expected_calls: $expected_calls:expr
$(,)?
) => {
$test_env.mount_get_genesis_info(
$crate::genesis_info!(
sequencer_start_block_height: $start_height,
sequencer_stop_block_height: $stop_height,
celestia_block_variance: $variance,
rollup_start_block_height: $rollup_start_block_height,
halt_at_stop_height: $halt_at_stop_height,
),
$up_to_n_times,
$expected_calls,
).await;
};
}
Expand Down
9 changes: 7 additions & 2 deletions crates/astria-conductor/tests/blackbox/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,20 @@ impl TestConductor {
mount_genesis(&self.mock_http, chain_id).await;
}

pub async fn mount_get_genesis_info(&self, genesis_info: GenesisInfo, up_to_n_times: u64) {
pub async fn mount_get_genesis_info(
&self,
genesis_info: GenesisInfo,
up_to_n_times: u64,
expected_calls: u64,
) {
use astria_core::generated::astria::execution::v1::GetGenesisInfoRequest;
astria_grpc_mock::Mock::for_rpc_given(
"get_genesis_info",
astria_grpc_mock::matcher::message_type::<GetGenesisInfoRequest>(),
)
.respond_with(astria_grpc_mock::response::constant_response(genesis_info))
.up_to_n_times(up_to_n_times)
.expect(1..)
.expect(expected_calls)
.mount(&self.mock_grpc.mock_server)
.await;
}
Expand Down
114 changes: 114 additions & 0 deletions crates/astria-conductor/tests/blackbox/soft_and_firm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,8 @@ async fn conductor_restarts_on_permission_denied() {
celestia_block_variance: 10,
rollup_start_block_height: 0,
up_to_n_times: 2,
halt_at_stop_height: false,
expected_calls: 2,
);

mount_get_commitment_state!(
Expand Down Expand Up @@ -817,3 +819,115 @@ async fn conductor_restarts_after_reaching_stop_height() {
.await
.expect("conductor should have updated the firm commitment state within 1000ms");
}

// ** Disabled until logic to handle this is implemented **
// /// Tests if the conductor correctly stops and does not restart after reaching the sequencer stop
// /// height if genesis info's `halt_at_stop_height` is `true`.
// ///
// /// This test consists of the following steps:
// /// 1. Mount commitment state and genesis info with a sequencer stop height of 3, expecting only
// 1 /// response.
// /// 2. Mount Celestia network head and sequencer genesis.
// /// 3. Mount ABCI info and sequencer (soft blocks) for height 3.
// /// 4. Mount firm blocks at height 3, with corresponding `update_commitment_state` mount.
// /// 5. Mount `execute_block` and `update_commitment_state` for firm block at height
// /// 3. The soft block should not be executed since it is at the stop height, but the firm
// should /// be.
// /// 6. Await satisfaction of the `execute_block` and `update_commitment_state` for the firm block
// at /// height 3 with a timeout of 1000ms.
// /// 7. Allow ample time for the conductor to potentially restart erroneously.
// #[tokio::test(flavor = "multi_thread", worker_threads = 1)]
// async fn conductor_stops_at_stop_height() {
// let test_conductor = spawn_conductor(CommitLevel::SoftAndFirm).await;

// mount_get_genesis_info!(
// test_conductor,
// sequencer_start_block_height: 1,
// sequencer_stop_block_height: 3,
// celestia_block_variance: 10,
// rollup_start_block_height: 0,
// up_to_n_times: 2, // allow for calls after an potential erroneous restart
// halt_at_stop_height: true,
// expected_calls: 1,
// );

// mount_get_commitment_state!(
// test_conductor,
// firm: (
// number: 1,
// hash: [1; 64],
// parent: [0; 64],
// ),
// soft: (
// number: 1,
// hash: [1; 64],
// parent: [0; 64],
// ),
// base_celestia_height: 1,
// );

// mount_sequencer_genesis!(test_conductor);
// mount_celestia_header_network_head!(
// test_conductor,
// height: 1u32,
// );
// mount_abci_info!(
// test_conductor,
// latest_sequencer_height: 3,
// );

// // Mount soft blocks for height 3
// mount_get_filtered_sequencer_block!(
// test_conductor,
// sequencer_height: 3,
// );

// // Mount firm blocks for height 3
// mount_celestia_blobs!(
// test_conductor,
// celestia_height: 1,
// sequencer_heights: [3],
// );
// mount_sequencer_commit!(
// test_conductor,
// height: 3u32,
// );
// mount_sequencer_validator_set!(test_conductor, height: 2u32);

// let execute_block_1 = mount_executed_block!(
// test_conductor,
// mock_name: "execute_block_1",
// number: 2,
// hash: [2; 64],
// parent: [1; 64],
// );

// let update_commitment_state_firm_1 = mount_update_commitment_state!(
// test_conductor,
// mock_name: "update_commitment_state_firm_1",
// firm: (
// number: 2,
// hash: [2; 64],
// parent: [1; 64],
// ),
// soft: (
// number: 2,
// hash: [2; 64],
// parent: [1; 64],
// ),
// base_celestia_height: 1,
// );

// timeout(
// Duration::from_millis(1000),
// join(
// execute_block_1.wait_until_satisfied(),
// update_commitment_state_firm_1.wait_until_satisfied(),
// ),
// )
// .await
// .expect("conductor should have updated the firm commitment state within 1000ms");

// // Allow time for a potential erroneous restart
// sleep(Duration::from_millis(1000)).await;
// }
6 changes: 6 additions & 0 deletions crates/astria-core/src/execution/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ pub struct GenesisInfo {
sequencer_chain_id: tendermint::chain::Id,
/// The chain ID of the celestia network.
celestia_chain_id: celestia_tendermint::chain::Id,
/// Whether the conductor halt at the stop height, or otherwise attempt restart.
halt_at_stop_height: bool,
}

impl GenesisInfo {
Expand Down Expand Up @@ -130,6 +132,7 @@ impl Protobuf for GenesisInfo {
rollup_start_block_height,
sequencer_chain_id,
celestia_chain_id,
halt_at_stop_height,
} = raw;
let Some(rollup_id) = rollup_id else {
return Err(Self::Error::no_rollup_id());
Expand All @@ -153,6 +156,7 @@ impl Protobuf for GenesisInfo {
rollup_start_block_height: *rollup_start_block_height,
sequencer_chain_id,
celestia_chain_id,
halt_at_stop_height: *halt_at_stop_height,
})
}

Expand All @@ -165,6 +169,7 @@ impl Protobuf for GenesisInfo {
rollup_start_block_height,
sequencer_chain_id,
celestia_chain_id,
halt_at_stop_height,
} = self;

let sequencer_start_block_height: u32 =
Expand All @@ -186,6 +191,7 @@ impl Protobuf for GenesisInfo {
rollup_start_block_height: *rollup_start_block_height,
sequencer_chain_id: sequencer_chain_id.to_string(),
celestia_chain_id: celestia_chain_id.to_string(),
halt_at_stop_height: *halt_at_stop_height,
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/astria-core/src/generated/astria.execution.v1.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions crates/astria-core/src/generated/astria.execution.v1.serde.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions proto/executionapis/astria/execution/v1/execution.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ message GenesisInfo {
uint64 rollup_start_block_height = 5;
string sequencer_chain_id = 6;
string celestia_chain_id = 7;
// True if the conductor should halt at the stop height instead of attempting restart.
bool halt_at_stop_height = 8;
}

// The set of information which deterministic driver of block production
Expand Down

0 comments on commit 680d984

Please sign in to comment.