-
Notifications
You must be signed in to change notification settings - Fork 79
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
RPC: add error codes and response errors #3063
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good. Here are several issues that need to be fixed:
- The most significant is that some of errors specified in the proposal remain unused. We have to use all of them, e.g. pay attantion to the contract-based witness verification: errors returned from the blockchain core can be destinguished and RPC server have to distinguish them to return proper (and specific) result from
invokecontractverify
. Check the other methods as far. - Each commit should contain changes that are grouped by meaning. If some change has a separate meaning or has its own purpose that is not related to the current commit, then create new commit for this change.
- Pay attantion to our GH action jobs, the results are attached to the PR. Some of our tests are failing (it's will be fixed in the next release), but the rest of the jobs hsould pass.
- Each commit message should include the "signed-off-by" line.
- Specify the issue that will be closed by this commit in the commit message: "Close rpc: take care of response errors and error codes #2248".
- Commit header should start with a component (or package) name that includes the most significant changes. Use "neorpc: add error codes and response errors" for the current commit.
1ba7184
to
cd0f574
Compare
pkg/neorpc/errors.go
Outdated
@@ -30,33 +30,95 @@ const ( | |||
const ( | |||
// RPCErrorCode is returned on RPC request processing error. | |||
RPCErrorCode = -100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer needed after all of the changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, It's still used in non-specified errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't be, but I guess you have not converted all of them yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get rid of this error code
Codecov Report
@@ Coverage Diff @@
## master #3063 +/- ##
==========================================
+ Coverage 84.65% 84.78% +0.12%
==========================================
Files 329 329
Lines 43941 43953 +12
==========================================
+ Hits 37200 37265 +65
+ Misses 5229 5189 -40
+ Partials 1512 1499 -13
... and 7 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's time to squash all related commits and make the PR structure more clear. I'll review the RPC server part one more time after PR finalization.
a11cc28
to
7357f19
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need some help to get several errors. Anna, could you, please help me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't reviewd the tests yet, but the overall structure is more clear now.
Note about the first commit: try to overwrite commit message to fit the commit header size limit. The rest of information can be placed into the commit message body.
907b120
to
0809b6c
Compare
Based on the https://docs.google.com/spreadsheets/d/1VShwR1qdVeE7J4gGUBzSPnjAIWkhXb-VT9yvf9cau6I/edit#gid=0 and nspcc-dev/neo-go#3063. Signed-off-by: Anna Shaleva <[email protected]>
Based on the https://docs.google.com/spreadsheets/d/1VShwR1qdVeE7J4gGUBzSPnjAIWkhXb-VT9yvf9cau6I/edit#gid=0 and nspcc-dev/neo-go#3063. Signed-off-by: Anna Shaleva <[email protected]>
0809b6c
to
88da09c
Compare
88da09c
to
409ff47
Compare
409ff47
to
f606e25
Compare
355ec06
to
020ff9c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AnnaShaleva, what do you think about adding
// ErrCompatGeneric is an error returned by nodes not compliant with the neo-project/proposals#156 (NeoGo pre-0.102.0 and all known C# versions). It can be returned for any call and doesn't have any specific meaning.
// Deprecated: to be removed after all nodes adopt new error standard.
ErrCompatGeneric = NewErrorWithCode(-100, "RPC error")
// ErrCompatNoOpenedWallet is an error code returned by nodes not compliant with the neo-project/proposals#156 (all known C# versions, NeoGo never used this code). It can be returned for wallet-related operations.
// Deprecated: to be removed after all nodes adopt new error standard.
ErrCompatGeneric = NewErrorWithCode(-400, "No opened wallet")
The rationale is rather simple, while our server no longer uses these codes they still can come from C# servers and while we consider them deprecated we better at least have some definition of them until C# implements our proposal.
We should also mention the proposal (and the fact that we use a completely different error code set in our server) in docs/rpc.md
.
Agree, let's do this. @tatiana-nspcc, and then we also need to add a note about these deprecated errors removal to our ROADMAP.md. |
Documentation adjustments are needed and minor fixes are required.
020ff9c
to
587056f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ErrAlreadyExists is in blockchain and ErrAlreadyInPool is in mempool. Signed-off-by: Tatiana Nesterenko <[email protected]>
587056f
to
8581f04
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, fix the links to proposal for all commit messages (use neo-project/proposals#156).
According to proposal: neo-project/proposals#156 Close nspcc-dev#2248 Signed-off-by: Tatiana Nesterenko <[email protected]>
According to proposal: neo-project/proposals#156 Close nspcc-dev#2248 Signed-off-by: Tatiana Nesterenko <[email protected]>
While our server no longer uses these codes (-100, -400) they still can come from C# servers and while we consider them deprecated we better at least have some definition of them until C# implements our proposal: neo-project/proposals#156 Also adding description of deprecated RPC error codes in ROADMAP.md. Signed-off-by: Tatiana Nesterenko <[email protected]>
No functional changes, just a refactoring. Signed-off-by: Tatiana Nesterenko <[email protected]>
Follow the reference implementation, the behaviour was changed in neo-project/neo-modules@237ef7d. Signed-off-by: Tatiana Nesterenko <[email protected]>
No functional changes, just a refactoring. Use more specific and meaningful names to be able to use these errors from external packages. Signed-off-by: Tatiana Nesterenko <[email protected]>
This change makes code incompatible with C# node, because currently no error is returned on invalid proof. According to proposal: neo-project/proposals#156 Also adding `verifyProof` descpiption in docs/rpc.md. Signed-off-by: Tatiana Nesterenko <[email protected]>
Behaviour change. `terminatesession` returns ErrUnknownSession in case of impossibility of finding session, previously there was no-error response with `false` result. `traverseIterator`returns ErrUnknownSession in case of impossibility of finding session, previously there was no-error response with default result; `traverseIterator`returns ErrUnknownIterator, there were no such errors before. Accordingly to proposal: neo-project/proposals#156 Also adding description of `traverseIterator` in docs/rpc.md. Signed-off-by: Tatiana Nesterenko <[email protected]>
No functional changes, just a refactoring. Change error text to be able to use this error from external packages. Signed-off-by: Tatiana Nesterenko <[email protected]>
8581f04
to
90f1b0f
Compare
Problem
We should carefully distinguish all kinds of RPC errors on the server side. Each meaningful error should have a separate meaningful error code. The problem is described in #2248
Solution
Add new error codes and handle them
Ref. neo-project/proposals#156 and https://docs.google.com/spreadsheets/d/1VShwR1qdVeE7J4gGUBzSPnjAIWkhXb-VT9yvf9cau6I/edit#gid=0.