penumbra_sdk_proto/gen/
penumbra.core.component.compact_block.v1.rs

1// This file is @generated by prost-build.
2/// Contains the minimum data needed to update client state.
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct CompactBlock {
5    #[prost(uint64, tag = "1")]
6    pub height: u64,
7    /// State payloads describing new state fragments.
8    #[prost(message, repeated, tag = "2")]
9    pub state_payloads: ::prost::alloc::vec::Vec<StatePayload>,
10    /// Nullifiers identifying spent notes.
11    #[prost(message, repeated, tag = "3")]
12    pub nullifiers: ::prost::alloc::vec::Vec<super::super::sct::v1::Nullifier>,
13    /// The block root of this block.
14    #[prost(message, optional, tag = "4")]
15    pub block_root: ::core::option::Option<
16        super::super::super::super::crypto::tct::v1::MerkleRoot,
17    >,
18    /// The epoch root of this epoch (only present when the block is the last in an epoch).
19    #[prost(message, optional, tag = "5")]
20    pub epoch_root: ::core::option::Option<
21        super::super::super::super::crypto::tct::v1::MerkleRoot,
22    >,
23    /// If a proposal started voting in this block, this is set to `true`.
24    #[prost(bool, tag = "6")]
25    pub proposal_started: bool,
26    /// Latest Fuzzy Message Detection parameters.
27    #[prost(message, optional, tag = "7")]
28    pub fmd_parameters: ::core::option::Option<
29        super::super::shielded_pool::v1::FmdParameters,
30    >,
31    /// Price data for swaps executed in this block.
32    #[prost(message, repeated, tag = "8")]
33    pub swap_outputs: ::prost::alloc::vec::Vec<
34        super::super::dex::v1::BatchSwapOutputData,
35    >,
36    /// Indicates updated app parameters.
37    #[prost(bool, tag = "9")]
38    pub app_parameters_updated: bool,
39    /// Updated gas prices, if they have changed.
40    #[prost(message, optional, tag = "10")]
41    pub gas_prices: ::core::option::Option<super::super::fee::v1::GasPrices>,
42    /// Updated gas prices for alternative fee tokens, if they have changed.
43    #[prost(message, repeated, tag = "100")]
44    pub alt_gas_prices: ::prost::alloc::vec::Vec<super::super::fee::v1::GasPrices>,
45    /// The epoch index
46    #[prost(uint64, tag = "11")]
47    pub epoch_index: u64,
48}
49impl ::prost::Name for CompactBlock {
50    const NAME: &'static str = "CompactBlock";
51    const PACKAGE: &'static str = "penumbra.core.component.compact_block.v1";
52    fn full_name() -> ::prost::alloc::string::String {
53        "penumbra.core.component.compact_block.v1.CompactBlock".into()
54    }
55    fn type_url() -> ::prost::alloc::string::String {
56        "/penumbra.core.component.compact_block.v1.CompactBlock".into()
57    }
58}
59/// An encrypted payload, corresponding to a single commitment in the state commitment tree.
60#[derive(Clone, PartialEq, ::prost::Message)]
61pub struct StatePayload {
62    /// The source of the payload, if known.
63    #[prost(message, optional, tag = "1")]
64    pub source: ::core::option::Option<super::super::sct::v1::CommitmentSource>,
65    /// The state payload itself.
66    #[prost(oneof = "state_payload::StatePayload", tags = "2, 3, 4")]
67    pub state_payload: ::core::option::Option<state_payload::StatePayload>,
68}
69/// Nested message and enum types in `StatePayload`.
70pub mod state_payload {
71    #[derive(Clone, PartialEq, ::prost::Message)]
72    pub struct RolledUp {
73        #[prost(message, optional, tag = "1")]
74        pub commitment: ::core::option::Option<
75            super::super::super::super::super::crypto::tct::v1::StateCommitment,
76        >,
77    }
78    impl ::prost::Name for RolledUp {
79        const NAME: &'static str = "RolledUp";
80        const PACKAGE: &'static str = "penumbra.core.component.compact_block.v1";
81        fn full_name() -> ::prost::alloc::string::String {
82            "penumbra.core.component.compact_block.v1.StatePayload.RolledUp".into()
83        }
84        fn type_url() -> ::prost::alloc::string::String {
85            "/penumbra.core.component.compact_block.v1.StatePayload.RolledUp".into()
86        }
87    }
88    #[derive(Clone, PartialEq, ::prost::Message)]
89    pub struct Note {
90        #[prost(message, optional, tag = "2")]
91        pub note: ::core::option::Option<
92            super::super::super::shielded_pool::v1::NotePayload,
93        >,
94    }
95    impl ::prost::Name for Note {
96        const NAME: &'static str = "Note";
97        const PACKAGE: &'static str = "penumbra.core.component.compact_block.v1";
98        fn full_name() -> ::prost::alloc::string::String {
99            "penumbra.core.component.compact_block.v1.StatePayload.Note".into()
100        }
101        fn type_url() -> ::prost::alloc::string::String {
102            "/penumbra.core.component.compact_block.v1.StatePayload.Note".into()
103        }
104    }
105    #[derive(Clone, PartialEq, ::prost::Message)]
106    pub struct Swap {
107        #[prost(message, optional, tag = "2")]
108        pub swap: ::core::option::Option<super::super::super::dex::v1::SwapPayload>,
109    }
110    impl ::prost::Name for Swap {
111        const NAME: &'static str = "Swap";
112        const PACKAGE: &'static str = "penumbra.core.component.compact_block.v1";
113        fn full_name() -> ::prost::alloc::string::String {
114            "penumbra.core.component.compact_block.v1.StatePayload.Swap".into()
115        }
116        fn type_url() -> ::prost::alloc::string::String {
117            "/penumbra.core.component.compact_block.v1.StatePayload.Swap".into()
118        }
119    }
120    /// The state payload itself.
121    #[derive(Clone, PartialEq, ::prost::Oneof)]
122    pub enum StatePayload {
123        #[prost(message, tag = "2")]
124        RolledUp(RolledUp),
125        #[prost(message, tag = "3")]
126        Note(Note),
127        #[prost(message, tag = "4")]
128        Swap(Swap),
129    }
130}
131impl ::prost::Name for StatePayload {
132    const NAME: &'static str = "StatePayload";
133    const PACKAGE: &'static str = "penumbra.core.component.compact_block.v1";
134    fn full_name() -> ::prost::alloc::string::String {
135        "penumbra.core.component.compact_block.v1.StatePayload".into()
136    }
137    fn type_url() -> ::prost::alloc::string::String {
138        "/penumbra.core.component.compact_block.v1.StatePayload".into()
139    }
140}
141/// Requests a range of compact block data.
142#[derive(Clone, Copy, PartialEq, ::prost::Message)]
143pub struct CompactBlockRangeRequest {
144    /// The start height of the range.
145    #[prost(uint64, tag = "2")]
146    pub start_height: u64,
147    /// The end height of the range, defaults to the latest block height.
148    #[prost(uint64, tag = "3")]
149    pub end_height: u64,
150    /// If set, keeps the connection alive past `end_height`,
151    /// streaming new compact blocks as they are created.
152    #[prost(bool, tag = "4")]
153    pub keep_alive: bool,
154}
155impl ::prost::Name for CompactBlockRangeRequest {
156    const NAME: &'static str = "CompactBlockRangeRequest";
157    const PACKAGE: &'static str = "penumbra.core.component.compact_block.v1";
158    fn full_name() -> ::prost::alloc::string::String {
159        "penumbra.core.component.compact_block.v1.CompactBlockRangeRequest".into()
160    }
161    fn type_url() -> ::prost::alloc::string::String {
162        "/penumbra.core.component.compact_block.v1.CompactBlockRangeRequest".into()
163    }
164}
165#[derive(Clone, PartialEq, ::prost::Message)]
166pub struct CompactBlockRangeResponse {
167    #[prost(message, optional, tag = "1")]
168    pub compact_block: ::core::option::Option<CompactBlock>,
169}
170impl ::prost::Name for CompactBlockRangeResponse {
171    const NAME: &'static str = "CompactBlockRangeResponse";
172    const PACKAGE: &'static str = "penumbra.core.component.compact_block.v1";
173    fn full_name() -> ::prost::alloc::string::String {
174        "penumbra.core.component.compact_block.v1.CompactBlockRangeResponse".into()
175    }
176    fn type_url() -> ::prost::alloc::string::String {
177        "/penumbra.core.component.compact_block.v1.CompactBlockRangeResponse".into()
178    }
179}
180#[derive(Clone, Copy, PartialEq, ::prost::Message)]
181pub struct CompactBlockRequest {
182    #[prost(uint64, tag = "1")]
183    pub height: u64,
184}
185impl ::prost::Name for CompactBlockRequest {
186    const NAME: &'static str = "CompactBlockRequest";
187    const PACKAGE: &'static str = "penumbra.core.component.compact_block.v1";
188    fn full_name() -> ::prost::alloc::string::String {
189        "penumbra.core.component.compact_block.v1.CompactBlockRequest".into()
190    }
191    fn type_url() -> ::prost::alloc::string::String {
192        "/penumbra.core.component.compact_block.v1.CompactBlockRequest".into()
193    }
194}
195#[derive(Clone, PartialEq, ::prost::Message)]
196pub struct CompactBlockResponse {
197    #[prost(message, optional, tag = "1")]
198    pub compact_block: ::core::option::Option<CompactBlock>,
199}
200impl ::prost::Name for CompactBlockResponse {
201    const NAME: &'static str = "CompactBlockResponse";
202    const PACKAGE: &'static str = "penumbra.core.component.compact_block.v1";
203    fn full_name() -> ::prost::alloc::string::String {
204        "penumbra.core.component.compact_block.v1.CompactBlockResponse".into()
205    }
206    fn type_url() -> ::prost::alloc::string::String {
207        "/penumbra.core.component.compact_block.v1.CompactBlockResponse".into()
208    }
209}
210/// Generated client implementations.
211#[cfg(feature = "rpc")]
212pub mod query_service_client {
213    #![allow(
214        unused_variables,
215        dead_code,
216        missing_docs,
217        clippy::wildcard_imports,
218        clippy::let_unit_value,
219    )]
220    use tonic::codegen::*;
221    use tonic::codegen::http::Uri;
222    /// Query operations for the compact block component.
223    #[derive(Debug, Clone)]
224    pub struct QueryServiceClient<T> {
225        inner: tonic::client::Grpc<T>,
226    }
227    impl QueryServiceClient<tonic::transport::Channel> {
228        /// Attempt to create a new client by connecting to a given endpoint.
229        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
230        where
231            D: TryInto<tonic::transport::Endpoint>,
232            D::Error: Into<StdError>,
233        {
234            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
235            Ok(Self::new(conn))
236        }
237    }
238    impl<T> QueryServiceClient<T>
239    where
240        T: tonic::client::GrpcService<tonic::body::BoxBody>,
241        T::Error: Into<StdError>,
242        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
243        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
244    {
245        pub fn new(inner: T) -> Self {
246            let inner = tonic::client::Grpc::new(inner);
247            Self { inner }
248        }
249        pub fn with_origin(inner: T, origin: Uri) -> Self {
250            let inner = tonic::client::Grpc::with_origin(inner, origin);
251            Self { inner }
252        }
253        pub fn with_interceptor<F>(
254            inner: T,
255            interceptor: F,
256        ) -> QueryServiceClient<InterceptedService<T, F>>
257        where
258            F: tonic::service::Interceptor,
259            T::ResponseBody: Default,
260            T: tonic::codegen::Service<
261                http::Request<tonic::body::BoxBody>,
262                Response = http::Response<
263                    <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
264                >,
265            >,
266            <T as tonic::codegen::Service<
267                http::Request<tonic::body::BoxBody>,
268            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
269        {
270            QueryServiceClient::new(InterceptedService::new(inner, interceptor))
271        }
272        /// Compress requests with the given encoding.
273        ///
274        /// This requires the server to support it otherwise it might respond with an
275        /// error.
276        #[must_use]
277        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
278            self.inner = self.inner.send_compressed(encoding);
279            self
280        }
281        /// Enable decompressing responses.
282        #[must_use]
283        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
284            self.inner = self.inner.accept_compressed(encoding);
285            self
286        }
287        /// Limits the maximum size of a decoded message.
288        ///
289        /// Default: `4MB`
290        #[must_use]
291        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
292            self.inner = self.inner.max_decoding_message_size(limit);
293            self
294        }
295        /// Limits the maximum size of an encoded message.
296        ///
297        /// Default: `usize::MAX`
298        #[must_use]
299        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
300            self.inner = self.inner.max_encoding_message_size(limit);
301            self
302        }
303        /// Returns a stream of compact blocks, optionally keeping the stream alive for push notifications.
304        pub async fn compact_block_range(
305            &mut self,
306            request: impl tonic::IntoRequest<super::CompactBlockRangeRequest>,
307        ) -> std::result::Result<
308            tonic::Response<tonic::codec::Streaming<super::CompactBlockRangeResponse>>,
309            tonic::Status,
310        > {
311            self.inner
312                .ready()
313                .await
314                .map_err(|e| {
315                    tonic::Status::unknown(
316                        format!("Service was not ready: {}", e.into()),
317                    )
318                })?;
319            let codec = tonic::codec::ProstCodec::default();
320            let path = http::uri::PathAndQuery::from_static(
321                "/penumbra.core.component.compact_block.v1.QueryService/CompactBlockRange",
322            );
323            let mut req = request.into_request();
324            req.extensions_mut()
325                .insert(
326                    GrpcMethod::new(
327                        "penumbra.core.component.compact_block.v1.QueryService",
328                        "CompactBlockRange",
329                    ),
330                );
331            self.inner.server_streaming(req, path, codec).await
332        }
333        /// Returns a single compact block at a specific height.
334        ///
335        /// Clients requesting multiple compact blocks should generally use the streaming RPC.
336        pub async fn compact_block(
337            &mut self,
338            request: impl tonic::IntoRequest<super::CompactBlockRequest>,
339        ) -> std::result::Result<
340            tonic::Response<super::CompactBlockResponse>,
341            tonic::Status,
342        > {
343            self.inner
344                .ready()
345                .await
346                .map_err(|e| {
347                    tonic::Status::unknown(
348                        format!("Service was not ready: {}", e.into()),
349                    )
350                })?;
351            let codec = tonic::codec::ProstCodec::default();
352            let path = http::uri::PathAndQuery::from_static(
353                "/penumbra.core.component.compact_block.v1.QueryService/CompactBlock",
354            );
355            let mut req = request.into_request();
356            req.extensions_mut()
357                .insert(
358                    GrpcMethod::new(
359                        "penumbra.core.component.compact_block.v1.QueryService",
360                        "CompactBlock",
361                    ),
362                );
363            self.inner.unary(req, path, codec).await
364        }
365    }
366}
367/// Generated server implementations.
368#[cfg(feature = "rpc")]
369pub mod query_service_server {
370    #![allow(
371        unused_variables,
372        dead_code,
373        missing_docs,
374        clippy::wildcard_imports,
375        clippy::let_unit_value,
376    )]
377    use tonic::codegen::*;
378    /// Generated trait containing gRPC methods that should be implemented for use with QueryServiceServer.
379    #[async_trait]
380    pub trait QueryService: std::marker::Send + std::marker::Sync + 'static {
381        /// Server streaming response type for the CompactBlockRange method.
382        type CompactBlockRangeStream: tonic::codegen::tokio_stream::Stream<
383                Item = std::result::Result<
384                    super::CompactBlockRangeResponse,
385                    tonic::Status,
386                >,
387            >
388            + std::marker::Send
389            + 'static;
390        /// Returns a stream of compact blocks, optionally keeping the stream alive for push notifications.
391        async fn compact_block_range(
392            &self,
393            request: tonic::Request<super::CompactBlockRangeRequest>,
394        ) -> std::result::Result<
395            tonic::Response<Self::CompactBlockRangeStream>,
396            tonic::Status,
397        >;
398        /// Returns a single compact block at a specific height.
399        ///
400        /// Clients requesting multiple compact blocks should generally use the streaming RPC.
401        async fn compact_block(
402            &self,
403            request: tonic::Request<super::CompactBlockRequest>,
404        ) -> std::result::Result<
405            tonic::Response<super::CompactBlockResponse>,
406            tonic::Status,
407        >;
408    }
409    /// Query operations for the compact block component.
410    #[derive(Debug)]
411    pub struct QueryServiceServer<T> {
412        inner: Arc<T>,
413        accept_compression_encodings: EnabledCompressionEncodings,
414        send_compression_encodings: EnabledCompressionEncodings,
415        max_decoding_message_size: Option<usize>,
416        max_encoding_message_size: Option<usize>,
417    }
418    impl<T> QueryServiceServer<T> {
419        pub fn new(inner: T) -> Self {
420            Self::from_arc(Arc::new(inner))
421        }
422        pub fn from_arc(inner: Arc<T>) -> Self {
423            Self {
424                inner,
425                accept_compression_encodings: Default::default(),
426                send_compression_encodings: Default::default(),
427                max_decoding_message_size: None,
428                max_encoding_message_size: None,
429            }
430        }
431        pub fn with_interceptor<F>(
432            inner: T,
433            interceptor: F,
434        ) -> InterceptedService<Self, F>
435        where
436            F: tonic::service::Interceptor,
437        {
438            InterceptedService::new(Self::new(inner), interceptor)
439        }
440        /// Enable decompressing requests with the given encoding.
441        #[must_use]
442        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
443            self.accept_compression_encodings.enable(encoding);
444            self
445        }
446        /// Compress responses with the given encoding, if the client supports it.
447        #[must_use]
448        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
449            self.send_compression_encodings.enable(encoding);
450            self
451        }
452        /// Limits the maximum size of a decoded message.
453        ///
454        /// Default: `4MB`
455        #[must_use]
456        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
457            self.max_decoding_message_size = Some(limit);
458            self
459        }
460        /// Limits the maximum size of an encoded message.
461        ///
462        /// Default: `usize::MAX`
463        #[must_use]
464        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
465            self.max_encoding_message_size = Some(limit);
466            self
467        }
468    }
469    impl<T, B> tonic::codegen::Service<http::Request<B>> for QueryServiceServer<T>
470    where
471        T: QueryService,
472        B: Body + std::marker::Send + 'static,
473        B::Error: Into<StdError> + std::marker::Send + 'static,
474    {
475        type Response = http::Response<tonic::body::BoxBody>;
476        type Error = std::convert::Infallible;
477        type Future = BoxFuture<Self::Response, Self::Error>;
478        fn poll_ready(
479            &mut self,
480            _cx: &mut Context<'_>,
481        ) -> Poll<std::result::Result<(), Self::Error>> {
482            Poll::Ready(Ok(()))
483        }
484        fn call(&mut self, req: http::Request<B>) -> Self::Future {
485            match req.uri().path() {
486                "/penumbra.core.component.compact_block.v1.QueryService/CompactBlockRange" => {
487                    #[allow(non_camel_case_types)]
488                    struct CompactBlockRangeSvc<T: QueryService>(pub Arc<T>);
489                    impl<
490                        T: QueryService,
491                    > tonic::server::ServerStreamingService<
492                        super::CompactBlockRangeRequest,
493                    > for CompactBlockRangeSvc<T> {
494                        type Response = super::CompactBlockRangeResponse;
495                        type ResponseStream = T::CompactBlockRangeStream;
496                        type Future = BoxFuture<
497                            tonic::Response<Self::ResponseStream>,
498                            tonic::Status,
499                        >;
500                        fn call(
501                            &mut self,
502                            request: tonic::Request<super::CompactBlockRangeRequest>,
503                        ) -> Self::Future {
504                            let inner = Arc::clone(&self.0);
505                            let fut = async move {
506                                <T as QueryService>::compact_block_range(&inner, request)
507                                    .await
508                            };
509                            Box::pin(fut)
510                        }
511                    }
512                    let accept_compression_encodings = self.accept_compression_encodings;
513                    let send_compression_encodings = self.send_compression_encodings;
514                    let max_decoding_message_size = self.max_decoding_message_size;
515                    let max_encoding_message_size = self.max_encoding_message_size;
516                    let inner = self.inner.clone();
517                    let fut = async move {
518                        let method = CompactBlockRangeSvc(inner);
519                        let codec = tonic::codec::ProstCodec::default();
520                        let mut grpc = tonic::server::Grpc::new(codec)
521                            .apply_compression_config(
522                                accept_compression_encodings,
523                                send_compression_encodings,
524                            )
525                            .apply_max_message_size_config(
526                                max_decoding_message_size,
527                                max_encoding_message_size,
528                            );
529                        let res = grpc.server_streaming(method, req).await;
530                        Ok(res)
531                    };
532                    Box::pin(fut)
533                }
534                "/penumbra.core.component.compact_block.v1.QueryService/CompactBlock" => {
535                    #[allow(non_camel_case_types)]
536                    struct CompactBlockSvc<T: QueryService>(pub Arc<T>);
537                    impl<
538                        T: QueryService,
539                    > tonic::server::UnaryService<super::CompactBlockRequest>
540                    for CompactBlockSvc<T> {
541                        type Response = super::CompactBlockResponse;
542                        type Future = BoxFuture<
543                            tonic::Response<Self::Response>,
544                            tonic::Status,
545                        >;
546                        fn call(
547                            &mut self,
548                            request: tonic::Request<super::CompactBlockRequest>,
549                        ) -> Self::Future {
550                            let inner = Arc::clone(&self.0);
551                            let fut = async move {
552                                <T as QueryService>::compact_block(&inner, request).await
553                            };
554                            Box::pin(fut)
555                        }
556                    }
557                    let accept_compression_encodings = self.accept_compression_encodings;
558                    let send_compression_encodings = self.send_compression_encodings;
559                    let max_decoding_message_size = self.max_decoding_message_size;
560                    let max_encoding_message_size = self.max_encoding_message_size;
561                    let inner = self.inner.clone();
562                    let fut = async move {
563                        let method = CompactBlockSvc(inner);
564                        let codec = tonic::codec::ProstCodec::default();
565                        let mut grpc = tonic::server::Grpc::new(codec)
566                            .apply_compression_config(
567                                accept_compression_encodings,
568                                send_compression_encodings,
569                            )
570                            .apply_max_message_size_config(
571                                max_decoding_message_size,
572                                max_encoding_message_size,
573                            );
574                        let res = grpc.unary(method, req).await;
575                        Ok(res)
576                    };
577                    Box::pin(fut)
578                }
579                _ => {
580                    Box::pin(async move {
581                        let mut response = http::Response::new(empty_body());
582                        let headers = response.headers_mut();
583                        headers
584                            .insert(
585                                tonic::Status::GRPC_STATUS,
586                                (tonic::Code::Unimplemented as i32).into(),
587                            );
588                        headers
589                            .insert(
590                                http::header::CONTENT_TYPE,
591                                tonic::metadata::GRPC_CONTENT_TYPE,
592                            );
593                        Ok(response)
594                    })
595                }
596            }
597        }
598    }
599    impl<T> Clone for QueryServiceServer<T> {
600        fn clone(&self) -> Self {
601            let inner = self.inner.clone();
602            Self {
603                inner,
604                accept_compression_encodings: self.accept_compression_encodings,
605                send_compression_encodings: self.send_compression_encodings,
606                max_decoding_message_size: self.max_decoding_message_size,
607                max_encoding_message_size: self.max_encoding_message_size,
608            }
609        }
610    }
611    /// Generated gRPC service name
612    pub const SERVICE_NAME: &str = "penumbra.core.component.compact_block.v1.QueryService";
613    impl<T> tonic::server::NamedService for QueryServiceServer<T> {
614        const NAME: &'static str = SERVICE_NAME;
615    }
616}