diff --git a/crates/sui-rpc/src/client/ledger_streams/retry.rs b/crates/sui-rpc/src/client/ledger_streams/retry.rs index 0a4cfe88b9..40be7f0caf 100644 --- a/crates/sui-rpc/src/client/ledger_streams/retry.rs +++ b/crates/sui-rpc/src/client/ledger_streams/retry.rs @@ -41,7 +41,9 @@ pub(super) enum RequestBounds { /// Classifies failures eligible for automatic retry. /// -/// `Unavailable`, `DeadlineExceeded`, `ResourceExhausted`, and `Aborted` are always retried. +/// `Unavailable`, `DeadlineExceeded`, `ResourceExhausted`, and `Aborted` are retried, except a +/// `ResourceExhausted` with the [`ErrorReason::ResponseTooLarge`] reason: an item's size does not +/// change, so the same request fails the same way on every attempt. /// /// `Cancelled` and `Unknown` use two heuristics based on where the error was observed: /// - During `Dispatch` (initiating the RPC), server-sent `Cancelled` and `Unknown` are @@ -66,12 +68,20 @@ fn transient(status: &Status, phase: FailurePhase, bounds: RequestBounds) -> boo let dispatch_transient = matches!( status.code(), Code::Unavailable | Code::DeadlineExceeded | Code::ResourceExhausted | Code::Aborted - ); + ) && !response_too_large(status); let reset_code = matches!(status.code(), Code::Cancelled | Code::Unknown); let transport_reset = reset_code && (phase == FailurePhase::Body || status.source().is_some()); dispatch_transient || transport_reset || above_latest_available_is_transient(status, bounds) } +/// Whether `status` is a `ResourceExhausted` whose status details carry an `ErrorInfo` with reason +/// [`ErrorReason::ResponseTooLarge`]. +fn response_too_large(status: &Status) -> bool { + status.code() == Code::ResourceExhausted + && sui_error_infos(status) + .any(|error_info| error_info.reason == ErrorReason::ResponseTooLarge.as_str_name()) +} + /// Whether `status` is an `OutOfRange` whose status details carry an `ErrorInfo` with reason /// [`ErrorReason::AboveLatestAvailable`] for a bound some server reported: any bound of a request /// whose bounds are [`RequestBounds::ServerReported`], or the `bound` metadata `"cursor"`, since @@ -81,22 +91,23 @@ fn above_latest_available_is_transient(status: &Status, bounds: RequestBounds) - if status.code() != Code::OutOfRange { return false; } - let Ok(details) = crate::proto::google::rpc::Status::decode(status.details()) else { - return false; - }; - details - .details - .iter() + sui_error_infos(status).any(|error_info| { + error_info.reason == ErrorReason::AboveLatestAvailable.as_str_name() + && (bounds == RequestBounds::ServerReported + || error_info + .metadata + .get("bound") + .is_some_and(|bound| bound == "cursor")) + }) +} + +/// The `ErrorInfo`s in `status`'s details whose domain is [`ErrorReason::DOMAIN`]. +fn sui_error_infos(status: &Status) -> impl Iterator { + crate::proto::google::rpc::Status::decode(status.details()) + .into_iter() + .flat_map(|details| details.details) .filter_map(|detail| detail.to_msg::().ok()) - .any(|error_info| { - error_info.domain == ErrorReason::DOMAIN - && error_info.reason == ErrorReason::AboveLatestAvailable.as_str_name() - && (bounds == RequestBounds::ServerReported - || error_info - .metadata - .get("bound") - .is_some_and(|bound| bound == "cursor")) - }) + .filter(|error_info| error_info.domain == ErrorReason::DOMAIN) } pub(super) struct RetryState { @@ -245,7 +256,7 @@ mod tests { assert!(transient(&status, FailurePhase::Body, CALLER)); } - fn out_of_range_with_reason(reason: ErrorReason, bound: Option<&str>) -> Status { + fn status_with_reason(code: Code, reason: ErrorReason, bound: Option<&str>) -> Status { let mut error_info = ErrorInfo::default() .with_domain(ErrorReason::DOMAIN) .with_reason(reason.as_str_name()); @@ -255,19 +266,40 @@ mod tests { .insert("bound".to_owned(), bound.to_owned()); } let details = crate::proto::google::rpc::Status { - code: Code::OutOfRange.into(), - message: "requested data out of range".to_owned(), + code: code.into(), + message: "request failed".to_owned(), details: vec![prost_types::Any::from_msg(&error_info).unwrap()], }; Status::with_details( - Code::OutOfRange, + code, details.message.clone(), details.encode_to_vec().into(), ) } fn above_latest_available(bound: &str) -> Status { - out_of_range_with_reason(ErrorReason::AboveLatestAvailable, Some(bound)) + status_with_reason( + Code::OutOfRange, + ErrorReason::AboveLatestAvailable, + Some(bound), + ) + } + + #[test] + fn response_too_large_is_terminal_in_both_phases() { + let status = + status_with_reason(Code::ResourceExhausted, ErrorReason::ResponseTooLarge, None); + for bounds in [CALLER, SERVER] { + assert!(!transient(&status, FailurePhase::Dispatch, bounds)); + assert!(!transient(&status, FailurePhase::Body, bounds)); + } + } + + #[test] + fn resource_exhausted_without_response_too_large_is_transient() { + let status = Status::resource_exhausted("rate limited"); + assert!(transient(&status, FailurePhase::Dispatch, CALLER)); + assert!(transient(&status, FailurePhase::Body, CALLER)); } #[test] @@ -306,8 +338,9 @@ mod tests { #[test] fn out_of_range_without_a_server_reported_bound_past_the_tip_is_terminal() { let below_earliest_available = - out_of_range_with_reason(ErrorReason::BelowEarliestAvailable, None); - let missing_bound = out_of_range_with_reason(ErrorReason::AboveLatestAvailable, None); + status_with_reason(Code::OutOfRange, ErrorReason::BelowEarliestAvailable, None); + let missing_bound = + status_with_reason(Code::OutOfRange, ErrorReason::AboveLatestAvailable, None); let without_reason = Status::out_of_range("requested data above latest available"); for status in [ below_earliest_available.clone(), diff --git a/crates/sui-rpc/src/client/mod.rs b/crates/sui-rpc/src/client/mod.rs index fc91a183bc..f28d8934f1 100644 --- a/crates/sui-rpc/src/client/mod.rs +++ b/crates/sui-rpc/src/client/mod.rs @@ -60,6 +60,10 @@ use crate::proto::sui::rpc::v2::subscription_service_client::SubscriptionService use crate::proto::sui::rpc::v2::transaction_execution_service_client::TransactionExecutionServiceClient; #[cfg(feature = "unstable")] use crate::proto::sui::rpc::v2alpha::proof_service_client::ProofServiceClient; +#[cfg(feature = "unstable")] +use crate::proto::sui::rpc::v2beta::ledger_service_client::LedgerServiceClient as BetaLedgerServiceClient; +#[cfg(feature = "unstable")] +use crate::proto::sui::rpc::v2beta::subscription_service_client::SubscriptionServiceClient as BetaSubscriptionServiceClient; type Result = std::result::Result; type BoxError = Box; @@ -681,6 +685,39 @@ impl Client { } }) } + + /// Returns a client for the unstable beta `LedgerService` + /// (`sui.rpc.v2beta`), which reads checkpoints as streams of bounded-size + /// parts. + #[cfg(feature = "unstable")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "unstable")))] + pub fn beta_ledger_client(&mut self) -> BetaLedgerServiceClient { + BetaLedgerServiceClient::new(self.channel()) + .accept_compressed(CompressionEncoding::Zstd) + .pipe(|client| { + if let Some(limit) = self.config.max_decoding_message_size { + client.max_decoding_message_size(limit) + } else { + client + } + }) + } + + /// Returns a client for the unstable beta `SubscriptionService` + /// (`sui.rpc.v2beta`), which streams new checkpoints as bounded-size parts. + #[cfg(feature = "unstable")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "unstable")))] + pub fn beta_subscription_client(&mut self) -> BetaSubscriptionServiceClient { + BetaSubscriptionServiceClient::new(self.channel()) + .accept_compressed(CompressionEncoding::Zstd) + .pipe(|client| { + if let Some(limit) = self.config.max_decoding_message_size { + client.max_decoding_message_size(limit) + } else { + client + } + }) + } } /// Map a transport error to a [`tonic::Status`]. diff --git a/crates/sui-rpc/src/proto/generated/sui.rpc.v2.fds.bin b/crates/sui-rpc/src/proto/generated/sui.rpc.v2.fds.bin index d4447710b7..6bc30d48a5 100644 Binary files a/crates/sui-rpc/src/proto/generated/sui.rpc.v2.fds.bin and b/crates/sui-rpc/src/proto/generated/sui.rpc.v2.fds.bin differ diff --git a/crates/sui-rpc/src/proto/generated/sui.rpc.v2.rs b/crates/sui-rpc/src/proto/generated/sui.rpc.v2.rs index 7f52eb7394..2c938c37e3 100644 --- a/crates/sui-rpc/src/proto/generated/sui.rpc.v2.rs +++ b/crates/sui-rpc/src/proto/generated/sui.rpc.v2.rs @@ -1196,6 +1196,54 @@ pub enum ErrorReason { /// /// It carries no metadata. VersionNotRetained = 10, + /// A single response message, rendered for the request's `read_mask`, would + /// be larger than the largest response message this server sends. Returned + /// with `RESOURCE_EXHAUSTED` by RPCs that send each item in one message: the + /// checkpoint RPCs `GetCheckpoint`, `ListCheckpoints` and + /// `SubscribeCheckpoints`, and the transaction and batch RPCs such as + /// `GetTransaction`, `BatchGetTransactions`, `ListTransactions` and + /// `SubscribeTransactions`. + /// + /// A `List*` stream first delivers the items before the one that is too + /// large, then a frame without an item whose watermark resumes at it, and + /// then fails with this error. A `Subscribe*` stream ends with this error + /// rather than skip the item. + /// + /// An item's size does not change, so requesting the same item with the + /// same `read_mask` fails the same way on this server. To read it: + /// + /// * Narrow `read_mask`: for example, request a checkpoint's + /// `summary,signature` only, or leave out `objects` or `events` and fetch + /// them separately with `BatchGetObjects` or `ListEvents`. + /// * For a `BatchGet*` request, ask for fewer items per request. + /// * For a checkpoint, read it in bounded-size parts with + /// `sui.rpc.v2beta.LedgerService` `GetCheckpointParts` or + /// `ListCheckpointParts`, or `sui.rpc.v2beta.SubscriptionService` + /// `SubscribeCheckpointParts`. + /// + /// Example of an ErrorInfo for checkpoint 1205 from a server whose message + /// limit is 128 MiB: + /// + /// ```text + /// { "reason": "RESPONSE_TOO_LARGE", + /// "domain": "sui.io", + /// "metadata": { + /// "checkpoint": "1205", + /// "maxMessageBytes": "134217728" + /// } + /// } + /// ``` + /// + /// Metadata: + /// + /// * `maxMessageBytes`: the server's limit on the size of a single response + /// message, in bytes, as a decimal string. Always present. + /// * `checkpoint`: the sequence number of the checkpoint that is too large, + /// or that contains the transaction that is too large, as a decimal + /// string. Set by the checkpoint RPCs; transaction RPCs may set it. + /// * `transaction`: the digest of the transaction that is too large, in + /// Base58. Set when a single transaction exceeds the limit. + ResponseTooLarge = 11, } impl ErrorReason { /// String value of the enum field names used in the ProtoBuf definition. @@ -1215,6 +1263,7 @@ impl ErrorReason { Self::NotServedHere => "NOT_SERVED_HERE", Self::NotReady => "NOT_READY", Self::VersionNotRetained => "VERSION_NOT_RETAINED", + Self::ResponseTooLarge => "RESPONSE_TOO_LARGE", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -1231,6 +1280,7 @@ impl ErrorReason { "NOT_SERVED_HERE" => Some(Self::NotServedHere), "NOT_READY" => Some(Self::NotReady), "VERSION_NOT_RETAINED" => Some(Self::VersionNotRetained), + "RESPONSE_TOO_LARGE" => Some(Self::ResponseTooLarge), _ => None, } } @@ -3162,6 +3212,10 @@ pub mod get_transaction_result { /// `BELOW_EARLIEST_AVAILABLE`: by `sequence_number` always, by `digest` while /// it can still find the checkpoint. A digest it can no longer find is /// `NOT_FOUND`. +/// +/// A checkpoint too large to send in one message for the requested +/// `read_mask` fails with `RESOURCE_EXHAUSTED` and reason +/// `RESPONSE_TOO_LARGE`. #[non_exhaustive] #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct GetCheckpointRequest { @@ -3236,6 +3290,12 @@ pub struct GetProtocolConfigResponse { pub protocol_config: ::core::option::Option, } /// Request message for LedgerService.ListCheckpoints. +/// +/// A checkpoint too large to send in one message for the requested +/// `read_mask` ends the stream with `RESOURCE_EXHAUSTED` and reason +/// `RESPONSE_TOO_LARGE`. Before the error, the stream delivers the +/// checkpoints before it and then a frame without a checkpoint whose +/// watermark resumes at it. #[non_exhaustive] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ListCheckpointsRequest { @@ -9474,6 +9534,10 @@ pub mod state_service_server { } } /// Request message for SubscriptionService.SubscribeCheckpoints. +/// +/// A checkpoint too large to send in one message for the requested +/// `read_mask` ends the stream with `RESOURCE_EXHAUSTED` and reason +/// `RESPONSE_TOO_LARGE`. #[derive(Eq, Hash)] #[non_exhaustive] #[derive(Clone, PartialEq, ::prost::Message)] diff --git a/crates/sui-rpc/src/proto/generated/sui.rpc.v2.serde.rs b/crates/sui-rpc/src/proto/generated/sui.rpc.v2.serde.rs index 88be8330e2..5207145d0c 100644 --- a/crates/sui-rpc/src/proto/generated/sui.rpc.v2.serde.rs +++ b/crates/sui-rpc/src/proto/generated/sui.rpc.v2.serde.rs @@ -10317,6 +10317,7 @@ impl serde::Serialize for ErrorReason { Self::NotServedHere => "NOT_SERVED_HERE", Self::NotReady => "NOT_READY", Self::VersionNotRetained => "VERSION_NOT_RETAINED", + Self::ResponseTooLarge => "RESPONSE_TOO_LARGE", }; serializer.serialize_str(variant) } @@ -10339,6 +10340,7 @@ impl<'de> serde::Deserialize<'de> for ErrorReason { "NOT_SERVED_HERE", "NOT_READY", "VERSION_NOT_RETAINED", + "RESPONSE_TOO_LARGE", ]; struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { @@ -10395,6 +10397,7 @@ impl<'de> serde::Deserialize<'de> for ErrorReason { "NOT_SERVED_HERE" => Ok(ErrorReason::NotServedHere), "NOT_READY" => Ok(ErrorReason::NotReady), "VERSION_NOT_RETAINED" => Ok(ErrorReason::VersionNotRetained), + "RESPONSE_TOO_LARGE" => Ok(ErrorReason::ResponseTooLarge), _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), } } diff --git a/crates/sui-rpc/src/proto/generated/sui.rpc.v2beta.accessors.rs b/crates/sui-rpc/src/proto/generated/sui.rpc.v2beta.accessors.rs new file mode 100644 index 0000000000..fc53dc2be2 --- /dev/null +++ b/crates/sui-rpc/src/proto/generated/sui.rpc.v2beta.accessors.rs @@ -0,0 +1,1217 @@ +mod _accessor_impls { + #![allow(clippy::useless_conversion)] + impl super::CheckpointContentsPart { + pub const fn const_default() -> Self { + Self { + digest: None, + version: None, + transactions: Vec::new(), + } + } + #[doc(hidden)] + pub fn default_instance() -> &'static Self { + static DEFAULT: super::CheckpointContentsPart = super::CheckpointContentsPart::const_default(); + &DEFAULT + } + ///If `digest` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn digest_opt_mut(&mut self) -> Option<&mut String> { + self.digest.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `digest`. + ///If the field is unset, it is first initialized with the default value. + pub fn digest_mut(&mut self) -> &mut String { + self.digest.get_or_insert_default() + } + ///If `digest` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn digest_opt(&self) -> Option<&str> { + self.digest.as_ref().map(|field| field as _) + } + ///Sets `digest` with the provided value. + pub fn set_digest>(&mut self, field: T) { + self.digest = Some(field.into().into()); + } + ///Sets `digest` with the provided value. + pub fn with_digest>(mut self, field: T) -> Self { + self.set_digest(field.into()); + self + } + ///If `version` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn version_opt_mut(&mut self) -> Option<&mut i32> { + self.version.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `version`. + ///If the field is unset, it is first initialized with the default value. + pub fn version_mut(&mut self) -> &mut i32 { + self.version.get_or_insert_default() + } + ///If `version` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn version_opt(&self) -> Option { + self.version.as_ref().map(|field| *field) + } + ///Sets `version` with the provided value. + pub fn set_version(&mut self, field: i32) { + self.version = Some(field); + } + ///Sets `version` with the provided value. + pub fn with_version(mut self, field: i32) -> Self { + self.set_version(field); + self + } + ///Returns the value of `transactions`, or the default value if `transactions` is unset. + pub fn transactions(&self) -> &[super::super::v2::CheckpointedTransactionInfo] { + &self.transactions + } + ///Returns a mutable reference to `transactions`. + ///If the field is unset, it is first initialized with the default value. + pub fn transactions_mut( + &mut self, + ) -> &mut Vec { + &mut self.transactions + } + ///Sets `transactions` with the provided value. + pub fn set_transactions( + &mut self, + field: Vec, + ) { + self.transactions = field; + } + ///Sets `transactions` with the provided value. + pub fn with_transactions( + mut self, + field: Vec, + ) -> Self { + self.set_transactions(field); + self + } + } + impl super::CheckpointPart { + pub const fn const_default() -> Self { + Self { + sequence_number: None, + digest: None, + summary: None, + signature: None, + contents: None, + transactions: Vec::new(), + objects: None, + part_index: None, + is_last: None, + first_tx_index: None, + total_transactions: None, + first_tx_sequence_number: None, + objects_continue: None, + continuation_events: Vec::new(), + events_continue: None, + } + } + #[doc(hidden)] + pub fn default_instance() -> &'static Self { + static DEFAULT: super::CheckpointPart = super::CheckpointPart::const_default(); + &DEFAULT + } + ///If `sequence_number` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn sequence_number_opt_mut(&mut self) -> Option<&mut u64> { + self.sequence_number.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `sequence_number`. + ///If the field is unset, it is first initialized with the default value. + pub fn sequence_number_mut(&mut self) -> &mut u64 { + self.sequence_number.get_or_insert_default() + } + ///If `sequence_number` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn sequence_number_opt(&self) -> Option { + self.sequence_number.as_ref().map(|field| *field) + } + ///Sets `sequence_number` with the provided value. + pub fn set_sequence_number(&mut self, field: u64) { + self.sequence_number = Some(field); + } + ///Sets `sequence_number` with the provided value. + pub fn with_sequence_number(mut self, field: u64) -> Self { + self.set_sequence_number(field); + self + } + ///If `digest` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn digest_opt_mut(&mut self) -> Option<&mut String> { + self.digest.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `digest`. + ///If the field is unset, it is first initialized with the default value. + pub fn digest_mut(&mut self) -> &mut String { + self.digest.get_or_insert_default() + } + ///If `digest` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn digest_opt(&self) -> Option<&str> { + self.digest.as_ref().map(|field| field as _) + } + ///Sets `digest` with the provided value. + pub fn set_digest>(&mut self, field: T) { + self.digest = Some(field.into().into()); + } + ///Sets `digest` with the provided value. + pub fn with_digest>(mut self, field: T) -> Self { + self.set_digest(field.into()); + self + } + ///Returns the value of `summary`, or the default value if `summary` is unset. + pub fn summary(&self) -> &super::super::v2::CheckpointSummary { + self.summary + .as_ref() + .map(|field| field as _) + .unwrap_or_else(|| { + super::super::v2::CheckpointSummary::default_instance() as _ + }) + } + ///If `summary` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn summary_opt_mut( + &mut self, + ) -> Option<&mut super::super::v2::CheckpointSummary> { + self.summary.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `summary`. + ///If the field is unset, it is first initialized with the default value. + pub fn summary_mut(&mut self) -> &mut super::super::v2::CheckpointSummary { + self.summary.get_or_insert_default() + } + ///If `summary` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn summary_opt(&self) -> Option<&super::super::v2::CheckpointSummary> { + self.summary.as_ref().map(|field| field as _) + } + ///Sets `summary` with the provided value. + pub fn set_summary>( + &mut self, + field: T, + ) { + self.summary = Some(field.into().into()); + } + ///Sets `summary` with the provided value. + pub fn with_summary>( + mut self, + field: T, + ) -> Self { + self.set_summary(field.into()); + self + } + ///Returns the value of `signature`, or the default value if `signature` is unset. + pub fn signature(&self) -> &super::super::v2::ValidatorAggregatedSignature { + self.signature + .as_ref() + .map(|field| field as _) + .unwrap_or_else(|| { + super::super::v2::ValidatorAggregatedSignature::default_instance() + as _ + }) + } + ///If `signature` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn signature_opt_mut( + &mut self, + ) -> Option<&mut super::super::v2::ValidatorAggregatedSignature> { + self.signature.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `signature`. + ///If the field is unset, it is first initialized with the default value. + pub fn signature_mut( + &mut self, + ) -> &mut super::super::v2::ValidatorAggregatedSignature { + self.signature.get_or_insert_default() + } + ///If `signature` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn signature_opt( + &self, + ) -> Option<&super::super::v2::ValidatorAggregatedSignature> { + self.signature.as_ref().map(|field| field as _) + } + ///Sets `signature` with the provided value. + pub fn set_signature>( + &mut self, + field: T, + ) { + self.signature = Some(field.into().into()); + } + ///Sets `signature` with the provided value. + pub fn with_signature>( + mut self, + field: T, + ) -> Self { + self.set_signature(field.into()); + self + } + ///Returns the value of `contents`, or the default value if `contents` is unset. + pub fn contents(&self) -> &super::CheckpointContentsPart { + self.contents + .as_ref() + .map(|field| field as _) + .unwrap_or_else(|| { + super::CheckpointContentsPart::default_instance() as _ + }) + } + ///If `contents` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn contents_opt_mut( + &mut self, + ) -> Option<&mut super::CheckpointContentsPart> { + self.contents.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `contents`. + ///If the field is unset, it is first initialized with the default value. + pub fn contents_mut(&mut self) -> &mut super::CheckpointContentsPart { + self.contents.get_or_insert_default() + } + ///If `contents` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn contents_opt(&self) -> Option<&super::CheckpointContentsPart> { + self.contents.as_ref().map(|field| field as _) + } + ///Sets `contents` with the provided value. + pub fn set_contents>( + &mut self, + field: T, + ) { + self.contents = Some(field.into().into()); + } + ///Sets `contents` with the provided value. + pub fn with_contents>( + mut self, + field: T, + ) -> Self { + self.set_contents(field.into()); + self + } + ///Returns the value of `transactions`, or the default value if `transactions` is unset. + pub fn transactions(&self) -> &[super::super::v2::ExecutedTransaction] { + &self.transactions + } + ///Returns a mutable reference to `transactions`. + ///If the field is unset, it is first initialized with the default value. + pub fn transactions_mut( + &mut self, + ) -> &mut Vec { + &mut self.transactions + } + ///Sets `transactions` with the provided value. + pub fn set_transactions( + &mut self, + field: Vec, + ) { + self.transactions = field; + } + ///Sets `transactions` with the provided value. + pub fn with_transactions( + mut self, + field: Vec, + ) -> Self { + self.set_transactions(field); + self + } + ///Returns the value of `objects`, or the default value if `objects` is unset. + pub fn objects(&self) -> &super::super::v2::ObjectSet { + self.objects + .as_ref() + .map(|field| field as _) + .unwrap_or_else(|| super::super::v2::ObjectSet::default_instance() as _) + } + ///If `objects` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn objects_opt_mut(&mut self) -> Option<&mut super::super::v2::ObjectSet> { + self.objects.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `objects`. + ///If the field is unset, it is first initialized with the default value. + pub fn objects_mut(&mut self) -> &mut super::super::v2::ObjectSet { + self.objects.get_or_insert_default() + } + ///If `objects` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn objects_opt(&self) -> Option<&super::super::v2::ObjectSet> { + self.objects.as_ref().map(|field| field as _) + } + ///Sets `objects` with the provided value. + pub fn set_objects>(&mut self, field: T) { + self.objects = Some(field.into().into()); + } + ///Sets `objects` with the provided value. + pub fn with_objects>( + mut self, + field: T, + ) -> Self { + self.set_objects(field.into()); + self + } + ///If `part_index` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn part_index_opt_mut(&mut self) -> Option<&mut u32> { + self.part_index.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `part_index`. + ///If the field is unset, it is first initialized with the default value. + pub fn part_index_mut(&mut self) -> &mut u32 { + self.part_index.get_or_insert_default() + } + ///If `part_index` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn part_index_opt(&self) -> Option { + self.part_index.as_ref().map(|field| *field) + } + ///Sets `part_index` with the provided value. + pub fn set_part_index(&mut self, field: u32) { + self.part_index = Some(field); + } + ///Sets `part_index` with the provided value. + pub fn with_part_index(mut self, field: u32) -> Self { + self.set_part_index(field); + self + } + ///If `is_last` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn is_last_opt_mut(&mut self) -> Option<&mut bool> { + self.is_last.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `is_last`. + ///If the field is unset, it is first initialized with the default value. + pub fn is_last_mut(&mut self) -> &mut bool { + self.is_last.get_or_insert_default() + } + ///If `is_last` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn is_last_opt(&self) -> Option { + self.is_last.as_ref().map(|field| *field) + } + ///Sets `is_last` with the provided value. + pub fn set_is_last(&mut self, field: bool) { + self.is_last = Some(field); + } + ///Sets `is_last` with the provided value. + pub fn with_is_last(mut self, field: bool) -> Self { + self.set_is_last(field); + self + } + ///If `first_tx_index` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn first_tx_index_opt_mut(&mut self) -> Option<&mut u64> { + self.first_tx_index.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `first_tx_index`. + ///If the field is unset, it is first initialized with the default value. + pub fn first_tx_index_mut(&mut self) -> &mut u64 { + self.first_tx_index.get_or_insert_default() + } + ///If `first_tx_index` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn first_tx_index_opt(&self) -> Option { + self.first_tx_index.as_ref().map(|field| *field) + } + ///Sets `first_tx_index` with the provided value. + pub fn set_first_tx_index(&mut self, field: u64) { + self.first_tx_index = Some(field); + } + ///Sets `first_tx_index` with the provided value. + pub fn with_first_tx_index(mut self, field: u64) -> Self { + self.set_first_tx_index(field); + self + } + ///If `total_transactions` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn total_transactions_opt_mut(&mut self) -> Option<&mut u64> { + self.total_transactions.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `total_transactions`. + ///If the field is unset, it is first initialized with the default value. + pub fn total_transactions_mut(&mut self) -> &mut u64 { + self.total_transactions.get_or_insert_default() + } + ///If `total_transactions` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn total_transactions_opt(&self) -> Option { + self.total_transactions.as_ref().map(|field| *field) + } + ///Sets `total_transactions` with the provided value. + pub fn set_total_transactions(&mut self, field: u64) { + self.total_transactions = Some(field); + } + ///Sets `total_transactions` with the provided value. + pub fn with_total_transactions(mut self, field: u64) -> Self { + self.set_total_transactions(field); + self + } + ///If `first_tx_sequence_number` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn first_tx_sequence_number_opt_mut(&mut self) -> Option<&mut u64> { + self.first_tx_sequence_number.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `first_tx_sequence_number`. + ///If the field is unset, it is first initialized with the default value. + pub fn first_tx_sequence_number_mut(&mut self) -> &mut u64 { + self.first_tx_sequence_number.get_or_insert_default() + } + ///If `first_tx_sequence_number` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn first_tx_sequence_number_opt(&self) -> Option { + self.first_tx_sequence_number.as_ref().map(|field| *field) + } + ///Sets `first_tx_sequence_number` with the provided value. + pub fn set_first_tx_sequence_number(&mut self, field: u64) { + self.first_tx_sequence_number = Some(field); + } + ///Sets `first_tx_sequence_number` with the provided value. + pub fn with_first_tx_sequence_number(mut self, field: u64) -> Self { + self.set_first_tx_sequence_number(field); + self + } + ///If `objects_continue` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn objects_continue_opt_mut(&mut self) -> Option<&mut bool> { + self.objects_continue.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `objects_continue`. + ///If the field is unset, it is first initialized with the default value. + pub fn objects_continue_mut(&mut self) -> &mut bool { + self.objects_continue.get_or_insert_default() + } + ///If `objects_continue` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn objects_continue_opt(&self) -> Option { + self.objects_continue.as_ref().map(|field| *field) + } + ///Sets `objects_continue` with the provided value. + pub fn set_objects_continue(&mut self, field: bool) { + self.objects_continue = Some(field); + } + ///Sets `objects_continue` with the provided value. + pub fn with_objects_continue(mut self, field: bool) -> Self { + self.set_objects_continue(field); + self + } + ///Returns the value of `continuation_events`, or the default value if `continuation_events` is unset. + pub fn continuation_events(&self) -> &[super::super::v2::Event] { + &self.continuation_events + } + ///Returns a mutable reference to `continuation_events`. + ///If the field is unset, it is first initialized with the default value. + pub fn continuation_events_mut(&mut self) -> &mut Vec { + &mut self.continuation_events + } + ///Sets `continuation_events` with the provided value. + pub fn set_continuation_events(&mut self, field: Vec) { + self.continuation_events = field; + } + ///Sets `continuation_events` with the provided value. + pub fn with_continuation_events( + mut self, + field: Vec, + ) -> Self { + self.set_continuation_events(field); + self + } + ///If `events_continue` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn events_continue_opt_mut(&mut self) -> Option<&mut bool> { + self.events_continue.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `events_continue`. + ///If the field is unset, it is first initialized with the default value. + pub fn events_continue_mut(&mut self) -> &mut bool { + self.events_continue.get_or_insert_default() + } + ///If `events_continue` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn events_continue_opt(&self) -> Option { + self.events_continue.as_ref().map(|field| *field) + } + ///Sets `events_continue` with the provided value. + pub fn set_events_continue(&mut self, field: bool) { + self.events_continue = Some(field); + } + ///Sets `events_continue` with the provided value. + pub fn with_events_continue(mut self, field: bool) -> Self { + self.set_events_continue(field); + self + } + } + impl super::GetCheckpointPartsRequest { + pub const fn const_default() -> Self { + Self { + read_mask: None, + resume_token: None, + checkpoint_id: None, + } + } + #[doc(hidden)] + pub fn default_instance() -> &'static Self { + static DEFAULT: super::GetCheckpointPartsRequest = super::GetCheckpointPartsRequest::const_default(); + &DEFAULT + } + ///If `read_mask` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn read_mask_opt_mut(&mut self) -> Option<&mut ::prost_types::FieldMask> { + self.read_mask.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `read_mask`. + ///If the field is unset, it is first initialized with the default value. + pub fn read_mask_mut(&mut self) -> &mut ::prost_types::FieldMask { + self.read_mask.get_or_insert_default() + } + ///If `read_mask` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn read_mask_opt(&self) -> Option<&::prost_types::FieldMask> { + self.read_mask.as_ref().map(|field| field as _) + } + ///Sets `read_mask` with the provided value. + pub fn set_read_mask>(&mut self, field: T) { + self.read_mask = Some(field.into().into()); + } + ///Sets `read_mask` with the provided value. + pub fn with_read_mask>( + mut self, + field: T, + ) -> Self { + self.set_read_mask(field.into()); + self + } + ///If `resume_token` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn resume_token_opt(&self) -> Option<&[u8]> { + self.resume_token.as_ref().map(|field| field as _) + } + ///Sets `resume_token` with the provided value. + pub fn set_resume_token>(&mut self, field: T) { + self.resume_token = Some(field.into().into()); + } + ///Sets `resume_token` with the provided value. + pub fn with_resume_token>( + mut self, + field: T, + ) -> Self { + self.set_resume_token(field.into()); + self + } + ///Returns the value of `sequence_number`, or the default value if `sequence_number` is unset. + pub fn sequence_number(&self) -> u64 { + if let Some( + super::get_checkpoint_parts_request::CheckpointId::SequenceNumber(field), + ) = &self.checkpoint_id + { + *field + } else { + 0u64 + } + } + ///If `sequence_number` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn sequence_number_opt(&self) -> Option { + if let Some( + super::get_checkpoint_parts_request::CheckpointId::SequenceNumber(field), + ) = &self.checkpoint_id + { + Some(*field) + } else { + None + } + } + ///If `sequence_number` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn sequence_number_opt_mut(&mut self) -> Option<&mut u64> { + if let Some( + super::get_checkpoint_parts_request::CheckpointId::SequenceNumber(field), + ) = &mut self.checkpoint_id + { + Some(field as _) + } else { + None + } + } + ///Returns a mutable reference to `sequence_number`. + ///If the field is unset, it is first initialized with the default value. + ///If any other oneof field in the same oneof is set, it will be cleared. + pub fn sequence_number_mut(&mut self) -> &mut u64 { + if self.sequence_number_opt_mut().is_none() { + self.checkpoint_id = Some( + super::get_checkpoint_parts_request::CheckpointId::SequenceNumber( + u64::default(), + ), + ); + } + self.sequence_number_opt_mut().unwrap() + } + ///Sets `sequence_number` with the provided value. + ///If any other oneof field in the same oneof is set, it will be cleared. + pub fn set_sequence_number(&mut self, field: u64) { + self.checkpoint_id = Some( + super::get_checkpoint_parts_request::CheckpointId::SequenceNumber(field), + ); + } + ///Sets `sequence_number` with the provided value. + ///If any other oneof field in the same oneof is set, it will be cleared. + pub fn with_sequence_number(mut self, field: u64) -> Self { + self.set_sequence_number(field); + self + } + ///Returns the value of `digest`, or the default value if `digest` is unset. + pub fn digest(&self) -> &str { + if let Some( + super::get_checkpoint_parts_request::CheckpointId::Digest(field), + ) = &self.checkpoint_id + { + field as _ + } else { + "" + } + } + ///If `digest` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn digest_opt(&self) -> Option<&str> { + if let Some( + super::get_checkpoint_parts_request::CheckpointId::Digest(field), + ) = &self.checkpoint_id + { + Some(field as _) + } else { + None + } + } + ///If `digest` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn digest_opt_mut(&mut self) -> Option<&mut String> { + if let Some( + super::get_checkpoint_parts_request::CheckpointId::Digest(field), + ) = &mut self.checkpoint_id + { + Some(field as _) + } else { + None + } + } + ///Returns a mutable reference to `digest`. + ///If the field is unset, it is first initialized with the default value. + ///If any other oneof field in the same oneof is set, it will be cleared. + pub fn digest_mut(&mut self) -> &mut String { + if self.digest_opt_mut().is_none() { + self.checkpoint_id = Some( + super::get_checkpoint_parts_request::CheckpointId::Digest( + String::default(), + ), + ); + } + self.digest_opt_mut().unwrap() + } + ///Sets `digest` with the provided value. + ///If any other oneof field in the same oneof is set, it will be cleared. + pub fn set_digest>(&mut self, field: T) { + self.checkpoint_id = Some( + super::get_checkpoint_parts_request::CheckpointId::Digest( + field.into().into(), + ), + ); + } + ///Sets `digest` with the provided value. + ///If any other oneof field in the same oneof is set, it will be cleared. + pub fn with_digest>(mut self, field: T) -> Self { + self.set_digest(field.into()); + self + } + } + impl super::GetCheckpointPartsResponse { + pub const fn const_default() -> Self { + Self { + part: None, + resume_token: None, + } + } + #[doc(hidden)] + pub fn default_instance() -> &'static Self { + static DEFAULT: super::GetCheckpointPartsResponse = super::GetCheckpointPartsResponse::const_default(); + &DEFAULT + } + ///Returns the value of `part`, or the default value if `part` is unset. + pub fn part(&self) -> &super::CheckpointPart { + self.part + .as_ref() + .map(|field| field as _) + .unwrap_or_else(|| super::CheckpointPart::default_instance() as _) + } + ///If `part` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn part_opt_mut(&mut self) -> Option<&mut super::CheckpointPart> { + self.part.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `part`. + ///If the field is unset, it is first initialized with the default value. + pub fn part_mut(&mut self) -> &mut super::CheckpointPart { + self.part.get_or_insert_default() + } + ///If `part` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn part_opt(&self) -> Option<&super::CheckpointPart> { + self.part.as_ref().map(|field| field as _) + } + ///Sets `part` with the provided value. + pub fn set_part>(&mut self, field: T) { + self.part = Some(field.into().into()); + } + ///Sets `part` with the provided value. + pub fn with_part>(mut self, field: T) -> Self { + self.set_part(field.into()); + self + } + ///If `resume_token` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn resume_token_opt(&self) -> Option<&[u8]> { + self.resume_token.as_ref().map(|field| field as _) + } + ///Sets `resume_token` with the provided value. + pub fn set_resume_token>(&mut self, field: T) { + self.resume_token = Some(field.into().into()); + } + ///Sets `resume_token` with the provided value. + pub fn with_resume_token>( + mut self, + field: T, + ) -> Self { + self.set_resume_token(field.into()); + self + } + } + impl super::ListCheckpointPartsRequest { + pub const fn const_default() -> Self { + Self { + read_mask: None, + start_checkpoint: None, + end_checkpoint: None, + filter: None, + options: None, + resume_token: None, + } + } + #[doc(hidden)] + pub fn default_instance() -> &'static Self { + static DEFAULT: super::ListCheckpointPartsRequest = super::ListCheckpointPartsRequest::const_default(); + &DEFAULT + } + ///If `read_mask` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn read_mask_opt_mut(&mut self) -> Option<&mut ::prost_types::FieldMask> { + self.read_mask.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `read_mask`. + ///If the field is unset, it is first initialized with the default value. + pub fn read_mask_mut(&mut self) -> &mut ::prost_types::FieldMask { + self.read_mask.get_or_insert_default() + } + ///If `read_mask` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn read_mask_opt(&self) -> Option<&::prost_types::FieldMask> { + self.read_mask.as_ref().map(|field| field as _) + } + ///Sets `read_mask` with the provided value. + pub fn set_read_mask>(&mut self, field: T) { + self.read_mask = Some(field.into().into()); + } + ///Sets `read_mask` with the provided value. + pub fn with_read_mask>( + mut self, + field: T, + ) -> Self { + self.set_read_mask(field.into()); + self + } + ///If `start_checkpoint` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn start_checkpoint_opt_mut(&mut self) -> Option<&mut u64> { + self.start_checkpoint.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `start_checkpoint`. + ///If the field is unset, it is first initialized with the default value. + pub fn start_checkpoint_mut(&mut self) -> &mut u64 { + self.start_checkpoint.get_or_insert_default() + } + ///If `start_checkpoint` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn start_checkpoint_opt(&self) -> Option { + self.start_checkpoint.as_ref().map(|field| *field) + } + ///Sets `start_checkpoint` with the provided value. + pub fn set_start_checkpoint(&mut self, field: u64) { + self.start_checkpoint = Some(field); + } + ///Sets `start_checkpoint` with the provided value. + pub fn with_start_checkpoint(mut self, field: u64) -> Self { + self.set_start_checkpoint(field); + self + } + ///If `end_checkpoint` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn end_checkpoint_opt_mut(&mut self) -> Option<&mut u64> { + self.end_checkpoint.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `end_checkpoint`. + ///If the field is unset, it is first initialized with the default value. + pub fn end_checkpoint_mut(&mut self) -> &mut u64 { + self.end_checkpoint.get_or_insert_default() + } + ///If `end_checkpoint` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn end_checkpoint_opt(&self) -> Option { + self.end_checkpoint.as_ref().map(|field| *field) + } + ///Sets `end_checkpoint` with the provided value. + pub fn set_end_checkpoint(&mut self, field: u64) { + self.end_checkpoint = Some(field); + } + ///Sets `end_checkpoint` with the provided value. + pub fn with_end_checkpoint(mut self, field: u64) -> Self { + self.set_end_checkpoint(field); + self + } + ///Returns the value of `filter`, or the default value if `filter` is unset. + pub fn filter(&self) -> &super::super::v2::TransactionFilter { + self.filter + .as_ref() + .map(|field| field as _) + .unwrap_or_else(|| { + super::super::v2::TransactionFilter::default_instance() as _ + }) + } + ///If `filter` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn filter_opt_mut( + &mut self, + ) -> Option<&mut super::super::v2::TransactionFilter> { + self.filter.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `filter`. + ///If the field is unset, it is first initialized with the default value. + pub fn filter_mut(&mut self) -> &mut super::super::v2::TransactionFilter { + self.filter.get_or_insert_default() + } + ///If `filter` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn filter_opt(&self) -> Option<&super::super::v2::TransactionFilter> { + self.filter.as_ref().map(|field| field as _) + } + ///Sets `filter` with the provided value. + pub fn set_filter>( + &mut self, + field: T, + ) { + self.filter = Some(field.into().into()); + } + ///Sets `filter` with the provided value. + pub fn with_filter>( + mut self, + field: T, + ) -> Self { + self.set_filter(field.into()); + self + } + ///Returns the value of `options`, or the default value if `options` is unset. + pub fn options(&self) -> &super::super::v2::QueryOptions { + self.options + .as_ref() + .map(|field| field as _) + .unwrap_or_else(|| { + super::super::v2::QueryOptions::default_instance() as _ + }) + } + ///If `options` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn options_opt_mut( + &mut self, + ) -> Option<&mut super::super::v2::QueryOptions> { + self.options.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `options`. + ///If the field is unset, it is first initialized with the default value. + pub fn options_mut(&mut self) -> &mut super::super::v2::QueryOptions { + self.options.get_or_insert_default() + } + ///If `options` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn options_opt(&self) -> Option<&super::super::v2::QueryOptions> { + self.options.as_ref().map(|field| field as _) + } + ///Sets `options` with the provided value. + pub fn set_options>( + &mut self, + field: T, + ) { + self.options = Some(field.into().into()); + } + ///Sets `options` with the provided value. + pub fn with_options>( + mut self, + field: T, + ) -> Self { + self.set_options(field.into()); + self + } + ///If `resume_token` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn resume_token_opt(&self) -> Option<&[u8]> { + self.resume_token.as_ref().map(|field| field as _) + } + ///Sets `resume_token` with the provided value. + pub fn set_resume_token>(&mut self, field: T) { + self.resume_token = Some(field.into().into()); + } + ///Sets `resume_token` with the provided value. + pub fn with_resume_token>( + mut self, + field: T, + ) -> Self { + self.set_resume_token(field.into()); + self + } + } + impl super::ListCheckpointPartsResponse { + pub const fn const_default() -> Self { + Self { + part: None, + watermark: None, + resume_token: None, + end: None, + } + } + #[doc(hidden)] + pub fn default_instance() -> &'static Self { + static DEFAULT: super::ListCheckpointPartsResponse = super::ListCheckpointPartsResponse::const_default(); + &DEFAULT + } + ///Returns the value of `part`, or the default value if `part` is unset. + pub fn part(&self) -> &super::CheckpointPart { + self.part + .as_ref() + .map(|field| field as _) + .unwrap_or_else(|| super::CheckpointPart::default_instance() as _) + } + ///If `part` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn part_opt_mut(&mut self) -> Option<&mut super::CheckpointPart> { + self.part.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `part`. + ///If the field is unset, it is first initialized with the default value. + pub fn part_mut(&mut self) -> &mut super::CheckpointPart { + self.part.get_or_insert_default() + } + ///If `part` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn part_opt(&self) -> Option<&super::CheckpointPart> { + self.part.as_ref().map(|field| field as _) + } + ///Sets `part` with the provided value. + pub fn set_part>(&mut self, field: T) { + self.part = Some(field.into().into()); + } + ///Sets `part` with the provided value. + pub fn with_part>(mut self, field: T) -> Self { + self.set_part(field.into()); + self + } + ///Returns the value of `watermark`, or the default value if `watermark` is unset. + pub fn watermark(&self) -> &super::super::v2::Watermark { + self.watermark + .as_ref() + .map(|field| field as _) + .unwrap_or_else(|| super::super::v2::Watermark::default_instance() as _) + } + ///If `watermark` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn watermark_opt_mut(&mut self) -> Option<&mut super::super::v2::Watermark> { + self.watermark.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `watermark`. + ///If the field is unset, it is first initialized with the default value. + pub fn watermark_mut(&mut self) -> &mut super::super::v2::Watermark { + self.watermark.get_or_insert_default() + } + ///If `watermark` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn watermark_opt(&self) -> Option<&super::super::v2::Watermark> { + self.watermark.as_ref().map(|field| field as _) + } + ///Sets `watermark` with the provided value. + pub fn set_watermark>(&mut self, field: T) { + self.watermark = Some(field.into().into()); + } + ///Sets `watermark` with the provided value. + pub fn with_watermark>( + mut self, + field: T, + ) -> Self { + self.set_watermark(field.into()); + self + } + ///If `resume_token` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn resume_token_opt(&self) -> Option<&[u8]> { + self.resume_token.as_ref().map(|field| field as _) + } + ///Sets `resume_token` with the provided value. + pub fn set_resume_token>(&mut self, field: T) { + self.resume_token = Some(field.into().into()); + } + ///Sets `resume_token` with the provided value. + pub fn with_resume_token>( + mut self, + field: T, + ) -> Self { + self.set_resume_token(field.into()); + self + } + ///Returns the value of `end`, or the default value if `end` is unset. + pub fn end(&self) -> &super::super::v2::QueryEnd { + self.end + .as_ref() + .map(|field| field as _) + .unwrap_or_else(|| super::super::v2::QueryEnd::default_instance() as _) + } + ///If `end` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn end_opt_mut(&mut self) -> Option<&mut super::super::v2::QueryEnd> { + self.end.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `end`. + ///If the field is unset, it is first initialized with the default value. + pub fn end_mut(&mut self) -> &mut super::super::v2::QueryEnd { + self.end.get_or_insert_default() + } + ///If `end` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn end_opt(&self) -> Option<&super::super::v2::QueryEnd> { + self.end.as_ref().map(|field| field as _) + } + ///Sets `end` with the provided value. + pub fn set_end>(&mut self, field: T) { + self.end = Some(field.into().into()); + } + ///Sets `end` with the provided value. + pub fn with_end>( + mut self, + field: T, + ) -> Self { + self.set_end(field.into()); + self + } + } + impl super::SubscribeCheckpointPartsRequest { + pub const fn const_default() -> Self { + Self { + read_mask: None, + filter: None, + } + } + #[doc(hidden)] + pub fn default_instance() -> &'static Self { + static DEFAULT: super::SubscribeCheckpointPartsRequest = super::SubscribeCheckpointPartsRequest::const_default(); + &DEFAULT + } + ///If `read_mask` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn read_mask_opt_mut(&mut self) -> Option<&mut ::prost_types::FieldMask> { + self.read_mask.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `read_mask`. + ///If the field is unset, it is first initialized with the default value. + pub fn read_mask_mut(&mut self) -> &mut ::prost_types::FieldMask { + self.read_mask.get_or_insert_default() + } + ///If `read_mask` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn read_mask_opt(&self) -> Option<&::prost_types::FieldMask> { + self.read_mask.as_ref().map(|field| field as _) + } + ///Sets `read_mask` with the provided value. + pub fn set_read_mask>(&mut self, field: T) { + self.read_mask = Some(field.into().into()); + } + ///Sets `read_mask` with the provided value. + pub fn with_read_mask>( + mut self, + field: T, + ) -> Self { + self.set_read_mask(field.into()); + self + } + ///Returns the value of `filter`, or the default value if `filter` is unset. + pub fn filter(&self) -> &super::super::v2::TransactionFilter { + self.filter + .as_ref() + .map(|field| field as _) + .unwrap_or_else(|| { + super::super::v2::TransactionFilter::default_instance() as _ + }) + } + ///If `filter` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn filter_opt_mut( + &mut self, + ) -> Option<&mut super::super::v2::TransactionFilter> { + self.filter.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `filter`. + ///If the field is unset, it is first initialized with the default value. + pub fn filter_mut(&mut self) -> &mut super::super::v2::TransactionFilter { + self.filter.get_or_insert_default() + } + ///If `filter` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn filter_opt(&self) -> Option<&super::super::v2::TransactionFilter> { + self.filter.as_ref().map(|field| field as _) + } + ///Sets `filter` with the provided value. + pub fn set_filter>( + &mut self, + field: T, + ) { + self.filter = Some(field.into().into()); + } + ///Sets `filter` with the provided value. + pub fn with_filter>( + mut self, + field: T, + ) -> Self { + self.set_filter(field.into()); + self + } + } + impl super::SubscribeCheckpointPartsResponse { + pub const fn const_default() -> Self { + Self { + part: None, + watermark: None, + resume_token: None, + } + } + #[doc(hidden)] + pub fn default_instance() -> &'static Self { + static DEFAULT: super::SubscribeCheckpointPartsResponse = super::SubscribeCheckpointPartsResponse::const_default(); + &DEFAULT + } + ///Returns the value of `part`, or the default value if `part` is unset. + pub fn part(&self) -> &super::CheckpointPart { + self.part + .as_ref() + .map(|field| field as _) + .unwrap_or_else(|| super::CheckpointPart::default_instance() as _) + } + ///If `part` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn part_opt_mut(&mut self) -> Option<&mut super::CheckpointPart> { + self.part.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `part`. + ///If the field is unset, it is first initialized with the default value. + pub fn part_mut(&mut self) -> &mut super::CheckpointPart { + self.part.get_or_insert_default() + } + ///If `part` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn part_opt(&self) -> Option<&super::CheckpointPart> { + self.part.as_ref().map(|field| field as _) + } + ///Sets `part` with the provided value. + pub fn set_part>(&mut self, field: T) { + self.part = Some(field.into().into()); + } + ///Sets `part` with the provided value. + pub fn with_part>(mut self, field: T) -> Self { + self.set_part(field.into()); + self + } + ///Returns the value of `watermark`, or the default value if `watermark` is unset. + pub fn watermark(&self) -> &super::super::v2::Watermark { + self.watermark + .as_ref() + .map(|field| field as _) + .unwrap_or_else(|| super::super::v2::Watermark::default_instance() as _) + } + ///If `watermark` is set, returns [`Some`] with a mutable reference to the value; otherwise returns [`None`]. + pub fn watermark_opt_mut(&mut self) -> Option<&mut super::super::v2::Watermark> { + self.watermark.as_mut().map(|field| field as _) + } + ///Returns a mutable reference to `watermark`. + ///If the field is unset, it is first initialized with the default value. + pub fn watermark_mut(&mut self) -> &mut super::super::v2::Watermark { + self.watermark.get_or_insert_default() + } + ///If `watermark` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn watermark_opt(&self) -> Option<&super::super::v2::Watermark> { + self.watermark.as_ref().map(|field| field as _) + } + ///Sets `watermark` with the provided value. + pub fn set_watermark>(&mut self, field: T) { + self.watermark = Some(field.into().into()); + } + ///Sets `watermark` with the provided value. + pub fn with_watermark>( + mut self, + field: T, + ) -> Self { + self.set_watermark(field.into()); + self + } + ///If `resume_token` is set, returns [`Some`] with the value; otherwise returns [`None`]. + pub fn resume_token_opt(&self) -> Option<&[u8]> { + self.resume_token.as_ref().map(|field| field as _) + } + ///Sets `resume_token` with the provided value. + pub fn set_resume_token>(&mut self, field: T) { + self.resume_token = Some(field.into().into()); + } + ///Sets `resume_token` with the provided value. + pub fn with_resume_token>( + mut self, + field: T, + ) -> Self { + self.set_resume_token(field.into()); + self + } + } +} diff --git a/crates/sui-rpc/src/proto/generated/sui.rpc.v2beta.fds.bin b/crates/sui-rpc/src/proto/generated/sui.rpc.v2beta.fds.bin new file mode 100644 index 0000000000..f35552e468 Binary files /dev/null and b/crates/sui-rpc/src/proto/generated/sui.rpc.v2beta.fds.bin differ diff --git a/crates/sui-rpc/src/proto/generated/sui.rpc.v2beta.field_info.rs b/crates/sui-rpc/src/proto/generated/sui.rpc.v2beta.field_info.rs new file mode 100644 index 0000000000..6c7bcedbb0 --- /dev/null +++ b/crates/sui-rpc/src/proto/generated/sui.rpc.v2beta.field_info.rs @@ -0,0 +1,651 @@ +pub(crate) mod _field_impls { + #![allow(clippy::wrong_self_convention)] + use super::*; + use crate::field::MessageFields; + use crate::field::MessageField; + impl CheckpointPart { + pub const SEQUENCE_NUMBER_FIELD: &'static MessageField = &MessageField { + name: "sequence_number", + json_name: "sequenceNumber", + number: 1i32, + message_fields: None, + }; + pub const DIGEST_FIELD: &'static MessageField = &MessageField { + name: "digest", + json_name: "digest", + number: 2i32, + message_fields: None, + }; + pub const SUMMARY_FIELD: &'static MessageField = &MessageField { + name: "summary", + json_name: "summary", + number: 3i32, + message_fields: Some(CheckpointSummary::FIELDS), + }; + pub const SIGNATURE_FIELD: &'static MessageField = &MessageField { + name: "signature", + json_name: "signature", + number: 4i32, + message_fields: Some(ValidatorAggregatedSignature::FIELDS), + }; + pub const CONTENTS_FIELD: &'static MessageField = &MessageField { + name: "contents", + json_name: "contents", + number: 5i32, + message_fields: Some(CheckpointContentsPart::FIELDS), + }; + pub const TRANSACTIONS_FIELD: &'static MessageField = &MessageField { + name: "transactions", + json_name: "transactions", + number: 6i32, + message_fields: Some(ExecutedTransaction::FIELDS), + }; + pub const OBJECTS_FIELD: &'static MessageField = &MessageField { + name: "objects", + json_name: "objects", + number: 7i32, + message_fields: Some(ObjectSet::FIELDS), + }; + pub const PART_INDEX_FIELD: &'static MessageField = &MessageField { + name: "part_index", + json_name: "partIndex", + number: 8i32, + message_fields: None, + }; + pub const IS_LAST_FIELD: &'static MessageField = &MessageField { + name: "is_last", + json_name: "isLast", + number: 9i32, + message_fields: None, + }; + pub const FIRST_TX_INDEX_FIELD: &'static MessageField = &MessageField { + name: "first_tx_index", + json_name: "firstTxIndex", + number: 10i32, + message_fields: None, + }; + pub const TOTAL_TRANSACTIONS_FIELD: &'static MessageField = &MessageField { + name: "total_transactions", + json_name: "totalTransactions", + number: 11i32, + message_fields: None, + }; + pub const FIRST_TX_SEQUENCE_NUMBER_FIELD: &'static MessageField = &MessageField { + name: "first_tx_sequence_number", + json_name: "firstTxSequenceNumber", + number: 12i32, + message_fields: None, + }; + pub const OBJECTS_CONTINUE_FIELD: &'static MessageField = &MessageField { + name: "objects_continue", + json_name: "objectsContinue", + number: 13i32, + message_fields: None, + }; + pub const CONTINUATION_EVENTS_FIELD: &'static MessageField = &MessageField { + name: "continuation_events", + json_name: "continuationEvents", + number: 14i32, + message_fields: Some(Event::FIELDS), + }; + pub const EVENTS_CONTINUE_FIELD: &'static MessageField = &MessageField { + name: "events_continue", + json_name: "eventsContinue", + number: 15i32, + message_fields: None, + }; + } + impl MessageFields for CheckpointPart { + const FIELDS: &'static [&'static MessageField] = &[ + Self::SEQUENCE_NUMBER_FIELD, + Self::DIGEST_FIELD, + Self::SUMMARY_FIELD, + Self::SIGNATURE_FIELD, + Self::CONTENTS_FIELD, + Self::TRANSACTIONS_FIELD, + Self::OBJECTS_FIELD, + Self::PART_INDEX_FIELD, + Self::IS_LAST_FIELD, + Self::FIRST_TX_INDEX_FIELD, + Self::TOTAL_TRANSACTIONS_FIELD, + Self::FIRST_TX_SEQUENCE_NUMBER_FIELD, + Self::OBJECTS_CONTINUE_FIELD, + Self::CONTINUATION_EVENTS_FIELD, + Self::EVENTS_CONTINUE_FIELD, + ]; + } + impl CheckpointPart { + pub fn path_builder() -> CheckpointPartFieldPathBuilder { + CheckpointPartFieldPathBuilder::new() + } + } + pub struct CheckpointPartFieldPathBuilder { + path: Vec<&'static str>, + } + impl CheckpointPartFieldPathBuilder { + #[allow(clippy::new_without_default)] + pub fn new() -> Self { + Self { path: Default::default() } + } + #[doc(hidden)] + pub fn new_with_base(base: Vec<&'static str>) -> Self { + Self { path: base } + } + pub fn finish(self) -> String { + self.path.join(".") + } + pub fn sequence_number(mut self) -> String { + self.path.push(CheckpointPart::SEQUENCE_NUMBER_FIELD.name); + self.finish() + } + pub fn digest(mut self) -> String { + self.path.push(CheckpointPart::DIGEST_FIELD.name); + self.finish() + } + pub fn summary(mut self) -> CheckpointSummaryFieldPathBuilder { + self.path.push(CheckpointPart::SUMMARY_FIELD.name); + CheckpointSummaryFieldPathBuilder::new_with_base(self.path) + } + pub fn signature(mut self) -> ValidatorAggregatedSignatureFieldPathBuilder { + self.path.push(CheckpointPart::SIGNATURE_FIELD.name); + ValidatorAggregatedSignatureFieldPathBuilder::new_with_base(self.path) + } + pub fn contents(mut self) -> CheckpointContentsPartFieldPathBuilder { + self.path.push(CheckpointPart::CONTENTS_FIELD.name); + CheckpointContentsPartFieldPathBuilder::new_with_base(self.path) + } + pub fn transactions(mut self) -> ExecutedTransactionFieldPathBuilder { + self.path.push(CheckpointPart::TRANSACTIONS_FIELD.name); + ExecutedTransactionFieldPathBuilder::new_with_base(self.path) + } + pub fn objects(mut self) -> ObjectSetFieldPathBuilder { + self.path.push(CheckpointPart::OBJECTS_FIELD.name); + ObjectSetFieldPathBuilder::new_with_base(self.path) + } + pub fn part_index(mut self) -> String { + self.path.push(CheckpointPart::PART_INDEX_FIELD.name); + self.finish() + } + pub fn is_last(mut self) -> String { + self.path.push(CheckpointPart::IS_LAST_FIELD.name); + self.finish() + } + pub fn first_tx_index(mut self) -> String { + self.path.push(CheckpointPart::FIRST_TX_INDEX_FIELD.name); + self.finish() + } + pub fn total_transactions(mut self) -> String { + self.path.push(CheckpointPart::TOTAL_TRANSACTIONS_FIELD.name); + self.finish() + } + pub fn first_tx_sequence_number(mut self) -> String { + self.path.push(CheckpointPart::FIRST_TX_SEQUENCE_NUMBER_FIELD.name); + self.finish() + } + pub fn objects_continue(mut self) -> String { + self.path.push(CheckpointPart::OBJECTS_CONTINUE_FIELD.name); + self.finish() + } + pub fn continuation_events(mut self) -> EventFieldPathBuilder { + self.path.push(CheckpointPart::CONTINUATION_EVENTS_FIELD.name); + EventFieldPathBuilder::new_with_base(self.path) + } + pub fn events_continue(mut self) -> String { + self.path.push(CheckpointPart::EVENTS_CONTINUE_FIELD.name); + self.finish() + } + } + impl CheckpointContentsPart { + pub const DIGEST_FIELD: &'static MessageField = &MessageField { + name: "digest", + json_name: "digest", + number: 2i32, + message_fields: None, + }; + pub const VERSION_FIELD: &'static MessageField = &MessageField { + name: "version", + json_name: "version", + number: 3i32, + message_fields: None, + }; + pub const TRANSACTIONS_FIELD: &'static MessageField = &MessageField { + name: "transactions", + json_name: "transactions", + number: 4i32, + message_fields: Some(CheckpointedTransactionInfo::FIELDS), + }; + } + impl MessageFields for CheckpointContentsPart { + const FIELDS: &'static [&'static MessageField] = &[ + Self::DIGEST_FIELD, + Self::VERSION_FIELD, + Self::TRANSACTIONS_FIELD, + ]; + } + impl CheckpointContentsPart { + pub fn path_builder() -> CheckpointContentsPartFieldPathBuilder { + CheckpointContentsPartFieldPathBuilder::new() + } + } + pub struct CheckpointContentsPartFieldPathBuilder { + path: Vec<&'static str>, + } + impl CheckpointContentsPartFieldPathBuilder { + #[allow(clippy::new_without_default)] + pub fn new() -> Self { + Self { path: Default::default() } + } + #[doc(hidden)] + pub fn new_with_base(base: Vec<&'static str>) -> Self { + Self { path: base } + } + pub fn finish(self) -> String { + self.path.join(".") + } + pub fn digest(mut self) -> String { + self.path.push(CheckpointContentsPart::DIGEST_FIELD.name); + self.finish() + } + pub fn version(mut self) -> String { + self.path.push(CheckpointContentsPart::VERSION_FIELD.name); + self.finish() + } + pub fn transactions(mut self) -> CheckpointedTransactionInfoFieldPathBuilder { + self.path.push(CheckpointContentsPart::TRANSACTIONS_FIELD.name); + CheckpointedTransactionInfoFieldPathBuilder::new_with_base(self.path) + } + } + impl GetCheckpointPartsRequest { + pub const SEQUENCE_NUMBER_FIELD: &'static MessageField = &MessageField { + name: "sequence_number", + json_name: "sequenceNumber", + number: 1i32, + message_fields: None, + }; + pub const DIGEST_FIELD: &'static MessageField = &MessageField { + name: "digest", + json_name: "digest", + number: 2i32, + message_fields: None, + }; + pub const READ_MASK_FIELD: &'static MessageField = &MessageField { + name: "read_mask", + json_name: "readMask", + number: 3i32, + message_fields: None, + }; + pub const RESUME_TOKEN_FIELD: &'static MessageField = &MessageField { + name: "resume_token", + json_name: "resumeToken", + number: 4i32, + message_fields: None, + }; + } + impl MessageFields for GetCheckpointPartsRequest { + const FIELDS: &'static [&'static MessageField] = &[ + Self::SEQUENCE_NUMBER_FIELD, + Self::DIGEST_FIELD, + Self::READ_MASK_FIELD, + Self::RESUME_TOKEN_FIELD, + ]; + } + impl GetCheckpointPartsRequest { + pub fn path_builder() -> GetCheckpointPartsRequestFieldPathBuilder { + GetCheckpointPartsRequestFieldPathBuilder::new() + } + } + pub struct GetCheckpointPartsRequestFieldPathBuilder { + path: Vec<&'static str>, + } + impl GetCheckpointPartsRequestFieldPathBuilder { + #[allow(clippy::new_without_default)] + pub fn new() -> Self { + Self { path: Default::default() } + } + #[doc(hidden)] + pub fn new_with_base(base: Vec<&'static str>) -> Self { + Self { path: base } + } + pub fn finish(self) -> String { + self.path.join(".") + } + pub fn sequence_number(mut self) -> String { + self.path.push(GetCheckpointPartsRequest::SEQUENCE_NUMBER_FIELD.name); + self.finish() + } + pub fn digest(mut self) -> String { + self.path.push(GetCheckpointPartsRequest::DIGEST_FIELD.name); + self.finish() + } + pub fn read_mask(mut self) -> String { + self.path.push(GetCheckpointPartsRequest::READ_MASK_FIELD.name); + self.finish() + } + pub fn resume_token(mut self) -> String { + self.path.push(GetCheckpointPartsRequest::RESUME_TOKEN_FIELD.name); + self.finish() + } + } + impl GetCheckpointPartsResponse { + pub const PART_FIELD: &'static MessageField = &MessageField { + name: "part", + json_name: "part", + number: 1i32, + message_fields: Some(CheckpointPart::FIELDS), + }; + pub const RESUME_TOKEN_FIELD: &'static MessageField = &MessageField { + name: "resume_token", + json_name: "resumeToken", + number: 2i32, + message_fields: None, + }; + } + impl MessageFields for GetCheckpointPartsResponse { + const FIELDS: &'static [&'static MessageField] = &[ + Self::PART_FIELD, + Self::RESUME_TOKEN_FIELD, + ]; + } + impl GetCheckpointPartsResponse { + pub fn path_builder() -> GetCheckpointPartsResponseFieldPathBuilder { + GetCheckpointPartsResponseFieldPathBuilder::new() + } + } + pub struct GetCheckpointPartsResponseFieldPathBuilder { + path: Vec<&'static str>, + } + impl GetCheckpointPartsResponseFieldPathBuilder { + #[allow(clippy::new_without_default)] + pub fn new() -> Self { + Self { path: Default::default() } + } + #[doc(hidden)] + pub fn new_with_base(base: Vec<&'static str>) -> Self { + Self { path: base } + } + pub fn finish(self) -> String { + self.path.join(".") + } + pub fn part(mut self) -> CheckpointPartFieldPathBuilder { + self.path.push(GetCheckpointPartsResponse::PART_FIELD.name); + CheckpointPartFieldPathBuilder::new_with_base(self.path) + } + pub fn resume_token(mut self) -> String { + self.path.push(GetCheckpointPartsResponse::RESUME_TOKEN_FIELD.name); + self.finish() + } + } + impl ListCheckpointPartsRequest { + pub const READ_MASK_FIELD: &'static MessageField = &MessageField { + name: "read_mask", + json_name: "readMask", + number: 1i32, + message_fields: None, + }; + pub const START_CHECKPOINT_FIELD: &'static MessageField = &MessageField { + name: "start_checkpoint", + json_name: "startCheckpoint", + number: 2i32, + message_fields: None, + }; + pub const END_CHECKPOINT_FIELD: &'static MessageField = &MessageField { + name: "end_checkpoint", + json_name: "endCheckpoint", + number: 3i32, + message_fields: None, + }; + pub const FILTER_FIELD: &'static MessageField = &MessageField { + name: "filter", + json_name: "filter", + number: 4i32, + message_fields: Some(TransactionFilter::FIELDS), + }; + pub const OPTIONS_FIELD: &'static MessageField = &MessageField { + name: "options", + json_name: "options", + number: 5i32, + message_fields: Some(QueryOptions::FIELDS), + }; + pub const RESUME_TOKEN_FIELD: &'static MessageField = &MessageField { + name: "resume_token", + json_name: "resumeToken", + number: 6i32, + message_fields: None, + }; + } + impl MessageFields for ListCheckpointPartsRequest { + const FIELDS: &'static [&'static MessageField] = &[ + Self::READ_MASK_FIELD, + Self::START_CHECKPOINT_FIELD, + Self::END_CHECKPOINT_FIELD, + Self::FILTER_FIELD, + Self::OPTIONS_FIELD, + Self::RESUME_TOKEN_FIELD, + ]; + } + impl ListCheckpointPartsRequest { + pub fn path_builder() -> ListCheckpointPartsRequestFieldPathBuilder { + ListCheckpointPartsRequestFieldPathBuilder::new() + } + } + pub struct ListCheckpointPartsRequestFieldPathBuilder { + path: Vec<&'static str>, + } + impl ListCheckpointPartsRequestFieldPathBuilder { + #[allow(clippy::new_without_default)] + pub fn new() -> Self { + Self { path: Default::default() } + } + #[doc(hidden)] + pub fn new_with_base(base: Vec<&'static str>) -> Self { + Self { path: base } + } + pub fn finish(self) -> String { + self.path.join(".") + } + pub fn read_mask(mut self) -> String { + self.path.push(ListCheckpointPartsRequest::READ_MASK_FIELD.name); + self.finish() + } + pub fn start_checkpoint(mut self) -> String { + self.path.push(ListCheckpointPartsRequest::START_CHECKPOINT_FIELD.name); + self.finish() + } + pub fn end_checkpoint(mut self) -> String { + self.path.push(ListCheckpointPartsRequest::END_CHECKPOINT_FIELD.name); + self.finish() + } + pub fn filter(mut self) -> TransactionFilterFieldPathBuilder { + self.path.push(ListCheckpointPartsRequest::FILTER_FIELD.name); + TransactionFilterFieldPathBuilder::new_with_base(self.path) + } + pub fn options(mut self) -> QueryOptionsFieldPathBuilder { + self.path.push(ListCheckpointPartsRequest::OPTIONS_FIELD.name); + QueryOptionsFieldPathBuilder::new_with_base(self.path) + } + pub fn resume_token(mut self) -> String { + self.path.push(ListCheckpointPartsRequest::RESUME_TOKEN_FIELD.name); + self.finish() + } + } + impl ListCheckpointPartsResponse { + pub const PART_FIELD: &'static MessageField = &MessageField { + name: "part", + json_name: "part", + number: 1i32, + message_fields: Some(CheckpointPart::FIELDS), + }; + pub const WATERMARK_FIELD: &'static MessageField = &MessageField { + name: "watermark", + json_name: "watermark", + number: 2i32, + message_fields: Some(Watermark::FIELDS), + }; + pub const RESUME_TOKEN_FIELD: &'static MessageField = &MessageField { + name: "resume_token", + json_name: "resumeToken", + number: 3i32, + message_fields: None, + }; + pub const END_FIELD: &'static MessageField = &MessageField { + name: "end", + json_name: "end", + number: 4i32, + message_fields: Some(QueryEnd::FIELDS), + }; + } + impl MessageFields for ListCheckpointPartsResponse { + const FIELDS: &'static [&'static MessageField] = &[ + Self::PART_FIELD, + Self::WATERMARK_FIELD, + Self::RESUME_TOKEN_FIELD, + Self::END_FIELD, + ]; + } + impl ListCheckpointPartsResponse { + pub fn path_builder() -> ListCheckpointPartsResponseFieldPathBuilder { + ListCheckpointPartsResponseFieldPathBuilder::new() + } + } + pub struct ListCheckpointPartsResponseFieldPathBuilder { + path: Vec<&'static str>, + } + impl ListCheckpointPartsResponseFieldPathBuilder { + #[allow(clippy::new_without_default)] + pub fn new() -> Self { + Self { path: Default::default() } + } + #[doc(hidden)] + pub fn new_with_base(base: Vec<&'static str>) -> Self { + Self { path: base } + } + pub fn finish(self) -> String { + self.path.join(".") + } + pub fn part(mut self) -> CheckpointPartFieldPathBuilder { + self.path.push(ListCheckpointPartsResponse::PART_FIELD.name); + CheckpointPartFieldPathBuilder::new_with_base(self.path) + } + pub fn watermark(mut self) -> WatermarkFieldPathBuilder { + self.path.push(ListCheckpointPartsResponse::WATERMARK_FIELD.name); + WatermarkFieldPathBuilder::new_with_base(self.path) + } + pub fn resume_token(mut self) -> String { + self.path.push(ListCheckpointPartsResponse::RESUME_TOKEN_FIELD.name); + self.finish() + } + pub fn end(mut self) -> QueryEndFieldPathBuilder { + self.path.push(ListCheckpointPartsResponse::END_FIELD.name); + QueryEndFieldPathBuilder::new_with_base(self.path) + } + } + impl SubscribeCheckpointPartsRequest { + pub const READ_MASK_FIELD: &'static MessageField = &MessageField { + name: "read_mask", + json_name: "readMask", + number: 1i32, + message_fields: None, + }; + pub const FILTER_FIELD: &'static MessageField = &MessageField { + name: "filter", + json_name: "filter", + number: 2i32, + message_fields: Some(TransactionFilter::FIELDS), + }; + } + impl MessageFields for SubscribeCheckpointPartsRequest { + const FIELDS: &'static [&'static MessageField] = &[ + Self::READ_MASK_FIELD, + Self::FILTER_FIELD, + ]; + } + impl SubscribeCheckpointPartsRequest { + pub fn path_builder() -> SubscribeCheckpointPartsRequestFieldPathBuilder { + SubscribeCheckpointPartsRequestFieldPathBuilder::new() + } + } + pub struct SubscribeCheckpointPartsRequestFieldPathBuilder { + path: Vec<&'static str>, + } + impl SubscribeCheckpointPartsRequestFieldPathBuilder { + #[allow(clippy::new_without_default)] + pub fn new() -> Self { + Self { path: Default::default() } + } + #[doc(hidden)] + pub fn new_with_base(base: Vec<&'static str>) -> Self { + Self { path: base } + } + pub fn finish(self) -> String { + self.path.join(".") + } + pub fn read_mask(mut self) -> String { + self.path.push(SubscribeCheckpointPartsRequest::READ_MASK_FIELD.name); + self.finish() + } + pub fn filter(mut self) -> TransactionFilterFieldPathBuilder { + self.path.push(SubscribeCheckpointPartsRequest::FILTER_FIELD.name); + TransactionFilterFieldPathBuilder::new_with_base(self.path) + } + } + impl SubscribeCheckpointPartsResponse { + pub const PART_FIELD: &'static MessageField = &MessageField { + name: "part", + json_name: "part", + number: 1i32, + message_fields: Some(CheckpointPart::FIELDS), + }; + pub const WATERMARK_FIELD: &'static MessageField = &MessageField { + name: "watermark", + json_name: "watermark", + number: 2i32, + message_fields: Some(Watermark::FIELDS), + }; + pub const RESUME_TOKEN_FIELD: &'static MessageField = &MessageField { + name: "resume_token", + json_name: "resumeToken", + number: 3i32, + message_fields: None, + }; + } + impl MessageFields for SubscribeCheckpointPartsResponse { + const FIELDS: &'static [&'static MessageField] = &[ + Self::PART_FIELD, + Self::WATERMARK_FIELD, + Self::RESUME_TOKEN_FIELD, + ]; + } + impl SubscribeCheckpointPartsResponse { + pub fn path_builder() -> SubscribeCheckpointPartsResponseFieldPathBuilder { + SubscribeCheckpointPartsResponseFieldPathBuilder::new() + } + } + pub struct SubscribeCheckpointPartsResponseFieldPathBuilder { + path: Vec<&'static str>, + } + impl SubscribeCheckpointPartsResponseFieldPathBuilder { + #[allow(clippy::new_without_default)] + pub fn new() -> Self { + Self { path: Default::default() } + } + #[doc(hidden)] + pub fn new_with_base(base: Vec<&'static str>) -> Self { + Self { path: base } + } + pub fn finish(self) -> String { + self.path.join(".") + } + pub fn part(mut self) -> CheckpointPartFieldPathBuilder { + self.path.push(SubscribeCheckpointPartsResponse::PART_FIELD.name); + CheckpointPartFieldPathBuilder::new_with_base(self.path) + } + pub fn watermark(mut self) -> WatermarkFieldPathBuilder { + self.path.push(SubscribeCheckpointPartsResponse::WATERMARK_FIELD.name); + WatermarkFieldPathBuilder::new_with_base(self.path) + } + pub fn resume_token(mut self) -> String { + self.path.push(SubscribeCheckpointPartsResponse::RESUME_TOKEN_FIELD.name); + self.finish() + } + } +} diff --git a/crates/sui-rpc/src/proto/generated/sui.rpc.v2beta.rs b/crates/sui-rpc/src/proto/generated/sui.rpc.v2beta.rs new file mode 100644 index 0000000000..57039d9d08 --- /dev/null +++ b/crates/sui-rpc/src/proto/generated/sui.rpc.v2beta.rs @@ -0,0 +1,1283 @@ +// This file is @generated by prost-build. +/// One part of a checkpoint, delivered by the streaming checkpoint parts RPCs. +/// +/// The server splits each checkpoint into a sequence of parts, each aimed at a +/// bounded target size of a few MiB. A part packs as many consecutive complete +/// transactions as fit within the target, each with its `contents` entry and +/// its objects. Most checkpoints fit in one part, with `part_index` 0 and +/// `is_last` set. A part that carries a single large object can exceed the +/// target by far (tens of MiB), and even a part within the target can exceed +/// the 4 MiB default receive limit of common gRPC clients, so set the client's +/// maximum receive message size well above it (for example, 128 MiB). +/// +/// Field names and numbers 1-7 match `sui.rpc.v2.Checkpoint`, and the fields +/// of the nested `CheckpointContentsPart` match `sui.rpc.v2.CheckpointContents`. +/// `read_mask` paths over them work as they do for `Checkpoint`, except for +/// the monolithic BCS fields, which parts never carry: +/// +/// * `transactions.events.bcs` is never returned. Masks that reach it only +/// through a parent path (`*`, `transactions`, `transactions.events`) +/// succeed and omit it; a mask that names it explicitly fails with +/// `INVALID_ARGUMENT`. +/// * `CheckpointContentsPart` has no `bcs` field, so `contents` and `*` +/// select its other fields, and a mask naming `contents.bcs` fails with +/// `INVALID_ARGUMENT`. +/// +/// `sequence_number` and the framing fields (8-15) are not subject to +/// `read_mask`: they are populated whenever they apply. +/// +/// Ordering: the parts of a checkpoint arrive in ascending `part_index` order +/// (0, 1, ...), and `transactions` and `contents.transactions` arrive across +/// those parts in the order the checkpoint lists them, even when +/// `ListCheckpointParts` lists checkpoints in `ORDERING_DESCENDING`. Fields +/// that describe the whole checkpoint (`digest`, `summary`, `signature`, +/// `total_transactions`, `first_tx_sequence_number`, `contents.version` and +/// `contents.digest`) are set only on part 0. +/// +/// Transactions too large for one part: every part is either a batch of +/// complete transactions, or one part of a sequence that carries a single +/// transaction too large for one part, never both. Only a transaction whose +/// own events or objects do not fit in one part is sent this way: +/// +/// * The transactions before it are sent in an earlier part, so the part that +/// starts it has exactly one entry in `transactions` (when `read_mask` +/// selects `transactions`). +/// * The continuation parts after it carry no `transactions` and no +/// `contents`, only the rest of its events or objects, as described below. +/// * Once it is complete, the transactions after it are again packed together +/// into batches, starting in a new part. +/// +/// The rest of that transaction's events and objects continue as follows: +/// +/// * If its events continue (`events_continue`), the following parts carry +/// the rest of its events in `continuation_events`, in emission order, until +/// a part sets `events_continue` to false. +/// * If its objects continue (`objects_continue`), the following parts carry +/// the rest of its objects in `objects`, in (`object_id`, `version`) order, +/// until a part sets `objects_continue` to false. +/// +/// When both continue, all of its events are sent before any of its objects: +/// `objects` stays empty on every part of the transaction while +/// `events_continue` is true, and its objects follow once its events are +/// complete. +#[non_exhaustive] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CheckpointPart { + /// The height of this checkpoint. Set on every part. + #[prost(uint64, optional, tag = "1")] + pub sequence_number: ::core::option::Option, + /// The digest of this checkpoint's `CheckpointSummary`. Set on part 0 when + /// requested. + #[prost(string, optional, tag = "2")] + pub digest: ::core::option::Option<::prost::alloc::string::String>, + /// The `CheckpointSummary` for this checkpoint. Set on part 0 when + /// requested. + #[prost(message, optional, tag = "3")] + pub summary: ::core::option::Option, + /// An aggregated quorum signature from the validator committee that + /// certified this checkpoint. Set on part 0 when requested. Unset when a + /// validator streams checkpoints it has built locally but that are not yet + /// certified. + #[prost(message, optional, tag = "4")] + pub signature: ::core::option::Option, + /// The slice of this checkpoint's `CheckpointContents` that covers the same + /// transactions as this part, starting at `first_tx_index`. + #[prost(message, optional, tag = "5")] + pub contents: ::core::option::Option, + /// A contiguous slice of this checkpoint's transactions, in the order the + /// checkpoint lists them: the entry at position `i` is the transaction at + /// checkpoint-local index `first_tx_index + i`, which is also the value of + /// its `transaction_index` when requested. + /// + /// `transactions.events.bcs` is never returned (see `CheckpointPart`); + /// request `transactions.events.events`, and `transactions.events.digest` + /// to verify them. `transactions.objects` is never populated: objects are + /// delivered, deduplicated, in `objects`. + /// + /// A request for both `contents` and `transactions` can leave + /// `transactions.signatures` out of `read_mask` and read the user signatures + /// from `contents.transactions.signatures.bcs`, so that each signature is + /// sent once, in one form. + #[prost(message, repeated, tag = "6")] + pub transactions: ::prost::alloc::vec::Vec, + /// The set of objects referenced as inputs or produced as outputs by this + /// part's transactions, or, on a part that continues a transaction's + /// objects, the next of that transaction's objects. Objects are + /// deduplicated within a part, in (`object_id`, `version`) order; an object + /// used by transactions in different parts can appear in each of them. + /// + /// A request for `objects` without `transactions` still receives parts that + /// each cover a contiguous range of the checkpoint's transactions; to tell + /// which transactions a part's objects belong to, also request + /// `transactions.digest`. + #[prost(message, optional, tag = "7")] + pub objects: ::core::option::Option, + /// Zero-based index of this part within the checkpoint. Set on every part. + #[prost(uint32, optional, tag = "8")] + pub part_index: ::core::option::Option, + /// True on the last part of the checkpoint and false on every part before + /// it. Never true while `events_continue` or `objects_continue` is true. Set + /// on every part. + #[prost(bool, optional, tag = "9")] + pub is_last: ::core::option::Option, + /// Zero-based checkpoint-local index of the first transaction in + /// `transactions` and `contents.transactions`. Set when either is + /// non-empty; unset on parts that carry neither, such as continuation + /// parts, parts that carry only checkpoint-level fields, and the single + /// part of a checkpoint with no transactions. + #[prost(uint64, optional, tag = "10")] + pub first_tx_index: ::core::option::Option, + /// Total number of transactions in the checkpoint. Set on part 0. + #[prost(uint64, optional, tag = "11")] + pub total_transactions: ::core::option::Option, + /// Global sequence number of the checkpoint's first transaction (index 0), + /// equal to `summary.total_network_transactions - total_transactions`. Set + /// on part 0. + #[prost(uint64, optional, tag = "12")] + pub first_tx_sequence_number: ::core::option::Option, + /// True when more objects of the transaction this part carries or continues + /// follow in the next parts (see `CheckpointPart`). It is reliable only on + /// parts where `events_continue` is false: while a transaction's events + /// still continue, it may be false even though the transaction's objects + /// follow its events. + #[prost(bool, optional, tag = "13")] + pub objects_continue: ::core::option::Option, + /// The next events of the transaction whose events continue from an earlier + /// part (see `events_continue`), in emission order. Set only on parts that + /// continue a transaction's events, which carry no `transactions` and no + /// `contents`. Its events carry the fields that `read_mask` selects under + /// `transactions.events.events`; events continue only when the mask selects + /// transaction events. + #[prost(message, repeated, tag = "14")] + pub continuation_events: ::prost::alloc::vec::Vec, + /// True when more events of the transaction this part carries or continues + /// follow in the next parts, in `continuation_events` (see + /// `CheckpointPart`). + #[prost(bool, optional, tag = "15")] + pub events_continue: ::core::option::Option, +} +/// The slice of a checkpoint's `CheckpointContents` that one `CheckpointPart` +/// carries. +#[non_exhaustive] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CheckpointContentsPart { + /// The digest of the checkpoint's whole `CheckpointContents`, equal to + /// `summary.content_digest`. Set on part 0 when requested. + #[prost(string, optional, tag = "2")] + pub digest: ::core::option::Option<::prost::alloc::string::String>, + /// Version of the checkpoint's `CheckpointContents` (1 or 2). Set on part 0 + /// whenever any `contents` field is requested. + #[prost(int32, optional, tag = "3")] + pub version: ::core::option::Option, + /// The entries for this part's transactions, in checkpoint order: the entry + /// at position `i` is for the transaction at checkpoint-local index + /// `CheckpointPart.first_tx_index + i`. + /// + /// Sub-paths of `signatures` in `read_mask` select which forms of each + /// signature are returned; for example, `contents.transactions.signatures.bcs` + /// returns only the BCS form. + #[prost(message, repeated, tag = "4")] + pub transactions: ::prost::alloc::vec::Vec, +} +/// Request message for LedgerService.GetCheckpointParts. +/// +/// A server that prunes history refuses a checkpoint below its lowest +/// available checkpoint with `OUT_OF_RANGE` and reason +/// `BELOW_EARLIEST_AVAILABLE`, as `sui.rpc.v2.LedgerService.GetCheckpoint` +/// does. A stream whose checkpoint is pruned while it is being sent fails the +/// same way. +#[non_exhaustive] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct GetCheckpointPartsRequest { + /// Mask specifying which `CheckpointPart` fields to read. + /// If no mask is specified, defaults to `sequence_number,digest`. + /// A mask naming `transactions.events.bcs` or `contents.bcs` fails with + /// `INVALID_ARGUMENT` (see `CheckpointPart`). + #[prost(message, optional, tag = "3")] + pub read_mask: ::core::option::Option<::prost_types::FieldMask>, + /// Optional. A `resume_token` from an earlier `GetCheckpointPartsResponse`, + /// `ListCheckpointPartsResponse` or `SubscribeCheckpointPartsResponse`, to + /// continue from the point where that token's frame left off (see + /// `checkpoint_id`). Resume with the same `read_mask` as the stream the + /// token came from: a mask that does not select what the token resumes + /// partway through fails with `INVALID_ARGUMENT`. + /// + /// When the stream resumes after part 0, the fields set only on part 0 + /// (`digest`, `summary`, `signature`, `total_transactions`, + /// `first_tx_sequence_number`, `contents.version` and `contents.digest`) are + /// not sent again; keep them from the earlier stream. + #[prost(bytes = "bytes", optional, tag = "4")] + pub resume_token: ::core::option::Option<::prost::bytes::Bytes>, + /// The checkpoint to read, looked up as by + /// `sui.rpc.v2.GetCheckpointRequest`. If neither is provided, the latest + /// checkpoint, unless `resume_token` is set: then the checkpoint the token + /// resumes in. A token from a part that is not the last of its checkpoint + /// resumes in that checkpoint. A token from a checkpoint's last part, or + /// from a frame without a part, resumes at the start of the next checkpoint + /// in its stream's direction, whether or not that checkpoint matches the + /// stream's filter. When both this and `resume_token` are set, they must + /// name the same checkpoint, or the request fails with `INVALID_ARGUMENT`. + #[prost(oneof = "get_checkpoint_parts_request::CheckpointId", tags = "1, 2")] + pub checkpoint_id: ::core::option::Option< + get_checkpoint_parts_request::CheckpointId, + >, +} +/// Nested message and enum types in `GetCheckpointPartsRequest`. +pub mod get_checkpoint_parts_request { + /// The checkpoint to read, looked up as by + /// `sui.rpc.v2.GetCheckpointRequest`. If neither is provided, the latest + /// checkpoint, unless `resume_token` is set: then the checkpoint the token + /// resumes in. A token from a part that is not the last of its checkpoint + /// resumes in that checkpoint. A token from a checkpoint's last part, or + /// from a frame without a part, resumes at the start of the next checkpoint + /// in its stream's direction, whether or not that checkpoint matches the + /// stream's filter. When both this and `resume_token` are set, they must + /// name the same checkpoint, or the request fails with `INVALID_ARGUMENT`. + #[non_exhaustive] + #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)] + pub enum CheckpointId { + /// The sequence number of the requested checkpoint. + #[prost(uint64, tag = "1")] + SequenceNumber(u64), + /// The digest of the requested checkpoint. + #[prost(string, tag = "2")] + Digest(::prost::alloc::string::String), + } +} +/// Response message for LedgerService.GetCheckpointParts. +#[non_exhaustive] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetCheckpointPartsResponse { + /// One part of the requested checkpoint. + #[prost(message, optional, tag = "1")] + pub part: ::core::option::Option, + /// Token to resume reading after this part. Set on every part except the + /// last (`is_last` true), after which nothing remains to resume. + #[prost(bytes = "bytes", optional, tag = "2")] + pub resume_token: ::core::option::Option<::prost::bytes::Bytes>, +} +/// Request message for LedgerService.ListCheckpointParts. +/// +/// Range, cursor, pruning and indexed-tip rules follow +/// `sui.rpc.v2.ListCheckpointsRequest`; see `sui.rpc.v2.ErrorReason` +/// `ABOVE_LATEST_AVAILABLE` and `BELOW_EARLIEST_AVAILABLE`. +#[non_exhaustive] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ListCheckpointPartsRequest { + /// Mask specifying which `CheckpointPart` fields to read. + /// If no mask is specified, defaults to `sequence_number,digest`. + /// A mask naming `transactions.events.bcs` or `contents.bcs` fails with + /// `INVALID_ARGUMENT` (see `CheckpointPart`). + #[prost(message, optional, tag = "1")] + pub read_mask: ::core::option::Option<::prost_types::FieldMask>, + /// Optional. Start of the checkpoint range to query (inclusive). Defaults to + /// genesis. + #[prost(uint64, optional, tag = "2")] + pub start_checkpoint: ::core::option::Option, + /// Optional. End of the checkpoint range to query (exclusive). Defaults to + /// the current indexed ledger tip. + #[prost(uint64, optional, tag = "3")] + pub end_checkpoint: ::core::option::Option, + /// Optional. DNF filter over indexed transaction dimensions. A checkpoint + /// matches if any transaction it contains satisfies the filter, and every + /// part of a matching checkpoint is returned. If absent, all checkpoints in + /// the range are returned. + /// + /// A `resume_token` that resumes in the middle of a checkpoint must name a + /// checkpoint that matches the filter, or the request fails with + /// `INVALID_ARGUMENT`. That checkpoint counts toward `options.limit` like + /// any other. + #[prost(message, optional, tag = "4")] + pub filter: ::core::option::Option, + /// Optional cursor-bounded query options, as for + /// `sui.rpc.v2.ListCheckpointsRequest.options`. The items are checkpoints: + /// `after` and `before` are checkpoint cursors interchangeable with those of + /// `ListCheckpoints`, and `limit` counts complete checkpoints, so a listing + /// never ends partway through a checkpoint. If unspecified, reads in + /// ascending order with the default item limit. The server enforces a + /// maximum item limit and silently coerces larger values down to it. To + /// paginate, pass the last received `Watermark.cursor` as `options.after` + /// (ascending) or `options.before` (descending) on the next request. + #[prost(message, optional, tag = "5")] + pub options: ::core::option::Option, + /// Optional. A `resume_token` from an earlier `ListCheckpointPartsResponse` + /// or `SubscribeCheckpointPartsResponse`, to continue from exactly where + /// that frame left off: at the next checkpoint, or at the next part of a + /// checkpoint it was partway through. Resume with the same `read_mask`, + /// `filter` and `options.ordering` as the stream the token came from (see + /// `GetCheckpointPartsRequest.resume_token`). + /// + /// A token takes the place of the start bound in the listing's direction: + /// a request that sets both `resume_token` and `options.after` when + /// ascending, or `options.before` when descending, fails with + /// `INVALID_ARGUMENT`. The far cursor bound and the checkpoint range still + /// apply. The request also fails with `INVALID_ARGUMENT` when the token was + /// issued for the other ordering, or when it resumes partway through a + /// checkpoint outside the request's bounds. A descending request whose + /// token names a checkpoint above the latest indexed checkpoint fails with + /// `OUT_OF_RANGE` and reason `ABOVE_LATEST_AVAILABLE` (bound "cursor"). + /// + /// When the stream resumes partway through a checkpoint, the fields set + /// only on part 0 are not sent again (see + /// `GetCheckpointPartsRequest.resume_token`). + #[prost(bytes = "bytes", optional, tag = "6")] + pub resume_token: ::core::option::Option<::prost::bytes::Bytes>, +} +/// Response message for LedgerService.ListCheckpointParts. +/// +/// Every frame carries a `watermark` and a `resume_token`. A frame with +/// `part` set delivers one part of a matching checkpoint; a frame without it +/// reports scan progress or terminal completion. Watermarks never regress in +/// the requested ordering but may repeat. +/// +/// `end` is set exactly once, on the final frame of a successful stream. For +/// `QUERY_END_REASON_ITEM_LIMIT`, that frame also carries the last part (with +/// `is_last` set) of the final checkpoint. For every other end reason, the +/// final frame has no `part`. +#[non_exhaustive] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ListCheckpointPartsResponse { + /// One part of a matching checkpoint. Unset on frames that only report + /// progress or the end of the stream. + #[prost(message, optional, tag = "1")] + pub part: ::core::option::Option, + /// Progress watermark as of this frame, at checkpoint granularity, with the + /// semantics of `sui.rpc.v2.ListCheckpointsResponse.watermark`. Present on + /// every frame. While a checkpoint's parts are being sent, the watermark + /// stays at the resume point from before that checkpoint's first part, so + /// resuming from it reads the whole checkpoint again. On the frame carrying + /// the checkpoint's last part (`is_last` true) it moves past the checkpoint + /// in the listing's direction. Frames without a `part` move it past + /// checkpoints that do not match. + #[prost(message, optional, tag = "2")] + pub watermark: ::core::option::Option, + /// Token to resume the listing right after this frame. Present on every + /// frame. + /// + /// A token from a frame whose `part` is not the last of its checkpoint + /// resumes partway through that checkpoint, and the resumed stream does not + /// resend the fields set only on part 0. Use such a token to reconnect a + /// broken stream while still holding what it delivered. To record a restart + /// point that does not depend on earlier parts, keep only tokens from + /// frames whose `part` has `is_last` set, or that carry no `part`. + /// + /// When an ascending request's `resume_token` names a checkpoint above the + /// latest indexed checkpoint, the stream's only frame has no `part`, ends + /// the stream with `QUERY_END_REASON_LEDGER_TIP`, and returns the request's + /// `resume_token` unchanged, so the same request can be retried later. + #[prost(bytes = "bytes", optional, tag = "3")] + pub resume_token: ::core::option::Option<::prost::bytes::Bytes>, + /// Set exactly once, on the final frame of a successful query stream. + #[prost(message, optional, tag = "4")] + pub end: ::core::option::Option, +} +/// Generated client implementations. +pub mod ledger_service_client { + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] + use tonic::codegen::*; + use tonic::codegen::http::Uri; + /// Streaming reads of checkpoints split into bounded-size parts. + /// + /// These RPCs serve the same checkpoints as `sui.rpc.v2.LedgerService` + /// `GetCheckpoint` and `ListCheckpoints`, but deliver each checkpoint as a + /// sequence of `CheckpointPart` messages, so a checkpoint too large for one + /// message can still be read (see `sui.rpc.v2.ErrorReason.RESPONSE_TOO_LARGE` + /// and, for client receive limits, `CheckpointPart`). + /// + /// Two kinds of resume point: + /// + /// * Checkpoint cursors (`Watermark.cursor`, passed back in `QueryOptions`) + /// work at checkpoint granularity and are interchangeable with those of + /// `sui.rpc.v2.LedgerService.ListCheckpoints`. Use them to page through + /// checkpoints. + /// * `resume_token` marks the point a frame left off: either the start of + /// the next checkpoint, or the next part of a checkpoint the stream was + /// partway through, so a client whose stream breaks mid-checkpoint can + /// continue from the next part instead of starting the checkpoint over. + /// Tokens are opaque: pass them back unchanged and never inspect or compare + /// them. + #[derive(Debug, Clone)] + pub struct LedgerServiceClient { + inner: tonic::client::Grpc, + } + impl LedgerServiceClient { + /// 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 LedgerServiceClient + where + T: tonic::client::GrpcService, + T::Error: Into, + T::ResponseBody: Body + std::marker::Send + 'static, + ::Error: Into + std::marker::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, + ) -> LedgerServiceClient> + where + F: tonic::service::Interceptor, + T::ResponseBody: Default, + T: tonic::codegen::Service< + http::Request, + Response = http::Response< + >::ResponseBody, + >, + >, + , + >>::Error: Into + std::marker::Send + std::marker::Sync, + { + LedgerServiceClient::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 + } + /// Get one checkpoint as a stream of parts. + /// + /// The stream sends the checkpoint's parts in order and ends after the part + /// with `is_last` set. + pub async fn get_checkpoint_parts( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response>, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic_prost::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/sui.rpc.v2beta.LedgerService/GetCheckpointParts", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new("sui.rpc.v2beta.LedgerService", "GetCheckpointParts"), + ); + self.inner.server_streaming(req, path, codec).await + } + /// List checkpoints matching the provided filters, each as a stream of + /// parts. + /// + /// Checkpoints are returned in ascending or descending checkpoint sequence + /// number order according to the query options ordering; the parts of each + /// checkpoint are always sent in ascending `part_index` order, one + /// checkpoint at a time. A checkpoint matches if any transaction it contains + /// satisfies the filter, and every part of a matching checkpoint is sent. + pub async fn list_checkpoint_parts( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response>, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic_prost::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/sui.rpc.v2beta.LedgerService/ListCheckpointParts", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "sui.rpc.v2beta.LedgerService", + "ListCheckpointParts", + ), + ); + self.inner.server_streaming(req, path, codec).await + } + } +} +/// Generated server implementations. +pub mod ledger_service_server { + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] + use tonic::codegen::*; + /// Generated trait containing gRPC methods that should be implemented for use with LedgerServiceServer. + #[async_trait] + pub trait LedgerService: std::marker::Send + std::marker::Sync + 'static { + /// Get one checkpoint as a stream of parts. + /// + /// The stream sends the checkpoint's parts in order and ends after the part + /// with `is_last` set. + async fn get_checkpoint_parts( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response>, + tonic::Status, + > { + Err(tonic::Status::unimplemented("Not yet implemented")) + } + /// List checkpoints matching the provided filters, each as a stream of + /// parts. + /// + /// Checkpoints are returned in ascending or descending checkpoint sequence + /// number order according to the query options ordering; the parts of each + /// checkpoint are always sent in ascending `part_index` order, one + /// checkpoint at a time. A checkpoint matches if any transaction it contains + /// satisfies the filter, and every part of a matching checkpoint is sent. + async fn list_checkpoint_parts( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response>, + tonic::Status, + > { + Err(tonic::Status::unimplemented("Not yet implemented")) + } + } + /// Streaming reads of checkpoints split into bounded-size parts. + /// + /// These RPCs serve the same checkpoints as `sui.rpc.v2.LedgerService` + /// `GetCheckpoint` and `ListCheckpoints`, but deliver each checkpoint as a + /// sequence of `CheckpointPart` messages, so a checkpoint too large for one + /// message can still be read (see `sui.rpc.v2.ErrorReason.RESPONSE_TOO_LARGE` + /// and, for client receive limits, `CheckpointPart`). + /// + /// Two kinds of resume point: + /// + /// * Checkpoint cursors (`Watermark.cursor`, passed back in `QueryOptions`) + /// work at checkpoint granularity and are interchangeable with those of + /// `sui.rpc.v2.LedgerService.ListCheckpoints`. Use them to page through + /// checkpoints. + /// * `resume_token` marks the point a frame left off: either the start of + /// the next checkpoint, or the next part of a checkpoint the stream was + /// partway through, so a client whose stream breaks mid-checkpoint can + /// continue from the next part instead of starting the checkpoint over. + /// Tokens are opaque: pass them back unchanged and never inspect or compare + /// them. + #[derive(Debug)] + pub struct LedgerServiceServer { + inner: Arc, + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, + } + impl LedgerServiceServer { + pub fn new(inner: T) -> Self { + Self::from_arc(Arc::new(inner)) + } + pub fn from_arc(inner: Arc) -> Self { + 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 LedgerServiceServer + where + T: LedgerService, + B: Body + std::marker::Send + 'static, + B::Error: Into + std::marker::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 { + match req.uri().path() { + "/sui.rpc.v2beta.LedgerService/GetCheckpointParts" => { + #[allow(non_camel_case_types)] + struct GetCheckpointPartsSvc(pub Arc); + impl< + T: LedgerService, + > tonic::server::ServerStreamingService< + super::GetCheckpointPartsRequest, + > for GetCheckpointPartsSvc { + type Response = super::GetCheckpointPartsResponse; + type ResponseStream = BoxStream< + super::GetCheckpointPartsResponse, + >; + 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 { + ::get_checkpoint_parts(&inner, 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 method = GetCheckpointPartsSvc(inner); + let codec = tonic_prost::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.server_streaming(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/sui.rpc.v2beta.LedgerService/ListCheckpointParts" => { + #[allow(non_camel_case_types)] + struct ListCheckpointPartsSvc(pub Arc); + impl< + T: LedgerService, + > tonic::server::ServerStreamingService< + super::ListCheckpointPartsRequest, + > for ListCheckpointPartsSvc { + type Response = super::ListCheckpointPartsResponse; + type ResponseStream = BoxStream< + super::ListCheckpointPartsResponse, + >; + 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 { + ::list_checkpoint_parts(&inner, 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 method = ListCheckpointPartsSvc(inner); + let codec = tonic_prost::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.server_streaming(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + _ => { + Box::pin(async move { + let mut response = http::Response::new( + tonic::body::Body::default(), + ); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) + }) + } + } + } + } + impl Clone for LedgerServiceServer { + 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, + } + } + } + /// Generated gRPC service name + pub const SERVICE_NAME: &str = "sui.rpc.v2beta.LedgerService"; + impl tonic::server::NamedService for LedgerServiceServer { + const NAME: &'static str = SERVICE_NAME; + } +} +/// Request message for SubscriptionService.SubscribeCheckpointParts. +#[non_exhaustive] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SubscribeCheckpointPartsRequest { + /// Mask specifying which `CheckpointPart` fields to read. + /// If no mask is specified, defaults to `sequence_number,digest`. + /// A mask naming `transactions.events.bcs` or `contents.bcs` fails with + /// `INVALID_ARGUMENT` (see `CheckpointPart`). + #[prost(message, optional, tag = "1")] + pub read_mask: ::core::option::Option<::prost_types::FieldMask>, + /// Optional. DNF filter over indexed transaction dimensions, as for + /// `sui.rpc.v2.SubscribeCheckpointsRequest.filter`. A checkpoint matches if + /// any transaction it contains satisfies the filter, and every part of a + /// matching checkpoint is streamed. If absent, every checkpoint is + /// streamed. + #[prost(message, optional, tag = "2")] + pub filter: ::core::option::Option, +} +/// Response message for SubscriptionService.SubscribeCheckpointParts. +/// +/// Mirrors `LedgerService.ListCheckpointPartsResponse`, except there is no +/// `end` field: a subscription stream has no successful end. As on the other +/// filtered subscriptions, the first frame of a filtered stream carries no +/// `part` and establishes the stream's start position, and frames without a +/// `part` keep reporting progress while no checkpoint matches. +#[non_exhaustive] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SubscribeCheckpointPartsResponse { + /// One part of a matching checkpoint. Unset on frames that only report + /// progress. + #[prost(message, optional, tag = "1")] + pub part: ::core::option::Option, + /// Progress watermark as of this frame, with the semantics of + /// `ListCheckpointPartsResponse.watermark`. Present on every frame. + #[prost(message, optional, tag = "2")] + pub watermark: ::core::option::Option, + /// Token to resume right after this frame, in the same format as + /// `ListCheckpointPartsResponse.resume_token`. Present on every frame. Pass + /// it as `ListCheckpointPartsRequest.resume_token` to replay what a broken + /// subscription missed, or as `GetCheckpointPartsRequest.resume_token` to + /// finish a checkpoint it was partway through without reading that + /// checkpoint again from part 0 (see the recovery steps on + /// `SubscriptionService`). + #[prost(bytes = "bytes", optional, tag = "3")] + pub resume_token: ::core::option::Option<::prost::bytes::Bytes>, +} +/// Generated client implementations. +pub mod subscription_service_client { + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] + use tonic::codegen::*; + use tonic::codegen::http::Uri; + /// Real-time streams of checkpoints split into bounded-size parts. + /// + /// `SubscribeCheckpointParts` pairs with `LedgerService.ListCheckpointParts` + /// in this package as `sui.rpc.v2.SubscriptionService.SubscribeCheckpoints` + /// pairs with `sui.rpc.v2.LedgerService.ListCheckpoints`: it takes the same + /// filter, and its frames carry the same part, watermark and `resume_token` + /// shapes. Like the other subscriptions it starts at the current tip of the + /// chain as seen by the server, behaves like an unbounded ascending scan, and + /// has no successful end. + /// + /// A subscription cannot be resumed, but `ListCheckpointParts` and + /// `GetCheckpointParts` can continue from its `resume_token`s. To recover + /// after a broken subscription: + /// + /// 1. Open a new subscription and read its first frame. Its starting + /// checkpoint is `part.sequence_number` if the frame carries a `part`, and + /// `watermark.cursor_position.checkpoint` otherwise. + /// 1. If the new subscription starts at or before the last checkpoint the old + /// one reached, for example on a replica that lags behind, skip the new + /// subscription's frames for checkpoints the old one delivered in full + /// (through its last `part` with `is_last` set). If the old subscription + /// was partway through a checkpoint (its last `part` did not have + /// `is_last` set), either discard that incomplete checkpoint and read it + /// again from part 0 on the new subscription, or finish it with + /// `GetCheckpointParts` and the last `resume_token` received, then skip + /// that checkpoint's frames on the new subscription too. + /// 1. Otherwise, replay the gap with `ListCheckpointParts`, passing the last + /// `resume_token` received, the subscription's `read_mask` and `filter`, + /// and `end_checkpoint` set to the new subscription's starting checkpoint. + /// Repeat the listing with the last `resume_token` it returned until it + /// ends with `QUERY_END_REASON_CHECKPOINT_BOUND`; any other end reason + /// means part of the gap remains, for example + /// `QUERY_END_REASON_LEDGER_TIP` while the indexed tip trails the + /// subscription, or `QUERY_END_REASON_ITEM_LIMIT` on a gap longer than one + /// listing returns. Then continue with the new subscription's frames, + /// starting with the first. + #[derive(Debug, Clone)] + pub struct SubscriptionServiceClient { + inner: tonic::client::Grpc, + } + impl SubscriptionServiceClient { + /// 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 SubscriptionServiceClient + where + T: tonic::client::GrpcService, + T::Error: Into, + T::ResponseBody: Body + std::marker::Send + 'static, + ::Error: Into + std::marker::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, + ) -> SubscriptionServiceClient> + where + F: tonic::service::Interceptor, + T::ResponseBody: Default, + T: tonic::codegen::Service< + http::Request, + Response = http::Response< + >::ResponseBody, + >, + >, + , + >>::Error: Into + std::marker::Send + std::marker::Sync, + { + SubscriptionServiceClient::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 + } + /// Subscribe to the stream of checkpoints, each as a sequence of parts. + /// + /// The stream begins at the latest executed checkpoint as seen by the + /// server and yields every part of each checkpoint matching the filter as + /// it is executed. A checkpoint matches if any transaction it contains + /// satisfies the filter. + pub async fn subscribe_checkpoint_parts( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response< + tonic::codec::Streaming, + >, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic_prost::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/sui.rpc.v2beta.SubscriptionService/SubscribeCheckpointParts", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "sui.rpc.v2beta.SubscriptionService", + "SubscribeCheckpointParts", + ), + ); + self.inner.server_streaming(req, path, codec).await + } + } +} +/// Generated server implementations. +pub mod subscription_service_server { + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] + use tonic::codegen::*; + /// Generated trait containing gRPC methods that should be implemented for use with SubscriptionServiceServer. + #[async_trait] + pub trait SubscriptionService: std::marker::Send + std::marker::Sync + 'static { + /// Subscribe to the stream of checkpoints, each as a sequence of parts. + /// + /// The stream begins at the latest executed checkpoint as seen by the + /// server and yields every part of each checkpoint matching the filter as + /// it is executed. A checkpoint matches if any transaction it contains + /// satisfies the filter. + async fn subscribe_checkpoint_parts( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response>, + tonic::Status, + > { + Err(tonic::Status::unimplemented("Not yet implemented")) + } + } + /// Real-time streams of checkpoints split into bounded-size parts. + /// + /// `SubscribeCheckpointParts` pairs with `LedgerService.ListCheckpointParts` + /// in this package as `sui.rpc.v2.SubscriptionService.SubscribeCheckpoints` + /// pairs with `sui.rpc.v2.LedgerService.ListCheckpoints`: it takes the same + /// filter, and its frames carry the same part, watermark and `resume_token` + /// shapes. Like the other subscriptions it starts at the current tip of the + /// chain as seen by the server, behaves like an unbounded ascending scan, and + /// has no successful end. + /// + /// A subscription cannot be resumed, but `ListCheckpointParts` and + /// `GetCheckpointParts` can continue from its `resume_token`s. To recover + /// after a broken subscription: + /// + /// 1. Open a new subscription and read its first frame. Its starting + /// checkpoint is `part.sequence_number` if the frame carries a `part`, and + /// `watermark.cursor_position.checkpoint` otherwise. + /// 1. If the new subscription starts at or before the last checkpoint the old + /// one reached, for example on a replica that lags behind, skip the new + /// subscription's frames for checkpoints the old one delivered in full + /// (through its last `part` with `is_last` set). If the old subscription + /// was partway through a checkpoint (its last `part` did not have + /// `is_last` set), either discard that incomplete checkpoint and read it + /// again from part 0 on the new subscription, or finish it with + /// `GetCheckpointParts` and the last `resume_token` received, then skip + /// that checkpoint's frames on the new subscription too. + /// 1. Otherwise, replay the gap with `ListCheckpointParts`, passing the last + /// `resume_token` received, the subscription's `read_mask` and `filter`, + /// and `end_checkpoint` set to the new subscription's starting checkpoint. + /// Repeat the listing with the last `resume_token` it returned until it + /// ends with `QUERY_END_REASON_CHECKPOINT_BOUND`; any other end reason + /// means part of the gap remains, for example + /// `QUERY_END_REASON_LEDGER_TIP` while the indexed tip trails the + /// subscription, or `QUERY_END_REASON_ITEM_LIMIT` on a gap longer than one + /// listing returns. Then continue with the new subscription's frames, + /// starting with the first. + #[derive(Debug)] + pub struct SubscriptionServiceServer { + inner: Arc, + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, + } + impl SubscriptionServiceServer { + pub fn new(inner: T) -> Self { + Self::from_arc(Arc::new(inner)) + } + pub fn from_arc(inner: Arc) -> Self { + 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 SubscriptionServiceServer + where + T: SubscriptionService, + B: Body + std::marker::Send + 'static, + B::Error: Into + std::marker::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 { + match req.uri().path() { + "/sui.rpc.v2beta.SubscriptionService/SubscribeCheckpointParts" => { + #[allow(non_camel_case_types)] + struct SubscribeCheckpointPartsSvc( + pub Arc, + ); + impl< + T: SubscriptionService, + > tonic::server::ServerStreamingService< + super::SubscribeCheckpointPartsRequest, + > for SubscribeCheckpointPartsSvc { + type Response = super::SubscribeCheckpointPartsResponse; + type ResponseStream = BoxStream< + super::SubscribeCheckpointPartsResponse, + >; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::SubscribeCheckpointPartsRequest, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::subscribe_checkpoint_parts( + &inner, + 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 method = SubscribeCheckpointPartsSvc(inner); + let codec = tonic_prost::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.server_streaming(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + _ => { + Box::pin(async move { + let mut response = http::Response::new( + tonic::body::Body::default(), + ); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) + }) + } + } + } + } + impl Clone for SubscriptionServiceServer { + 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, + } + } + } + /// Generated gRPC service name + pub const SERVICE_NAME: &str = "sui.rpc.v2beta.SubscriptionService"; + impl tonic::server::NamedService for SubscriptionServiceServer { + const NAME: &'static str = SERVICE_NAME; + } +} diff --git a/crates/sui-rpc/src/proto/generated/sui.rpc.v2beta.serde.rs b/crates/sui-rpc/src/proto/generated/sui.rpc.v2beta.serde.rs new file mode 100644 index 0000000000..5d6d52a17f --- /dev/null +++ b/crates/sui-rpc/src/proto/generated/sui.rpc.v2beta.serde.rs @@ -0,0 +1,1615 @@ +impl serde::Serialize for CheckpointContentsPart { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0usize; + if self.digest.is_some() { + len += 1; + } + if self.version.is_some() { + len += 1; + } + if !self.transactions.is_empty() { + len += 1; + } + let mut struct_ser = serializer + .serialize_struct("sui.rpc.v2beta.CheckpointContentsPart", len)?; + if let Some(v) = self.digest.as_ref() { + struct_ser.serialize_field("digest", v)?; + } + if let Some(v) = self.version.as_ref() { + struct_ser.serialize_field("version", v)?; + } + if !self.transactions.is_empty() { + struct_ser.serialize_field("transactions", &self.transactions)?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for CheckpointContentsPart { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &["digest", "version", "transactions"]; + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + Digest, + Version, + Transactions, + __SkipField__, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize( + deserializer: D, + ) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + fn expecting( + &self, + formatter: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", FIELDS) + } + #[allow(unused_variables)] + fn visit_str( + self, + value: &str, + ) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "digest" => Ok(GeneratedField::Digest), + "version" => Ok(GeneratedField::Version), + "transactions" => Ok(GeneratedField::Transactions), + _ => Ok(GeneratedField::__SkipField__), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + #[allow(clippy::useless_conversion)] + #[allow(clippy::unit_arg)] + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = CheckpointContentsPart; + fn expecting( + &self, + formatter: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + formatter.write_str("struct sui.rpc.v2beta.CheckpointContentsPart") + } + fn visit_map( + self, + mut map_: V, + ) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut digest__ = None; + let mut version__ = None; + let mut transactions__ = None; + while let Some(k) = map_.next_key()? { + match k { + GeneratedField::Digest => { + if digest__.is_some() { + return Err(serde::de::Error::duplicate_field("digest")); + } + digest__ = map_.next_value()?; + } + GeneratedField::Version => { + if version__.is_some() { + return Err(serde::de::Error::duplicate_field("version")); + } + version__ = map_ + .next_value::< + ::std::option::Option>, + >()? + .map(|x| x.0); + } + GeneratedField::Transactions => { + if transactions__.is_some() { + return Err( + serde::de::Error::duplicate_field("transactions"), + ); + } + transactions__ = Some(map_.next_value()?); + } + GeneratedField::__SkipField__ => { + let _ = map_.next_value::()?; + } + } + } + Ok(CheckpointContentsPart { + digest: digest__, + version: version__, + transactions: transactions__.unwrap_or_default(), + }) + } + } + deserializer + .deserialize_struct( + "sui.rpc.v2beta.CheckpointContentsPart", + FIELDS, + GeneratedVisitor, + ) + } +} +impl serde::Serialize for CheckpointPart { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0usize; + if self.sequence_number.is_some() { + len += 1; + } + if self.digest.is_some() { + len += 1; + } + if self.summary.is_some() { + len += 1; + } + if self.signature.is_some() { + len += 1; + } + if self.contents.is_some() { + len += 1; + } + if !self.transactions.is_empty() { + len += 1; + } + if self.objects.is_some() { + len += 1; + } + if self.part_index.is_some() { + len += 1; + } + if self.is_last.is_some() { + len += 1; + } + if self.first_tx_index.is_some() { + len += 1; + } + if self.total_transactions.is_some() { + len += 1; + } + if self.first_tx_sequence_number.is_some() { + len += 1; + } + if self.objects_continue.is_some() { + len += 1; + } + if !self.continuation_events.is_empty() { + len += 1; + } + if self.events_continue.is_some() { + len += 1; + } + let mut struct_ser = serializer + .serialize_struct("sui.rpc.v2beta.CheckpointPart", len)?; + if let Some(v) = self.sequence_number.as_ref() { + #[allow(clippy::needless_borrow)] + #[allow(clippy::needless_borrows_for_generic_args)] + struct_ser + .serialize_field("sequenceNumber", ToString::to_string(&v).as_str())?; + } + if let Some(v) = self.digest.as_ref() { + struct_ser.serialize_field("digest", v)?; + } + if let Some(v) = self.summary.as_ref() { + struct_ser.serialize_field("summary", v)?; + } + if let Some(v) = self.signature.as_ref() { + struct_ser.serialize_field("signature", v)?; + } + if let Some(v) = self.contents.as_ref() { + struct_ser.serialize_field("contents", v)?; + } + if !self.transactions.is_empty() { + struct_ser.serialize_field("transactions", &self.transactions)?; + } + if let Some(v) = self.objects.as_ref() { + struct_ser.serialize_field("objects", v)?; + } + if let Some(v) = self.part_index.as_ref() { + struct_ser.serialize_field("partIndex", v)?; + } + if let Some(v) = self.is_last.as_ref() { + struct_ser.serialize_field("isLast", v)?; + } + if let Some(v) = self.first_tx_index.as_ref() { + #[allow(clippy::needless_borrow)] + #[allow(clippy::needless_borrows_for_generic_args)] + struct_ser + .serialize_field("firstTxIndex", ToString::to_string(&v).as_str())?; + } + if let Some(v) = self.total_transactions.as_ref() { + #[allow(clippy::needless_borrow)] + #[allow(clippy::needless_borrows_for_generic_args)] + struct_ser + .serialize_field("totalTransactions", ToString::to_string(&v).as_str())?; + } + if let Some(v) = self.first_tx_sequence_number.as_ref() { + #[allow(clippy::needless_borrow)] + #[allow(clippy::needless_borrows_for_generic_args)] + struct_ser + .serialize_field( + "firstTxSequenceNumber", + ToString::to_string(&v).as_str(), + )?; + } + if let Some(v) = self.objects_continue.as_ref() { + struct_ser.serialize_field("objectsContinue", v)?; + } + if !self.continuation_events.is_empty() { + struct_ser.serialize_field("continuationEvents", &self.continuation_events)?; + } + if let Some(v) = self.events_continue.as_ref() { + struct_ser.serialize_field("eventsContinue", v)?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for CheckpointPart { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "sequence_number", + "sequenceNumber", + "digest", + "summary", + "signature", + "contents", + "transactions", + "objects", + "part_index", + "partIndex", + "is_last", + "isLast", + "first_tx_index", + "firstTxIndex", + "total_transactions", + "totalTransactions", + "first_tx_sequence_number", + "firstTxSequenceNumber", + "objects_continue", + "objectsContinue", + "continuation_events", + "continuationEvents", + "events_continue", + "eventsContinue", + ]; + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + SequenceNumber, + Digest, + Summary, + Signature, + Contents, + Transactions, + Objects, + PartIndex, + IsLast, + FirstTxIndex, + TotalTransactions, + FirstTxSequenceNumber, + ObjectsContinue, + ContinuationEvents, + EventsContinue, + __SkipField__, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize( + deserializer: D, + ) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + fn expecting( + &self, + formatter: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", FIELDS) + } + #[allow(unused_variables)] + fn visit_str( + self, + value: &str, + ) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "sequenceNumber" | "sequence_number" => { + Ok(GeneratedField::SequenceNumber) + } + "digest" => Ok(GeneratedField::Digest), + "summary" => Ok(GeneratedField::Summary), + "signature" => Ok(GeneratedField::Signature), + "contents" => Ok(GeneratedField::Contents), + "transactions" => Ok(GeneratedField::Transactions), + "objects" => Ok(GeneratedField::Objects), + "partIndex" | "part_index" => Ok(GeneratedField::PartIndex), + "isLast" | "is_last" => Ok(GeneratedField::IsLast), + "firstTxIndex" | "first_tx_index" => { + Ok(GeneratedField::FirstTxIndex) + } + "totalTransactions" | "total_transactions" => { + Ok(GeneratedField::TotalTransactions) + } + "firstTxSequenceNumber" | "first_tx_sequence_number" => { + Ok(GeneratedField::FirstTxSequenceNumber) + } + "objectsContinue" | "objects_continue" => { + Ok(GeneratedField::ObjectsContinue) + } + "continuationEvents" | "continuation_events" => { + Ok(GeneratedField::ContinuationEvents) + } + "eventsContinue" | "events_continue" => { + Ok(GeneratedField::EventsContinue) + } + _ => Ok(GeneratedField::__SkipField__), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + #[allow(clippy::useless_conversion)] + #[allow(clippy::unit_arg)] + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = CheckpointPart; + fn expecting( + &self, + formatter: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + formatter.write_str("struct sui.rpc.v2beta.CheckpointPart") + } + fn visit_map( + self, + mut map_: V, + ) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut sequence_number__ = None; + let mut digest__ = None; + let mut summary__ = None; + let mut signature__ = None; + let mut contents__ = None; + let mut transactions__ = None; + let mut objects__ = None; + let mut part_index__ = None; + let mut is_last__ = None; + let mut first_tx_index__ = None; + let mut total_transactions__ = None; + let mut first_tx_sequence_number__ = None; + let mut objects_continue__ = None; + let mut continuation_events__ = None; + let mut events_continue__ = None; + while let Some(k) = map_.next_key()? { + match k { + GeneratedField::SequenceNumber => { + if sequence_number__.is_some() { + return Err( + serde::de::Error::duplicate_field("sequenceNumber"), + ); + } + sequence_number__ = map_ + .next_value::< + ::std::option::Option>, + >()? + .map(|x| x.0); + } + GeneratedField::Digest => { + if digest__.is_some() { + return Err(serde::de::Error::duplicate_field("digest")); + } + digest__ = map_.next_value()?; + } + GeneratedField::Summary => { + if summary__.is_some() { + return Err(serde::de::Error::duplicate_field("summary")); + } + summary__ = map_.next_value()?; + } + GeneratedField::Signature => { + if signature__.is_some() { + return Err(serde::de::Error::duplicate_field("signature")); + } + signature__ = map_.next_value()?; + } + GeneratedField::Contents => { + if contents__.is_some() { + return Err(serde::de::Error::duplicate_field("contents")); + } + contents__ = map_.next_value()?; + } + GeneratedField::Transactions => { + if transactions__.is_some() { + return Err( + serde::de::Error::duplicate_field("transactions"), + ); + } + transactions__ = Some(map_.next_value()?); + } + GeneratedField::Objects => { + if objects__.is_some() { + return Err(serde::de::Error::duplicate_field("objects")); + } + objects__ = map_.next_value()?; + } + GeneratedField::PartIndex => { + if part_index__.is_some() { + return Err(serde::de::Error::duplicate_field("partIndex")); + } + part_index__ = map_ + .next_value::< + ::std::option::Option>, + >()? + .map(|x| x.0); + } + GeneratedField::IsLast => { + if is_last__.is_some() { + return Err(serde::de::Error::duplicate_field("isLast")); + } + is_last__ = map_.next_value()?; + } + GeneratedField::FirstTxIndex => { + if first_tx_index__.is_some() { + return Err( + serde::de::Error::duplicate_field("firstTxIndex"), + ); + } + first_tx_index__ = map_ + .next_value::< + ::std::option::Option>, + >()? + .map(|x| x.0); + } + GeneratedField::TotalTransactions => { + if total_transactions__.is_some() { + return Err( + serde::de::Error::duplicate_field("totalTransactions"), + ); + } + total_transactions__ = map_ + .next_value::< + ::std::option::Option>, + >()? + .map(|x| x.0); + } + GeneratedField::FirstTxSequenceNumber => { + if first_tx_sequence_number__.is_some() { + return Err( + serde::de::Error::duplicate_field("firstTxSequenceNumber"), + ); + } + first_tx_sequence_number__ = map_ + .next_value::< + ::std::option::Option>, + >()? + .map(|x| x.0); + } + GeneratedField::ObjectsContinue => { + if objects_continue__.is_some() { + return Err( + serde::de::Error::duplicate_field("objectsContinue"), + ); + } + objects_continue__ = map_.next_value()?; + } + GeneratedField::ContinuationEvents => { + if continuation_events__.is_some() { + return Err( + serde::de::Error::duplicate_field("continuationEvents"), + ); + } + continuation_events__ = Some(map_.next_value()?); + } + GeneratedField::EventsContinue => { + if events_continue__.is_some() { + return Err( + serde::de::Error::duplicate_field("eventsContinue"), + ); + } + events_continue__ = map_.next_value()?; + } + GeneratedField::__SkipField__ => { + let _ = map_.next_value::()?; + } + } + } + Ok(CheckpointPart { + sequence_number: sequence_number__, + digest: digest__, + summary: summary__, + signature: signature__, + contents: contents__, + transactions: transactions__.unwrap_or_default(), + objects: objects__, + part_index: part_index__, + is_last: is_last__, + first_tx_index: first_tx_index__, + total_transactions: total_transactions__, + first_tx_sequence_number: first_tx_sequence_number__, + objects_continue: objects_continue__, + continuation_events: continuation_events__.unwrap_or_default(), + events_continue: events_continue__, + }) + } + } + deserializer + .deserialize_struct( + "sui.rpc.v2beta.CheckpointPart", + FIELDS, + GeneratedVisitor, + ) + } +} +impl serde::Serialize for GetCheckpointPartsRequest { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0usize; + if self.read_mask.is_some() { + len += 1; + } + if self.resume_token.is_some() { + len += 1; + } + if self.checkpoint_id.is_some() { + len += 1; + } + let mut struct_ser = serializer + .serialize_struct("sui.rpc.v2beta.GetCheckpointPartsRequest", len)?; + if let Some(v) = self.read_mask.as_ref() { + struct_ser + .serialize_field("readMask", &crate::_serde::FieldMaskSerializer(v))?; + } + if let Some(v) = self.resume_token.as_ref() { + #[allow(clippy::needless_borrow)] + #[allow(clippy::needless_borrows_for_generic_args)] + struct_ser + .serialize_field( + "resumeToken", + crate::_serde::base64::encode(&v).as_str(), + )?; + } + if let Some(v) = self.checkpoint_id.as_ref() { + match v { + get_checkpoint_parts_request::CheckpointId::SequenceNumber(v) => { + #[allow(clippy::needless_borrow)] + #[allow(clippy::needless_borrows_for_generic_args)] + struct_ser + .serialize_field( + "sequenceNumber", + ToString::to_string(&v).as_str(), + )?; + } + get_checkpoint_parts_request::CheckpointId::Digest(v) => { + struct_ser.serialize_field("digest", v)?; + } + } + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for GetCheckpointPartsRequest { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "read_mask", + "readMask", + "resume_token", + "resumeToken", + "sequence_number", + "sequenceNumber", + "digest", + ]; + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + ReadMask, + ResumeToken, + SequenceNumber, + Digest, + __SkipField__, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize( + deserializer: D, + ) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + fn expecting( + &self, + formatter: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", FIELDS) + } + #[allow(unused_variables)] + fn visit_str( + self, + value: &str, + ) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "readMask" | "read_mask" => Ok(GeneratedField::ReadMask), + "resumeToken" | "resume_token" => { + Ok(GeneratedField::ResumeToken) + } + "sequenceNumber" | "sequence_number" => { + Ok(GeneratedField::SequenceNumber) + } + "digest" => Ok(GeneratedField::Digest), + _ => Ok(GeneratedField::__SkipField__), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + #[allow(clippy::useless_conversion)] + #[allow(clippy::unit_arg)] + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GetCheckpointPartsRequest; + fn expecting( + &self, + formatter: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + formatter.write_str("struct sui.rpc.v2beta.GetCheckpointPartsRequest") + } + fn visit_map( + self, + mut map_: V, + ) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut read_mask__ = None; + let mut resume_token__ = None; + let mut checkpoint_id__ = None; + while let Some(k) = map_.next_key()? { + match k { + GeneratedField::ReadMask => { + if read_mask__.is_some() { + return Err(serde::de::Error::duplicate_field("readMask")); + } + read_mask__ = map_ + .next_value::< + ::std::option::Option, + >()? + .map(|x| x.0.into()); + } + GeneratedField::ResumeToken => { + if resume_token__.is_some() { + return Err( + serde::de::Error::duplicate_field("resumeToken"), + ); + } + resume_token__ = map_ + .next_value::< + ::std::option::Option>, + >()? + .map(|x| x.0); + } + GeneratedField::SequenceNumber => { + if checkpoint_id__.is_some() { + return Err( + serde::de::Error::duplicate_field("sequenceNumber"), + ); + } + checkpoint_id__ = map_ + .next_value::< + ::std::option::Option>, + >()? + .map(|x| get_checkpoint_parts_request::CheckpointId::SequenceNumber( + x.0, + )); + } + GeneratedField::Digest => { + if checkpoint_id__.is_some() { + return Err(serde::de::Error::duplicate_field("digest")); + } + checkpoint_id__ = map_ + .next_value::<::std::option::Option<_>>()? + .map(get_checkpoint_parts_request::CheckpointId::Digest); + } + GeneratedField::__SkipField__ => { + let _ = map_.next_value::()?; + } + } + } + Ok(GetCheckpointPartsRequest { + read_mask: read_mask__, + resume_token: resume_token__, + checkpoint_id: checkpoint_id__, + }) + } + } + deserializer + .deserialize_struct( + "sui.rpc.v2beta.GetCheckpointPartsRequest", + FIELDS, + GeneratedVisitor, + ) + } +} +impl serde::Serialize for GetCheckpointPartsResponse { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0usize; + if self.part.is_some() { + len += 1; + } + if self.resume_token.is_some() { + len += 1; + } + let mut struct_ser = serializer + .serialize_struct("sui.rpc.v2beta.GetCheckpointPartsResponse", len)?; + if let Some(v) = self.part.as_ref() { + struct_ser.serialize_field("part", v)?; + } + if let Some(v) = self.resume_token.as_ref() { + #[allow(clippy::needless_borrow)] + #[allow(clippy::needless_borrows_for_generic_args)] + struct_ser + .serialize_field( + "resumeToken", + crate::_serde::base64::encode(&v).as_str(), + )?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for GetCheckpointPartsResponse { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &["part", "resume_token", "resumeToken"]; + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + Part, + ResumeToken, + __SkipField__, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize( + deserializer: D, + ) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + fn expecting( + &self, + formatter: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", FIELDS) + } + #[allow(unused_variables)] + fn visit_str( + self, + value: &str, + ) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "part" => Ok(GeneratedField::Part), + "resumeToken" | "resume_token" => { + Ok(GeneratedField::ResumeToken) + } + _ => Ok(GeneratedField::__SkipField__), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + #[allow(clippy::useless_conversion)] + #[allow(clippy::unit_arg)] + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GetCheckpointPartsResponse; + fn expecting( + &self, + formatter: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + formatter.write_str("struct sui.rpc.v2beta.GetCheckpointPartsResponse") + } + fn visit_map( + self, + mut map_: V, + ) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut part__ = None; + let mut resume_token__ = None; + while let Some(k) = map_.next_key()? { + match k { + GeneratedField::Part => { + if part__.is_some() { + return Err(serde::de::Error::duplicate_field("part")); + } + part__ = map_.next_value()?; + } + GeneratedField::ResumeToken => { + if resume_token__.is_some() { + return Err( + serde::de::Error::duplicate_field("resumeToken"), + ); + } + resume_token__ = map_ + .next_value::< + ::std::option::Option>, + >()? + .map(|x| x.0); + } + GeneratedField::__SkipField__ => { + let _ = map_.next_value::()?; + } + } + } + Ok(GetCheckpointPartsResponse { + part: part__, + resume_token: resume_token__, + }) + } + } + deserializer + .deserialize_struct( + "sui.rpc.v2beta.GetCheckpointPartsResponse", + FIELDS, + GeneratedVisitor, + ) + } +} +impl serde::Serialize for ListCheckpointPartsRequest { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0usize; + if self.read_mask.is_some() { + len += 1; + } + if self.start_checkpoint.is_some() { + len += 1; + } + if self.end_checkpoint.is_some() { + len += 1; + } + if self.filter.is_some() { + len += 1; + } + if self.options.is_some() { + len += 1; + } + if self.resume_token.is_some() { + len += 1; + } + let mut struct_ser = serializer + .serialize_struct("sui.rpc.v2beta.ListCheckpointPartsRequest", len)?; + if let Some(v) = self.read_mask.as_ref() { + struct_ser + .serialize_field("readMask", &crate::_serde::FieldMaskSerializer(v))?; + } + if let Some(v) = self.start_checkpoint.as_ref() { + #[allow(clippy::needless_borrow)] + #[allow(clippy::needless_borrows_for_generic_args)] + struct_ser + .serialize_field("startCheckpoint", ToString::to_string(&v).as_str())?; + } + if let Some(v) = self.end_checkpoint.as_ref() { + #[allow(clippy::needless_borrow)] + #[allow(clippy::needless_borrows_for_generic_args)] + struct_ser + .serialize_field("endCheckpoint", ToString::to_string(&v).as_str())?; + } + if let Some(v) = self.filter.as_ref() { + struct_ser.serialize_field("filter", v)?; + } + if let Some(v) = self.options.as_ref() { + struct_ser.serialize_field("options", v)?; + } + if let Some(v) = self.resume_token.as_ref() { + #[allow(clippy::needless_borrow)] + #[allow(clippy::needless_borrows_for_generic_args)] + struct_ser + .serialize_field( + "resumeToken", + crate::_serde::base64::encode(&v).as_str(), + )?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for ListCheckpointPartsRequest { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "read_mask", + "readMask", + "start_checkpoint", + "startCheckpoint", + "end_checkpoint", + "endCheckpoint", + "filter", + "options", + "resume_token", + "resumeToken", + ]; + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + ReadMask, + StartCheckpoint, + EndCheckpoint, + Filter, + Options, + ResumeToken, + __SkipField__, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize( + deserializer: D, + ) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + fn expecting( + &self, + formatter: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", FIELDS) + } + #[allow(unused_variables)] + fn visit_str( + self, + value: &str, + ) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "readMask" | "read_mask" => Ok(GeneratedField::ReadMask), + "startCheckpoint" | "start_checkpoint" => { + Ok(GeneratedField::StartCheckpoint) + } + "endCheckpoint" | "end_checkpoint" => { + Ok(GeneratedField::EndCheckpoint) + } + "filter" => Ok(GeneratedField::Filter), + "options" => Ok(GeneratedField::Options), + "resumeToken" | "resume_token" => { + Ok(GeneratedField::ResumeToken) + } + _ => Ok(GeneratedField::__SkipField__), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + #[allow(clippy::useless_conversion)] + #[allow(clippy::unit_arg)] + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = ListCheckpointPartsRequest; + fn expecting( + &self, + formatter: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + formatter.write_str("struct sui.rpc.v2beta.ListCheckpointPartsRequest") + } + fn visit_map( + self, + mut map_: V, + ) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut read_mask__ = None; + let mut start_checkpoint__ = None; + let mut end_checkpoint__ = None; + let mut filter__ = None; + let mut options__ = None; + let mut resume_token__ = None; + while let Some(k) = map_.next_key()? { + match k { + GeneratedField::ReadMask => { + if read_mask__.is_some() { + return Err(serde::de::Error::duplicate_field("readMask")); + } + read_mask__ = map_ + .next_value::< + ::std::option::Option, + >()? + .map(|x| x.0.into()); + } + GeneratedField::StartCheckpoint => { + if start_checkpoint__.is_some() { + return Err( + serde::de::Error::duplicate_field("startCheckpoint"), + ); + } + start_checkpoint__ = map_ + .next_value::< + ::std::option::Option>, + >()? + .map(|x| x.0); + } + GeneratedField::EndCheckpoint => { + if end_checkpoint__.is_some() { + return Err( + serde::de::Error::duplicate_field("endCheckpoint"), + ); + } + end_checkpoint__ = map_ + .next_value::< + ::std::option::Option>, + >()? + .map(|x| x.0); + } + GeneratedField::Filter => { + if filter__.is_some() { + return Err(serde::de::Error::duplicate_field("filter")); + } + filter__ = map_.next_value()?; + } + GeneratedField::Options => { + if options__.is_some() { + return Err(serde::de::Error::duplicate_field("options")); + } + options__ = map_.next_value()?; + } + GeneratedField::ResumeToken => { + if resume_token__.is_some() { + return Err( + serde::de::Error::duplicate_field("resumeToken"), + ); + } + resume_token__ = map_ + .next_value::< + ::std::option::Option>, + >()? + .map(|x| x.0); + } + GeneratedField::__SkipField__ => { + let _ = map_.next_value::()?; + } + } + } + Ok(ListCheckpointPartsRequest { + read_mask: read_mask__, + start_checkpoint: start_checkpoint__, + end_checkpoint: end_checkpoint__, + filter: filter__, + options: options__, + resume_token: resume_token__, + }) + } + } + deserializer + .deserialize_struct( + "sui.rpc.v2beta.ListCheckpointPartsRequest", + FIELDS, + GeneratedVisitor, + ) + } +} +impl serde::Serialize for ListCheckpointPartsResponse { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0usize; + if self.part.is_some() { + len += 1; + } + if self.watermark.is_some() { + len += 1; + } + if self.resume_token.is_some() { + len += 1; + } + if self.end.is_some() { + len += 1; + } + let mut struct_ser = serializer + .serialize_struct("sui.rpc.v2beta.ListCheckpointPartsResponse", len)?; + if let Some(v) = self.part.as_ref() { + struct_ser.serialize_field("part", v)?; + } + if let Some(v) = self.watermark.as_ref() { + struct_ser.serialize_field("watermark", v)?; + } + if let Some(v) = self.resume_token.as_ref() { + #[allow(clippy::needless_borrow)] + #[allow(clippy::needless_borrows_for_generic_args)] + struct_ser + .serialize_field( + "resumeToken", + crate::_serde::base64::encode(&v).as_str(), + )?; + } + if let Some(v) = self.end.as_ref() { + struct_ser.serialize_field("end", v)?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for ListCheckpointPartsResponse { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "part", + "watermark", + "resume_token", + "resumeToken", + "end", + ]; + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + Part, + Watermark, + ResumeToken, + End, + __SkipField__, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize( + deserializer: D, + ) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + fn expecting( + &self, + formatter: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", FIELDS) + } + #[allow(unused_variables)] + fn visit_str( + self, + value: &str, + ) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "part" => Ok(GeneratedField::Part), + "watermark" => Ok(GeneratedField::Watermark), + "resumeToken" | "resume_token" => { + Ok(GeneratedField::ResumeToken) + } + "end" => Ok(GeneratedField::End), + _ => Ok(GeneratedField::__SkipField__), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + #[allow(clippy::useless_conversion)] + #[allow(clippy::unit_arg)] + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = ListCheckpointPartsResponse; + fn expecting( + &self, + formatter: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + formatter.write_str("struct sui.rpc.v2beta.ListCheckpointPartsResponse") + } + fn visit_map( + self, + mut map_: V, + ) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut part__ = None; + let mut watermark__ = None; + let mut resume_token__ = None; + let mut end__ = None; + while let Some(k) = map_.next_key()? { + match k { + GeneratedField::Part => { + if part__.is_some() { + return Err(serde::de::Error::duplicate_field("part")); + } + part__ = map_.next_value()?; + } + GeneratedField::Watermark => { + if watermark__.is_some() { + return Err(serde::de::Error::duplicate_field("watermark")); + } + watermark__ = map_.next_value()?; + } + GeneratedField::ResumeToken => { + if resume_token__.is_some() { + return Err( + serde::de::Error::duplicate_field("resumeToken"), + ); + } + resume_token__ = map_ + .next_value::< + ::std::option::Option>, + >()? + .map(|x| x.0); + } + GeneratedField::End => { + if end__.is_some() { + return Err(serde::de::Error::duplicate_field("end")); + } + end__ = map_.next_value()?; + } + GeneratedField::__SkipField__ => { + let _ = map_.next_value::()?; + } + } + } + Ok(ListCheckpointPartsResponse { + part: part__, + watermark: watermark__, + resume_token: resume_token__, + end: end__, + }) + } + } + deserializer + .deserialize_struct( + "sui.rpc.v2beta.ListCheckpointPartsResponse", + FIELDS, + GeneratedVisitor, + ) + } +} +impl serde::Serialize for SubscribeCheckpointPartsRequest { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0usize; + if self.read_mask.is_some() { + len += 1; + } + if self.filter.is_some() { + len += 1; + } + let mut struct_ser = serializer + .serialize_struct("sui.rpc.v2beta.SubscribeCheckpointPartsRequest", len)?; + if let Some(v) = self.read_mask.as_ref() { + struct_ser + .serialize_field("readMask", &crate::_serde::FieldMaskSerializer(v))?; + } + if let Some(v) = self.filter.as_ref() { + struct_ser.serialize_field("filter", v)?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for SubscribeCheckpointPartsRequest { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &["read_mask", "readMask", "filter"]; + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + ReadMask, + Filter, + __SkipField__, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize( + deserializer: D, + ) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + fn expecting( + &self, + formatter: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", FIELDS) + } + #[allow(unused_variables)] + fn visit_str( + self, + value: &str, + ) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "readMask" | "read_mask" => Ok(GeneratedField::ReadMask), + "filter" => Ok(GeneratedField::Filter), + _ => Ok(GeneratedField::__SkipField__), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + #[allow(clippy::useless_conversion)] + #[allow(clippy::unit_arg)] + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = SubscribeCheckpointPartsRequest; + fn expecting( + &self, + formatter: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + formatter + .write_str("struct sui.rpc.v2beta.SubscribeCheckpointPartsRequest") + } + fn visit_map( + self, + mut map_: V, + ) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut read_mask__ = None; + let mut filter__ = None; + while let Some(k) = map_.next_key()? { + match k { + GeneratedField::ReadMask => { + if read_mask__.is_some() { + return Err(serde::de::Error::duplicate_field("readMask")); + } + read_mask__ = map_ + .next_value::< + ::std::option::Option, + >()? + .map(|x| x.0.into()); + } + GeneratedField::Filter => { + if filter__.is_some() { + return Err(serde::de::Error::duplicate_field("filter")); + } + filter__ = map_.next_value()?; + } + GeneratedField::__SkipField__ => { + let _ = map_.next_value::()?; + } + } + } + Ok(SubscribeCheckpointPartsRequest { + read_mask: read_mask__, + filter: filter__, + }) + } + } + deserializer + .deserialize_struct( + "sui.rpc.v2beta.SubscribeCheckpointPartsRequest", + FIELDS, + GeneratedVisitor, + ) + } +} +impl serde::Serialize for SubscribeCheckpointPartsResponse { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0usize; + if self.part.is_some() { + len += 1; + } + if self.watermark.is_some() { + len += 1; + } + if self.resume_token.is_some() { + len += 1; + } + let mut struct_ser = serializer + .serialize_struct("sui.rpc.v2beta.SubscribeCheckpointPartsResponse", len)?; + if let Some(v) = self.part.as_ref() { + struct_ser.serialize_field("part", v)?; + } + if let Some(v) = self.watermark.as_ref() { + struct_ser.serialize_field("watermark", v)?; + } + if let Some(v) = self.resume_token.as_ref() { + #[allow(clippy::needless_borrow)] + #[allow(clippy::needless_borrows_for_generic_args)] + struct_ser + .serialize_field( + "resumeToken", + crate::_serde::base64::encode(&v).as_str(), + )?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for SubscribeCheckpointPartsResponse { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &["part", "watermark", "resume_token", "resumeToken"]; + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + Part, + Watermark, + ResumeToken, + __SkipField__, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize( + deserializer: D, + ) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + fn expecting( + &self, + formatter: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", FIELDS) + } + #[allow(unused_variables)] + fn visit_str( + self, + value: &str, + ) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "part" => Ok(GeneratedField::Part), + "watermark" => Ok(GeneratedField::Watermark), + "resumeToken" | "resume_token" => { + Ok(GeneratedField::ResumeToken) + } + _ => Ok(GeneratedField::__SkipField__), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + #[allow(clippy::useless_conversion)] + #[allow(clippy::unit_arg)] + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = SubscribeCheckpointPartsResponse; + fn expecting( + &self, + formatter: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + formatter + .write_str("struct sui.rpc.v2beta.SubscribeCheckpointPartsResponse") + } + fn visit_map( + self, + mut map_: V, + ) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut part__ = None; + let mut watermark__ = None; + let mut resume_token__ = None; + while let Some(k) = map_.next_key()? { + match k { + GeneratedField::Part => { + if part__.is_some() { + return Err(serde::de::Error::duplicate_field("part")); + } + part__ = map_.next_value()?; + } + GeneratedField::Watermark => { + if watermark__.is_some() { + return Err(serde::de::Error::duplicate_field("watermark")); + } + watermark__ = map_.next_value()?; + } + GeneratedField::ResumeToken => { + if resume_token__.is_some() { + return Err( + serde::de::Error::duplicate_field("resumeToken"), + ); + } + resume_token__ = map_ + .next_value::< + ::std::option::Option>, + >()? + .map(|x| x.0); + } + GeneratedField::__SkipField__ => { + let _ = map_.next_value::()?; + } + } + } + Ok(SubscribeCheckpointPartsResponse { + part: part__, + watermark: watermark__, + resume_token: resume_token__, + }) + } + } + deserializer + .deserialize_struct( + "sui.rpc.v2beta.SubscribeCheckpointPartsResponse", + FIELDS, + GeneratedVisitor, + ) + } +} diff --git a/crates/sui-rpc/src/proto/sui/rpc/mod.rs b/crates/sui-rpc/src/proto/sui/rpc/mod.rs index a66c3371a6..d7c65f5c3e 100644 --- a/crates/sui-rpc/src/proto/sui/rpc/mod.rs +++ b/crates/sui-rpc/src/proto/sui/rpc/mod.rs @@ -3,3 +3,7 @@ pub mod v2; #[cfg(feature = "unstable")] #[cfg_attr(doc_cfg, doc(cfg(feature = "unstable")))] pub mod v2alpha; + +#[cfg(feature = "unstable")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "unstable")))] +pub mod v2beta; diff --git a/crates/sui-rpc/src/proto/sui/rpc/v2beta/mod.rs b/crates/sui-rpc/src/proto/sui/rpc/v2beta/mod.rs new file mode 100644 index 0000000000..f50f275e50 --- /dev/null +++ b/crates/sui-rpc/src/proto/sui/rpc/v2beta/mod.rs @@ -0,0 +1,50 @@ +#![allow(clippy::uninlined_format_args)] + +use super::v2::_field_impls::CheckpointSummaryFieldPathBuilder; +use super::v2::_field_impls::CheckpointedTransactionInfoFieldPathBuilder; +use super::v2::_field_impls::EventFieldPathBuilder; +use super::v2::_field_impls::ExecutedTransactionFieldPathBuilder; +use super::v2::_field_impls::ObjectSetFieldPathBuilder; +use super::v2::_field_impls::QueryEndFieldPathBuilder; +use super::v2::_field_impls::QueryOptionsFieldPathBuilder; +use super::v2::_field_impls::TransactionFilterFieldPathBuilder; +use super::v2::_field_impls::ValidatorAggregatedSignatureFieldPathBuilder; +use super::v2::_field_impls::WatermarkFieldPathBuilder; +use super::v2::CheckpointSummary; +use super::v2::CheckpointedTransactionInfo; +use super::v2::Event; +use super::v2::ExecutedTransaction; +use super::v2::ObjectSet; +use super::v2::QueryEnd; +use super::v2::QueryOptions; +use super::v2::TransactionFilter; +use super::v2::ValidatorAggregatedSignature; +use super::v2::Watermark; + +// Include the generated proto definitions +include!("../../../generated/sui.rpc.v2beta.rs"); + +// Include generated field info impls +include!("../../../generated/sui.rpc.v2beta.field_info.rs"); + +// Include generated serde impls +include!("../../../generated/sui.rpc.v2beta.serde.rs"); +include!("../../../generated/sui.rpc.v2beta.accessors.rs"); + +pub use descriptor::FILE_DESCRIPTOR_SET; +mod descriptor { + /// Byte encoded FILE_DESCRIPTOR_SET. + pub const FILE_DESCRIPTOR_SET: &[u8] = + include_bytes!("../../../generated/sui.rpc.v2beta.fds.bin"); + + #[cfg(test)] + mod tests { + use super::FILE_DESCRIPTOR_SET; + use prost::Message as _; + + #[test] + fn file_descriptor_set_is_valid() { + prost_types::FileDescriptorSet::decode(FILE_DESCRIPTOR_SET).unwrap(); + } + } +} diff --git a/crates/sui-rpc/vendored/proto/sui/rpc/v2/error_reason.proto b/crates/sui-rpc/vendored/proto/sui/rpc/v2/error_reason.proto index fe091ea88b..5ad17915ee 100644 --- a/crates/sui-rpc/vendored/proto/sui/rpc/v2/error_reason.proto +++ b/crates/sui-rpc/vendored/proto/sui/rpc/v2/error_reason.proto @@ -328,4 +328,50 @@ enum ErrorReason { // // It carries no metadata. VERSION_NOT_RETAINED = 10; + + // A single response message, rendered for the request's `read_mask`, would + // be larger than the largest response message this server sends. Returned + // with `RESOURCE_EXHAUSTED` by RPCs that send each item in one message: the + // checkpoint RPCs `GetCheckpoint`, `ListCheckpoints` and + // `SubscribeCheckpoints`, and the transaction and batch RPCs such as + // `GetTransaction`, `BatchGetTransactions`, `ListTransactions` and + // `SubscribeTransactions`. + // + // A `List*` stream first delivers the items before the one that is too + // large, then a frame without an item whose watermark resumes at it, and + // then fails with this error. A `Subscribe*` stream ends with this error + // rather than skip the item. + // + // An item's size does not change, so requesting the same item with the + // same `read_mask` fails the same way on this server. To read it: + // + // - Narrow `read_mask`: for example, request a checkpoint's + // `summary,signature` only, or leave out `objects` or `events` and fetch + // them separately with `BatchGetObjects` or `ListEvents`. + // - For a `BatchGet*` request, ask for fewer items per request. + // - For a checkpoint, read it in bounded-size parts with + // `sui.rpc.v2beta.LedgerService` `GetCheckpointParts` or + // `ListCheckpointParts`, or `sui.rpc.v2beta.SubscriptionService` + // `SubscribeCheckpointParts`. + // + // Example of an ErrorInfo for checkpoint 1205 from a server whose message + // limit is 128 MiB: + // + // { "reason": "RESPONSE_TOO_LARGE", + // "domain": "sui.io", + // "metadata": { + // "checkpoint": "1205", + // "maxMessageBytes": "134217728" + // } + // } + // + // Metadata: + // - `maxMessageBytes`: the server's limit on the size of a single response + // message, in bytes, as a decimal string. Always present. + // - `checkpoint`: the sequence number of the checkpoint that is too large, + // or that contains the transaction that is too large, as a decimal + // string. Set by the checkpoint RPCs; transaction RPCs may set it. + // - `transaction`: the digest of the transaction that is too large, in + // Base58. Set when a single transaction exceeds the limit. + RESPONSE_TOO_LARGE = 11; } diff --git a/crates/sui-rpc/vendored/proto/sui/rpc/v2/ledger_service.proto b/crates/sui-rpc/vendored/proto/sui/rpc/v2/ledger_service.proto index 6cbc94b9cc..3ee735fb35 100644 --- a/crates/sui-rpc/vendored/proto/sui/rpc/v2/ledger_service.proto +++ b/crates/sui-rpc/vendored/proto/sui/rpc/v2/ledger_service.proto @@ -464,6 +464,10 @@ message GetTransactionResult { // `BELOW_EARLIEST_AVAILABLE`: by `sequence_number` always, by `digest` while // it can still find the checkpoint. A digest it can no longer find is // `NOT_FOUND`. +// +// A checkpoint too large to send in one message for the requested +// `read_mask` fails with `RESOURCE_EXHAUSTED` and reason +// `RESPONSE_TOO_LARGE`. message GetCheckpointRequest { // If neither is provided, return the latest oneof checkpoint_id { @@ -518,6 +522,12 @@ message GetProtocolConfigResponse { } // Request message for LedgerService.ListCheckpoints. +// +// A checkpoint too large to send in one message for the requested +// `read_mask` ends the stream with `RESOURCE_EXHAUSTED` and reason +// `RESPONSE_TOO_LARGE`. Before the error, the stream delivers the +// checkpoints before it and then a frame without a checkpoint whose +// watermark resumes at it. message ListCheckpointsRequest { // Optional. Mask for specifying which parts of the Checkpoint should be // returned (e.g. summary, contents, signatures). diff --git a/crates/sui-rpc/vendored/proto/sui/rpc/v2/signature.proto b/crates/sui-rpc/vendored/proto/sui/rpc/v2/signature.proto index cfd50135c5..a75379ebed 100644 --- a/crates/sui-rpc/vendored/proto/sui/rpc/v2/signature.proto +++ b/crates/sui-rpc/vendored/proto/sui/rpc/v2/signature.proto @@ -11,6 +11,9 @@ import "sui/rpc/v2/signature_scheme.proto"; // A signature from a user. message UserSignature { + reserved 7; + reserved "zklogin_v2"; + // This signature serialized as as BCS. // // When provided as input this will support both the form that is length @@ -102,6 +105,9 @@ message MultisigAggregatedSignature { // A signature from a member of a multisig committee. message MultisigMemberSignature { + reserved 5; + reserved "zklogin_v2"; + // The signature scheme of this signature. optional SignatureScheme scheme = 1; diff --git a/crates/sui-rpc/vendored/proto/sui/rpc/v2/signature_scheme.proto b/crates/sui-rpc/vendored/proto/sui/rpc/v2/signature_scheme.proto index 0e93f1b1e8..14e7695b75 100644 --- a/crates/sui-rpc/vendored/proto/sui/rpc/v2/signature_scheme.proto +++ b/crates/sui-rpc/vendored/proto/sui/rpc/v2/signature_scheme.proto @@ -12,6 +12,9 @@ package sui.rpc.v2; // [enum.SignatureScheme](https://mystenlabs.github.io/sui-rust-sdk/sui_sdk_types/enum.SignatureScheme.html) // for more information about signature schemes. enum SignatureScheme { + reserved 8; + reserved "ZKLOGIN_V2"; + ED25519 = 0; SECP256K1 = 1; SECP256R1 = 2; diff --git a/crates/sui-rpc/vendored/proto/sui/rpc/v2/subscription_service.proto b/crates/sui-rpc/vendored/proto/sui/rpc/v2/subscription_service.proto index dc33e2101f..20959cc610 100644 --- a/crates/sui-rpc/vendored/proto/sui/rpc/v2/subscription_service.proto +++ b/crates/sui-rpc/vendored/proto/sui/rpc/v2/subscription_service.proto @@ -65,6 +65,10 @@ service SubscriptionService { } // Request message for SubscriptionService.SubscribeCheckpoints. +// +// A checkpoint too large to send in one message for the requested +// `read_mask` ends the stream with `RESOURCE_EXHAUSTED` and reason +// `RESPONSE_TOO_LARGE`. message SubscribeCheckpointsRequest { // Optional. Mask for specifying which parts of the Checkpoint should be // returned (e.g. summary, contents, signatures). `cursor` is always diff --git a/crates/sui-rpc/vendored/proto/sui/rpc/v2beta/README.md b/crates/sui-rpc/vendored/proto/sui/rpc/v2beta/README.md new file mode 100644 index 0000000000..1ab74b8129 --- /dev/null +++ b/crates/sui-rpc/vendored/proto/sui/rpc/v2beta/README.md @@ -0,0 +1,21 @@ +## Overview +This package, `sui.rpc.v2beta`, holds APIs that are still being designed +before they are added to [`sui.rpc.v2`](../v2/README.md). APIs here may change +in backwards-incompatible ways, or be removed, until they graduate to +`sui.rpc.v2`; for that reason this package is excluded from the `buf breaking` +checks in [`buf.yaml`](../../../../buf.yaml). Do not depend on these APIs where +stability matters. + +The services in this package follow the conventions of `sui.rpc.v2` +(encoding, field masks, field presence, errors and HTTP headers; see its +[README](../v2/README.md)), and reuse `sui.rpc.v2` messages directly rather +than redefining them. + +The services in this package are: + +- [`LedgerService`](./ledger_service.proto): `GetCheckpointParts` and + `ListCheckpointParts`, which read checkpoints as streams of bounded-size + [`CheckpointPart`](./checkpoint.proto)s. +- [`SubscriptionService`](./subscription_service.proto): + `SubscribeCheckpointParts`, a real-time stream of checkpoints as + `CheckpointPart`s. diff --git a/crates/sui-rpc/vendored/proto/sui/rpc/v2beta/checkpoint.proto b/crates/sui-rpc/vendored/proto/sui/rpc/v2beta/checkpoint.proto new file mode 100644 index 0000000000..b01dd99cee --- /dev/null +++ b/crates/sui-rpc/vendored/proto/sui/rpc/v2beta/checkpoint.proto @@ -0,0 +1,194 @@ +// Copyright (c) Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + +syntax = "proto3"; + +package sui.rpc.v2beta; + +import "sui/rpc/v2/checkpoint_contents.proto"; +import "sui/rpc/v2/checkpoint_summary.proto"; +import "sui/rpc/v2/event.proto"; +import "sui/rpc/v2/executed_transaction.proto"; +import "sui/rpc/v2/object.proto"; +import "sui/rpc/v2/signature.proto"; + +// One part of a checkpoint, delivered by the streaming checkpoint parts RPCs. +// +// The server splits each checkpoint into a sequence of parts, each aimed at a +// bounded target size of a few MiB. A part packs as many consecutive complete +// transactions as fit within the target, each with its `contents` entry and +// its objects. Most checkpoints fit in one part, with `part_index` 0 and +// `is_last` set. A part that carries a single large object can exceed the +// target by far (tens of MiB), and even a part within the target can exceed +// the 4 MiB default receive limit of common gRPC clients, so set the client's +// maximum receive message size well above it (for example, 128 MiB). +// +// Field names and numbers 1-7 match `sui.rpc.v2.Checkpoint`, and the fields +// of the nested `CheckpointContentsPart` match `sui.rpc.v2.CheckpointContents`. +// `read_mask` paths over them work as they do for `Checkpoint`, except for +// the monolithic BCS fields, which parts never carry: +// +// - `transactions.events.bcs` is never returned. Masks that reach it only +// through a parent path (`*`, `transactions`, `transactions.events`) +// succeed and omit it; a mask that names it explicitly fails with +// `INVALID_ARGUMENT`. +// - `CheckpointContentsPart` has no `bcs` field, so `contents` and `*` +// select its other fields, and a mask naming `contents.bcs` fails with +// `INVALID_ARGUMENT`. +// +// `sequence_number` and the framing fields (8-15) are not subject to +// `read_mask`: they are populated whenever they apply. +// +// Ordering: the parts of a checkpoint arrive in ascending `part_index` order +// (0, 1, ...), and `transactions` and `contents.transactions` arrive across +// those parts in the order the checkpoint lists them, even when +// `ListCheckpointParts` lists checkpoints in `ORDERING_DESCENDING`. Fields +// that describe the whole checkpoint (`digest`, `summary`, `signature`, +// `total_transactions`, `first_tx_sequence_number`, `contents.version` and +// `contents.digest`) are set only on part 0. +// +// Transactions too large for one part: every part is either a batch of +// complete transactions, or one part of a sequence that carries a single +// transaction too large for one part, never both. Only a transaction whose +// own events or objects do not fit in one part is sent this way: +// +// - The transactions before it are sent in an earlier part, so the part that +// starts it has exactly one entry in `transactions` (when `read_mask` +// selects `transactions`). +// - The continuation parts after it carry no `transactions` and no +// `contents`, only the rest of its events or objects, as described below. +// - Once it is complete, the transactions after it are again packed together +// into batches, starting in a new part. +// +// The rest of that transaction's events and objects continue as follows: +// +// - If its events continue (`events_continue`), the following parts carry +// the rest of its events in `continuation_events`, in emission order, until +// a part sets `events_continue` to false. +// - If its objects continue (`objects_continue`), the following parts carry +// the rest of its objects in `objects`, in (`object_id`, `version`) order, +// until a part sets `objects_continue` to false. +// +// When both continue, all of its events are sent before any of its objects: +// `objects` stays empty on every part of the transaction while +// `events_continue` is true, and its objects follow once its events are +// complete. +message CheckpointPart { + // The height of this checkpoint. Set on every part. + optional uint64 sequence_number = 1; + + // The digest of this checkpoint's `CheckpointSummary`. Set on part 0 when + // requested. + optional string digest = 2; + + // The `CheckpointSummary` for this checkpoint. Set on part 0 when + // requested. + optional sui.rpc.v2.CheckpointSummary summary = 3; + + // An aggregated quorum signature from the validator committee that + // certified this checkpoint. Set on part 0 when requested. Unset when a + // validator streams checkpoints it has built locally but that are not yet + // certified. + optional sui.rpc.v2.ValidatorAggregatedSignature signature = 4; + + // The slice of this checkpoint's `CheckpointContents` that covers the same + // transactions as this part, starting at `first_tx_index`. + optional CheckpointContentsPart contents = 5; + + // A contiguous slice of this checkpoint's transactions, in the order the + // checkpoint lists them: the entry at position `i` is the transaction at + // checkpoint-local index `first_tx_index + i`, which is also the value of + // its `transaction_index` when requested. + // + // `transactions.events.bcs` is never returned (see `CheckpointPart`); + // request `transactions.events.events`, and `transactions.events.digest` + // to verify them. `transactions.objects` is never populated: objects are + // delivered, deduplicated, in `objects`. + // + // A request for both `contents` and `transactions` can leave + // `transactions.signatures` out of `read_mask` and read the user signatures + // from `contents.transactions.signatures.bcs`, so that each signature is + // sent once, in one form. + repeated sui.rpc.v2.ExecutedTransaction transactions = 6; + + // The set of objects referenced as inputs or produced as outputs by this + // part's transactions, or, on a part that continues a transaction's + // objects, the next of that transaction's objects. Objects are + // deduplicated within a part, in (`object_id`, `version`) order; an object + // used by transactions in different parts can appear in each of them. + // + // A request for `objects` without `transactions` still receives parts that + // each cover a contiguous range of the checkpoint's transactions; to tell + // which transactions a part's objects belong to, also request + // `transactions.digest`. + optional sui.rpc.v2.ObjectSet objects = 7; + + // Zero-based index of this part within the checkpoint. Set on every part. + optional uint32 part_index = 8; + + // True on the last part of the checkpoint and false on every part before + // it. Never true while `events_continue` or `objects_continue` is true. Set + // on every part. + optional bool is_last = 9; + + // Zero-based checkpoint-local index of the first transaction in + // `transactions` and `contents.transactions`. Set when either is + // non-empty; unset on parts that carry neither, such as continuation + // parts, parts that carry only checkpoint-level fields, and the single + // part of a checkpoint with no transactions. + optional uint64 first_tx_index = 10; + + // Total number of transactions in the checkpoint. Set on part 0. + optional uint64 total_transactions = 11; + + // Global sequence number of the checkpoint's first transaction (index 0), + // equal to `summary.total_network_transactions - total_transactions`. Set + // on part 0. + optional uint64 first_tx_sequence_number = 12; + + // True when more objects of the transaction this part carries or continues + // follow in the next parts (see `CheckpointPart`). It is reliable only on + // parts where `events_continue` is false: while a transaction's events + // still continue, it may be false even though the transaction's objects + // follow its events. + optional bool objects_continue = 13; + + // The next events of the transaction whose events continue from an earlier + // part (see `events_continue`), in emission order. Set only on parts that + // continue a transaction's events, which carry no `transactions` and no + // `contents`. Its events carry the fields that `read_mask` selects under + // `transactions.events.events`; events continue only when the mask selects + // transaction events. + repeated sui.rpc.v2.Event continuation_events = 14; + + // True when more events of the transaction this part carries or continues + // follow in the next parts, in `continuation_events` (see + // `CheckpointPart`). + optional bool events_continue = 15; +} + +// The slice of a checkpoint's `CheckpointContents` that one `CheckpointPart` +// carries. +message CheckpointContentsPart { + // Field 1 is `bcs` in `sui.rpc.v2.CheckpointContents`; parts never carry + // the monolithic BCS form. + reserved 1; + reserved "bcs"; + + // The digest of the checkpoint's whole `CheckpointContents`, equal to + // `summary.content_digest`. Set on part 0 when requested. + optional string digest = 2; + + // Version of the checkpoint's `CheckpointContents` (1 or 2). Set on part 0 + // whenever any `contents` field is requested. + optional int32 version = 3; + + // The entries for this part's transactions, in checkpoint order: the entry + // at position `i` is for the transaction at checkpoint-local index + // `CheckpointPart.first_tx_index + i`. + // + // Sub-paths of `signatures` in `read_mask` select which forms of each + // signature are returned; for example, `contents.transactions.signatures.bcs` + // returns only the BCS form. + repeated sui.rpc.v2.CheckpointedTransactionInfo transactions = 4; +} diff --git a/crates/sui-rpc/vendored/proto/sui/rpc/v2beta/ledger_service.proto b/crates/sui-rpc/vendored/proto/sui/rpc/v2beta/ledger_service.proto new file mode 100644 index 0000000000..e40fa649ef --- /dev/null +++ b/crates/sui-rpc/vendored/proto/sui/rpc/v2beta/ledger_service.proto @@ -0,0 +1,215 @@ +// Copyright (c) Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + +syntax = "proto3"; + +package sui.rpc.v2beta; + +import "google/protobuf/field_mask.proto"; +import "sui/rpc/v2/filter.proto"; +import "sui/rpc/v2/query_options.proto"; +import "sui/rpc/v2beta/checkpoint.proto"; + +// Streaming reads of checkpoints split into bounded-size parts. +// +// These RPCs serve the same checkpoints as `sui.rpc.v2.LedgerService` +// `GetCheckpoint` and `ListCheckpoints`, but deliver each checkpoint as a +// sequence of `CheckpointPart` messages, so a checkpoint too large for one +// message can still be read (see `sui.rpc.v2.ErrorReason.RESPONSE_TOO_LARGE` +// and, for client receive limits, `CheckpointPart`). +// +// Two kinds of resume point: +// +// - Checkpoint cursors (`Watermark.cursor`, passed back in `QueryOptions`) +// work at checkpoint granularity and are interchangeable with those of +// `sui.rpc.v2.LedgerService.ListCheckpoints`. Use them to page through +// checkpoints. +// - `resume_token` marks the point a frame left off: either the start of +// the next checkpoint, or the next part of a checkpoint the stream was +// partway through, so a client whose stream breaks mid-checkpoint can +// continue from the next part instead of starting the checkpoint over. +// Tokens are opaque: pass them back unchanged and never inspect or compare +// them. +service LedgerService { + // Get one checkpoint as a stream of parts. + // + // The stream sends the checkpoint's parts in order and ends after the part + // with `is_last` set. + rpc GetCheckpointParts(GetCheckpointPartsRequest) returns (stream GetCheckpointPartsResponse); + + // List checkpoints matching the provided filters, each as a stream of + // parts. + // + // Checkpoints are returned in ascending or descending checkpoint sequence + // number order according to the query options ordering; the parts of each + // checkpoint are always sent in ascending `part_index` order, one + // checkpoint at a time. A checkpoint matches if any transaction it contains + // satisfies the filter, and every part of a matching checkpoint is sent. + rpc ListCheckpointParts(ListCheckpointPartsRequest) returns (stream ListCheckpointPartsResponse); +} + +// Request message for LedgerService.GetCheckpointParts. +// +// A server that prunes history refuses a checkpoint below its lowest +// available checkpoint with `OUT_OF_RANGE` and reason +// `BELOW_EARLIEST_AVAILABLE`, as `sui.rpc.v2.LedgerService.GetCheckpoint` +// does. A stream whose checkpoint is pruned while it is being sent fails the +// same way. +message GetCheckpointPartsRequest { + // The checkpoint to read, looked up as by + // `sui.rpc.v2.GetCheckpointRequest`. If neither is provided, the latest + // checkpoint, unless `resume_token` is set: then the checkpoint the token + // resumes in. A token from a part that is not the last of its checkpoint + // resumes in that checkpoint. A token from a checkpoint's last part, or + // from a frame without a part, resumes at the start of the next checkpoint + // in its stream's direction, whether or not that checkpoint matches the + // stream's filter. When both this and `resume_token` are set, they must + // name the same checkpoint, or the request fails with `INVALID_ARGUMENT`. + oneof checkpoint_id { + // The sequence number of the requested checkpoint. + uint64 sequence_number = 1; + + // The digest of the requested checkpoint. + string digest = 2; + } + + // Mask specifying which `CheckpointPart` fields to read. + // If no mask is specified, defaults to `sequence_number,digest`. + // A mask naming `transactions.events.bcs` or `contents.bcs` fails with + // `INVALID_ARGUMENT` (see `CheckpointPart`). + optional google.protobuf.FieldMask read_mask = 3; + + // Optional. A `resume_token` from an earlier `GetCheckpointPartsResponse`, + // `ListCheckpointPartsResponse` or `SubscribeCheckpointPartsResponse`, to + // continue from the point where that token's frame left off (see + // `checkpoint_id`). Resume with the same `read_mask` as the stream the + // token came from: a mask that does not select what the token resumes + // partway through fails with `INVALID_ARGUMENT`. + // + // When the stream resumes after part 0, the fields set only on part 0 + // (`digest`, `summary`, `signature`, `total_transactions`, + // `first_tx_sequence_number`, `contents.version` and `contents.digest`) are + // not sent again; keep them from the earlier stream. + optional bytes resume_token = 4; +} + +// Response message for LedgerService.GetCheckpointParts. +message GetCheckpointPartsResponse { + // One part of the requested checkpoint. + optional CheckpointPart part = 1; + + // Token to resume reading after this part. Set on every part except the + // last (`is_last` true), after which nothing remains to resume. + optional bytes resume_token = 2; +} + +// Request message for LedgerService.ListCheckpointParts. +// +// Range, cursor, pruning and indexed-tip rules follow +// `sui.rpc.v2.ListCheckpointsRequest`; see `sui.rpc.v2.ErrorReason` +// `ABOVE_LATEST_AVAILABLE` and `BELOW_EARLIEST_AVAILABLE`. +message ListCheckpointPartsRequest { + // Mask specifying which `CheckpointPart` fields to read. + // If no mask is specified, defaults to `sequence_number,digest`. + // A mask naming `transactions.events.bcs` or `contents.bcs` fails with + // `INVALID_ARGUMENT` (see `CheckpointPart`). + optional google.protobuf.FieldMask read_mask = 1; + + // Optional. Start of the checkpoint range to query (inclusive). Defaults to + // genesis. + optional uint64 start_checkpoint = 2; + + // Optional. End of the checkpoint range to query (exclusive). Defaults to + // the current indexed ledger tip. + optional uint64 end_checkpoint = 3; + + // Optional. DNF filter over indexed transaction dimensions. A checkpoint + // matches if any transaction it contains satisfies the filter, and every + // part of a matching checkpoint is returned. If absent, all checkpoints in + // the range are returned. + // + // A `resume_token` that resumes in the middle of a checkpoint must name a + // checkpoint that matches the filter, or the request fails with + // `INVALID_ARGUMENT`. That checkpoint counts toward `options.limit` like + // any other. + optional sui.rpc.v2.TransactionFilter filter = 4; + + // Optional cursor-bounded query options, as for + // `sui.rpc.v2.ListCheckpointsRequest.options`. The items are checkpoints: + // `after` and `before` are checkpoint cursors interchangeable with those of + // `ListCheckpoints`, and `limit` counts complete checkpoints, so a listing + // never ends partway through a checkpoint. If unspecified, reads in + // ascending order with the default item limit. The server enforces a + // maximum item limit and silently coerces larger values down to it. To + // paginate, pass the last received `Watermark.cursor` as `options.after` + // (ascending) or `options.before` (descending) on the next request. + optional sui.rpc.v2.QueryOptions options = 5; + + // Optional. A `resume_token` from an earlier `ListCheckpointPartsResponse` + // or `SubscribeCheckpointPartsResponse`, to continue from exactly where + // that frame left off: at the next checkpoint, or at the next part of a + // checkpoint it was partway through. Resume with the same `read_mask`, + // `filter` and `options.ordering` as the stream the token came from (see + // `GetCheckpointPartsRequest.resume_token`). + // + // A token takes the place of the start bound in the listing's direction: + // a request that sets both `resume_token` and `options.after` when + // ascending, or `options.before` when descending, fails with + // `INVALID_ARGUMENT`. The far cursor bound and the checkpoint range still + // apply. The request also fails with `INVALID_ARGUMENT` when the token was + // issued for the other ordering, or when it resumes partway through a + // checkpoint outside the request's bounds. A descending request whose + // token names a checkpoint above the latest indexed checkpoint fails with + // `OUT_OF_RANGE` and reason `ABOVE_LATEST_AVAILABLE` (bound "cursor"). + // + // When the stream resumes partway through a checkpoint, the fields set + // only on part 0 are not sent again (see + // `GetCheckpointPartsRequest.resume_token`). + optional bytes resume_token = 6; +} + +// Response message for LedgerService.ListCheckpointParts. +// +// Every frame carries a `watermark` and a `resume_token`. A frame with +// `part` set delivers one part of a matching checkpoint; a frame without it +// reports scan progress or terminal completion. Watermarks never regress in +// the requested ordering but may repeat. +// +// `end` is set exactly once, on the final frame of a successful stream. For +// `QUERY_END_REASON_ITEM_LIMIT`, that frame also carries the last part (with +// `is_last` set) of the final checkpoint. For every other end reason, the +// final frame has no `part`. +message ListCheckpointPartsResponse { + // One part of a matching checkpoint. Unset on frames that only report + // progress or the end of the stream. + optional CheckpointPart part = 1; + + // Progress watermark as of this frame, at checkpoint granularity, with the + // semantics of `sui.rpc.v2.ListCheckpointsResponse.watermark`. Present on + // every frame. While a checkpoint's parts are being sent, the watermark + // stays at the resume point from before that checkpoint's first part, so + // resuming from it reads the whole checkpoint again. On the frame carrying + // the checkpoint's last part (`is_last` true) it moves past the checkpoint + // in the listing's direction. Frames without a `part` move it past + // checkpoints that do not match. + optional sui.rpc.v2.Watermark watermark = 2; + + // Token to resume the listing right after this frame. Present on every + // frame. + // + // A token from a frame whose `part` is not the last of its checkpoint + // resumes partway through that checkpoint, and the resumed stream does not + // resend the fields set only on part 0. Use such a token to reconnect a + // broken stream while still holding what it delivered. To record a restart + // point that does not depend on earlier parts, keep only tokens from + // frames whose `part` has `is_last` set, or that carry no `part`. + // + // When an ascending request's `resume_token` names a checkpoint above the + // latest indexed checkpoint, the stream's only frame has no `part`, ends + // the stream with `QUERY_END_REASON_LEDGER_TIP`, and returns the request's + // `resume_token` unchanged, so the same request can be retried later. + optional bytes resume_token = 3; + + // Set exactly once, on the final frame of a successful query stream. + optional sui.rpc.v2.QueryEnd end = 4; +} diff --git a/crates/sui-rpc/vendored/proto/sui/rpc/v2beta/subscription_service.proto b/crates/sui-rpc/vendored/proto/sui/rpc/v2beta/subscription_service.proto new file mode 100644 index 0000000000..dc3d93201e --- /dev/null +++ b/crates/sui-rpc/vendored/proto/sui/rpc/v2beta/subscription_service.proto @@ -0,0 +1,99 @@ +// Copyright (c) Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + +syntax = "proto3"; + +package sui.rpc.v2beta; + +import "google/protobuf/field_mask.proto"; +import "sui/rpc/v2/filter.proto"; +import "sui/rpc/v2/query_options.proto"; +import "sui/rpc/v2beta/checkpoint.proto"; + +// Real-time streams of checkpoints split into bounded-size parts. +// +// `SubscribeCheckpointParts` pairs with `LedgerService.ListCheckpointParts` +// in this package as `sui.rpc.v2.SubscriptionService.SubscribeCheckpoints` +// pairs with `sui.rpc.v2.LedgerService.ListCheckpoints`: it takes the same +// filter, and its frames carry the same part, watermark and `resume_token` +// shapes. Like the other subscriptions it starts at the current tip of the +// chain as seen by the server, behaves like an unbounded ascending scan, and +// has no successful end. +// +// A subscription cannot be resumed, but `ListCheckpointParts` and +// `GetCheckpointParts` can continue from its `resume_token`s. To recover +// after a broken subscription: +// +// 1. Open a new subscription and read its first frame. Its starting +// checkpoint is `part.sequence_number` if the frame carries a `part`, and +// `watermark.cursor_position.checkpoint` otherwise. +// 2. If the new subscription starts at or before the last checkpoint the old +// one reached, for example on a replica that lags behind, skip the new +// subscription's frames for checkpoints the old one delivered in full +// (through its last `part` with `is_last` set). If the old subscription +// was partway through a checkpoint (its last `part` did not have +// `is_last` set), either discard that incomplete checkpoint and read it +// again from part 0 on the new subscription, or finish it with +// `GetCheckpointParts` and the last `resume_token` received, then skip +// that checkpoint's frames on the new subscription too. +// 3. Otherwise, replay the gap with `ListCheckpointParts`, passing the last +// `resume_token` received, the subscription's `read_mask` and `filter`, +// and `end_checkpoint` set to the new subscription's starting checkpoint. +// Repeat the listing with the last `resume_token` it returned until it +// ends with `QUERY_END_REASON_CHECKPOINT_BOUND`; any other end reason +// means part of the gap remains, for example +// `QUERY_END_REASON_LEDGER_TIP` while the indexed tip trails the +// subscription, or `QUERY_END_REASON_ITEM_LIMIT` on a gap longer than one +// listing returns. Then continue with the new subscription's frames, +// starting with the first. +service SubscriptionService { + // Subscribe to the stream of checkpoints, each as a sequence of parts. + // + // The stream begins at the latest executed checkpoint as seen by the + // server and yields every part of each checkpoint matching the filter as + // it is executed. A checkpoint matches if any transaction it contains + // satisfies the filter. + rpc SubscribeCheckpointParts(SubscribeCheckpointPartsRequest) returns (stream SubscribeCheckpointPartsResponse); +} + +// Request message for SubscriptionService.SubscribeCheckpointParts. +message SubscribeCheckpointPartsRequest { + // Mask specifying which `CheckpointPart` fields to read. + // If no mask is specified, defaults to `sequence_number,digest`. + // A mask naming `transactions.events.bcs` or `contents.bcs` fails with + // `INVALID_ARGUMENT` (see `CheckpointPart`). + optional google.protobuf.FieldMask read_mask = 1; + + // Optional. DNF filter over indexed transaction dimensions, as for + // `sui.rpc.v2.SubscribeCheckpointsRequest.filter`. A checkpoint matches if + // any transaction it contains satisfies the filter, and every part of a + // matching checkpoint is streamed. If absent, every checkpoint is + // streamed. + optional sui.rpc.v2.TransactionFilter filter = 2; +} + +// Response message for SubscriptionService.SubscribeCheckpointParts. +// +// Mirrors `LedgerService.ListCheckpointPartsResponse`, except there is no +// `end` field: a subscription stream has no successful end. As on the other +// filtered subscriptions, the first frame of a filtered stream carries no +// `part` and establishes the stream's start position, and frames without a +// `part` keep reporting progress while no checkpoint matches. +message SubscribeCheckpointPartsResponse { + // One part of a matching checkpoint. Unset on frames that only report + // progress. + optional CheckpointPart part = 1; + + // Progress watermark as of this frame, with the semantics of + // `ListCheckpointPartsResponse.watermark`. Present on every frame. + optional sui.rpc.v2.Watermark watermark = 2; + + // Token to resume right after this frame, in the same format as + // `ListCheckpointPartsResponse.resume_token`. Present on every frame. Pass + // it as `ListCheckpointPartsRequest.resume_token` to replay what a broken + // subscription missed, or as `GetCheckpointPartsRequest.resume_token` to + // finish a checkpoint it was partway through without reading that + // checkpoint again from part 0 (see the recovery steps on + // `SubscriptionService`). + optional bytes resume_token = 3; +}