diff --git a/Cargo.lock b/Cargo.lock index d47477a0b9..4f40b3b57c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -477,7 +477,9 @@ dependencies = [ "tendermint 0.33.2", "tendermint-proto 0.33.2", "tonic", + "tonic-build", "tracing", + "walkdir", "which", ] @@ -882,7 +884,7 @@ dependencies = [ "lazy_static", "lazycell", "peeking_take_while", - "prettyplease", + "prettyplease 0.2.15", "proc-macro2", "quote", "regex", @@ -1117,7 +1119,7 @@ source = "git+https://github.com/eigerco/celestia-node-rs?rev=1fa61eb#1fa61ebd6b dependencies = [ "anyhow", "prost 0.12.1", - "prost-build", + "prost-build 0.12.1", "prost-types 0.12.1", "serde", "tendermint-proto 0.32.0", @@ -1961,7 +1963,7 @@ dependencies = [ "ethers-core", "ethers-etherscan", "eyre", - "prettyplease", + "prettyplease 0.2.15", "proc-macro2", "quote", "regex", @@ -3995,6 +3997,16 @@ dependencies = [ "termtree", ] +[[package]] +name = "prettyplease" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" +dependencies = [ + "proc-macro2", + "syn 1.0.109", +] + [[package]] name = "prettyplease" version = "0.2.15" @@ -4120,6 +4132,28 @@ dependencies = [ "prost-derive 0.12.1", ] +[[package]] +name = "prost-build" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" +dependencies = [ + "bytes", + "heck", + "itertools 0.10.5", + "lazy_static", + "log", + "multimap", + "petgraph", + "prettyplease 0.1.25", + "prost 0.11.9", + "prost-types 0.11.9", + "regex", + "syn 1.0.109", + "tempfile", + "which", +] + [[package]] name = "prost-build" version = "0.12.1" @@ -4133,7 +4167,7 @@ dependencies = [ "multimap", "once_cell", "petgraph", - "prettyplease", + "prettyplease 0.2.15", "prost 0.12.1", "prost-types 0.12.1", "regex", @@ -5726,6 +5760,19 @@ dependencies = [ "tracing", ] +[[package]] +name = "tonic-build" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6fdaae4c2c638bb70fe42803a26fbd6fc6ac8c72f5c59f67ecc2a2dcabf4b07" +dependencies = [ + "prettyplease 0.1.25", + "proc-macro2", + "prost-build 0.11.9", + "quote", + "syn 1.0.109", +] + [[package]] name = "tower" version = "0.4.13" diff --git a/crates/astria-proto/Cargo.toml b/crates/astria-proto/Cargo.toml index 18a01abc11..ad8aa8af81 100644 --- a/crates/astria-proto/Cargo.toml +++ b/crates/astria-proto/Cargo.toml @@ -33,4 +33,6 @@ server = ["dep:tonic"] [dev-dependencies] tempfile = { workspace = true } +tonic-build = "0.9" +walkdir = "2.4.0" which = { workspace = true } diff --git a/crates/astria-proto/buf.gen.yaml b/crates/astria-proto/buf.gen.yaml deleted file mode 100644 index 618788decc..0000000000 --- a/crates/astria-proto/buf.gen.yaml +++ /dev/null @@ -1,15 +0,0 @@ -version: v1 -managed: - enabled: true -plugins: - - plugin: buf.build/community/neoeinstein-prost:v0.2.3 - out: . - opt: - - extern_path=.tendermint.types=::tendermint-proto::types - - extern_path=.tendermint.abci=::tendermint-proto::abci - - type_attribute=.astria.primitive.v1.Uint128=#[derive(Copy)] - - plugin: buf.build/community/neoeinstein-tonic:v0.3.0 - out: . - opt: - - server_mod_attribute=.=#[cfg(feature="server")] - - client_mod_attribute=.=#[cfg(feature="client")] diff --git a/crates/astria-proto/src/proto/generated/astria.execution.v1alpha1.rs b/crates/astria-proto/src/proto/generated/astria.execution.v1alpha1.rs index 56d348fd5b..69a041202e 100644 --- a/crates/astria-proto/src/proto/generated/astria.execution.v1alpha1.rs +++ b/crates/astria-proto/src/proto/generated/astria.execution.v1alpha1.rs @@ -1,39 +1,493 @@ -// @generated #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DoBlockRequest { - #[prost(bytes="vec", tag="1")] + #[prost(bytes = "vec", tag = "1")] pub prev_block_hash: ::prost::alloc::vec::Vec, - #[prost(bytes="vec", repeated, tag="2")] + #[prost(bytes = "vec", repeated, tag = "2")] pub transactions: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, - #[prost(message, optional, tag="3")] + #[prost(message, optional, tag = "3")] pub timestamp: ::core::option::Option<::prost_types::Timestamp>, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DoBlockResponse { - #[prost(bytes="vec", tag="1")] + #[prost(bytes = "vec", tag = "1")] pub block_hash: ::prost::alloc::vec::Vec, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct FinalizeBlockRequest { - #[prost(bytes="vec", tag="1")] + #[prost(bytes = "vec", tag = "1")] pub block_hash: ::prost::alloc::vec::Vec, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct FinalizeBlockResponse { -} +pub struct FinalizeBlockResponse {} #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct InitStateRequest { -} +pub struct InitStateRequest {} #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct InitStateResponse { - #[prost(bytes="vec", tag="1")] + #[prost(bytes = "vec", tag = "1")] pub block_hash: ::prost::alloc::vec::Vec, } -include!("astria.execution.v1alpha1.tonic.rs"); -// @@protoc_insertion_point(module) \ No newline at end of file +/// Generated client implementations. +#[cfg(feature = "client")] +pub mod execution_service_client { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::*; + use tonic::codegen::http::Uri; + #[derive(Debug, Clone)] + pub struct ExecutionServiceClient { + inner: tonic::client::Grpc, + } + impl ExecutionServiceClient { + /// Attempt to create a new client by connecting to a given endpoint. + pub async fn connect(dst: D) -> Result + where + D: TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl ExecutionServiceClient + where + T: tonic::client::GrpcService, + T::Error: Into, + T::ResponseBody: Body + Send + 'static, + ::Error: Into + Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_origin(inner: T, origin: Uri) -> Self { + let inner = tonic::client::Grpc::with_origin(inner, origin); + Self { inner } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> ExecutionServiceClient> + where + F: tonic::service::Interceptor, + T::ResponseBody: Default, + T: tonic::codegen::Service< + http::Request, + Response = http::Response< + >::ResponseBody, + >, + >, + , + >>::Error: Into + Send + Sync, + { + ExecutionServiceClient::new(InterceptedService::new(inner, interceptor)) + } + /// Compress requests with the given encoding. + /// + /// This requires the server to support it otherwise it might respond with an + /// error. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.send_compressed(encoding); + self + } + /// Enable decompressing responses. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.accept_compressed(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_encoding_message_size(limit); + self + } + pub async fn init_state( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/astria.execution.v1alpha1.ExecutionService/InitState", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "astria.execution.v1alpha1.ExecutionService", + "InitState", + ), + ); + self.inner.unary(req, path, codec).await + } + pub async fn do_block( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/astria.execution.v1alpha1.ExecutionService/DoBlock", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "astria.execution.v1alpha1.ExecutionService", + "DoBlock", + ), + ); + self.inner.unary(req, path, codec).await + } + pub async fn finalize_block( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/astria.execution.v1alpha1.ExecutionService/FinalizeBlock", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "astria.execution.v1alpha1.ExecutionService", + "FinalizeBlock", + ), + ); + self.inner.unary(req, path, codec).await + } + } +} +/// Generated server implementations. +#[cfg(feature = "server")] +pub mod execution_service_server { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::*; + /// Generated trait containing gRPC methods that should be implemented for use with ExecutionServiceServer. + #[async_trait] + pub trait ExecutionService: Send + Sync + 'static { + async fn init_state( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn do_block( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + async fn finalize_block( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + } + #[derive(Debug)] + pub struct ExecutionServiceServer { + inner: _Inner, + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, + } + struct _Inner(Arc); + impl ExecutionServiceServer { + pub fn new(inner: T) -> Self { + Self::from_arc(Arc::new(inner)) + } + pub fn from_arc(inner: Arc) -> Self { + let inner = _Inner(inner); + Self { + inner, + accept_compression_encodings: Default::default(), + send_compression_encodings: Default::default(), + max_decoding_message_size: None, + max_encoding_message_size: None, + } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService + where + F: tonic::service::Interceptor, + { + InterceptedService::new(Self::new(inner), interceptor) + } + /// Enable decompressing requests with the given encoding. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.accept_compression_encodings.enable(encoding); + self + } + /// Compress responses with the given encoding, if the client supports it. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.send_compression_encodings.enable(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } + } + impl tonic::codegen::Service> for ExecutionServiceServer + where + T: ExecutionService, + B: Body + Send + 'static, + B::Error: Into + Send + 'static, + { + type Response = http::Response; + type Error = std::convert::Infallible; + type Future = BoxFuture; + fn poll_ready( + &mut self, + _cx: &mut Context<'_>, + ) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + let inner = self.inner.clone(); + match req.uri().path() { + "/astria.execution.v1alpha1.ExecutionService/InitState" => { + #[allow(non_camel_case_types)] + struct InitStateSvc(pub Arc); + impl< + T: ExecutionService, + > tonic::server::UnaryService + for InitStateSvc { + type Response = super::InitStateResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { (*inner).init_state(request).await }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = InitStateSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/astria.execution.v1alpha1.ExecutionService/DoBlock" => { + #[allow(non_camel_case_types)] + struct DoBlockSvc(pub Arc); + impl< + T: ExecutionService, + > tonic::server::UnaryService + for DoBlockSvc { + type Response = super::DoBlockResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { (*inner).do_block(request).await }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = DoBlockSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/astria.execution.v1alpha1.ExecutionService/FinalizeBlock" => { + #[allow(non_camel_case_types)] + struct FinalizeBlockSvc(pub Arc); + impl< + T: ExecutionService, + > tonic::server::UnaryService + for FinalizeBlockSvc { + type Response = super::FinalizeBlockResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + (*inner).finalize_block(request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = FinalizeBlockSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } + } + } + } + impl Clone for ExecutionServiceServer { + fn clone(&self) -> Self { + let inner = self.inner.clone(); + Self { + inner, + accept_compression_encodings: self.accept_compression_encodings, + send_compression_encodings: self.send_compression_encodings, + max_decoding_message_size: self.max_decoding_message_size, + max_encoding_message_size: self.max_encoding_message_size, + } + } + } + impl Clone for _Inner { + fn clone(&self) -> Self { + Self(Arc::clone(&self.0)) + } + } + impl std::fmt::Debug for _Inner { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self.0) + } + } + impl tonic::server::NamedService for ExecutionServiceServer { + const NAME: &'static str = "astria.execution.v1alpha1.ExecutionService"; + } +} diff --git a/crates/astria-proto/src/proto/generated/astria.execution.v1alpha1.tonic.rs b/crates/astria-proto/src/proto/generated/astria.execution.v1alpha1.tonic.rs deleted file mode 100644 index 51900f6760..0000000000 --- a/crates/astria-proto/src/proto/generated/astria.execution.v1alpha1.tonic.rs +++ /dev/null @@ -1,468 +0,0 @@ -// @generated -/// Generated client implementations. -#[cfg(feature = "client")] -pub mod execution_service_client { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; - use tonic::codegen::http::Uri; - /// - #[derive(Debug, Clone)] - pub struct ExecutionServiceClient { - inner: tonic::client::Grpc, - } - impl ExecutionServiceClient { - /// Attempt to create a new client by connecting to a given endpoint. - pub async fn connect(dst: D) -> Result - where - D: TryInto, - D::Error: Into, - { - let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; - Ok(Self::new(conn)) - } - } - impl ExecutionServiceClient - where - T: tonic::client::GrpcService, - T::Error: Into, - T::ResponseBody: Body + Send + 'static, - ::Error: Into + Send, - { - pub fn new(inner: T) -> Self { - let inner = tonic::client::Grpc::new(inner); - Self { inner } - } - pub fn with_origin(inner: T, origin: Uri) -> Self { - let inner = tonic::client::Grpc::with_origin(inner, origin); - Self { inner } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> ExecutionServiceClient> - where - F: tonic::service::Interceptor, - T::ResponseBody: Default, - T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, - >, - , - >>::Error: Into + Send + Sync, - { - ExecutionServiceClient::new(InterceptedService::new(inner, interceptor)) - } - /// Compress requests with the given encoding. - /// - /// This requires the server to support it otherwise it might respond with an - /// error. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.send_compressed(encoding); - self - } - /// Enable decompressing responses. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.accept_compressed(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_decoding_message_size(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_encoding_message_size(limit); - self - } - /// - pub async fn init_state( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/astria.execution.v1alpha1.ExecutionService/InitState", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "astria.execution.v1alpha1.ExecutionService", - "InitState", - ), - ); - self.inner.unary(req, path, codec).await - } - /// - pub async fn do_block( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/astria.execution.v1alpha1.ExecutionService/DoBlock", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "astria.execution.v1alpha1.ExecutionService", - "DoBlock", - ), - ); - self.inner.unary(req, path, codec).await - } - /// - pub async fn finalize_block( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/astria.execution.v1alpha1.ExecutionService/FinalizeBlock", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "astria.execution.v1alpha1.ExecutionService", - "FinalizeBlock", - ), - ); - self.inner.unary(req, path, codec).await - } - } -} -/// Generated server implementations. -#[cfg(feature = "server")] -pub mod execution_service_server { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with ExecutionServiceServer. - #[async_trait] - pub trait ExecutionService: Send + Sync + 'static { - /// - async fn init_state( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; - /// - async fn do_block( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// - async fn finalize_block( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; - } - /// - #[derive(Debug)] - pub struct ExecutionServiceServer { - inner: _Inner, - accept_compression_encodings: EnabledCompressionEncodings, - send_compression_encodings: EnabledCompressionEncodings, - max_decoding_message_size: Option, - max_encoding_message_size: Option, - } - struct _Inner(Arc); - impl ExecutionServiceServer { - pub fn new(inner: T) -> Self { - Self::from_arc(Arc::new(inner)) - } - pub fn from_arc(inner: Arc) -> Self { - let inner = _Inner(inner); - Self { - inner, - accept_compression_encodings: Default::default(), - send_compression_encodings: Default::default(), - max_decoding_message_size: None, - max_encoding_message_size: None, - } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService - where - F: tonic::service::Interceptor, - { - InterceptedService::new(Self::new(inner), interceptor) - } - /// Enable decompressing requests with the given encoding. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.accept_compression_encodings.enable(encoding); - self - } - /// Compress responses with the given encoding, if the client supports it. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.send_compression_encodings.enable(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.max_decoding_message_size = Some(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.max_encoding_message_size = Some(limit); - self - } - } - impl tonic::codegen::Service> for ExecutionServiceServer - where - T: ExecutionService, - B: Body + Send + 'static, - B::Error: Into + Send + 'static, - { - type Response = http::Response; - type Error = std::convert::Infallible; - type Future = BoxFuture; - fn poll_ready( - &mut self, - _cx: &mut Context<'_>, - ) -> Poll> { - Poll::Ready(Ok(())) - } - fn call(&mut self, req: http::Request) -> Self::Future { - let inner = self.inner.clone(); - match req.uri().path() { - "/astria.execution.v1alpha1.ExecutionService/InitState" => { - #[allow(non_camel_case_types)] - struct InitStateSvc(pub Arc); - impl< - T: ExecutionService, - > tonic::server::UnaryService - for InitStateSvc { - type Response = super::InitStateResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { (*inner).init_state(request).await }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let inner = inner.0; - let method = InitStateSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/astria.execution.v1alpha1.ExecutionService/DoBlock" => { - #[allow(non_camel_case_types)] - struct DoBlockSvc(pub Arc); - impl< - T: ExecutionService, - > tonic::server::UnaryService - for DoBlockSvc { - type Response = super::DoBlockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { (*inner).do_block(request).await }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let inner = inner.0; - let method = DoBlockSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/astria.execution.v1alpha1.ExecutionService/FinalizeBlock" => { - #[allow(non_camel_case_types)] - struct FinalizeBlockSvc(pub Arc); - impl< - T: ExecutionService, - > tonic::server::UnaryService - for FinalizeBlockSvc { - type Response = super::FinalizeBlockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - (*inner).finalize_block(request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let inner = inner.0; - let method = FinalizeBlockSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } - } - } - } - impl Clone for ExecutionServiceServer { - fn clone(&self) -> Self { - let inner = self.inner.clone(); - Self { - inner, - accept_compression_encodings: self.accept_compression_encodings, - send_compression_encodings: self.send_compression_encodings, - max_decoding_message_size: self.max_decoding_message_size, - max_encoding_message_size: self.max_encoding_message_size, - } - } - } - impl Clone for _Inner { - fn clone(&self) -> Self { - Self(Arc::clone(&self.0)) - } - } - impl std::fmt::Debug for _Inner { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{:?}", self.0) - } - } - impl tonic::server::NamedService for ExecutionServiceServer { - const NAME: &'static str = "astria.execution.v1alpha1.ExecutionService"; - } -} diff --git a/crates/astria-proto/src/proto/generated/astria.execution.v1alpha2.rs b/crates/astria-proto/src/proto/generated/astria.execution.v1alpha2.rs index 63851548c4..d2053b8c08 100644 --- a/crates/astria-proto/src/proto/generated/astria.execution.v1alpha2.rs +++ b/crates/astria-proto/src/proto/generated/astria.execution.v1alpha2.rs @@ -1,37 +1,36 @@ -// @generated /// The set of information which deterministic driver of block production /// must know about a given rollup Block #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Block { /// The block number - #[prost(uint32, tag="1")] + #[prost(uint32, tag = "1")] pub number: u32, /// The hash of the block - #[prost(bytes="vec", tag="2")] + #[prost(bytes = "vec", tag = "2")] pub hash: ::prost::alloc::vec::Vec, /// The hash from the parent block - #[prost(bytes="vec", tag="3")] + #[prost(bytes = "vec", tag = "3")] pub parent_block_hash: ::prost::alloc::vec::Vec, /// Timestamp on the block, standardized to google protobuf standard. - #[prost(message, optional, tag="4")] + #[prost(message, optional, tag = "4")] pub timestamp: ::core::option::Option<::prost_types::Timestamp>, } /// Fields which are indexed for finding blocks on a blockchain. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct BlockIdentifier { - #[prost(oneof="block_identifier::Identifier", tags="1, 2")] + #[prost(oneof = "block_identifier::Identifier", tags = "1, 2")] pub identifier: ::core::option::Option, } /// Nested message and enum types in `BlockIdentifier`. pub mod block_identifier { #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Oneof)] + #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Identifier { - #[prost(uint32, tag="1")] + #[prost(uint32, tag = "1")] BlockNumber(u32), - #[prost(bytes, tag="2")] + #[prost(bytes, tag = "2")] BlockHash(::prost::alloc::vec::Vec), } } @@ -39,7 +38,7 @@ pub mod block_identifier { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetBlockRequest { - #[prost(message, optional, tag="1")] + #[prost(message, optional, tag = "1")] pub identifier: ::core::option::Option, } /// Used in BatchGetBlocks, will find all or none based on the list of @@ -47,14 +46,14 @@ pub struct GetBlockRequest { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct BatchGetBlocksRequest { - #[prost(message, repeated, tag="1")] + #[prost(message, repeated, tag = "1")] pub identifiers: ::prost::alloc::vec::Vec, } /// The list of blocks in response to BatchGetBlocks. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct BatchGetBlocksResponse { - #[prost(message, repeated, tag="1")] + #[prost(message, repeated, tag = "1")] pub blocks: ::prost::alloc::vec::Vec, } /// ExecuteBlockRequest contains all the information needed to create a new rollup @@ -66,13 +65,13 @@ pub struct BatchGetBlocksResponse { #[derive(Clone, PartialEq, ::prost::Message)] pub struct ExecuteBlockRequest { /// The hash of previous block, which new block will be created on top of. - #[prost(bytes="vec", tag="1")] + #[prost(bytes = "vec", tag = "1")] pub prev_block_hash: ::prost::alloc::vec::Vec, /// List of transactions to include in the new block. - #[prost(bytes="vec", repeated, tag="2")] + #[prost(bytes = "vec", repeated, tag = "2")] pub transactions: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, /// Timestamp to be used for new block. - #[prost(message, optional, tag="3")] + #[prost(message, optional, tag = "3")] pub timestamp: ::core::option::Option<::prost_types::Timestamp>, } /// The CommitmentState holds the block at each stage of sequencer commitment @@ -87,23 +86,658 @@ pub struct ExecuteBlockRequest { #[derive(Clone, PartialEq, ::prost::Message)] pub struct CommitmentState { /// Soft commitment is the rollup block matching latest sequencer block. - #[prost(message, optional, tag="1")] + #[prost(message, optional, tag = "1")] pub soft: ::core::option::Option, /// Firm commitment is achieved when data has been seen in DA. - #[prost(message, optional, tag="2")] + #[prost(message, optional, tag = "2")] pub firm: ::core::option::Option, } /// There is only one CommitmentState object, so the request is empty. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetCommitmentStateRequest { -} +pub struct GetCommitmentStateRequest {} /// The CommitmentState to set, must include complete state. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct UpdateCommitmentStateRequest { - #[prost(message, optional, tag="1")] + #[prost(message, optional, tag = "1")] pub commitment_state: ::core::option::Option, } -include!("astria.execution.v1alpha2.tonic.rs"); -// @@protoc_insertion_point(module) \ No newline at end of file +/// Generated client implementations. +#[cfg(feature = "client")] +pub mod execution_service_client { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::*; + use tonic::codegen::http::Uri; + /// ExecutionService is used to drive deterministic production of blocks. + /// + /// The service can be implemented by any blockchain which wants to utilize the + /// Astria Shared Sequencer, and will have block production driven via the Astria + /// "Conductor". + #[derive(Debug, Clone)] + pub struct ExecutionServiceClient { + inner: tonic::client::Grpc, + } + impl ExecutionServiceClient { + /// Attempt to create a new client by connecting to a given endpoint. + pub async fn connect(dst: D) -> Result + where + D: TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl ExecutionServiceClient + where + T: tonic::client::GrpcService, + T::Error: Into, + T::ResponseBody: Body + Send + 'static, + ::Error: Into + Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_origin(inner: T, origin: Uri) -> Self { + let inner = tonic::client::Grpc::with_origin(inner, origin); + Self { inner } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> ExecutionServiceClient> + where + F: tonic::service::Interceptor, + T::ResponseBody: Default, + T: tonic::codegen::Service< + http::Request, + Response = http::Response< + >::ResponseBody, + >, + >, + , + >>::Error: Into + Send + Sync, + { + ExecutionServiceClient::new(InterceptedService::new(inner, interceptor)) + } + /// Compress requests with the given encoding. + /// + /// This requires the server to support it otherwise it might respond with an + /// error. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.send_compressed(encoding); + self + } + /// Enable decompressing responses. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.accept_compressed(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_encoding_message_size(limit); + self + } + /// GetBlock will return a block given an identifier. + pub async fn get_block( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/astria.execution.v1alpha2.ExecutionService/GetBlock", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "astria.execution.v1alpha2.ExecutionService", + "GetBlock", + ), + ); + self.inner.unary(req, path, codec).await + } + /// BatchGetBlocks will return an array of Blocks given an array of block + /// identifiers. + pub async fn batch_get_blocks( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/astria.execution.v1alpha2.ExecutionService/BatchGetBlocks", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "astria.execution.v1alpha2.ExecutionService", + "BatchGetBlocks", + ), + ); + self.inner.unary(req, path, codec).await + } + /// ExecuteBlock is called to deterministically derive a rollup block from + /// filtered sequencer block information. + pub async fn execute_block( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/astria.execution.v1alpha2.ExecutionService/ExecuteBlock", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "astria.execution.v1alpha2.ExecutionService", + "ExecuteBlock", + ), + ); + self.inner.unary(req, path, codec).await + } + /// GetCommitmentState fetches the current CommitmentState of the chain. + pub async fn get_commitment_state( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/astria.execution.v1alpha2.ExecutionService/GetCommitmentState", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "astria.execution.v1alpha2.ExecutionService", + "GetCommitmentState", + ), + ); + self.inner.unary(req, path, codec).await + } + /// UpdateCommitmentState replaces the whole CommitmentState with a new + /// CommitmentState. + pub async fn update_commitment_state( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/astria.execution.v1alpha2.ExecutionService/UpdateCommitmentState", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "astria.execution.v1alpha2.ExecutionService", + "UpdateCommitmentState", + ), + ); + self.inner.unary(req, path, codec).await + } + } +} +/// Generated server implementations. +#[cfg(feature = "server")] +pub mod execution_service_server { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::*; + /// Generated trait containing gRPC methods that should be implemented for use with ExecutionServiceServer. + #[async_trait] + pub trait ExecutionService: Send + Sync + 'static { + /// GetBlock will return a block given an identifier. + async fn get_block( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// BatchGetBlocks will return an array of Blocks given an array of block + /// identifiers. + async fn batch_get_blocks( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + /// ExecuteBlock is called to deterministically derive a rollup block from + /// filtered sequencer block information. + async fn execute_block( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// GetCommitmentState fetches the current CommitmentState of the chain. + async fn get_commitment_state( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// UpdateCommitmentState replaces the whole CommitmentState with a new + /// CommitmentState. + async fn update_commitment_state( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + } + /// ExecutionService is used to drive deterministic production of blocks. + /// + /// The service can be implemented by any blockchain which wants to utilize the + /// Astria Shared Sequencer, and will have block production driven via the Astria + /// "Conductor". + #[derive(Debug)] + pub struct ExecutionServiceServer { + inner: _Inner, + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, + } + struct _Inner(Arc); + impl ExecutionServiceServer { + pub fn new(inner: T) -> Self { + Self::from_arc(Arc::new(inner)) + } + pub fn from_arc(inner: Arc) -> Self { + let inner = _Inner(inner); + Self { + inner, + accept_compression_encodings: Default::default(), + send_compression_encodings: Default::default(), + max_decoding_message_size: None, + max_encoding_message_size: None, + } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService + where + F: tonic::service::Interceptor, + { + InterceptedService::new(Self::new(inner), interceptor) + } + /// Enable decompressing requests with the given encoding. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.accept_compression_encodings.enable(encoding); + self + } + /// Compress responses with the given encoding, if the client supports it. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.send_compression_encodings.enable(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } + } + impl tonic::codegen::Service> for ExecutionServiceServer + where + T: ExecutionService, + B: Body + Send + 'static, + B::Error: Into + Send + 'static, + { + type Response = http::Response; + type Error = std::convert::Infallible; + type Future = BoxFuture; + fn poll_ready( + &mut self, + _cx: &mut Context<'_>, + ) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + let inner = self.inner.clone(); + match req.uri().path() { + "/astria.execution.v1alpha2.ExecutionService/GetBlock" => { + #[allow(non_camel_case_types)] + struct GetBlockSvc(pub Arc); + impl< + T: ExecutionService, + > tonic::server::UnaryService + for GetBlockSvc { + type Response = super::Block; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { (*inner).get_block(request).await }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = GetBlockSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/astria.execution.v1alpha2.ExecutionService/BatchGetBlocks" => { + #[allow(non_camel_case_types)] + struct BatchGetBlocksSvc(pub Arc); + impl< + T: ExecutionService, + > tonic::server::UnaryService + for BatchGetBlocksSvc { + type Response = super::BatchGetBlocksResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + (*inner).batch_get_blocks(request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = BatchGetBlocksSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/astria.execution.v1alpha2.ExecutionService/ExecuteBlock" => { + #[allow(non_camel_case_types)] + struct ExecuteBlockSvc(pub Arc); + impl< + T: ExecutionService, + > tonic::server::UnaryService + for ExecuteBlockSvc { + type Response = super::Block; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + (*inner).execute_block(request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = ExecuteBlockSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/astria.execution.v1alpha2.ExecutionService/GetCommitmentState" => { + #[allow(non_camel_case_types)] + struct GetCommitmentStateSvc(pub Arc); + impl< + T: ExecutionService, + > tonic::server::UnaryService + for GetCommitmentStateSvc { + type Response = super::CommitmentState; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + (*inner).get_commitment_state(request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = GetCommitmentStateSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/astria.execution.v1alpha2.ExecutionService/UpdateCommitmentState" => { + #[allow(non_camel_case_types)] + struct UpdateCommitmentStateSvc(pub Arc); + impl< + T: ExecutionService, + > tonic::server::UnaryService + for UpdateCommitmentStateSvc { + type Response = super::CommitmentState; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + (*inner).update_commitment_state(request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = UpdateCommitmentStateSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } + } + } + } + impl Clone for ExecutionServiceServer { + fn clone(&self) -> Self { + let inner = self.inner.clone(); + Self { + inner, + accept_compression_encodings: self.accept_compression_encodings, + send_compression_encodings: self.send_compression_encodings, + max_decoding_message_size: self.max_decoding_message_size, + max_encoding_message_size: self.max_encoding_message_size, + } + } + } + impl Clone for _Inner { + fn clone(&self) -> Self { + Self(Arc::clone(&self.0)) + } + } + impl std::fmt::Debug for _Inner { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self.0) + } + } + impl tonic::server::NamedService for ExecutionServiceServer { + const NAME: &'static str = "astria.execution.v1alpha2.ExecutionService"; + } +} diff --git a/crates/astria-proto/src/proto/generated/astria.execution.v1alpha2.tonic.rs b/crates/astria-proto/src/proto/generated/astria.execution.v1alpha2.tonic.rs deleted file mode 100644 index 3b26fe9270..0000000000 --- a/crates/astria-proto/src/proto/generated/astria.execution.v1alpha2.tonic.rs +++ /dev/null @@ -1,651 +0,0 @@ -// @generated -/// Generated client implementations. -#[cfg(feature = "client")] -pub mod execution_service_client { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; - use tonic::codegen::http::Uri; - /** ExecutionService is used to drive deterministic production of blocks. - - The service can be implemented by any blockchain which wants to utilize the - Astria Shared Sequencer, and will have block production driven via the Astria - "Conductor". -*/ - #[derive(Debug, Clone)] - pub struct ExecutionServiceClient { - inner: tonic::client::Grpc, - } - impl ExecutionServiceClient { - /// Attempt to create a new client by connecting to a given endpoint. - pub async fn connect(dst: D) -> Result - where - D: TryInto, - D::Error: Into, - { - let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; - Ok(Self::new(conn)) - } - } - impl ExecutionServiceClient - where - T: tonic::client::GrpcService, - T::Error: Into, - T::ResponseBody: Body + Send + 'static, - ::Error: Into + Send, - { - pub fn new(inner: T) -> Self { - let inner = tonic::client::Grpc::new(inner); - Self { inner } - } - pub fn with_origin(inner: T, origin: Uri) -> Self { - let inner = tonic::client::Grpc::with_origin(inner, origin); - Self { inner } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> ExecutionServiceClient> - where - F: tonic::service::Interceptor, - T::ResponseBody: Default, - T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, - >, - , - >>::Error: Into + Send + Sync, - { - ExecutionServiceClient::new(InterceptedService::new(inner, interceptor)) - } - /// Compress requests with the given encoding. - /// - /// This requires the server to support it otherwise it might respond with an - /// error. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.send_compressed(encoding); - self - } - /// Enable decompressing responses. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.accept_compressed(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_decoding_message_size(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_encoding_message_size(limit); - self - } - /** GetBlock will return a block given an identifier. -*/ - pub async fn get_block( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/astria.execution.v1alpha2.ExecutionService/GetBlock", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "astria.execution.v1alpha2.ExecutionService", - "GetBlock", - ), - ); - self.inner.unary(req, path, codec).await - } - /** BatchGetBlocks will return an array of Blocks given an array of block - identifiers. -*/ - pub async fn batch_get_blocks( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/astria.execution.v1alpha2.ExecutionService/BatchGetBlocks", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "astria.execution.v1alpha2.ExecutionService", - "BatchGetBlocks", - ), - ); - self.inner.unary(req, path, codec).await - } - /** ExecuteBlock is called to deterministically derive a rollup block from - filtered sequencer block information. -*/ - pub async fn execute_block( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/astria.execution.v1alpha2.ExecutionService/ExecuteBlock", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "astria.execution.v1alpha2.ExecutionService", - "ExecuteBlock", - ), - ); - self.inner.unary(req, path, codec).await - } - /** GetCommitmentState fetches the current CommitmentState of the chain. -*/ - pub async fn get_commitment_state( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/astria.execution.v1alpha2.ExecutionService/GetCommitmentState", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "astria.execution.v1alpha2.ExecutionService", - "GetCommitmentState", - ), - ); - self.inner.unary(req, path, codec).await - } - /** UpdateCommitmentState replaces the whole CommitmentState with a new - CommitmentState. -*/ - pub async fn update_commitment_state( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/astria.execution.v1alpha2.ExecutionService/UpdateCommitmentState", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "astria.execution.v1alpha2.ExecutionService", - "UpdateCommitmentState", - ), - ); - self.inner.unary(req, path, codec).await - } - } -} -/// Generated server implementations. -#[cfg(feature = "server")] -pub mod execution_service_server { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with ExecutionServiceServer. - #[async_trait] - pub trait ExecutionService: Send + Sync + 'static { - /** GetBlock will return a block given an identifier. -*/ - async fn get_block( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /** BatchGetBlocks will return an array of Blocks given an array of block - identifiers. -*/ - async fn batch_get_blocks( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; - /** ExecuteBlock is called to deterministically derive a rollup block from - filtered sequencer block information. -*/ - async fn execute_block( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /** GetCommitmentState fetches the current CommitmentState of the chain. -*/ - async fn get_commitment_state( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /** UpdateCommitmentState replaces the whole CommitmentState with a new - CommitmentState. -*/ - async fn update_commitment_state( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - } - /** ExecutionService is used to drive deterministic production of blocks. - - The service can be implemented by any blockchain which wants to utilize the - Astria Shared Sequencer, and will have block production driven via the Astria - "Conductor". -*/ - #[derive(Debug)] - pub struct ExecutionServiceServer { - inner: _Inner, - accept_compression_encodings: EnabledCompressionEncodings, - send_compression_encodings: EnabledCompressionEncodings, - max_decoding_message_size: Option, - max_encoding_message_size: Option, - } - struct _Inner(Arc); - impl ExecutionServiceServer { - pub fn new(inner: T) -> Self { - Self::from_arc(Arc::new(inner)) - } - pub fn from_arc(inner: Arc) -> Self { - let inner = _Inner(inner); - Self { - inner, - accept_compression_encodings: Default::default(), - send_compression_encodings: Default::default(), - max_decoding_message_size: None, - max_encoding_message_size: None, - } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService - where - F: tonic::service::Interceptor, - { - InterceptedService::new(Self::new(inner), interceptor) - } - /// Enable decompressing requests with the given encoding. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.accept_compression_encodings.enable(encoding); - self - } - /// Compress responses with the given encoding, if the client supports it. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.send_compression_encodings.enable(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.max_decoding_message_size = Some(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.max_encoding_message_size = Some(limit); - self - } - } - impl tonic::codegen::Service> for ExecutionServiceServer - where - T: ExecutionService, - B: Body + Send + 'static, - B::Error: Into + Send + 'static, - { - type Response = http::Response; - type Error = std::convert::Infallible; - type Future = BoxFuture; - fn poll_ready( - &mut self, - _cx: &mut Context<'_>, - ) -> Poll> { - Poll::Ready(Ok(())) - } - fn call(&mut self, req: http::Request) -> Self::Future { - let inner = self.inner.clone(); - match req.uri().path() { - "/astria.execution.v1alpha2.ExecutionService/GetBlock" => { - #[allow(non_camel_case_types)] - struct GetBlockSvc(pub Arc); - impl< - T: ExecutionService, - > tonic::server::UnaryService - for GetBlockSvc { - type Response = super::Block; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { (*inner).get_block(request).await }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let inner = inner.0; - let method = GetBlockSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/astria.execution.v1alpha2.ExecutionService/BatchGetBlocks" => { - #[allow(non_camel_case_types)] - struct BatchGetBlocksSvc(pub Arc); - impl< - T: ExecutionService, - > tonic::server::UnaryService - for BatchGetBlocksSvc { - type Response = super::BatchGetBlocksResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - (*inner).batch_get_blocks(request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let inner = inner.0; - let method = BatchGetBlocksSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/astria.execution.v1alpha2.ExecutionService/ExecuteBlock" => { - #[allow(non_camel_case_types)] - struct ExecuteBlockSvc(pub Arc); - impl< - T: ExecutionService, - > tonic::server::UnaryService - for ExecuteBlockSvc { - type Response = super::Block; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - (*inner).execute_block(request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let inner = inner.0; - let method = ExecuteBlockSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/astria.execution.v1alpha2.ExecutionService/GetCommitmentState" => { - #[allow(non_camel_case_types)] - struct GetCommitmentStateSvc(pub Arc); - impl< - T: ExecutionService, - > tonic::server::UnaryService - for GetCommitmentStateSvc { - type Response = super::CommitmentState; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - (*inner).get_commitment_state(request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let inner = inner.0; - let method = GetCommitmentStateSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/astria.execution.v1alpha2.ExecutionService/UpdateCommitmentState" => { - #[allow(non_camel_case_types)] - struct UpdateCommitmentStateSvc(pub Arc); - impl< - T: ExecutionService, - > tonic::server::UnaryService - for UpdateCommitmentStateSvc { - type Response = super::CommitmentState; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - (*inner).update_commitment_state(request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let inner = inner.0; - let method = UpdateCommitmentStateSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } - } - } - } - impl Clone for ExecutionServiceServer { - fn clone(&self) -> Self { - let inner = self.inner.clone(); - Self { - inner, - accept_compression_encodings: self.accept_compression_encodings, - send_compression_encodings: self.send_compression_encodings, - max_decoding_message_size: self.max_decoding_message_size, - max_encoding_message_size: self.max_encoding_message_size, - } - } - } - impl Clone for _Inner { - fn clone(&self) -> Self { - Self(Arc::clone(&self.0)) - } - } - impl std::fmt::Debug for _Inner { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{:?}", self.0) - } - } - impl tonic::server::NamedService for ExecutionServiceServer { - const NAME: &'static str = "astria.execution.v1alpha2.ExecutionService"; - } -} diff --git a/crates/astria-proto/src/proto/generated/astria.primitive.v1.rs b/crates/astria-proto/src/proto/generated/astria.primitive.v1.rs index 95fde01df9..ba7ebb49a0 100644 --- a/crates/astria-proto/src/proto/generated/astria.primitive.v1.rs +++ b/crates/astria-proto/src/proto/generated/astria.primitive.v1.rs @@ -1,4 +1,3 @@ -// @generated /// A 128 bit unsigned integer encoded in protobuf., /// /// Protobuf does not support integers larger than 64 bits, @@ -14,9 +13,8 @@ #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Uint128 { - #[prost(uint64, tag="1")] + #[prost(uint64, tag = "1")] pub lo: u64, - #[prost(uint64, tag="2")] + #[prost(uint64, tag = "2")] pub hi: u64, } -// @@protoc_insertion_point(module) diff --git a/crates/astria-proto/src/proto/generated/astria.sequencer.v1alpha1.rs b/crates/astria-proto/src/proto/generated/astria.sequencer.v1alpha1.rs index 19597804ad..52e9e910b1 100644 --- a/crates/astria-proto/src/proto/generated/astria.sequencer.v1alpha1.rs +++ b/crates/astria-proto/src/proto/generated/astria.sequencer.v1alpha1.rs @@ -1,20 +1,19 @@ -// @generated /// A response containing the balance of an account. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct BalanceResponse { - #[prost(uint64, tag="2")] + #[prost(uint64, tag = "2")] pub height: u64, - #[prost(message, optional, tag="3")] + #[prost(message, optional, tag = "3")] pub balance: ::core::option::Option, } /// A response containing the current nonce for an account. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct NonceResponse { - #[prost(uint64, tag="2")] + #[prost(uint64, tag = "2")] pub height: u64, - #[prost(uint32, tag="3")] + #[prost(uint32, tag = "3")] pub nonce: u32, } /// `IndexedTransaction` represents a sequencer transaction along with the index @@ -23,39 +22,39 @@ pub struct NonceResponse { #[derive(Clone, PartialEq, ::prost::Message)] pub struct IndexedTransaction { /// TODO: this is usize - how to define for variable size? - #[prost(uint64, tag="1")] + #[prost(uint64, tag = "1")] pub block_index: u64, - #[prost(bytes="vec", tag="2")] + #[prost(bytes = "vec", tag = "2")] pub transaction: ::prost::alloc::vec::Vec, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RollupNamespace { - #[prost(uint64, tag="1")] + #[prost(uint64, tag = "1")] pub block_height: u64, - #[prost(bytes="vec", tag="2")] + #[prost(bytes = "vec", tag = "2")] pub namespace: ::prost::alloc::vec::Vec, } /// `RollupNamespaceData` #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RollupNamespaceData { - #[prost(bytes="vec", tag="1")] + #[prost(bytes = "vec", tag = "1")] pub block_hash: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag="2")] + #[prost(message, repeated, tag = "2")] pub rollup_txs: ::prost::alloc::vec::Vec, } /// `SequencerNamespaceData` #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SequencerNamespaceData { - #[prost(bytes="vec", tag="1")] + #[prost(bytes = "vec", tag = "1")] pub block_hash: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag="2")] + #[prost(message, optional, tag = "2")] pub header: ::core::option::Option<::tendermint_proto::types::Header>, - #[prost(message, repeated, tag="3")] + #[prost(message, repeated, tag = "3")] pub sequencer_txs: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag="4")] + #[prost(message, repeated, tag = "4")] pub rollup_namespaces: ::prost::alloc::vec::Vec, } /// helper type - these should get parsed into a map from namespace to @@ -63,71 +62,71 @@ pub struct SequencerNamespaceData { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct NamespacedIndexedTransactions { - #[prost(bytes="vec", tag="1")] + #[prost(bytes = "vec", tag = "1")] pub namespace: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag="2")] + #[prost(message, repeated, tag = "2")] pub txs: ::prost::alloc::vec::Vec, } /// `SequencerBlock` #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SequencerBlock { - #[prost(bytes="vec", tag="1")] + #[prost(bytes = "vec", tag = "1")] pub block_hash: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag="2")] + #[prost(message, optional, tag = "2")] pub header: ::core::option::Option<::tendermint_proto::types::Header>, - #[prost(message, repeated, tag="3")] + #[prost(message, repeated, tag = "3")] pub sequencer_transactions: ::prost::alloc::vec::Vec, /// FIXME: the current nested array layout results in bad allocation behavior on deserialization /// see - #[prost(message, repeated, tag="4")] + #[prost(message, repeated, tag = "4")] pub rollup_transactions: ::prost::alloc::vec::Vec, } /// `SignedTransaction` is a transaction that has /// been signed by the given public key. -/// It wraps an `UnsignedTransaction` with a +/// It wraps an `UnsignedTransaction` with a /// signature and public key. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SignedTransaction { - #[prost(bytes="vec", tag="1")] + #[prost(bytes = "vec", tag = "1")] pub signature: ::prost::alloc::vec::Vec, - #[prost(bytes="vec", tag="2")] + #[prost(bytes = "vec", tag = "2")] pub public_key: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag="3")] + #[prost(message, optional, tag = "3")] pub transaction: ::core::option::Option, } -/// `UnsignedTransaction` is a transaction that does +/// `UnsignedTransaction` is a transaction that does /// not have an attached signature. /// Note: `value` must be set, it cannot be `None`. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct UnsignedTransaction { - #[prost(uint32, tag="1")] + #[prost(uint32, tag = "1")] pub nonce: u32, - #[prost(message, repeated, tag="2")] + #[prost(message, repeated, tag = "2")] pub actions: ::prost::alloc::vec::Vec, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Action { - #[prost(oneof="action::Value", tags="1, 2, 3, 4, 5")] + #[prost(oneof = "action::Value", tags = "1, 2, 3, 4, 5")] pub value: ::core::option::Option, } /// Nested message and enum types in `Action`. pub mod action { #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Oneof)] + #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Value { - #[prost(message, tag="1")] + #[prost(message, tag = "1")] TransferAction(super::TransferAction), - #[prost(message, tag="2")] + #[prost(message, tag = "2")] SequenceAction(super::SequenceAction), - #[prost(message, tag="3")] + #[prost(message, tag = "3")] ValidatorUpdateAction(::tendermint_proto::abci::ValidatorUpdate), - #[prost(message, tag="4")] + #[prost(message, tag = "4")] SudoAddressChangeAction(super::SudoAddressChangeAction), - #[prost(message, tag="5")] + #[prost(message, tag = "5")] MintAction(super::MintAction), } } @@ -138,9 +137,9 @@ pub mod action { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct TransferAction { - #[prost(bytes="vec", tag="1")] + #[prost(bytes = "vec", tag = "1")] pub to: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag="2")] + #[prost(message, optional, tag = "2")] pub amount: ::core::option::Option, } /// `SequenceAction` represents a transaction destined for another @@ -151,20 +150,20 @@ pub struct TransferAction { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SequenceAction { - #[prost(bytes="vec", tag="1")] + #[prost(bytes = "vec", tag = "1")] pub chain_id: ::prost::alloc::vec::Vec, - #[prost(bytes="vec", tag="2")] + #[prost(bytes = "vec", tag = "2")] pub data: ::prost::alloc::vec::Vec, } /// / `SudoAddressChangeAction` represents a transaction that changes -/// / the sudo address of the chain, which is the address authorized to +/// / the sudo address of the chain, which is the address authorized to /// / make validator update actions. /// / /// / It contains the new sudo address. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SudoAddressChangeAction { - #[prost(bytes="vec", tag="1")] + #[prost(bytes = "vec", tag = "1")] pub new_address: ::prost::alloc::vec::Vec, } /// `MintAction` represents a minting transaction. @@ -174,9 +173,8 @@ pub struct SudoAddressChangeAction { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct MintAction { - #[prost(bytes="vec", tag="1")] + #[prost(bytes = "vec", tag = "1")] pub to: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag="2")] + #[prost(message, optional, tag = "2")] pub amount: ::core::option::Option, } -// @@protoc_insertion_point(module) diff --git a/crates/astria-proto/tests/proto_build.rs b/crates/astria-proto/tests/proto_build.rs index b085a2b0af..60b8c02c8e 100644 --- a/crates/astria-proto/tests/proto_build.rs +++ b/crates/astria-proto/tests/proto_build.rs @@ -1,12 +1,11 @@ use std::{ collections::HashMap, - env::{ - self, - consts::OS, - }, + env, + ffi::OsStr, fs::{ read_dir, read_to_string, + remove_file, write, }, path::{ @@ -20,8 +19,11 @@ use tempfile::tempdir; const OUT_DIR: &str = "src/proto/generated"; -fn buf_from_env() -> PathBuf { - let os_specific_hint = match OS { +const PROTO_DIR: &str = "proto/"; +const INCLUDES: &[&str] = &[PROTO_DIR]; + +fn get_buf_from_env() -> PathBuf { + let os_specific_hint = match env::consts::OS { "macos" => "You could try running `brew install buf` or downloading a recent release from https://github.com/bufbuild/buf/releases", "linux" => "You can download it from https://github.com/bufbuild/buf/releases; if you are on Arch Linux, install it from the AUR with `rua install buf` or another helper", _other => "Check if there is a precompiled version for your OS at https://github.com/bufbuild/buf/releases" @@ -37,72 +39,96 @@ fn buf_from_env() -> PathBuf { .or_else(|| which::which("buf").ok()) .expect(&msg) } - -fn build_content_map(path: impl AsRef) -> HashMap { - read_dir(path) - .expect("should be able to read target folder for generated files") - .flatten() - .map(|entry| { - let path = entry.path(); - let name = path - .file_name() - .expect("every generated file should have a file name") - .to_string_lossy() - .to_string(); - let contents = read_to_string(path) - .expect("should be able to read the contents of an existing generated file"); - (name, contents) - }) - .collect() -} - #[test] fn build() { let before_build = build_content_map(OUT_DIR); - let buf = buf_from_env(); - let out_dir = - tempdir().expect("should be able to create a temp dir to store the generated files"); - let out_dir_str = out_dir - .path() - .to_str() - .expect( - "temp out dir should always be generated with valid utf8 encoded alphanumeric bytes", - ) - .to_string(); - - // Run the `buf generate` command to generate the Rust files + let buf = get_buf_from_env(); let mut cmd = Command::new(buf.clone()); - cmd.arg("generate") + + let buf_img = tempfile::NamedTempFile::new() + .expect("should be able to create a temp file to hold the buf image file descriptor set"); + cmd.arg("build") .arg("--output") - .arg(out_dir_str) - .arg("--template") - .arg("buf.gen.yaml") + .arg(buf_img.path()) + .arg("--as-file-descriptor-set") + .arg(".") .current_dir(env!("CARGO_MANIFEST_DIR")); match cmd.output() { Err(e) => { - panic!("failed compiling protobuf: failed to invoke buf (path: {buf:?}): {e:?}"); + panic!( + "failed creating file descriptor set from protobuf: failed to invoke buf (path: \ + {buf:?}): {e:?}" + ); } Ok(output) if !output.status.success() => { panic!( - "failed compiling protobuf: `buf` returned error: {}", + "failed creating file descriptor set from protobuf: `buf` returned error: {}", String::from_utf8_lossy(&output.stderr) ); } Ok(_) => {} }; - let after_build = build_content_map(out_dir.path()); + let files = find_protos(PROTO_DIR); + + let out_dir = + tempdir().expect("should be able to create a temp dir to store the generated files"); + + tonic_build::configure() + .build_client(true) + .build_server(true) + .client_mod_attribute(".", "#[cfg(feature=\"client\")]") + .server_mod_attribute(".", "#[cfg(feature=\"server\")]") + .extern_path(".tendermint.abci", "::tendermint-proto::abci") + .extern_path(".tendermint.crypto", "::tendermint-proto::crypto") + .extern_path(".tendermint.version", "::tendermint-proto::version") + .extern_path(".tendermint.types", "::tendermint-proto::types") + .type_attribute(".astria.primitive.v1.Uint128", "#[derive(Copy)]") + .out_dir(out_dir.path()) + .file_descriptor_set_path(buf_img.path()) + .skip_protoc_run() + .compile(&files, INCLUDES) + .expect("should be able to compile protobuf using tonic"); + + let mut after_build = build_content_map(out_dir.path()); + clean_non_astria_code(&mut after_build); ensure_files_are_the_same(&before_build, after_build, OUT_DIR); } -fn ensure_files_are_the_same( - before: &HashMap, - after: HashMap, - target_dir: &'static str, -) { - if before == &after { +fn clean_non_astria_code(generated: &mut ContentMap) { + let foreign_file_names: Vec<_> = generated + .files + .keys() + .filter(|name| !name.starts_with("astria.")) + .cloned() + .collect(); + for name in foreign_file_names { + let _ = generated.codes.remove(&name); + let file = generated + .files + .remove(&name) + .expect("file should exist under the name"); + let _ = remove_file(file); + } +} + +fn find_protos>(dir: P) -> Vec { + use walkdir::{ + DirEntry, + WalkDir, + }; + WalkDir::new(dir) + .into_iter() + .filter_map(Result::ok) + .filter(|e| e.file_type().is_file() && e.path().extension() == Some(OsStr::new("proto"))) + .map(DirEntry::into_path) + .collect() +} + +fn ensure_files_are_the_same(before: &ContentMap, after: ContentMap, target_dir: &'static str) { + if before.codes == after.codes { return; } @@ -112,7 +138,7 @@ fn ensure_files_are_the_same( locally and commit the changes." ); - for (name, content) in after { + for (name, content) in after.codes { let dst = Path::new(target_dir).join(name); if let Err(e) = write(&dst, content) { panic!( @@ -125,3 +151,32 @@ fn ensure_files_are_the_same( panic!("the generated files have changed; please commit the changes"); } + +struct ContentMap { + files: HashMap, + codes: HashMap, +} + +fn build_content_map(path: impl AsRef) -> ContentMap { + let mut files = HashMap::new(); + let mut codes = HashMap::new(); + for entry in read_dir(path) + .expect("should be able to read target folder for generated files") + .flatten() + { + let path = entry.path(); + let name = path + .file_name() + .expect("generated file should have a file name") + .to_string_lossy() + .to_string(); + let contents = read_to_string(&path) + .expect("should be able to read the contents of an existing generated file"); + files.insert(name.clone(), path); + codes.insert(name.clone(), contents); + } + ContentMap { + files, + codes, + } +}