Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc: leverage FieldMasks for partial responses and other proto tweaks #21182

Merged
merged 3 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/sui-e2e-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ shared-crypto.workspace = true
sui-sdk-types.workspace = true
sui-sdk-transaction-builder.workspace = true
tonic.workspace = true
prost-types.workspace = true

passkey-types.workspace = true
passkey-client.workspace = true
Expand Down
43 changes: 28 additions & 15 deletions crates/sui-e2e-tests/tests/rpc/checkpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ async fn get_checkpoint() {
sequence_number: Some(sequence_number.unwrap()),
digest: Some(digest.clone().unwrap()),
options: None,
read_mask: None,
})
.await
.unwrap_err();
Expand Down Expand Up @@ -210,6 +211,8 @@ async fn get_full_checkpoint() {
events_bcs,
input_objects,
output_objects,
input_objects_old,
output_objects_old,
} in transactions
{
assert!(digest.is_some());
Expand All @@ -222,8 +225,10 @@ async fn get_full_checkpoint() {
}
assert!(events.is_none());
assert!(events_bcs.is_none());
assert!(input_objects.is_none());
assert!(output_objects.is_none());
assert!(input_objects.is_empty());
assert!(output_objects.is_empty());
assert!(input_objects_old.is_none());
assert!(output_objects_old.is_none());
}
// Ensure we found the transaction we used for picking the checkpoint to test against
assert!(found_transaction);
Expand Down Expand Up @@ -266,6 +271,8 @@ async fn get_full_checkpoint() {
events_bcs,
input_objects,
output_objects,
input_objects_old,
output_objects_old,
} in transactions
{
assert!(digest.is_some());
Expand All @@ -278,8 +285,10 @@ async fn get_full_checkpoint() {
}
assert!(events.is_none());
assert!(events_bcs.is_none());
assert!(input_objects.is_none());
assert!(output_objects.is_none());
assert!(input_objects.is_empty());
assert!(output_objects.is_empty());
assert!(input_objects_old.is_none());
assert!(output_objects_old.is_none());
}
// Ensure we found the transaction we used for picking the checkpoint to test against
assert!(found_transaction);
Expand Down Expand Up @@ -324,6 +333,8 @@ async fn get_full_checkpoint() {
events_bcs,
input_objects,
output_objects,
input_objects_old,
output_objects_old,
} in transactions
{
assert!(digest.is_some());
Expand All @@ -336,23 +347,18 @@ async fn get_full_checkpoint() {
assert!(events.is_some());
assert!(events_bcs.is_some());
}
assert!(input_objects.is_some());
assert!(output_objects.is_some());
assert!(!input_objects.is_empty());
assert!(!output_objects.is_empty());
assert!(input_objects_old.is_some());
assert!(output_objects_old.is_some());

for FullCheckpointObject {
object_id,
version,
digest,
object,
object_bcs,
} in input_objects
.iter()
.flat_map(|objects| objects.objects.iter())
.chain(
output_objects
.iter()
.flat_map(|objects| objects.objects.iter()),
)
} in input_objects.iter().chain(output_objects.iter())
{
assert!(object_id.is_some());
assert!(version.is_some());
Expand Down Expand Up @@ -396,6 +402,7 @@ async fn get_full_checkpoint() {
sequence_number: Some(sequence_number.unwrap()),
digest: Some(digest.clone().unwrap()),
options: None,
read_mask: None,
})
.await
.unwrap_err();
Expand All @@ -415,8 +422,14 @@ async fn subscribe_checkpoint() {
.await
.unwrap();

let request = SubscribeCheckpointsRequest {
read_mask: Some(prost_types::FieldMask {
paths: vec!["sequence_number".to_owned()],
}),
};

let mut stream = client
.subscribe_checkpoints(SubscribeCheckpointsRequest::default())
.subscribe_checkpoints(request)
.await
.unwrap()
.into_inner();
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-e2e-tests/tests/rpc/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async fn execute_transaction_transfer() {
];
expected.sort_by_key(|e| e.address);

let mut actual = response.balance_changes.unwrap();
let mut actual = response.balance_changes;
actual.sort_by_key(|e| e.address);

assert_eq!(actual, expected);
Expand Down
11 changes: 9 additions & 2 deletions crates/sui-e2e-tests/tests/rpc/resolve.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use prost_types::FieldMask;
use shared_crypto::intent::Intent;
use sui_keys::keystore::AccountKeystore;
use sui_macros::sim_test;
Expand All @@ -20,10 +21,16 @@ fn build_resolve_request(
transaction: &unresolved::Transaction,
simulate: bool,
) -> ResolveTransactionRequest {
let read_mask = if simulate {
Some(FieldMask {
paths: vec!["simulation".to_string()],
})
} else {
None
};
ResolveTransactionRequest {
unresolved_transaction: Some(serde_json::to_string(transaction).unwrap()),
simulate: Some(simulate),
simulate_options: None,
read_mask,
}
}

Expand Down
12 changes: 6 additions & 6 deletions crates/sui-e2e-tests/tests/rpc/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ async fn get_transaction() {
assert!(digest.is_some());
assert!(transaction.is_none());
assert!(transaction_bcs.is_none());
assert!(signatures.is_none());
assert!(signatures_bytes.is_none());
assert!(signatures.is_empty());
assert!(signatures_bytes.is_empty());
assert!(effects.is_none());
assert!(effects_bcs.is_none());
assert!(events.is_none());
Expand Down Expand Up @@ -75,8 +75,8 @@ async fn get_transaction() {
assert!(digest.is_some());
assert!(transaction.is_none());
assert!(transaction_bcs.is_none());
assert!(signatures.is_none());
assert!(signatures_bytes.is_none());
assert!(signatures.is_empty());
assert!(signatures_bytes.is_empty());
assert!(effects.is_none());
assert!(effects_bcs.is_none());
assert!(events.is_none());
Expand Down Expand Up @@ -111,8 +111,8 @@ async fn get_transaction() {
assert!(digest.is_some());
assert!(transaction.is_some());
assert!(transaction_bcs.is_some());
assert!(signatures.is_some());
assert!(signatures_bytes.is_some());
assert!(!signatures.is_empty());
assert!(!signatures_bytes.is_empty());
assert!(effects.is_some());
assert!(effects_bcs.is_some());
assert!(events.is_some());
Expand Down
4 changes: 4 additions & 0 deletions crates/sui-rpc-api/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ modules:
ignore_only:
PACKAGE_VERSION_SUFFIX:
- proto/sui/types
ENUM_VALUE_PREFIX:
- proto/sui/types/signature_scheme.proto
ENUM_ZERO_VALUE_SUFFIX:
- proto/sui/types/signature_scheme.proto

enum_zero_value_suffix: _UNKNOWN
rpc_allow_same_request_response: false
Expand Down
Loading
Loading