From ba29401cc530e22faacd9bb217fec32133143e62 Mon Sep 17 00:00:00 2001 From: itamar Date: Wed, 25 Sep 2024 15:45:48 -0400 Subject: [PATCH] request type for baseblock --- .../src/generated/astria.bundle.v1alpha1.rs | 32 ++++++- .../generated/astria.bundle.v1alpha1.serde.rs | 91 +++++++++++++++++++ .../astria/bundle/v1alpha1/bundle.proto | 8 +- 3 files changed, 125 insertions(+), 6 deletions(-) diff --git a/crates/astria-core/src/generated/astria.bundle.v1alpha1.rs b/crates/astria-core/src/generated/astria.bundle.v1alpha1.rs index b1c5205644..a56ccf5eab 100644 --- a/crates/astria-core/src/generated/astria.bundle.v1alpha1.rs +++ b/crates/astria-core/src/generated/astria.bundle.v1alpha1.rs @@ -24,7 +24,22 @@ impl ::prost::Name for BaseBlock { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct StreamExecuteOptimisticBlockRequest { + #[prost(message, optional, tag = "1")] + pub block: ::core::option::Option, +} +impl ::prost::Name for StreamExecuteOptimisticBlockRequest { + const NAME: &'static str = "StreamExecuteOptimisticBlockRequest"; + const PACKAGE: &'static str = "astria.bundle.v1alpha1"; + fn full_name() -> ::prost::alloc::string::String { + ::prost::alloc::format!("astria.bundle.v1alpha1.{}", Self::NAME) + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct StreamExecuteOptimisticBlockResponse { + /// Metadata identifying the block resulting from executing a block. Includes number, hash, + /// parent hash and timestamp. #[prost(message, optional, tag = "1")] pub block: ::core::option::Option, /// The base_sequencer_block_hash is the hash from the base sequencer block this block @@ -173,7 +188,9 @@ pub mod bundle_service_client { /// metadata from the executed blocks. pub async fn stream_execute_optimistic_block( &mut self, - request: impl tonic::IntoStreamingRequest, + request: impl tonic::IntoStreamingRequest< + Message = super::StreamExecuteOptimisticBlockRequest, + >, ) -> std::result::Result< tonic::Response< tonic::codec::Streaming, @@ -259,7 +276,9 @@ pub mod bundle_service_server { /// metadata from the executed blocks. async fn stream_execute_optimistic_block( self: std::sync::Arc, - request: tonic::Request>, + request: tonic::Request< + tonic::Streaming, + >, ) -> std::result::Result< tonic::Response, tonic::Status, @@ -366,8 +385,9 @@ pub mod bundle_service_server { struct StreamExecuteOptimisticBlockSvc(pub Arc); impl< T: BundleService, - > tonic::server::StreamingService - for StreamExecuteOptimisticBlockSvc { + > tonic::server::StreamingService< + super::StreamExecuteOptimisticBlockRequest, + > for StreamExecuteOptimisticBlockSvc { type Response = super::StreamExecuteOptimisticBlockResponse; type ResponseStream = T::StreamExecuteOptimisticBlockStream; type Future = BoxFuture< @@ -376,7 +396,9 @@ pub mod bundle_service_server { >; fn call( &mut self, - request: tonic::Request>, + request: tonic::Request< + tonic::Streaming, + >, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { diff --git a/crates/astria-core/src/generated/astria.bundle.v1alpha1.serde.rs b/crates/astria-core/src/generated/astria.bundle.v1alpha1.serde.rs index 38eb79befb..dab3fd07a2 100644 --- a/crates/astria-core/src/generated/astria.bundle.v1alpha1.serde.rs +++ b/crates/astria-core/src/generated/astria.bundle.v1alpha1.serde.rs @@ -354,6 +354,97 @@ impl<'de> serde::Deserialize<'de> for StreamBundlesRequest { deserializer.deserialize_struct("astria.bundle.v1alpha1.StreamBundlesRequest", FIELDS, GeneratedVisitor) } } +impl serde::Serialize for StreamExecuteOptimisticBlockRequest { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0; + if self.block.is_some() { + len += 1; + } + let mut struct_ser = serializer.serialize_struct("astria.bundle.v1alpha1.StreamExecuteOptimisticBlockRequest", len)?; + if let Some(v) = self.block.as_ref() { + struct_ser.serialize_field("block", v)?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for StreamExecuteOptimisticBlockRequest { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "block", + ]; + + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + Block, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", &FIELDS) + } + + #[allow(unused_variables)] + fn visit_str(self, value: &str) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "block" => Ok(GeneratedField::Block), + _ => Err(serde::de::Error::unknown_field(value, FIELDS)), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = StreamExecuteOptimisticBlockRequest; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + formatter.write_str("struct astria.bundle.v1alpha1.StreamExecuteOptimisticBlockRequest") + } + + fn visit_map(self, mut map_: V) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut block__ = None; + while let Some(k) = map_.next_key()? { + match k { + GeneratedField::Block => { + if block__.is_some() { + return Err(serde::de::Error::duplicate_field("block")); + } + block__ = map_.next_value()?; + } + } + } + Ok(StreamExecuteOptimisticBlockRequest { + block: block__, + }) + } + } + deserializer.deserialize_struct("astria.bundle.v1alpha1.StreamExecuteOptimisticBlockRequest", FIELDS, GeneratedVisitor) + } +} impl serde::Serialize for StreamExecuteOptimisticBlockResponse { #[allow(deprecated)] fn serialize(&self, serializer: S) -> std::result::Result diff --git a/proto/executionapis/astria/bundle/v1alpha1/bundle.proto b/proto/executionapis/astria/bundle/v1alpha1/bundle.proto index c03636512d..1e469e32a3 100644 --- a/proto/executionapis/astria/bundle/v1alpha1/bundle.proto +++ b/proto/executionapis/astria/bundle/v1alpha1/bundle.proto @@ -17,7 +17,13 @@ message BaseBlock { google.protobuf.Timestamp timestamp = 3; } +message StreamExecuteOptimisticBlockRequest { + BaseBlock block = 1; +} + message StreamExecuteOptimisticBlockResponse { + // Metadata identifying the block resulting from executing a block. Includes number, hash, + // parent hash and timestamp. astria.execution.v1alpha2.Block block = 1; // The base_sequencer_block_hash is the hash from the base sequencer block this block // is based on. This is used to associate an optimistic execution result with the hash @@ -51,7 +57,7 @@ message Bundle { service BundleService { // Stream blocks from the Auctioneer to Geth for optimistic execution. Geth will stream back // metadata from the executed blocks. - rpc StreamExecuteOptimisticBlock(stream BaseBlock) returns (stream StreamExecuteOptimisticBlockResponse); + rpc StreamExecuteOptimisticBlock(stream StreamExecuteOptimisticBlockRequest) returns (stream StreamExecuteOptimisticBlockResponse); // A bundle submitter requests bundles given a new optimistic Sequencer block, // and receives a stream of potential bundles for submission, until either a timeout // or the connection is closed by the client.