Skip to content

Commit

Permalink
[rpc][structured-error-handling][2/n] State trait for AuthorityState,…
Browse files Browse the repository at this point in the history
… group AuthorityState-originating SuiErrors (#12933)

## Description 

Part of the first set of PRs is to group the errors that are possible on
the RPC today into a few categories transparently, setting us up to
eventually standardize error strings and resolution. This PR
specifically introduces a `State` trait which `AuthorityState`
implements to centralize `AuthorityState`-originating `SuiError`s so
that we can disambiguate these errors from other sources of `SuiError`.
This has the added benefit of helping w/ unit test writing, as
demonstrated by `coin_api` and `move_utils`.

No change has been made to error strings, but StateReadError::Internal
will now code to `-32603` instead of `-32000`. But this can be
negotiable too.

## Test Plan 

Existing tests

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] protocol change
- [x] user-visible impact
- [x] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
Internal errors that arise while reading from authority will now return
-32603 error code. Client-fault errors that arise while reading from
authority will now return -32602 error code. Error strings have not been
modified.
  • Loading branch information
wlmyng authored and ebmifa committed Aug 10, 2023
1 parent babdc0f commit 6e20240
Show file tree
Hide file tree
Showing 14 changed files with 864 additions and 430 deletions.
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.

2 changes: 2 additions & 0 deletions crates/sui-json-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ publish = false
edition = "2021"

[dependencies]
arc-swap.workspace = true
fastcrypto.workspace = true
jsonrpsee.workspace = true
jsonrpsee-proc-macros.workspace = true
Expand Down Expand Up @@ -54,3 +55,4 @@ cached.workspace = true
[dev-dependencies]
mockall.workspace = true
expect-test.workspace = true
sui-types = { workspace = true, features = ["test-utils"] }
Loading

0 comments on commit 6e20240

Please sign in to comment.