diff --git a/charts/evm-rollup/Chart.yaml b/charts/evm-rollup/Chart.yaml index b79b9fac56..5b03f32944 100644 --- a/charts/evm-rollup/Chart.yaml +++ b/charts/evm-rollup/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.18.4 +version: 0.18.5 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/evm-rollup/values.yaml b/charts/evm-rollup/values.yaml index 05e13711a6..a0e12b310f 100644 --- a/charts/evm-rollup/values.yaml +++ b/charts/evm-rollup/values.yaml @@ -10,7 +10,7 @@ images: geth: repo: ghcr.io/astriaorg/astria-geth tag: 0.10.1 - devTag: latest + devTag: pr-22 # Reset to latest once this PR has been merged conductor: repo: ghcr.io/astriaorg/conductor tag: "0.16.0" diff --git a/crates/astria-conductor/src/celestia/mod.rs b/crates/astria-conductor/src/celestia/mod.rs index 3979b0e337..4cd1cab2fc 100644 --- a/crates/astria-conductor/src/celestia/mod.rs +++ b/crates/astria-conductor/src/celestia/mod.rs @@ -266,9 +266,9 @@ impl RunningReader { let sequencer_namespace = astria_core::celestia::namespace_v0_from_sha256_of_bytes(sequencer_chain_id.as_bytes()); - let celestia_next_height = executor.celestia_base_block_height().value(); - let celestia_reference_height = executor.celestia_base_block_height().value(); - let celestia_variance = executor.celestia_block_variance().into(); + let celestia_next_height = executor.celestia_base_block_height(); + let celestia_reference_height = executor.celestia_base_block_height(); + let celestia_variance = executor.celestia_block_variance(); Ok(Self { block_cache, diff --git a/crates/astria-conductor/src/executor/mod.rs b/crates/astria-conductor/src/executor/mod.rs index 9c5d2fc36e..89b94ee07e 100644 --- a/crates/astria-conductor/src/executor/mod.rs +++ b/crates/astria-conductor/src/executor/mod.rs @@ -18,7 +18,6 @@ use astria_eyre::eyre::{ WrapErr as _, }; use bytes::Bytes; -use celestia_types::Height as CelestiaHeight; use sequencer_client::tendermint::{ block::Height as SequencerHeight, Time as TendermintTime, @@ -59,6 +58,8 @@ use state::StateReceiver; use self::state::StateSender; +type CelestiaHeight = u64; + #[derive(Clone, Debug)] pub(crate) struct StateNotInit; #[derive(Clone, Debug)] @@ -209,7 +210,7 @@ impl Handle { self.state.celestia_base_block_height() } - pub(crate) fn celestia_block_variance(&mut self) -> u32 { + pub(crate) fn celestia_block_variance(&mut self) -> u64 { self.state.celestia_block_variance() } } @@ -456,6 +457,7 @@ impl Executor { block.height = block.sequencer_height().value(), ))] async fn execute_firm(&mut self, block: ReconstructedBlock) -> eyre::Result<()> { + let celestia_height = block.celestia_height; let executable_block = ExecutableBlock::from_reconstructed(block); let expected_height = self.state.next_expected_firm_sequencer_height(); let block_height = executable_block.height; @@ -484,13 +486,13 @@ impl Executor { .wrap_err("failed to execute block")?; self.does_block_response_fulfill_contract(ExecutionKind::Firm, &executed_block) .wrap_err("execution API server violated contract")?; - Update::ToSame(executed_block) + Update::ToSame(executed_block, celestia_height) } else if let Some(block) = self.blocks_pending_finalization.remove(&block_number) { debug!( block_number, "found pending block in cache; updating state but not not re-executing it" ); - Update::OnlyFirm(block) + Update::OnlyFirm(block, celestia_height) } else { debug!( block_number, @@ -498,7 +500,7 @@ impl Executor { Trying to fetch the already-executed block from the rollup before giving up." ); match self.client.get_block_with_retry(block_number).await { - Ok(block) => Update::OnlyFirm(block), + Ok(block) => Update::OnlyFirm(block, celestia_height), Err(error) => { error!( block_number, @@ -594,14 +596,19 @@ impl Executor { OnlySoft, ToSame, }; - let (firm, soft) = match update { - OnlyFirm(firm) => (firm, self.state.soft()), - OnlySoft(soft) => (self.state.firm(), soft), - ToSame(block) => (block.clone(), block), + let (firm, soft, celestia_height) = match update { + OnlyFirm(firm, celestia_height) => (firm, self.state.soft(), celestia_height), + OnlySoft(soft) => ( + self.state.firm(), + soft, + self.state.celestia_base_block_height(), + ), + ToSame(block, celestia_height) => (block.clone(), block, celestia_height), }; let commitment_state = CommitmentState::builder() .firm(firm) .soft(soft) + .base_celestia_height(celestia_height) .build() .wrap_err("failed constructing commitment state")?; let new_state = self @@ -645,9 +652,9 @@ impl Executor { } enum Update { - OnlyFirm(Block), + OnlyFirm(Block, CelestiaHeight), OnlySoft(Block), - ToSame(Block), + ToSame(Block, CelestiaHeight), } #[derive(Debug)] diff --git a/crates/astria-conductor/src/executor/state.rs b/crates/astria-conductor/src/executor/state.rs index 00f1251cfe..f5d1bab6b2 100644 --- a/crates/astria-conductor/src/executor/state.rs +++ b/crates/astria-conductor/src/executor/state.rs @@ -15,7 +15,6 @@ use astria_eyre::{ eyre::WrapErr as _, }; use bytes::Bytes; -use celestia_types::Height as CelestiaHeight; use sequencer_client::tendermint::block::Height as SequencerHeight; use tokio::sync::watch::{ self, @@ -218,15 +217,16 @@ forward_impls!( [soft_number -> u32], [firm_hash -> Bytes], [soft_hash -> Bytes], - [celestia_block_variance -> u32], + [celestia_block_variance -> u64], [rollup_id -> RollupId], [sequencer_genesis_block_height -> SequencerHeight], + [celestia_base_block_height -> u64], ); forward_impls!( StateReceiver: - [celestia_base_block_height -> CelestiaHeight], - [celestia_block_variance -> u32], + [celestia_base_block_height -> u64], + [celestia_block_variance -> u64], [rollup_id -> RollupId], ); @@ -278,11 +278,11 @@ impl State { self.soft().hash().clone() } - fn celestia_base_block_height(&self) -> CelestiaHeight { - self.genesis_info.celestia_base_block_height() + fn celestia_base_block_height(&self) -> u64 { + self.commitment_state.base_celestia_height() } - fn celestia_block_variance(&self) -> u32 { + fn celestia_block_variance(&self) -> u64 { self.genesis_info.celestia_block_variance() } @@ -372,6 +372,7 @@ mod tests { CommitmentState::builder() .firm(firm) .soft(soft) + .base_celestia_height(1u64) .build() .unwrap() } @@ -380,7 +381,6 @@ mod tests { GenesisInfo::try_from_raw(raw::GenesisInfo { rollup_id: vec![24; 32].into(), sequencer_genesis_block_height: 10, - celestia_base_block_height: 1, celestia_block_variance: 0, }) .unwrap() diff --git a/crates/astria-conductor/src/executor/tests.rs b/crates/astria-conductor/src/executor/tests.rs index 76118883de..f6deb4db0d 100644 --- a/crates/astria-conductor/src/executor/tests.rs +++ b/crates/astria-conductor/src/executor/tests.rs @@ -48,13 +48,13 @@ fn make_state( let genesis_info = GenesisInfo::try_from_raw(raw::GenesisInfo { rollup_id: Bytes::copy_from_slice(ROLLUP_ID.as_ref()), sequencer_genesis_block_height: 1, - celestia_base_block_height: 1, celestia_block_variance: 1, }) .unwrap(); let commitment_state = CommitmentState::try_from_raw(raw::CommitmentState { firm: Some(make_block(firm)), soft: Some(make_block(soft)), + base_celestia_height: 1, }) .unwrap(); let (mut tx, rx) = super::state::channel(); diff --git a/crates/astria-conductor/tests/blackbox/firm_only.rs b/crates/astria-conductor/tests/blackbox/firm_only.rs index 6ec5ac7a8e..ea7b5056b4 100644 --- a/crates/astria-conductor/tests/blackbox/firm_only.rs +++ b/crates/astria-conductor/tests/blackbox/firm_only.rs @@ -27,7 +27,6 @@ async fn simple() { mount_get_genesis_info!( test_conductor, sequencer_genesis_block_height: 1, - celestia_base_block_height: 1, celestia_block_variance: 10, ); @@ -43,6 +42,7 @@ async fn simple() { hash: [1; 64], parent: [0; 64], ), + base_celestia_height: 1, ); mount_sequencer_genesis!(test_conductor); @@ -84,6 +84,7 @@ async fn simple() { hash: [2; 64], parent: [1; 64], ), + base_celestia_height: 1, ); timeout( @@ -107,7 +108,6 @@ async fn submits_two_heights_in_succession() { mount_get_genesis_info!( test_conductor, sequencer_genesis_block_height: 1, - celestia_base_block_height: 1, celestia_block_variance: 10, ); @@ -123,6 +123,7 @@ async fn submits_two_heights_in_succession() { hash: [1; 64], parent: [0; 64], ), + base_celestia_height: 1, ); mount_sequencer_genesis!(test_conductor); @@ -177,6 +178,7 @@ async fn submits_two_heights_in_succession() { hash: [2; 64], parent: [1; 64], ), + base_celestia_height: 1, ); let execute_block_number_3 = mount_executed_block!( @@ -198,6 +200,7 @@ async fn submits_two_heights_in_succession() { hash: [3; 64], parent: [2; 64], ), + base_celestia_height: 2, ); timeout( @@ -223,7 +226,6 @@ async fn skips_already_executed_heights() { mount_get_genesis_info!( test_conductor, sequencer_genesis_block_height: 1, - celestia_base_block_height: 1, celestia_block_variance: 10, ); @@ -239,6 +241,7 @@ async fn skips_already_executed_heights() { hash: [1; 64], parent: [0; 64], ), + base_celestia_height: 1, ); mount_sequencer_genesis!(test_conductor); @@ -293,6 +296,7 @@ async fn skips_already_executed_heights() { hash: [2; 64], parent: [1; 64], ), + base_celestia_height: 2, ); timeout( @@ -316,7 +320,6 @@ async fn fetch_from_later_celestia_height() { mount_get_genesis_info!( test_conductor, sequencer_genesis_block_height: 1, - celestia_base_block_height: 4, celestia_block_variance: 10, ); @@ -332,6 +335,7 @@ async fn fetch_from_later_celestia_height() { hash: [1; 64], parent: [0; 64], ), + base_celestia_height: 4, ); mount_sequencer_genesis!(test_conductor); @@ -373,6 +377,7 @@ async fn fetch_from_later_celestia_height() { hash: [2; 64], parent: [1; 64], ), + base_celestia_height: 4, ); timeout( diff --git a/crates/astria-conductor/tests/blackbox/helpers/macros.rs b/crates/astria-conductor/tests/blackbox/helpers/macros.rs index d33a1e342c..f3abbee2dc 100644 --- a/crates/astria-conductor/tests/blackbox/helpers/macros.rs +++ b/crates/astria-conductor/tests/blackbox/helpers/macros.rs @@ -53,8 +53,8 @@ macro_rules! celestia_network_head { macro_rules! commitment_state { ( firm: (number: $firm_number:expr,hash: $firm_hash:expr,parent: $firm_parent:expr $(,)?), - soft: (number: $soft_number:expr,hash: $soft_hash:expr,parent: $soft_parent:expr $(,)?) - $(,)? + soft: (number: $soft_number:expr,hash: $soft_hash:expr,parent: $soft_parent:expr $(,)?), + base_celestia_height: $base_celestia_height:expr $(,)? ) => { ::astria_core::generated::execution::v1alpha2::CommitmentState { firm: Some($crate::block!( @@ -67,6 +67,7 @@ macro_rules! commitment_state { hash: $soft_hash, parent: $soft_parent, )), + base_celestia_height: $base_celestia_height, } }; } @@ -91,14 +92,12 @@ macro_rules! filtered_sequencer_block { macro_rules! genesis_info { ( sequencer_genesis_block_height: - $sequencer_height:expr,celestia_base_block_height: - $celestia_height:expr,celestia_block_variance: + $sequencer_height:expr,celestia_block_variance: $variance:expr $(,)? ) => { ::astria_core::generated::execution::v1alpha2::GenesisInfo { rollup_id: ::bytes::Bytes::from($crate::ROLLUP_ID.to_vec()), sequencer_genesis_block_height: $sequencer_height, - celestia_base_block_height: $celestia_height, celestia_block_variance: $variance, } }; @@ -153,7 +152,8 @@ macro_rules! mount_get_commitment_state { ( $test_env:ident, firm: ( number: $firm_number:expr, hash: $firm_hash:expr, parent: $firm_parent:expr$(,)? ), - soft: ( number: $soft_number:expr, hash: $soft_hash:expr, parent: $soft_parent:expr$(,)? ) + soft: ( number: $soft_number:expr, hash: $soft_hash:expr, parent: $soft_parent:expr$(,)? ), + base_celestia_height: $base_celestia_height:expr $(,)? ) => { $test_env @@ -168,6 +168,7 @@ macro_rules! mount_get_commitment_state { hash: $soft_hash, parent: $soft_parent, ), + base_celestia_height: $base_celestia_height, )) .await }; @@ -179,7 +180,8 @@ macro_rules! mount_update_commitment_state { $test_env:ident, mock_name: $mock_name:expr, firm: ( number: $firm_number:expr, hash: $firm_hash:expr, parent: $firm_parent:expr$(,)? ), - soft: ( number: $soft_number:expr, hash: $soft_hash:expr, parent: $soft_parent:expr$(,)? ) + soft: ( number: $soft_number:expr, hash: $soft_hash:expr, parent: $soft_parent:expr$(,)? ), + base_celestia_height: $base_celestia_height:expr $(,)? ) => { $test_env @@ -196,6 +198,7 @@ macro_rules! mount_update_commitment_state { hash: $soft_hash, parent: $soft_parent, ), + base_celestia_height: $base_celestia_height, ), ) .await @@ -203,7 +206,8 @@ macro_rules! mount_update_commitment_state { ( $test_env:ident, firm: ( number: $firm_number:expr, hash: $firm_hash:expr, parent: $firm_parent:expr$(,)? ), - soft: ( number: $soft_number:expr, hash: $soft_hash:expr, parent: $soft_parent:expr$(,)? ) + soft: ( number: $soft_number:expr, hash: $soft_hash:expr, parent: $soft_parent:expr$(,)? ), + base_celestia_height: $base_celestia_height:expr $(,)? ) => { mount_update_commitment_state!( @@ -211,6 +215,7 @@ macro_rules! mount_update_commitment_state { mock_name: None, firm: ( number: $firm_number, hash: $firm_hash, parent: $firm_parent, ), soft: ( number: $soft_number, hash: $soft_hash, parent: $soft_parent, ), + base_celestia_height: $base_celestia_height, ) }; } @@ -282,14 +287,12 @@ macro_rules! mount_get_genesis_info { ( $test_env:ident, sequencer_genesis_block_height: $sequencer_height:expr, - celestia_base_block_height: $celestia_height:expr, celestia_block_variance: $variance:expr $(,)? ) => { $test_env.mount_get_genesis_info( $crate::genesis_info!( sequencer_genesis_block_height: $sequencer_height, - celestia_base_block_height: $celestia_height, celestia_block_variance: $variance, ) ).await; diff --git a/crates/astria-conductor/tests/blackbox/soft_and_firm.rs b/crates/astria-conductor/tests/blackbox/soft_and_firm.rs index 3f6e3cab93..9d9a1e059e 100644 --- a/crates/astria-conductor/tests/blackbox/soft_and_firm.rs +++ b/crates/astria-conductor/tests/blackbox/soft_and_firm.rs @@ -43,7 +43,6 @@ async fn simple() { mount_get_genesis_info!( test_conductor, sequencer_genesis_block_height: 1, - celestia_base_block_height: 1, celestia_block_variance: 10, ); @@ -59,6 +58,7 @@ async fn simple() { hash: [1; 64], parent: [0; 64], ), + base_celestia_height: 1, ); mount_abci_info!( @@ -110,6 +110,7 @@ async fn simple() { hash: [2; 64], parent: [1; 64], ), + base_celestia_height: 1, ); let update_commitment_state_firm = mount_update_commitment_state!( @@ -124,6 +125,7 @@ async fn simple() { hash: [2; 64], parent: [1; 64], ), + base_celestia_height: 1, ); timeout( @@ -141,6 +143,7 @@ async fn simple() { ); } +#[allow(clippy::too_many_lines)] // it's a test, it's fine #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn missing_block_is_fetched_for_updating_firm_commitment() { let test_conductor = spawn_conductor(CommitLevel::SoftAndFirm).await; @@ -148,7 +151,6 @@ async fn missing_block_is_fetched_for_updating_firm_commitment() { mount_get_genesis_info!( test_conductor, sequencer_genesis_block_height: 1, - celestia_base_block_height: 1, celestia_block_variance: 10, ); @@ -164,6 +166,7 @@ async fn missing_block_is_fetched_for_updating_firm_commitment() { hash: [2; 64], parent: [1; 64], ), + base_celestia_height: 1, ); mount_abci_info!( @@ -210,6 +213,7 @@ async fn missing_block_is_fetched_for_updating_firm_commitment() { hash: [2; 64], parent: [1; 64], ), + base_celestia_height: 1, ); timeout( @@ -243,6 +247,7 @@ async fn missing_block_is_fetched_for_updating_firm_commitment() { hash: [3; 64], parent: [2; 64], ), + base_celestia_height: 1, ); timeout( diff --git a/crates/astria-conductor/tests/blackbox/soft_only.rs b/crates/astria-conductor/tests/blackbox/soft_only.rs index 8e3d84cba9..4795979f2c 100644 --- a/crates/astria-conductor/tests/blackbox/soft_only.rs +++ b/crates/astria-conductor/tests/blackbox/soft_only.rs @@ -24,7 +24,6 @@ async fn simple() { mount_get_genesis_info!( test_conductor, sequencer_genesis_block_height: 1, - celestia_base_block_height: 1, celestia_block_variance: 10, ); @@ -40,6 +39,7 @@ async fn simple() { hash: [1; 64], parent: [0; 64], ), + base_celestia_height: 1, ); mount_abci_info!( @@ -71,6 +71,7 @@ async fn simple() { hash: [2; 64], parent: [1; 64], ), + base_celestia_height: 1, ); timeout( @@ -94,7 +95,6 @@ async fn submits_two_heights_in_succession() { mount_get_genesis_info!( test_conductor, sequencer_genesis_block_height: 1, - celestia_base_block_height: 1, celestia_block_variance: 10, ); @@ -110,6 +110,7 @@ async fn submits_two_heights_in_succession() { hash: [1; 64], parent: [0; 64], ), + base_celestia_height: 1, ); mount_abci_info!( @@ -148,6 +149,7 @@ async fn submits_two_heights_in_succession() { hash: [2; 64], parent: [1; 64], ), + base_celestia_height: 1, ); let execute_block_number_3 = mount_executed_block!( @@ -171,6 +173,7 @@ async fn submits_two_heights_in_succession() { hash: [3; 64], parent: [2; 64], ), + base_celestia_height: 1, ); timeout( @@ -196,7 +199,6 @@ async fn skips_already_executed_heights() { mount_get_genesis_info!( test_conductor, sequencer_genesis_block_height: 1, - celestia_base_block_height: 1, celestia_block_variance: 10, ); @@ -212,6 +214,7 @@ async fn skips_already_executed_heights() { hash: [1; 64], parent: [0; 64], ), + base_celestia_height: 1, ); mount_abci_info!( @@ -243,6 +246,7 @@ async fn skips_already_executed_heights() { hash: [2; 64], parent: [1; 64], ), + base_celestia_height: 1, ); timeout( @@ -266,7 +270,6 @@ async fn requests_from_later_genesis_height() { mount_get_genesis_info!( test_conductor, sequencer_genesis_block_height: 10, - celestia_base_block_height: 1, celestia_block_variance: 10, ); @@ -282,6 +285,7 @@ async fn requests_from_later_genesis_height() { hash: [1; 64], parent: [0; 64], ), + base_celestia_height: 1, ); mount_abci_info!( @@ -313,6 +317,7 @@ async fn requests_from_later_genesis_height() { hash: [2; 64], parent: [1; 64], ), + base_celestia_height: 1 ); timeout( diff --git a/crates/astria-core/src/execution/v1alpha2/mod.rs b/crates/astria-core/src/execution/v1alpha2/mod.rs index 522759821b..9e646cf149 100644 --- a/crates/astria-core/src/execution/v1alpha2/mod.rs +++ b/crates/astria-core/src/execution/v1alpha2/mod.rs @@ -27,7 +27,7 @@ enum GenesisInfoErrorKind { IncorrectRollupIdLength(IncorrectRollupIdLength), } -/// Genesis Info required from a rollup to start a an execution client. +/// Genesis Info required from a rollup to start an execution client. /// /// Contains information about the rollup id, and base heights for both sequencer & celestia. /// @@ -44,11 +44,8 @@ pub struct GenesisInfo { rollup_id: RollupId, /// The Sequencer block height which contains the first block of the rollup. sequencer_genesis_block_height: tendermint::block::Height, - /// The first Celestia height within which to look for Sequencer and Rollup blobs for the - /// rollup. - celestia_base_block_height: celestia_tendermint::block::Height, /// The allowed variance in the block height of celestia when looking for sequencer blocks. - celestia_block_variance: u32, + celestia_block_variance: u64, } impl GenesisInfo { @@ -63,12 +60,7 @@ impl GenesisInfo { } #[must_use] - pub fn celestia_base_block_height(&self) -> celestia_tendermint::block::Height { - self.celestia_base_block_height - } - - #[must_use] - pub fn celestia_block_variance(&self) -> u32 { + pub fn celestia_block_variance(&self) -> u64 { self.celestia_block_variance } } @@ -87,7 +79,6 @@ impl Protobuf for GenesisInfo { let raw::GenesisInfo { rollup_id, sequencer_genesis_block_height, - celestia_base_block_height, celestia_block_variance, } = raw; let rollup_id = @@ -96,7 +87,6 @@ impl Protobuf for GenesisInfo { Ok(Self { rollup_id, sequencer_genesis_block_height: (*sequencer_genesis_block_height).into(), - celestia_base_block_height: (*celestia_base_block_height).into(), celestia_block_variance: *celestia_block_variance, }) } @@ -105,7 +95,6 @@ impl Protobuf for GenesisInfo { let Self { rollup_id, sequencer_genesis_block_height, - celestia_base_block_height, celestia_block_variance, } = self; @@ -114,15 +103,9 @@ impl Protobuf for GenesisInfo { "block height overflow, this should not happen since tendermint heights are i64 \ under the hood", ); - let celestia_base_block_height: u32 = - (*celestia_base_block_height).value().try_into().expect( - "block height overflow, this should not happen since tendermint heights are i64 \ - under the hood", - ); Self::Raw { rollup_id: Bytes::copy_from_slice(rollup_id.as_ref()), sequencer_genesis_block_height, - celestia_base_block_height, celestia_block_variance: *celestia_block_variance, } } @@ -284,47 +267,76 @@ pub struct FirmExceedsSoft { pub struct NoFirm; pub struct NoSoft; +pub struct NoBaseCelestiaHeight; pub struct WithFirm(Block); pub struct WithSoft(Block); - +pub struct WithCelestiaBaseHeight(u64); #[derive(Default)] -pub struct CommitmentStateBuilder { +pub struct CommitmentStateBuilder< + TFirm = NoFirm, + TSoft = NoSoft, + TBaseCelestiaHeight = NoBaseCelestiaHeight, +> { firm: TFirm, soft: TSoft, + base_celestia_height: TBaseCelestiaHeight, } -impl CommitmentStateBuilder { +impl CommitmentStateBuilder { fn new() -> Self { Self { firm: NoFirm, soft: NoSoft, + base_celestia_height: NoBaseCelestiaHeight, } } } -impl CommitmentStateBuilder { - pub fn firm(self, firm: Block) -> CommitmentStateBuilder { +impl CommitmentStateBuilder { + pub fn firm(self, firm: Block) -> CommitmentStateBuilder { let Self { - soft, .. + soft, + base_celestia_height, + .. } = self; CommitmentStateBuilder { firm: WithFirm(firm), soft, + base_celestia_height, } } - pub fn soft(self, soft: Block) -> CommitmentStateBuilder { + pub fn soft(self, soft: Block) -> CommitmentStateBuilder { let Self { - firm, .. + firm, + base_celestia_height, + .. } = self; CommitmentStateBuilder { firm, soft: WithSoft(soft), + base_celestia_height, + } + } + + pub fn base_celestia_height( + self, + base_celestia_height: u64, + ) -> CommitmentStateBuilder { + let Self { + firm, + soft, + .. + } = self; + CommitmentStateBuilder { + firm, + soft, + base_celestia_height: WithCelestiaBaseHeight(base_celestia_height), } } } -impl CommitmentStateBuilder { +impl CommitmentStateBuilder { /// Finalize the commitment state. /// /// # Errors @@ -333,6 +345,7 @@ impl CommitmentStateBuilder { let Self { firm: WithFirm(firm), soft: WithSoft(soft), + base_celestia_height: WithCelestiaBaseHeight(base_celestia_height), } = self; if firm.number() > soft.number() { return Err(FirmExceedsSoft { @@ -343,6 +356,7 @@ impl CommitmentStateBuilder { Ok(CommitmentState { soft, firm, + base_celestia_height, }) } } @@ -364,6 +378,9 @@ pub struct CommitmentState { soft: Block, /// Firm commitment is achieved when data has been seen in DA. firm: Block, + /// The base height of celestia from which to search for blocks after this + /// commitment state. + base_celestia_height: u64, } impl CommitmentState { @@ -381,6 +398,10 @@ impl CommitmentState { pub fn soft(&self) -> &Block { &self.soft } + + pub fn base_celestia_height(&self) -> u64 { + self.base_celestia_height + } } impl From for raw::CommitmentState { @@ -397,6 +418,7 @@ impl Protobuf for CommitmentState { let Self::Raw { soft, firm, + base_celestia_height, } = raw; let soft = 'soft: { let Some(soft) = soft else { @@ -410,9 +432,11 @@ impl Protobuf for CommitmentState { }; Block::try_from_raw_ref(firm).map_err(Self::Error::firm) }?; + Self::builder() .firm(firm) .soft(soft) + .base_celestia_height(*base_celestia_height) .build() .map_err(Self::Error::firm_exceeds_soft) } @@ -421,12 +445,15 @@ impl Protobuf for CommitmentState { let Self { soft, firm, + base_celestia_height, } = self; let soft = soft.to_raw(); let firm = firm.to_raw(); + let base_celestia_height = *base_celestia_height; Self::Raw { soft: Some(soft), firm: Some(firm), + base_celestia_height, } } } diff --git a/crates/astria-core/src/generated/astria.execution.v1alpha2.rs b/crates/astria-core/src/generated/astria.execution.v1alpha2.rs index 31adf8985c..088b997e80 100644 --- a/crates/astria-core/src/generated/astria.execution.v1alpha2.rs +++ b/crates/astria-core/src/generated/astria.execution.v1alpha2.rs @@ -11,12 +11,9 @@ pub struct GenesisInfo { /// The first block height of sequencer chain to use for rollup transactions. #[prost(uint32, tag = "2")] pub sequencer_genesis_block_height: u32, - /// The first block height of celestia chain to use for rollup transactions. - #[prost(uint32, tag = "3")] - pub celestia_base_block_height: u32, /// The allowed variance in celestia for sequencer blocks to have been posted. - #[prost(uint32, tag = "4")] - pub celestia_block_variance: u32, + #[prost(uint64, tag = "4")] + pub celestia_block_variance: u64, } impl ::prost::Name for GenesisInfo { const NAME: &'static str = "GenesisInfo"; @@ -172,6 +169,9 @@ pub struct CommitmentState { /// Firm commitment is achieved when data has been seen in DA. #[prost(message, optional, tag = "2")] pub firm: ::core::option::Option, + /// The lowest block number of celestia chain to be searched for rollup blocks given current state + #[prost(uint64, tag = "3")] + pub base_celestia_height: u64, } impl ::prost::Name for CommitmentState { const NAME: &'static str = "CommitmentState"; diff --git a/crates/astria-core/src/generated/astria.execution.v1alpha2.serde.rs b/crates/astria-core/src/generated/astria.execution.v1alpha2.serde.rs index 94ad554304..90671b8292 100644 --- a/crates/astria-core/src/generated/astria.execution.v1alpha2.serde.rs +++ b/crates/astria-core/src/generated/astria.execution.v1alpha2.serde.rs @@ -455,6 +455,9 @@ impl serde::Serialize for CommitmentState { if self.firm.is_some() { len += 1; } + if self.base_celestia_height != 0 { + len += 1; + } let mut struct_ser = serializer.serialize_struct("astria.execution.v1alpha2.CommitmentState", len)?; if let Some(v) = self.soft.as_ref() { struct_ser.serialize_field("soft", v)?; @@ -462,6 +465,10 @@ impl serde::Serialize for CommitmentState { if let Some(v) = self.firm.as_ref() { struct_ser.serialize_field("firm", v)?; } + if self.base_celestia_height != 0 { + #[allow(clippy::needless_borrow)] + struct_ser.serialize_field("base_celestia_height", ToString::to_string(&self.base_celestia_height).as_str())?; + } struct_ser.end() } } @@ -474,12 +481,15 @@ impl<'de> serde::Deserialize<'de> for CommitmentState { const FIELDS: &[&str] = &[ "soft", "firm", + "base_celestia_height", + "baseCelestiaHeight", ]; #[allow(clippy::enum_variant_names)] enum GeneratedField { Soft, Firm, + BaseCelestiaHeight, } impl<'de> serde::Deserialize<'de> for GeneratedField { fn deserialize(deserializer: D) -> std::result::Result @@ -503,6 +513,7 @@ impl<'de> serde::Deserialize<'de> for CommitmentState { match value { "soft" => Ok(GeneratedField::Soft), "firm" => Ok(GeneratedField::Firm), + "baseCelestiaHeight" | "base_celestia_height" => Ok(GeneratedField::BaseCelestiaHeight), _ => Err(serde::de::Error::unknown_field(value, FIELDS)), } } @@ -524,6 +535,7 @@ impl<'de> serde::Deserialize<'de> for CommitmentState { { let mut soft__ = None; let mut firm__ = None; + let mut base_celestia_height__ = None; while let Some(k) = map_.next_key()? { match k { GeneratedField::Soft => { @@ -538,11 +550,20 @@ impl<'de> serde::Deserialize<'de> for CommitmentState { } firm__ = map_.next_value()?; } + GeneratedField::BaseCelestiaHeight => { + if base_celestia_height__.is_some() { + return Err(serde::de::Error::duplicate_field("baseCelestiaHeight")); + } + base_celestia_height__ = + Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) + ; + } } } Ok(CommitmentState { soft: soft__, firm: firm__, + base_celestia_height: base_celestia_height__.unwrap_or_default(), }) } } @@ -692,9 +713,6 @@ impl serde::Serialize for GenesisInfo { if self.sequencer_genesis_block_height != 0 { len += 1; } - if self.celestia_base_block_height != 0 { - len += 1; - } if self.celestia_block_variance != 0 { len += 1; } @@ -706,11 +724,9 @@ impl serde::Serialize for GenesisInfo { if self.sequencer_genesis_block_height != 0 { struct_ser.serialize_field("sequencer_genesis_block_height", &self.sequencer_genesis_block_height)?; } - if self.celestia_base_block_height != 0 { - struct_ser.serialize_field("celestia_base_block_height", &self.celestia_base_block_height)?; - } if self.celestia_block_variance != 0 { - struct_ser.serialize_field("celestia_block_variance", &self.celestia_block_variance)?; + #[allow(clippy::needless_borrow)] + struct_ser.serialize_field("celestia_block_variance", ToString::to_string(&self.celestia_block_variance).as_str())?; } struct_ser.end() } @@ -726,8 +742,6 @@ impl<'de> serde::Deserialize<'de> for GenesisInfo { "rollupId", "sequencer_genesis_block_height", "sequencerGenesisBlockHeight", - "celestia_base_block_height", - "celestiaBaseBlockHeight", "celestia_block_variance", "celestiaBlockVariance", ]; @@ -736,7 +750,6 @@ impl<'de> serde::Deserialize<'de> for GenesisInfo { enum GeneratedField { RollupId, SequencerGenesisBlockHeight, - CelestiaBaseBlockHeight, CelestiaBlockVariance, } impl<'de> serde::Deserialize<'de> for GeneratedField { @@ -761,7 +774,6 @@ impl<'de> serde::Deserialize<'de> for GenesisInfo { match value { "rollupId" | "rollup_id" => Ok(GeneratedField::RollupId), "sequencerGenesisBlockHeight" | "sequencer_genesis_block_height" => Ok(GeneratedField::SequencerGenesisBlockHeight), - "celestiaBaseBlockHeight" | "celestia_base_block_height" => Ok(GeneratedField::CelestiaBaseBlockHeight), "celestiaBlockVariance" | "celestia_block_variance" => Ok(GeneratedField::CelestiaBlockVariance), _ => Err(serde::de::Error::unknown_field(value, FIELDS)), } @@ -784,7 +796,6 @@ impl<'de> serde::Deserialize<'de> for GenesisInfo { { let mut rollup_id__ = None; let mut sequencer_genesis_block_height__ = None; - let mut celestia_base_block_height__ = None; let mut celestia_block_variance__ = None; while let Some(k) = map_.next_key()? { match k { @@ -804,14 +815,6 @@ impl<'de> serde::Deserialize<'de> for GenesisInfo { Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) ; } - GeneratedField::CelestiaBaseBlockHeight => { - if celestia_base_block_height__.is_some() { - return Err(serde::de::Error::duplicate_field("celestiaBaseBlockHeight")); - } - celestia_base_block_height__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } GeneratedField::CelestiaBlockVariance => { if celestia_block_variance__.is_some() { return Err(serde::de::Error::duplicate_field("celestiaBlockVariance")); @@ -825,7 +828,6 @@ impl<'de> serde::Deserialize<'de> for GenesisInfo { Ok(GenesisInfo { rollup_id: rollup_id__.unwrap_or_default(), sequencer_genesis_block_height: sequencer_genesis_block_height__.unwrap_or_default(), - celestia_base_block_height: celestia_base_block_height__.unwrap_or_default(), celestia_block_variance: celestia_block_variance__.unwrap_or_default(), }) } diff --git a/proto/executionapis/astria/execution/v1alpha2/execution.proto b/proto/executionapis/astria/execution/v1alpha2/execution.proto index c1635159f6..996b5111de 100644 --- a/proto/executionapis/astria/execution/v1alpha2/execution.proto +++ b/proto/executionapis/astria/execution/v1alpha2/execution.proto @@ -14,10 +14,8 @@ message GenesisInfo { bytes rollup_id = 1; // The first block height of sequencer chain to use for rollup transactions. uint32 sequencer_genesis_block_height = 2; - // The first block height of celestia chain to use for rollup transactions. - uint32 celestia_base_block_height = 3; // The allowed variance in celestia for sequencer blocks to have been posted. - uint32 celestia_block_variance = 4; + uint64 celestia_block_variance = 4; } // The set of information which deterministic driver of block production @@ -86,6 +84,8 @@ message CommitmentState { Block soft = 1; // Firm commitment is achieved when data has been seen in DA. Block firm = 2; + // The lowest block number of celestia chain to be searched for rollup blocks given current state + uint64 base_celestia_height = 3; } // There is only one CommitmentState object, so the request is empty.