Skip to content

Commit

Permalink
do not fail the request if objects are pruned for object and balance …
Browse files Browse the repository at this point in the history
…change (MystenLabs#11476)

## Description 

as titled.

Tested on testnet:

request
```
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "sui_getTransactionBlock",
  "params": ["Cgww1sn7XViCPSdDcAPmVcARueWuexJ8af8zD842Ff43", {"showBalanceChanges": true, "showObjectChanges":true}]
}
```

response:
```
{
    "jsonrpc": "2.0",
    "result": {
        "digest": "Cgww1sn7XViCPSdDcAPmVcARueWuexJ8af8zD842Ff43",
        "timestampMs": "1679936400000",
        "checkpoint": "0",
        "errors": [
            "Cannot retrieve balance changes: Error checking transaction input objects: ObjectNotFound { object_id: 0x0000000000000000000000000000000000000000000000000000000000000002, version: Some(SequenceNumber(1)) }",
            "Cannot retrieve object changes: Error checking transaction input objects: ObjectNotFound { object_id: 0x0000000000000000000000000000000000000000000000000000000000000002, version: Some(SequenceNumber(1)) }"
        ]
    },
    "id": 1
}
```
  • Loading branch information
patrickkuo authored Apr 28, 2023
1 parent f8b5ad9 commit deb8d58
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions crates/sui-json-rpc/src/read_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,9 +702,16 @@ impl ReadApiServer for ReadApi {
input_objects,
None,
)
.await
.map_err(Error::SuiError)?;
temp_response.balance_changes = Some(balance_changes);
.await;

if let Ok(balance_changes) = balance_changes {
temp_response.balance_changes = Some(balance_changes);
} else {
temp_response.errors.push(format!(
"Cannot retrieve balance changes: {}",
balance_changes.unwrap_err()
));
}
}
}

Expand All @@ -720,9 +727,16 @@ impl ReadApiServer for ReadApi {
effects.all_changed_objects(),
effects.all_deleted(),
)
.await
.map_err(Error::SuiError)?;
temp_response.object_changes = Some(object_changes);
.await;

if let Ok(object_changes) = object_changes {
temp_response.object_changes = Some(object_changes);
} else {
temp_response.errors.push(format!(
"Cannot retrieve object changes: {}",
object_changes.unwrap_err()
));
}
}
}
let epoch_store = self.state.load_epoch_store_one_call_per_task();
Expand Down

0 comments on commit deb8d58

Please sign in to comment.