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

refactor(jsonrpc): Initial refactoring for Structured Error handling for JSON RPC and ViewClient #3805

Merged
merged 14 commits into from
Jan 27, 2021

Conversation

khorolets
Copy link
Member

Start of #3788
It's just a beginning of refactoring. @frol and I decided that having error structures for each handler would be better solution. This is a first try with GetBlock handler, which doesn't change the response from jsonrpc.

To start it, I've done:

  • Extract types from chain/client to separate crate client-primitives
  • Extract messages.rs from chain/jsonrpc/client to separate jsonrpc-client-primitives crate
  • Refactor GetBlock handler to have GetBlockError

Work in progress.

@frol I'd like to know what should be changed in GetBlockError to make it better

P.S. Commented code in the commit will be cleared while I move further.

@khorolets khorolets requested a review from frol January 14, 2021 13:23
@khorolets khorolets force-pushed the refactor/structured-errors-view-client branch from d581fd9 to 661fb67 Compare January 14, 2021 13:25
chain/jsonrpc/src/lib.rs Outdated Show resolved Hide resolved
chain/jsonrpc/src/lib.rs Outdated Show resolved Hide resolved
chain/jsonrpc-primitives/src/message.rs Outdated Show resolved Hide resolved
chain/jsonrpc-primitives/src/lib.rs Outdated Show resolved Hide resolved
chain/client-primitives/src/types.rs Outdated Show resolved Hide resolved
@khorolets khorolets force-pushed the refactor/structured-errors-view-client branch 2 times, most recently from af4c7a9 to f1a630d Compare January 18, 2021 15:46
@khorolets khorolets force-pushed the refactor/structured-errors-view-client branch from f1a630d to 00e2633 Compare January 21, 2021 11:44
chain/jsonrpc-primitives/src/blocks.rs Outdated Show resolved Hide resolved
chain/jsonrpc-primitives/src/blocks.rs Outdated Show resolved Hide resolved
chain/jsonrpc-primitives/src/message.rs Outdated Show resolved Hide resolved
chain/jsonrpc-primitives/src/metrics.rs Outdated Show resolved Hide resolved
chain/jsonrpc/src/lib.rs Outdated Show resolved Hide resolved
chain/jsonrpc/src/lib.rs Outdated Show resolved Hide resolved
core/primitives/src/rpc.rs Outdated Show resolved Hide resolved
chain/jsonrpc/src/lib.rs Outdated Show resolved Hide resolved
chain/client-primitives/src/types.rs Outdated Show resolved Hide resolved
chain/jsonrpc-primitives/src/blocks.rs Outdated Show resolved Hide resolved
chain/jsonrpc-primitives/src/metrics.rs Outdated Show resolved Hide resolved
core/primitives/src/lib.rs Outdated Show resolved Hide resolved
@khorolets khorolets marked this pull request as ready for review January 21, 2021 18:51
Copy link
Collaborator

@frol frol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I unblock this PR. The minor changes are agreed to be addressed, so other code owners need to review.

Review hits:

  • The changes mostly target chain/jsonrpc (@frol and @khorolets are code-owners, so we review that)
  • The rest of the changes are about extracting modules into separate crates to avoid fat dependencies, fat primitives, and circular dependencies

@frol frol changed the title refactor (client): Error handling for jsonrpc (structured errors for ViewClient) refactor(jsonrpc): Initial refactoring for Structured Error handling for JSON RPC and ViewClient Jan 21, 2021
@khorolets khorolets force-pushed the refactor/structured-errors-view-client branch from 9cbda12 to 5a70bf7 Compare January 25, 2021 09:36
chain/jsonrpc-primitives/src/errors.rs Outdated Show resolved Hide resolved
chain/jsonrpc-primitives/src/types/blocks.rs Show resolved Hide resolved
@khorolets
Copy link
Member Author

@bowenwang1996 could you please take a look at this PR? Thank you.

chain/client-primitives/src/types.rs Outdated Show resolved Hide resolved
chain/jsonrpc/src/lib.rs Show resolved Hide resolved
…te crate client-primitives. Extract messages from jsonrpc-client to separate jsonrpc-client-primitives crate. Refactor GetBlock handler to have GetBlockError. Work in progress.
…BlockError possible to be casted from chain-primitives Error
…ockRequest to near-primitives::rpc. Add metrics to watch for unexpected errors
@khorolets khorolets force-pushed the refactor/structured-errors-view-client branch from 71015fa to deef168 Compare January 27, 2021 11:59
@frol frol merged commit 38d83a8 into master Jan 27, 2021
@frol frol deleted the refactor/structured-errors-view-client branch January 27, 2021 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants