diff --git a/crates/cnidarium/src/gen/proto_descriptor.bin.no_lfs b/crates/cnidarium/src/gen/proto_descriptor.bin.no_lfs index 67d781308d..c2c1f4df90 100644 Binary files a/crates/cnidarium/src/gen/proto_descriptor.bin.no_lfs and b/crates/cnidarium/src/gen/proto_descriptor.bin.no_lfs differ diff --git a/crates/core/component/compact-block/src/compact_block.rs b/crates/core/component/compact-block/src/compact_block.rs index 4a896c708f..2041a0995f 100644 --- a/crates/core/component/compact-block/src/compact_block.rs +++ b/crates/core/component/compact-block/src/compact_block.rs @@ -38,6 +38,8 @@ pub struct CompactBlock { pub app_parameters_updated: bool, /// Updated gas prices, if they have changed. pub gas_prices: Option, + // The epoch index + pub epoch_index: u64, // **IMPORTANT NOTE FOR FUTURE HUMANS**: if you want to add new fields to the `CompactBlock`, // you must update `CompactBlock::requires_scanning` to check for the emptiness of those fields, // because the client will skip processing any compact block that is marked as not requiring @@ -57,6 +59,7 @@ impl Default for CompactBlock { swap_outputs: BTreeMap::new(), app_parameters_updated: false, gas_prices: None, + epoch_index: 0, } } } @@ -95,6 +98,7 @@ impl From for pb::CompactBlock { swap_outputs: cb.swap_outputs.into_values().map(Into::into).collect(), app_parameters_updated: cb.app_parameters_updated, gas_prices: cb.gas_prices.map(Into::into), + epoch_index: cb.epoch_index, } } } @@ -132,6 +136,7 @@ impl TryFrom for CompactBlock { proposal_started: value.proposal_started, app_parameters_updated: value.app_parameters_updated, gas_prices: value.gas_prices.map(TryInto::try_into).transpose()?, + epoch_index: value.epoch_index, }) } } diff --git a/crates/core/component/compact-block/src/component/manager.rs b/crates/core/component/compact-block/src/component/manager.rs index f0bf34e122..3b84fabb45 100644 --- a/crates/core/component/compact-block/src/component/manager.rs +++ b/crates/core/component/compact-block/src/component/manager.rs @@ -113,6 +113,13 @@ trait Inner: StateWrite { // Add all the pending nullifiers to the compact block let nullifiers = self.pending_nullifiers().into_iter().collect(); + //Get the index of the current epoch + let epoch_index = self + .get_current_epoch() + .await + .expect("epoch is always set") + .index; + let compact_block = CompactBlock { height, state_payloads, @@ -124,6 +131,7 @@ trait Inner: StateWrite { fmd_parameters, app_parameters_updated, gas_prices, + epoch_index, }; self.nonverifiable_put_raw( diff --git a/crates/proto/src/gen/penumbra.core.component.compact_block.v1.rs b/crates/proto/src/gen/penumbra.core.component.compact_block.v1.rs index 5013cd3a27..92edba517e 100644 --- a/crates/proto/src/gen/penumbra.core.component.compact_block.v1.rs +++ b/crates/proto/src/gen/penumbra.core.component.compact_block.v1.rs @@ -39,6 +39,9 @@ pub struct CompactBlock { /// Updated gas prices, if they have changed. #[prost(message, optional, tag = "10")] pub gas_prices: ::core::option::Option, + /// The epoch index + #[prost(uint64, tag = "11")] + pub epoch_index: u64, } impl ::prost::Name for CompactBlock { const NAME: &'static str = "CompactBlock"; diff --git a/crates/proto/src/gen/penumbra.core.component.compact_block.v1.serde.rs b/crates/proto/src/gen/penumbra.core.component.compact_block.v1.serde.rs index 524801fad4..8f49ca36c7 100644 --- a/crates/proto/src/gen/penumbra.core.component.compact_block.v1.serde.rs +++ b/crates/proto/src/gen/penumbra.core.component.compact_block.v1.serde.rs @@ -36,6 +36,9 @@ impl serde::Serialize for CompactBlock { if self.gas_prices.is_some() { len += 1; } + if self.epoch_index != 0 { + len += 1; + } let mut struct_ser = serializer.serialize_struct("penumbra.core.component.compact_block.v1.CompactBlock", len)?; if self.height != 0 { #[allow(clippy::needless_borrow)] @@ -68,6 +71,10 @@ impl serde::Serialize for CompactBlock { if let Some(v) = self.gas_prices.as_ref() { struct_ser.serialize_field("gasPrices", v)?; } + if self.epoch_index != 0 { + #[allow(clippy::needless_borrow)] + struct_ser.serialize_field("epochIndex", ToString::to_string(&self.epoch_index).as_str())?; + } struct_ser.end() } } @@ -96,6 +103,8 @@ impl<'de> serde::Deserialize<'de> for CompactBlock { "appParametersUpdated", "gas_prices", "gasPrices", + "epoch_index", + "epochIndex", ]; #[allow(clippy::enum_variant_names)] @@ -110,6 +119,7 @@ impl<'de> serde::Deserialize<'de> for CompactBlock { SwapOutputs, AppParametersUpdated, GasPrices, + EpochIndex, __SkipField__, } impl<'de> serde::Deserialize<'de> for GeneratedField { @@ -142,6 +152,7 @@ impl<'de> serde::Deserialize<'de> for CompactBlock { "swapOutputs" | "swap_outputs" => Ok(GeneratedField::SwapOutputs), "appParametersUpdated" | "app_parameters_updated" => Ok(GeneratedField::AppParametersUpdated), "gasPrices" | "gas_prices" => Ok(GeneratedField::GasPrices), + "epochIndex" | "epoch_index" => Ok(GeneratedField::EpochIndex), _ => Ok(GeneratedField::__SkipField__), } } @@ -171,6 +182,7 @@ impl<'de> serde::Deserialize<'de> for CompactBlock { let mut swap_outputs__ = None; let mut app_parameters_updated__ = None; let mut gas_prices__ = None; + let mut epoch_index__ = None; while let Some(k) = map_.next_key()? { match k { GeneratedField::Height => { @@ -235,6 +247,14 @@ impl<'de> serde::Deserialize<'de> for CompactBlock { } gas_prices__ = map_.next_value()?; } + GeneratedField::EpochIndex => { + if epoch_index__.is_some() { + return Err(serde::de::Error::duplicate_field("epochIndex")); + } + epoch_index__ = + Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) + ; + } GeneratedField::__SkipField__ => { let _ = map_.next_value::()?; } @@ -251,6 +271,7 @@ impl<'de> serde::Deserialize<'de> for CompactBlock { swap_outputs: swap_outputs__.unwrap_or_default(), app_parameters_updated: app_parameters_updated__.unwrap_or_default(), gas_prices: gas_prices__, + epoch_index: epoch_index__.unwrap_or_default(), }) } } diff --git a/crates/proto/src/gen/proto_descriptor.bin.no_lfs b/crates/proto/src/gen/proto_descriptor.bin.no_lfs index 1800672860..4657e8905a 100644 Binary files a/crates/proto/src/gen/proto_descriptor.bin.no_lfs and b/crates/proto/src/gen/proto_descriptor.bin.no_lfs differ diff --git a/proto/penumbra/penumbra/core/component/compact_block/v1/compact_block.proto b/proto/penumbra/penumbra/core/component/compact_block/v1/compact_block.proto index 54af53e878..83bb115d34 100644 --- a/proto/penumbra/penumbra/core/component/compact_block/v1/compact_block.proto +++ b/proto/penumbra/penumbra/core/component/compact_block/v1/compact_block.proto @@ -28,6 +28,8 @@ message CompactBlock { bool app_parameters_updated = 9; // Updated gas prices, if they have changed. fee.v1.GasPrices gas_prices = 10; + // The epoch index + uint64 epoch_index = 11; } // An encrypted payload, corresponding to a single commitment in the state commitment tree.