Skip to content

Commit

Permalink
rpc: change all options to default to false when not provided
Browse files Browse the repository at this point in the history
Change all gRPC method options to default to false when not provided.
This will result push clients to explicitly ask for the fields that they
want instead of relying on any defaults that could change. This also will
also make it easier to rely on the generated protobuf option types where
if a field isn't present, its accessor will provide the default value of
`false`.
  • Loading branch information
bmwill committed Dec 23, 2024
1 parent 685b067 commit ad58cb9
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 153 deletions.
14 changes: 7 additions & 7 deletions crates/sui-e2e-tests/tests/rpc/checkpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ async fn get_checkpoint() {

assert!(sequence_number.is_some());
assert!(digest.is_some());
assert!(summary.is_some());
assert!(summary.is_none());
assert!(summary_bcs.is_none());
assert!(signature.is_some());
assert!(signature.is_none());
assert!(contents.is_none());
assert!(contents_bcs.is_none());

Expand Down Expand Up @@ -210,9 +210,9 @@ async fn get_full_checkpoint() {

assert!(sequence_number.is_some());
assert!(digest.is_some());
assert!(summary.is_some());
assert!(summary.is_none());
assert!(summary_bcs.is_none());
assert!(signature.is_some());
assert!(signature.is_none());
assert!(contents.is_none());
assert!(contents_bcs.is_none());

Expand All @@ -230,14 +230,14 @@ async fn get_full_checkpoint() {
} in transactions
{
assert!(digest.is_some());
assert!(transaction.is_some());
assert!(transaction.is_none());
assert!(transaction_bcs.is_none());
assert!(effects.is_some());
assert!(effects.is_none());
assert!(effects_bcs.is_none());
if digest == Some(transaction_digest.into()) {
found_transaction = true;
assert!(events.is_some());
}
assert!(events.is_none());
assert!(events_bcs.is_none());
assert!(input_objects.is_none());
assert!(output_objects.is_none());
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-e2e-tests/tests/rpc/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async fn get_object() {
assert_eq!(object_id, Some(id.into()));
assert!(version.is_some());
assert!(digest.is_some());
assert!(object.is_some());
assert!(object.is_none());
assert!(object_bcs.is_none()); // By default object_bcs isn't returned

let GetObjectResponse {
Expand Down
8 changes: 4 additions & 4 deletions crates/sui-e2e-tests/tests/rpc/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ async fn get_transaction() {
.into_inner();

assert!(digest.is_some());
assert!(transaction.is_some());
assert!(transaction.is_none());
assert!(transaction_bcs.is_none());
assert!(signatures.is_some());
assert!(signatures.is_none());
assert!(signatures_bytes.is_none());
assert!(effects.is_some());
assert!(effects.is_none());
assert!(effects_bcs.is_none());
assert!(events.is_some());
assert!(events.is_none());
assert!(events_bcs.is_none());
assert!(checkpoint.is_some());
assert!(timestamp.is_some());
Expand Down
64 changes: 32 additions & 32 deletions crates/sui-rpc-api/openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,19 @@
{
"in": "query",
"name": "signature",
"description": "Request `ValidatorAggregatedSignature` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `ValidatorAggregatedSignature` be included in the response\n\nDefaults to `false` if not provided.",
"schema": {
"description": "Request `ValidatorAggregatedSignature` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `ValidatorAggregatedSignature` be included in the response\n\nDefaults to `false` if not provided.",
"type": "boolean"
},
"style": "form"
},
{
"in": "query",
"name": "summary",
"description": "Request `CheckpointSummary` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `CheckpointSummary` be included in the response\n\nDefaults to `false` if not provided.",
"schema": {
"description": "Request `CheckpointSummary` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `CheckpointSummary` be included in the response\n\nDefaults to `false` if not provided.",
"type": "boolean"
},
"style": "form"
Expand Down Expand Up @@ -249,9 +249,9 @@
{
"in": "query",
"name": "object",
"description": "Request that `Object` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request that `Object` be included in the response\n\nDefaults to `false` if not provided.",
"schema": {
"description": "Request that `Object` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request that `Object` be included in the response\n\nDefaults to `false` if not provided.",
"type": "boolean"
},
"style": "form"
Expand Down Expand Up @@ -315,9 +315,9 @@
{
"in": "query",
"name": "object",
"description": "Request that `Object` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request that `Object` be included in the response\n\nDefaults to `false` if not provided.",
"schema": {
"description": "Request that `Object` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request that `Object` be included in the response\n\nDefaults to `false` if not provided.",
"type": "boolean"
},
"style": "form"
Expand Down Expand Up @@ -480,19 +480,19 @@
{
"in": "query",
"name": "signature",
"description": "Request `ValidatorAggregatedSignature` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `ValidatorAggregatedSignature` be included in the response\n\nDefaults to `false` if not provided.",
"schema": {
"description": "Request `ValidatorAggregatedSignature` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `ValidatorAggregatedSignature` be included in the response\n\nDefaults to `false` if not provided.",
"type": "boolean"
},
"style": "form"
},
{
"in": "query",
"name": "summary",
"description": "Request `CheckpointSummary` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `CheckpointSummary` be included in the response\n\nDefaults to `false` if not provided.",
"schema": {
"description": "Request `CheckpointSummary` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `CheckpointSummary` be included in the response\n\nDefaults to `false` if not provided.",
"type": "boolean"
},
"style": "form"
Expand Down Expand Up @@ -559,9 +559,9 @@
{
"in": "query",
"name": "effects",
"description": "Request `TransactionEffects` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `TransactionEffects` be included in the response\n\nDefaults to `false` if not provided.",
"schema": {
"description": "Request `TransactionEffects` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `TransactionEffects` be included in the response\n\nDefaults to `false` if not provided.",
"type": "boolean"
},
"style": "form"
Expand All @@ -579,9 +579,9 @@
{
"in": "query",
"name": "events",
"description": "Request `TransactionEvents` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `TransactionEvents` be included in the response\n\nDefaults to `false` if not provided.",
"schema": {
"description": "Request `TransactionEvents` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `TransactionEvents` be included in the response\n\nDefaults to `false` if not provided.",
"type": "boolean"
},
"style": "form"
Expand All @@ -599,9 +599,9 @@
{
"in": "query",
"name": "signatures",
"description": "Request `Vec<UserSignature>` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `Vec<UserSignature>` be included in the response\n\nDefaults to `false` if not provided.",
"schema": {
"description": "Request `Vec<UserSignature>` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `Vec<UserSignature>` be included in the response\n\nDefaults to `false` if not provided.",
"type": "boolean"
},
"style": "form"
Expand All @@ -619,9 +619,9 @@
{
"in": "query",
"name": "transaction",
"description": "Request `Transaction` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `Transaction` be included in the response\n\nDefaults to `false` if not provided.",
"schema": {
"description": "Request `Transaction` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `Transaction` be included in the response\n\nDefaults to `false` if not provided.",
"type": "boolean"
},
"style": "form"
Expand Down Expand Up @@ -691,9 +691,9 @@
{
"in": "query",
"name": "effects",
"description": "Request `TransactionEffects` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `TransactionEffects` be included in the response\n\nDefaults to `false` if not provided.",
"schema": {
"description": "Request `TransactionEffects` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `TransactionEffects` be included in the response\n\nDefaults to `false` if not provided.",
"type": "boolean"
},
"style": "form"
Expand All @@ -711,9 +711,9 @@
{
"in": "query",
"name": "events",
"description": "Request `TransactionEvents` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `TransactionEvents` be included in the response\n\nDefaults to `false` if not provided.",
"schema": {
"description": "Request `TransactionEvents` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `TransactionEvents` be included in the response\n\nDefaults to `false` if not provided.",
"type": "boolean"
},
"style": "form"
Expand All @@ -731,9 +731,9 @@
{
"in": "query",
"name": "signatures",
"description": "Request `Vec<UserSignature>` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `Vec<UserSignature>` be included in the response\n\nDefaults to `false` if not provided.",
"schema": {
"description": "Request `Vec<UserSignature>` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `Vec<UserSignature>` be included in the response\n\nDefaults to `false` if not provided.",
"type": "boolean"
},
"style": "form"
Expand All @@ -751,9 +751,9 @@
{
"in": "query",
"name": "transaction",
"description": "Request `Transaction` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `Transaction` be included in the response\n\nDefaults to `false` if not provided.",
"schema": {
"description": "Request `Transaction` be included in the response\n\nDefaults to `true` if not provided.",
"description": "Request `Transaction` be included in the response\n\nDefaults to `false` if not provided.",
"type": "boolean"
},
"style": "form"
Expand Down Expand Up @@ -816,9 +816,9 @@
{
"in": "query",
"name": "effects",
"description": "Request `TransactionEffects` be included in the Response.\n\nDefaults to `true` if not provided.",
"description": "Request `TransactionEffects` be included in the Response.\n\nDefaults to `false` if not provided.",
"schema": {
"description": "Request `TransactionEffects` be included in the Response.\n\nDefaults to `true` if not provided.",
"description": "Request `TransactionEffects` be included in the Response.\n\nDefaults to `false` if not provided.",
"type": "boolean"
},
"style": "form"
Expand All @@ -836,9 +836,9 @@
{
"in": "query",
"name": "events",
"description": "Request `TransactionEvents` be included in the Response.\n\nDefaults to `true` if not provided.",
"description": "Request `TransactionEvents` be included in the Response.\n\nDefaults to `false` if not provided.",
"schema": {
"description": "Request `TransactionEvents` be included in the Response.\n\nDefaults to `true` if not provided.",
"description": "Request `TransactionEvents` be included in the Response.\n\nDefaults to `false` if not provided.",
"type": "boolean"
},
"style": "form"
Expand Down
Loading

0 comments on commit ad58cb9

Please sign in to comment.