From b24b871e16c131092033c78fc2a15583587c93b0 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 20 Feb 2025 16:10:21 -0600 Subject: [PATCH] proto: remove options field from GetFullCheckpointRequest --- crates/sui-e2e-tests/tests/rpc/checkpoints.rs | 34 ++- .../proto/sui/node/v2/node_service.proto | 80 ----- crates/sui-rpc-api/src/client/mod.rs | 17 -- crates/sui-rpc-api/src/grpc.rs | 10 +- .../src/proto/generated/sui.node.v2.fds.bin | Bin 7781 -> 6898 bytes .../src/proto/generated/sui.node.v2.rs | 82 ----- crates/sui-rpc-api/src/proto/node.rs | 283 +----------------- crates/sui-rpc-api/src/subscription.rs | 3 +- crates/sui-rpc-api/src/types.rs | 32 ++ 9 files changed, 56 insertions(+), 485 deletions(-) diff --git a/crates/sui-e2e-tests/tests/rpc/checkpoints.rs b/crates/sui-e2e-tests/tests/rpc/checkpoints.rs index 1700a37def94f..2309571b681ef 100644 --- a/crates/sui-e2e-tests/tests/rpc/checkpoints.rs +++ b/crates/sui-e2e-tests/tests/rpc/checkpoints.rs @@ -7,7 +7,7 @@ use sui_rpc_api::field_mask::FieldMaskUtil; use sui_rpc_api::proto::node::v2::node_service_client::NodeServiceClient; use sui_rpc_api::proto::node::v2::{ FullCheckpointObject, FullCheckpointTransaction, GetCheckpointRequest, GetCheckpointResponse, - GetFullCheckpointOptions, GetFullCheckpointRequest, GetFullCheckpointResponse, + GetFullCheckpointRequest, GetFullCheckpointResponse, }; use test_cluster::TestClusterBuilder; @@ -245,10 +245,7 @@ async fn get_full_checkpoint() { contents_bcs, transactions, } = grpc_client - .get_full_checkpoint( - GetFullCheckpointRequest::by_sequence_number(checkpoint) - .with_options(GetFullCheckpointOptions::none()), - ) + .get_full_checkpoint(GetFullCheckpointRequest::by_sequence_number(checkpoint)) .await .unwrap() .into_inner(); @@ -293,8 +290,18 @@ async fn get_full_checkpoint() { // Request all fields let response = grpc_client .get_full_checkpoint( - GetFullCheckpointRequest::by_sequence_number(checkpoint) - .with_options(GetFullCheckpointOptions::all()), + GetFullCheckpointRequest::by_sequence_number(checkpoint).with_read_mask( + FieldMaskUtil::from_paths([ + "sequence_number", + "digest", + "summary", + "summary_bcs", + "signature", + "contents", + "contents_bcs", + "transactions", + ]), + ), ) .await .unwrap() @@ -368,10 +375,7 @@ async fn get_full_checkpoint() { // Request by digest let response = grpc_client - .get_full_checkpoint( - GetFullCheckpointRequest::by_digest(digest.clone().unwrap()) - .with_options(GetFullCheckpointOptions::none()), - ) + .get_full_checkpoint(GetFullCheckpointRequest::by_digest(digest.clone().unwrap())) .await .unwrap() .into_inner(); @@ -379,10 +383,9 @@ async fn get_full_checkpoint() { // Request by sequence_number let response = grpc_client - .get_full_checkpoint( - GetFullCheckpointRequest::by_sequence_number(sequence_number.unwrap()) - .with_options(GetFullCheckpointOptions::none()), - ) + .get_full_checkpoint(GetFullCheckpointRequest::by_sequence_number( + sequence_number.unwrap(), + )) .await .unwrap() .into_inner(); @@ -394,7 +397,6 @@ async fn get_full_checkpoint() { .get_full_checkpoint(GetFullCheckpointRequest { sequence_number: Some(sequence_number.unwrap()), digest: Some(digest.clone().unwrap()), - options: None, read_mask: None, }) .await diff --git a/crates/sui-rpc-api/proto/sui/node/v2/node_service.proto b/crates/sui-rpc-api/proto/sui/node/v2/node_service.proto index ad78229fb0aac..d6bd0eb67b3c0 100644 --- a/crates/sui-rpc-api/proto/sui/node/v2/node_service.proto +++ b/crates/sui-rpc-api/proto/sui/node/v2/node_service.proto @@ -287,91 +287,11 @@ message GetFullCheckpointRequest { // Optional. The digest of the requested checkpoint. optional sui.types.Digest digest = 2; - // DEPRECATED To be removed in the next release - optional GetFullCheckpointOptions options = 3; // Optional. Mask for specifying which parts of the `GetFullCheckpointResponse` // should be returned. optional google.protobuf.FieldMask read_mask = 4; } -// DEPRECATED To be removed in the next release -message GetFullCheckpointOptions { - // Include the `sui.types.CheckpointSummary` in the response. - // - // Defaults to `false` if not included. - optional bool summary = 3; - - // Include the `CheckpointSummary` formatted as BCS in the response. - // - // Defaults to `false` if not included. - optional bool summary_bcs = 4; - - // Include the `sui.types.ValidatorAggregatedSignature` in the response. - // - // Defaults to `false` if not included. - optional bool signature = 5; - - // Include the `sui.types.CheckpointContents` message in the response. - // - // Defaults to `false` if not included. - optional bool contents = 6; - - // Include the `CheckpointContents` formatted as BCS in the response. - // - // Defaults to `false` if not included. - optional bool contents_bcs = 7; - - // Include the `sui.types.Transaction` message in the response. - // - // Defaults to `false` if not included. - optional bool transaction = 8; - - // Include the transaction formatted as BCS in the response. - // - // Defaults to `false` if not included. - optional bool transaction_bcs = 9; - - // Include the `sui.types.TransactionEffects` message in the response. - // - // Defaults to `false` if not included. - optional bool effects = 10; - - // Include the `TransactionEffects` formatted as BCS in the response. - // - // Defaults to `false` if not included. - optional bool effects_bcs = 11; - - // Include the `sui.types.TransactionEvents` message in the response. - // - // Defaults to `false` if not included. - optional bool events = 12; - - // Include the `TransactionEvents` formatted as BCS in the response. - // - // Defaults to `false` if not included. - optional bool events_bcs = 13; - - // Include the input objects for transactions in the response. - // - // Defaults to `false` if not included. - optional bool input_objects = 14; - - // Include the output objects for transactions in the response. - // - // Defaults to `false` if not included. - optional bool output_objects = 15; - - // Include the `sui.types.Object` message in the response. - // - // Defaults to `false` if not included. - optional bool object = 16; - - // Include the object formatted as BCS in the response. - // - // Defaults to `false` if not included. - optional bool object_bcs = 17; -} - // Response message for `NodeService.GetFullCheckpoint`. message GetFullCheckpointResponse { // The sequence number of this checkpoint. diff --git a/crates/sui-rpc-api/src/client/mod.rs b/crates/sui-rpc-api/src/client/mod.rs index 3fb68d4bb0609..76a549459c9e9 100644 --- a/crates/sui-rpc-api/src/client/mod.rs +++ b/crates/sui-rpc-api/src/client/mod.rs @@ -120,23 +120,6 @@ impl Client { let request = crate::proto::node::v2::GetFullCheckpointRequest { sequence_number: Some(sequence_number), digest: None, - options: Some(crate::proto::node::v2::GetFullCheckpointOptions { - summary: Some(false), - summary_bcs: Some(true), - signature: Some(true), - contents: Some(false), - contents_bcs: Some(true), - transaction: Some(false), - transaction_bcs: Some(true), - effects: Some(false), - effects_bcs: Some(true), - events: Some(false), - events_bcs: Some(true), - input_objects: Some(true), - output_objects: Some(true), - object: Some(false), - object_bcs: Some(true), - }), read_mask: FieldMaskUtil::from_paths([ "summary_bcs", "signature", diff --git a/crates/sui-rpc-api/src/grpc.rs b/crates/sui-rpc-api/src/grpc.rs index 8c7d8b15fb5e9..a5535868ae48a 100644 --- a/crates/sui-rpc-api/src/grpc.rs +++ b/crates/sui-rpc-api/src/grpc.rs @@ -197,13 +197,9 @@ impl crate::proto::node::v2::node_service_server::NodeService for crate::RpcServ } }; - let options = if let Some(read_mask) = request.read_mask { - crate::types::GetFullCheckpointOptions::from_read_mask(read_mask) - } else if let Some(options) = request.options { - options.into() - } else { - Default::default() - }; + let options = crate::types::GetFullCheckpointOptions::from_read_mask( + request.read_mask.unwrap_or_default(), + ); self.get_full_checkpoint(checkpoint, &options) .map(Into::into) diff --git a/crates/sui-rpc-api/src/proto/generated/sui.node.v2.fds.bin b/crates/sui-rpc-api/src/proto/generated/sui.node.v2.fds.bin index cf31c658cfde83cd02e8f7ac99ce1ac808470e83..853ccf3b829ed00d42493a1628d5000b93b63ca7 100644 GIT binary patch delta 37 tcmaEA^U0K%>%Hkl=4c+K$BdH`cq%8~<;-Sz%)%u(`L3+g=Bok|cmWKs4Z#2a delta 725 zcmY+A%TB^T6oxIuUQSy;;-W&l5jDiiM&phZ8YOW-GFxM6sYQ#>5;`?;#nz?C?0pAg zT>2_5G`@gOVCQsdVA=0{=Rg1S_xPtJ!&mE7zBCK(1$J#dR!>2V#x#h+*p@e>rg6B< zu4-%5ZpJzVl8@PkdL+rrf`ci5=7^=X3E)h8_r@8y@qOb(0sGviXUTAQa_4*Z<0uHJ z$f~Y_8YiQXJ9)%YT4#ae;7O9ITVRN>)AM4xn6}Y65&;3*Ud*jc(5G>58@e=^`1T@7 z1)~2W?yQ66MIrS=8rupQGWjQ5*a0&a@Ro{Fkr+7@$F{+s6E}=qkN+WCLv3-7%u=4W z59JvTBXx8Y=2n)c>BIeg-}llwfLJ9t;M?iL#TYjYR5SttiY|3f{0DrJiGohVH;-rl zWJ64_PynK5Y$_6(U1i{C|9VS`%jt!F)3 Ee`VLuM*si- diff --git a/crates/sui-rpc-api/src/proto/generated/sui.node.v2.rs b/crates/sui-rpc-api/src/proto/generated/sui.node.v2.rs index 72c1a2c69839c..da9b0e82e9a79 100644 --- a/crates/sui-rpc-api/src/proto/generated/sui.node.v2.rs +++ b/crates/sui-rpc-api/src/proto/generated/sui.node.v2.rs @@ -213,93 +213,11 @@ pub struct GetFullCheckpointRequest { /// Optional. The digest of the requested checkpoint. #[prost(message, optional, tag = "2")] pub digest: ::core::option::Option, - /// DEPRECATED To be removed in the next release - #[prost(message, optional, tag = "3")] - pub options: ::core::option::Option, /// Optional. Mask for specifying which parts of the `GetFullCheckpointResponse` /// should be returned. #[prost(message, optional, tag = "4")] pub read_mask: ::core::option::Option<::prost_types::FieldMask>, } -/// DEPRECATED To be removed in the next release -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct GetFullCheckpointOptions { - /// Include the `sui.types.CheckpointSummary` in the response. - /// - /// Defaults to `false` if not included. - #[prost(bool, optional, tag = "3")] - pub summary: ::core::option::Option, - /// Include the `CheckpointSummary` formatted as BCS in the response. - /// - /// Defaults to `false` if not included. - #[prost(bool, optional, tag = "4")] - pub summary_bcs: ::core::option::Option, - /// Include the `sui.types.ValidatorAggregatedSignature` in the response. - /// - /// Defaults to `false` if not included. - #[prost(bool, optional, tag = "5")] - pub signature: ::core::option::Option, - /// Include the `sui.types.CheckpointContents` message in the response. - /// - /// Defaults to `false` if not included. - #[prost(bool, optional, tag = "6")] - pub contents: ::core::option::Option, - /// Include the `CheckpointContents` formatted as BCS in the response. - /// - /// Defaults to `false` if not included. - #[prost(bool, optional, tag = "7")] - pub contents_bcs: ::core::option::Option, - /// Include the `sui.types.Transaction` message in the response. - /// - /// Defaults to `false` if not included. - #[prost(bool, optional, tag = "8")] - pub transaction: ::core::option::Option, - /// Include the transaction formatted as BCS in the response. - /// - /// Defaults to `false` if not included. - #[prost(bool, optional, tag = "9")] - pub transaction_bcs: ::core::option::Option, - /// Include the `sui.types.TransactionEffects` message in the response. - /// - /// Defaults to `false` if not included. - #[prost(bool, optional, tag = "10")] - pub effects: ::core::option::Option, - /// Include the `TransactionEffects` formatted as BCS in the response. - /// - /// Defaults to `false` if not included. - #[prost(bool, optional, tag = "11")] - pub effects_bcs: ::core::option::Option, - /// Include the `sui.types.TransactionEvents` message in the response. - /// - /// Defaults to `false` if not included. - #[prost(bool, optional, tag = "12")] - pub events: ::core::option::Option, - /// Include the `TransactionEvents` formatted as BCS in the response. - /// - /// Defaults to `false` if not included. - #[prost(bool, optional, tag = "13")] - pub events_bcs: ::core::option::Option, - /// Include the input objects for transactions in the response. - /// - /// Defaults to `false` if not included. - #[prost(bool, optional, tag = "14")] - pub input_objects: ::core::option::Option, - /// Include the output objects for transactions in the response. - /// - /// Defaults to `false` if not included. - #[prost(bool, optional, tag = "15")] - pub output_objects: ::core::option::Option, - /// Include the `sui.types.Object` message in the response. - /// - /// Defaults to `false` if not included. - #[prost(bool, optional, tag = "16")] - pub object: ::core::option::Option, - /// Include the object formatted as BCS in the response. - /// - /// Defaults to `false` if not included. - #[prost(bool, optional, tag = "17")] - pub object_bcs: ::core::option::Option, -} /// Response message for `NodeService.GetFullCheckpoint`. #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetFullCheckpointResponse { diff --git a/crates/sui-rpc-api/src/proto/node.rs b/crates/sui-rpc-api/src/proto/node.rs index 52b13a5b7be57..f7848be57c0c1 100644 --- a/crates/sui-rpc-api/src/proto/node.rs +++ b/crates/sui-rpc-api/src/proto/node.rs @@ -305,282 +305,6 @@ impl GetTransactionRequest { } } -// -// GetFullCheckpointOptions -// - -impl GetFullCheckpointOptions { - pub fn all() -> Self { - Self { - summary: Some(true), - summary_bcs: Some(true), - signature: Some(true), - contents: Some(true), - contents_bcs: Some(true), - transaction: Some(true), - transaction_bcs: Some(true), - effects: Some(true), - effects_bcs: Some(true), - events: Some(true), - events_bcs: Some(true), - input_objects: Some(true), - output_objects: Some(true), - object: Some(true), - object_bcs: Some(true), - } - } - - pub fn none() -> Self { - Self { - summary: Some(false), - summary_bcs: Some(false), - signature: Some(false), - contents: Some(false), - contents_bcs: Some(false), - transaction: Some(false), - transaction_bcs: Some(false), - effects: Some(false), - effects_bcs: Some(false), - events: Some(false), - events_bcs: Some(false), - input_objects: Some(false), - output_objects: Some(false), - object: Some(false), - object_bcs: Some(false), - } - } - - pub fn with_summary(mut self) -> Self { - self.summary = Some(true); - self - } - - pub fn without_summary(mut self) -> Self { - self.summary = Some(false); - self - } - - pub fn with_summary_bcs(mut self) -> Self { - self.summary_bcs = Some(true); - self - } - - pub fn without_summary_bcs(mut self) -> Self { - self.summary_bcs = Some(false); - self - } - - pub fn with_signature(mut self) -> Self { - self.signature = Some(true); - self - } - - pub fn without_signature(mut self) -> Self { - self.signature = Some(false); - self - } - - pub fn with_contents(mut self) -> Self { - self.contents = Some(true); - self - } - - pub fn without_contents(mut self) -> Self { - self.contents = Some(false); - self - } - - pub fn with_contents_bcs(mut self) -> Self { - self.contents_bcs = Some(true); - self - } - - pub fn without_contents_bcs(mut self) -> Self { - self.contents_bcs = Some(false); - self - } - - pub fn with_transaction(mut self) -> Self { - self.transaction = Some(true); - self - } - - pub fn without_transaction(mut self) -> Self { - self.transaction = Some(false); - self - } - - pub fn with_transaction_bcs(mut self) -> Self { - self.transaction_bcs = Some(true); - self - } - - pub fn without_transaction_bcs(mut self) -> Self { - self.transaction_bcs = Some(false); - self - } - - pub fn with_effects(mut self) -> Self { - self.effects = Some(true); - self - } - - pub fn without_effects(mut self) -> Self { - self.effects = Some(false); - self - } - - pub fn with_effects_bcs(mut self) -> Self { - self.effects_bcs = Some(true); - self - } - - pub fn without_effects_bcs(mut self) -> Self { - self.effects_bcs = Some(false); - self - } - - pub fn with_events(mut self) -> Self { - self.events = Some(true); - self - } - - pub fn without_events(mut self) -> Self { - self.events = Some(false); - self - } - - pub fn with_events_bcs(mut self) -> Self { - self.events_bcs = Some(true); - self - } - - pub fn without_events_bcs(mut self) -> Self { - self.events_bcs = Some(false); - self - } - - pub fn with_input_objects(mut self) -> Self { - self.input_objects = Some(true); - self - } - - pub fn without_input_objects(mut self) -> Self { - self.input_objects = Some(false); - self - } - - pub fn with_output_objects(mut self) -> Self { - self.output_objects = Some(true); - self - } - - pub fn without_output_objects(mut self) -> Self { - self.output_objects = Some(false); - self - } - - pub fn with_object(mut self) -> Self { - self.object = Some(true); - self - } - - pub fn without_object(mut self) -> Self { - self.object = Some(false); - self - } - - pub fn with_object_bcs(mut self) -> Self { - self.object_bcs = Some(true); - self - } - - pub fn without_object_bcs(mut self) -> Self { - self.object = Some(false); - self - } -} - -impl From for GetFullCheckpointOptions { - fn from( - crate::types::GetFullCheckpointOptions { - summary, - summary_bcs, - signature, - contents, - contents_bcs, - transaction, - transaction_bcs, - effects, - effects_bcs, - events, - events_bcs, - input_objects, - output_objects, - object, - object_bcs, - }: crate::types::GetFullCheckpointOptions, - ) -> Self { - Self { - summary, - summary_bcs, - signature, - contents, - contents_bcs, - transaction, - transaction_bcs, - effects, - effects_bcs, - events, - events_bcs, - input_objects, - output_objects, - object, - object_bcs, - } - } -} - -impl From for crate::types::GetFullCheckpointOptions { - fn from( - GetFullCheckpointOptions { - summary, - summary_bcs, - signature, - contents, - contents_bcs, - transaction, - transaction_bcs, - effects, - effects_bcs, - events, - events_bcs, - input_objects, - output_objects, - object, - object_bcs, - }: GetFullCheckpointOptions, - ) -> Self { - Self { - summary, - summary_bcs, - signature, - contents, - contents_bcs, - transaction, - transaction_bcs, - effects, - effects_bcs, - events, - events_bcs, - input_objects, - output_objects, - object, - object_bcs, - } - } -} - // // GetFullCheckpointRequest // @@ -590,7 +314,6 @@ impl GetFullCheckpointRequest { Self { sequence_number: None, digest: None, - options: None, read_mask: None, } } @@ -599,7 +322,6 @@ impl GetFullCheckpointRequest { Self { sequence_number: None, digest: Some(digest.into()), - options: None, read_mask: None, } } @@ -608,13 +330,12 @@ impl GetFullCheckpointRequest { Self { sequence_number: Some(sequence_number), digest: None, - options: None, read_mask: None, } } - pub fn with_options(mut self, options: GetFullCheckpointOptions) -> Self { - self.options = Some(options); + pub fn with_read_mask(mut self, read_mask: FieldMask) -> Self { + self.read_mask = Some(read_mask); self } } diff --git a/crates/sui-rpc-api/src/subscription.rs b/crates/sui-rpc-api/src/subscription.rs index 6a0c363fef6d9..8827477306138 100644 --- a/crates/sui-rpc-api/src/subscription.rs +++ b/crates/sui-rpc-api/src/subscription.rs @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 use crate::metrics::SubscriptionMetrics; -use crate::proto::node::v2::GetFullCheckpointOptions; use crate::proto::node::v2::GetFullCheckpointResponse; use std::sync::Arc; use sui_types::full_checkpoint_content::CheckpointData; @@ -125,7 +124,7 @@ impl SubscriptionService { let checkpoint = match crate::service::checkpoints::checkpoint_data_to_full_checkpoint_response( checkpoint, - &GetFullCheckpointOptions::all().into(), + &crate::types::GetFullCheckpointOptions::all(), ) { Ok(checkpoint) => GetFullCheckpointResponse::from(checkpoint).pipe(Arc::new), Err(e) => { diff --git a/crates/sui-rpc-api/src/types.rs b/crates/sui-rpc-api/src/types.rs index 2daae7b046ee6..addc61870796a 100644 --- a/crates/sui-rpc-api/src/types.rs +++ b/crates/sui-rpc-api/src/types.rs @@ -671,6 +671,18 @@ impl GetFullCheckpointOptions { "signature" => options.signature = Some(true), "contents" => options.contents = Some(true), "contents_bcs" => options.contents_bcs = Some(true), + "transactions" => { + options.transaction = Some(true); + options.transaction_bcs = Some(true); + options.effects = Some(true); + options.effects_bcs = Some(true); + options.events = Some(true); + options.events_bcs = Some(true); + options.input_objects = Some(true); + options.output_objects = Some(true); + options.object = Some(true); + options.object_bcs = Some(true); + } "transactions.transaction" => options.transaction = Some(true), "transactions.transaction_bcs" => options.transaction_bcs = Some(true), "transactions.effects" => options.effects = Some(true), @@ -699,6 +711,26 @@ impl GetFullCheckpointOptions { options } + + pub fn all() -> Self { + Self { + summary: Some(true), + summary_bcs: Some(true), + signature: Some(true), + contents: Some(true), + contents_bcs: Some(true), + transaction: Some(true), + transaction_bcs: Some(true), + effects: Some(true), + effects_bcs: Some(true), + events: Some(true), + events_bcs: Some(true), + input_objects: Some(true), + output_objects: Some(true), + object: Some(true), + object_bcs: Some(true), + } + } } #[derive(Clone, Debug, PartialEq)]