sui_rpc/proto/generated/sui.rpc.v2alpha.rs
1// This file is @generated by prost-build.
2/// A node in a Blake2b256 Merkle tree.
3///
4/// An empty node represents an empty subtree (used as padding for odd-sized
5/// levels and as the root of a tree built from zero leaves). A digest node
6/// carries a 32-byte Blake2b256 hash of either a leaf or an inner node.
7#[non_exhaustive]
8#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
9pub struct MerkleNode {
10 #[prost(oneof = "merkle_node::Node", tags = "1, 2")]
11 pub node: ::core::option::Option<merkle_node::Node>,
12}
13/// Nested message and enum types in `MerkleNode`.
14pub mod merkle_node {
15 #[non_exhaustive]
16 #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
17 pub enum Node {
18 /// Marker for an empty subtree.
19 #[prost(message, tag = "1")]
20 Empty(()),
21 /// 32-byte Blake2b256 hash.
22 #[prost(bytes, tag = "2")]
23 Digest(::prost::bytes::Bytes),
24 }
25}
26/// An inclusion proof for a leaf in a Blake2b256 Merkle tree.
27///
28/// The proof carries the sibling node hashes on the path from the leaf up
29/// to the root, leaf-side first. To verify, hash the leaf bytes with the
30/// `0x00` leaf prefix, then walk `path` upward and compute each parent as
31/// `BLAKE2b-256(0x01 || left || right)`. The final computed hash must equal
32/// the tree root.
33#[non_exhaustive]
34#[derive(Clone, PartialEq, ::prost::Message)]
35pub struct MerkleProof {
36 /// Sibling node hashes, leaf-side first.
37 #[prost(message, repeated, tag = "1")]
38 pub path: ::prost::alloc::vec::Vec<MerkleNode>,
39}
40/// A non-inclusion proof for a Blake2b256 Merkle tree built over leaves
41/// in sorted order.
42///
43/// The proof carries the absent leaf's would-be position in sort order
44/// plus inclusion proofs for the leaves immediately before and after it.
45/// A verifier checks that the two neighbours strictly bracket the
46/// target's sort key and that they sit at adjacent indices in the tree.
47#[non_exhaustive]
48#[derive(Clone, PartialEq, ::prost::Message)]
49pub struct MerkleNonInclusionProof {
50 /// The 0-based index the target would occupy in sort order if it
51 /// were present. `left_leaf` is unset iff `index == 0` (the target
52 /// would be the very first leaf); `right_leaf` is unset iff the
53 /// target would be appended past the last leaf, in which case
54 /// `left_leaf.merkle_proof` must identify the tree's right-most leaf.
55 #[prost(uint64, optional, tag = "1")]
56 pub index: ::core::option::Option<u64>,
57 /// Sort-order neighbour with sort key strictly less than the target,
58 /// accompanied by its inclusion proof at position `index - 1`.
59 #[prost(message, optional, tag = "2")]
60 pub left_leaf: ::core::option::Option<MerkleNeighbourLeaf>,
61 /// Sort-order neighbour with sort key strictly greater than the
62 /// target, accompanied by its inclusion proof at position `index`.
63 #[prost(message, optional, tag = "3")]
64 pub right_leaf: ::core::option::Option<MerkleNeighbourLeaf>,
65}
66/// A neighbour leaf in a `MerkleNonInclusionProof`: an object reference
67/// at a specific sorted position in the OCS tree, plus the inclusion
68/// proof that authenticates it against the tree root.
69#[non_exhaustive]
70#[derive(Clone, PartialEq, ::prost::Message)]
71pub struct MerkleNeighbourLeaf {
72 /// The object reference stored at this leaf.
73 #[prost(message, optional, tag = "1")]
74 pub leaf: ::core::option::Option<super::v2::ObjectReference>,
75 /// Inclusion proof for `leaf` at its position in the tree.
76 #[prost(message, optional, tag = "2")]
77 pub merkle_proof: ::core::option::Option<MerkleProof>,
78}
79/// An Object Checkpoint State (OCS) inclusion proof.
80///
81/// The OCS is a Blake2b256 Merkle tree built by each checkpoint over the
82/// set of object references it modified (created, mutated, unwrapped, or
83/// otherwise written). Each leaf is a BCS-encoded
84/// `(ObjectID, SequenceNumber, ObjectDigest)` tuple, with leaves arranged
85/// in ascending `ObjectID` order. The tree's root is committed to by the
86/// containing `CheckpointSummary` via the `CheckpointArtifacts` variant of
87/// its `checkpoint_commitments`.
88///
89/// An `OcsInclusionProof` proves that a particular leaf appears in this
90/// tree. Combined with a verified `CheckpointSummary` it cryptographically
91/// authenticates that a specific object reference was written in a specific
92/// checkpoint.
93#[non_exhaustive]
94#[derive(Clone, PartialEq, ::prost::Message)]
95pub struct OcsInclusionProof {
96 /// Object reference being proven: (object_id, version, digest).
97 /// For a deletion or wrap, `digest` is a framework sentinel value
98 /// and `object_data` is absent. Consumers that only care whether
99 /// the object is live after the change can check `object_data`
100 /// presence instead of inspecting the digest.
101 #[prost(message, optional, tag = "1")]
102 pub object_ref: ::core::option::Option<super::v2::ObjectReference>,
103 /// Merkle inclusion proof for the leaf.
104 #[prost(message, optional, tag = "2")]
105 pub merkle_proof: ::core::option::Option<MerkleProof>,
106 /// Position of the leaf in the modified-objects tree.
107 #[prost(uint64, optional, tag = "3")]
108 pub leaf_index: ::core::option::Option<u64>,
109 /// 32-byte Merkle root of the modified-objects tree.
110 #[prost(bytes = "bytes", optional, tag = "4")]
111 pub tree_root: ::core::option::Option<::prost::bytes::Bytes>,
112 /// BCS-encoded `Object` data at the version committed by this
113 /// checkpoint. Present iff the modification left the object live
114 /// (created, mutated, or unwrapped). Absent if the modification was
115 /// a deletion or wrap.
116 #[prost(bytes = "bytes", optional, tag = "5")]
117 pub object_data: ::core::option::Option<::prost::bytes::Bytes>,
118}
119/// An Object Checkpoint State (OCS) non-inclusion proof.
120///
121/// Proves that no leaf with a given object id appears in the OCS Merkle
122/// tree -- i.e. that the checkpoint did not modify the object id at all.
123/// The proof's bracketing neighbours must have object ids strictly
124/// flanking the target id, which combined with the neighbours being at
125/// adjacent indices in the sorted tree proves that no leaf with any
126/// version or digest under the target id can be in the tree.
127///
128/// As with `OcsInclusionProof`, this is anchored at the containing
129/// `CheckpointSummary`'s `CheckpointArtifacts` commitment.
130#[non_exhaustive]
131#[derive(Clone, PartialEq, ::prost::Message)]
132pub struct OcsNonInclusionProof {
133 /// Merkle non-inclusion proof over the OCS tree.
134 #[prost(message, optional, tag = "1")]
135 pub non_inclusion_proof: ::core::option::Option<MerkleNonInclusionProof>,
136 /// 32-byte Merkle root of the modified-objects tree.
137 #[prost(bytes = "bytes", optional, tag = "2")]
138 pub tree_root: ::core::option::Option<::prost::bytes::Bytes>,
139}
140/// Request for a `GetCheckpointObjectProof` call.
141#[non_exhaustive]
142#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
143pub struct GetCheckpointObjectProofRequest {
144 /// Required. The object id to prove a checkpoint outcome for
145 /// (hex-encoded address).
146 #[prost(string, optional, tag = "1")]
147 pub object_id: ::core::option::Option<::prost::alloc::string::String>,
148 /// Required. The checkpoint sequence number to query.
149 #[prost(uint64, optional, tag = "2")]
150 pub checkpoint: ::core::option::Option<u64>,
151}
152/// Response containing a checkpoint-object proof and the materials needed
153/// to verify it end-to-end.
154#[non_exhaustive]
155#[derive(Clone, PartialEq, ::prost::Message)]
156pub struct GetCheckpointObjectProofResponse {
157 /// BCS-encoded `CertifiedCheckpointSummary` for the requested
158 /// checkpoint, carrying the `checkpoint_artifacts_digest` that the
159 /// proof's `tree_root` must reconstruct, plus the BLS aggregate
160 /// signature attesting to it.
161 #[prost(bytes = "bytes", optional, tag = "1")]
162 pub checkpoint_summary: ::core::option::Option<::prost::bytes::Bytes>,
163 /// The proof itself: either an inclusion or a non-inclusion proof.
164 #[prost(oneof = "get_checkpoint_object_proof_response::Proof", tags = "2, 3")]
165 pub proof: ::core::option::Option<get_checkpoint_object_proof_response::Proof>,
166}
167/// Nested message and enum types in `GetCheckpointObjectProofResponse`.
168pub mod get_checkpoint_object_proof_response {
169 /// The proof itself: either an inclusion or a non-inclusion proof.
170 #[non_exhaustive]
171 #[derive(Clone, PartialEq, ::prost::Oneof)]
172 pub enum Proof {
173 /// The object id was modified in this checkpoint.
174 #[prost(message, tag = "2")]
175 Inclusion(super::OcsInclusionProof),
176 /// The object id was not modified in this checkpoint.
177 #[prost(message, tag = "3")]
178 NonInclusion(super::OcsNonInclusionProof),
179 }
180}
181/// Generated client implementations.
182pub mod proof_service_client {
183 #![allow(
184 unused_variables,
185 dead_code,
186 missing_docs,
187 clippy::wildcard_imports,
188 clippy::let_unit_value,
189 )]
190 use tonic::codegen::*;
191 use tonic::codegen::http::Uri;
192 /// ProofService provides cryptographic proofs of blockchain state.
193 ///
194 /// Proofs in this service are anchored at a checkpoint summary's
195 /// `checkpoint_artifacts_digest`, which commits to the Object Checkpoint
196 /// State (OCS) -- the per-checkpoint Merkle tree of object references
197 /// written in that checkpoint. "OCS" appears throughout this file to refer
198 /// to that commitment scheme; see the doc on `OcsInclusionProof` below for
199 /// the full definition.
200 #[derive(Debug, Clone)]
201 pub struct ProofServiceClient<T> {
202 inner: tonic::client::Grpc<T>,
203 }
204 impl ProofServiceClient<tonic::transport::Channel> {
205 /// Attempt to create a new client by connecting to a given endpoint.
206 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
207 where
208 D: TryInto<tonic::transport::Endpoint>,
209 D::Error: Into<StdError>,
210 {
211 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
212 Ok(Self::new(conn))
213 }
214 }
215 impl<T> ProofServiceClient<T>
216 where
217 T: tonic::client::GrpcService<tonic::body::Body>,
218 T::Error: Into<StdError>,
219 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
220 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
221 {
222 pub fn new(inner: T) -> Self {
223 let inner = tonic::client::Grpc::new(inner);
224 Self { inner }
225 }
226 pub fn with_origin(inner: T, origin: Uri) -> Self {
227 let inner = tonic::client::Grpc::with_origin(inner, origin);
228 Self { inner }
229 }
230 pub fn with_interceptor<F>(
231 inner: T,
232 interceptor: F,
233 ) -> ProofServiceClient<InterceptedService<T, F>>
234 where
235 F: tonic::service::Interceptor,
236 T::ResponseBody: Default,
237 T: tonic::codegen::Service<
238 http::Request<tonic::body::Body>,
239 Response = http::Response<
240 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
241 >,
242 >,
243 <T as tonic::codegen::Service<
244 http::Request<tonic::body::Body>,
245 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
246 {
247 ProofServiceClient::new(InterceptedService::new(inner, interceptor))
248 }
249 /// Compress requests with the given encoding.
250 ///
251 /// This requires the server to support it otherwise it might respond with an
252 /// error.
253 #[must_use]
254 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
255 self.inner = self.inner.send_compressed(encoding);
256 self
257 }
258 /// Enable decompressing responses.
259 #[must_use]
260 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
261 self.inner = self.inner.accept_compressed(encoding);
262 self
263 }
264 /// Limits the maximum size of a decoded message.
265 ///
266 /// Default: `4MB`
267 #[must_use]
268 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
269 self.inner = self.inner.max_decoding_message_size(limit);
270 self
271 }
272 /// Limits the maximum size of an encoded message.
273 ///
274 /// Default: `usize::MAX`
275 #[must_use]
276 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
277 self.inner = self.inner.max_encoding_message_size(limit);
278 self
279 }
280 /// Returns a cryptographic proof attesting to what (if anything) a
281 /// specific checkpoint did to a specific object id.
282 ///
283 /// If the object id appears in the checkpoint's set of modified
284 /// objects (the OCS Merkle tree's leaves), the response carries an
285 /// `OcsInclusionProof` and -- when the modification left the object
286 /// live -- the BCS-encoded object data. If the object id does not
287 /// appear in the modified set, the response carries an
288 /// `OcsNonInclusionProof`.
289 ///
290 /// IMPORTANT: a non-inclusion proof attests only that this checkpoint
291 /// did NOT modify the requested object id. It does NOT attest that the
292 /// object doesn't exist on chain: an object that was last modified in
293 /// some earlier checkpoint and remained unchanged here will produce a
294 /// non-inclusion proof. Clients that need the object's state at this
295 /// checkpoint when it wasn't modified here must use a separate query
296 /// (e.g. ratchet back to the most recent modification).
297 pub async fn get_checkpoint_object_proof(
298 &mut self,
299 request: impl tonic::IntoRequest<super::GetCheckpointObjectProofRequest>,
300 ) -> std::result::Result<
301 tonic::Response<super::GetCheckpointObjectProofResponse>,
302 tonic::Status,
303 > {
304 self.inner
305 .ready()
306 .await
307 .map_err(|e| {
308 tonic::Status::unknown(
309 format!("Service was not ready: {}", e.into()),
310 )
311 })?;
312 let codec = tonic_prost::ProstCodec::default();
313 let path = http::uri::PathAndQuery::from_static(
314 "/sui.rpc.v2alpha.ProofService/GetCheckpointObjectProof",
315 );
316 let mut req = request.into_request();
317 req.extensions_mut()
318 .insert(
319 GrpcMethod::new(
320 "sui.rpc.v2alpha.ProofService",
321 "GetCheckpointObjectProof",
322 ),
323 );
324 self.inner.unary(req, path, codec).await
325 }
326 }
327}
328/// Generated server implementations.
329pub mod proof_service_server {
330 #![allow(
331 unused_variables,
332 dead_code,
333 missing_docs,
334 clippy::wildcard_imports,
335 clippy::let_unit_value,
336 )]
337 use tonic::codegen::*;
338 /// Generated trait containing gRPC methods that should be implemented for use with ProofServiceServer.
339 #[async_trait]
340 pub trait ProofService: std::marker::Send + std::marker::Sync + 'static {
341 /// Returns a cryptographic proof attesting to what (if anything) a
342 /// specific checkpoint did to a specific object id.
343 ///
344 /// If the object id appears in the checkpoint's set of modified
345 /// objects (the OCS Merkle tree's leaves), the response carries an
346 /// `OcsInclusionProof` and -- when the modification left the object
347 /// live -- the BCS-encoded object data. If the object id does not
348 /// appear in the modified set, the response carries an
349 /// `OcsNonInclusionProof`.
350 ///
351 /// IMPORTANT: a non-inclusion proof attests only that this checkpoint
352 /// did NOT modify the requested object id. It does NOT attest that the
353 /// object doesn't exist on chain: an object that was last modified in
354 /// some earlier checkpoint and remained unchanged here will produce a
355 /// non-inclusion proof. Clients that need the object's state at this
356 /// checkpoint when it wasn't modified here must use a separate query
357 /// (e.g. ratchet back to the most recent modification).
358 async fn get_checkpoint_object_proof(
359 &self,
360 request: tonic::Request<super::GetCheckpointObjectProofRequest>,
361 ) -> std::result::Result<
362 tonic::Response<super::GetCheckpointObjectProofResponse>,
363 tonic::Status,
364 > {
365 Err(tonic::Status::unimplemented("Not yet implemented"))
366 }
367 }
368 /// ProofService provides cryptographic proofs of blockchain state.
369 ///
370 /// Proofs in this service are anchored at a checkpoint summary's
371 /// `checkpoint_artifacts_digest`, which commits to the Object Checkpoint
372 /// State (OCS) -- the per-checkpoint Merkle tree of object references
373 /// written in that checkpoint. "OCS" appears throughout this file to refer
374 /// to that commitment scheme; see the doc on `OcsInclusionProof` below for
375 /// the full definition.
376 #[derive(Debug)]
377 pub struct ProofServiceServer<T> {
378 inner: Arc<T>,
379 accept_compression_encodings: EnabledCompressionEncodings,
380 send_compression_encodings: EnabledCompressionEncodings,
381 max_decoding_message_size: Option<usize>,
382 max_encoding_message_size: Option<usize>,
383 }
384 impl<T> ProofServiceServer<T> {
385 pub fn new(inner: T) -> Self {
386 Self::from_arc(Arc::new(inner))
387 }
388 pub fn from_arc(inner: Arc<T>) -> Self {
389 Self {
390 inner,
391 accept_compression_encodings: Default::default(),
392 send_compression_encodings: Default::default(),
393 max_decoding_message_size: None,
394 max_encoding_message_size: None,
395 }
396 }
397 pub fn with_interceptor<F>(
398 inner: T,
399 interceptor: F,
400 ) -> InterceptedService<Self, F>
401 where
402 F: tonic::service::Interceptor,
403 {
404 InterceptedService::new(Self::new(inner), interceptor)
405 }
406 /// Enable decompressing requests with the given encoding.
407 #[must_use]
408 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
409 self.accept_compression_encodings.enable(encoding);
410 self
411 }
412 /// Compress responses with the given encoding, if the client supports it.
413 #[must_use]
414 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
415 self.send_compression_encodings.enable(encoding);
416 self
417 }
418 /// Limits the maximum size of a decoded message.
419 ///
420 /// Default: `4MB`
421 #[must_use]
422 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
423 self.max_decoding_message_size = Some(limit);
424 self
425 }
426 /// Limits the maximum size of an encoded message.
427 ///
428 /// Default: `usize::MAX`
429 #[must_use]
430 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
431 self.max_encoding_message_size = Some(limit);
432 self
433 }
434 }
435 impl<T, B> tonic::codegen::Service<http::Request<B>> for ProofServiceServer<T>
436 where
437 T: ProofService,
438 B: Body + std::marker::Send + 'static,
439 B::Error: Into<StdError> + std::marker::Send + 'static,
440 {
441 type Response = http::Response<tonic::body::Body>;
442 type Error = std::convert::Infallible;
443 type Future = BoxFuture<Self::Response, Self::Error>;
444 fn poll_ready(
445 &mut self,
446 _cx: &mut Context<'_>,
447 ) -> Poll<std::result::Result<(), Self::Error>> {
448 Poll::Ready(Ok(()))
449 }
450 fn call(&mut self, req: http::Request<B>) -> Self::Future {
451 match req.uri().path() {
452 "/sui.rpc.v2alpha.ProofService/GetCheckpointObjectProof" => {
453 #[allow(non_camel_case_types)]
454 struct GetCheckpointObjectProofSvc<T: ProofService>(pub Arc<T>);
455 impl<
456 T: ProofService,
457 > tonic::server::UnaryService<super::GetCheckpointObjectProofRequest>
458 for GetCheckpointObjectProofSvc<T> {
459 type Response = super::GetCheckpointObjectProofResponse;
460 type Future = BoxFuture<
461 tonic::Response<Self::Response>,
462 tonic::Status,
463 >;
464 fn call(
465 &mut self,
466 request: tonic::Request<
467 super::GetCheckpointObjectProofRequest,
468 >,
469 ) -> Self::Future {
470 let inner = Arc::clone(&self.0);
471 let fut = async move {
472 <T as ProofService>::get_checkpoint_object_proof(
473 &inner,
474 request,
475 )
476 .await
477 };
478 Box::pin(fut)
479 }
480 }
481 let accept_compression_encodings = self.accept_compression_encodings;
482 let send_compression_encodings = self.send_compression_encodings;
483 let max_decoding_message_size = self.max_decoding_message_size;
484 let max_encoding_message_size = self.max_encoding_message_size;
485 let inner = self.inner.clone();
486 let fut = async move {
487 let method = GetCheckpointObjectProofSvc(inner);
488 let codec = tonic_prost::ProstCodec::default();
489 let mut grpc = tonic::server::Grpc::new(codec)
490 .apply_compression_config(
491 accept_compression_encodings,
492 send_compression_encodings,
493 )
494 .apply_max_message_size_config(
495 max_decoding_message_size,
496 max_encoding_message_size,
497 );
498 let res = grpc.unary(method, req).await;
499 Ok(res)
500 };
501 Box::pin(fut)
502 }
503 _ => {
504 Box::pin(async move {
505 let mut response = http::Response::new(
506 tonic::body::Body::default(),
507 );
508 let headers = response.headers_mut();
509 headers
510 .insert(
511 tonic::Status::GRPC_STATUS,
512 (tonic::Code::Unimplemented as i32).into(),
513 );
514 headers
515 .insert(
516 http::header::CONTENT_TYPE,
517 tonic::metadata::GRPC_CONTENT_TYPE,
518 );
519 Ok(response)
520 })
521 }
522 }
523 }
524 }
525 impl<T> Clone for ProofServiceServer<T> {
526 fn clone(&self) -> Self {
527 let inner = self.inner.clone();
528 Self {
529 inner,
530 accept_compression_encodings: self.accept_compression_encodings,
531 send_compression_encodings: self.send_compression_encodings,
532 max_decoding_message_size: self.max_decoding_message_size,
533 max_encoding_message_size: self.max_encoding_message_size,
534 }
535 }
536 }
537 /// Generated gRPC service name
538 pub const SERVICE_NAME: &str = "sui.rpc.v2alpha.ProofService";
539 impl<T> tonic::server::NamedService for ProofServiceServer<T> {
540 const NAME: &'static str = SERVICE_NAME;
541 }
542}