-
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
rpcclient: return FaultException in checkResOk if any #3356
Conversation
pkg/rpcclient/unwrap/unwrap.go
Outdated
@@ -401,6 +401,9 @@ func checkResOK(r *result.Invoke, err error) error { | |||
if r.State != vmstate.Halt.String() { | |||
return fmt.Errorf("invocation failed: %s", r.FaultException) | |||
} | |||
if r.FaultException != "" { | |||
return errors.New(r.FaultException) |
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.
Not sure it is the best message, but error:
context seems excessive, FaultException usually contains something.
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.
inconsistent result, HALTed with exception: %w
?
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.
@fyfyrchik, let's fix this comment and merge the PR. We'll remove stack marshalling error from result.Invoke
's FaultException in #3359.
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.
fixed
On a side-note, I think it would be nice to have some flexibility in JSON marshaling of the stackitems: we care about the size in interops, but RPC is a different story. |
I don't think it's a correct fix. Unfortunately |
bdfd69a
to
8733586
Compare
I disagree here, but the compatibility is probably more important. Another option we have is to attach
This way user opts-in to the semantics they want and it is backwards compatible. |
I think you want #3130 now, but it's a different story from this PR. |
Hm, in some sense I want exactly the opposite: |
For the sake of completeness: we could also make global switch, but I probably know the answer to this suggestion :) |
They can't. HALTed transactions have no exceptions. It's just a server-side issue (clients can refuse these replies as bogus though). We always tell people:
|
That's true. But then again, the solution with Basically, I can either use unwrap (and have an error which doesn't point me to the root cause, unless I know where to dig) or do manual checks. Yet another solution is to handle this in the invoker? (not by default). I see that the solution is not straightforward as it seemed to be, but to me the problem is worth solving (be it server- or client- side). Do we have any tracking issue for the semantics of |
Another point is |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3356 +/- ##
=======================================
Coverage 84.68% 84.69%
=======================================
Files 331 331
Lines 44932 44938 +6
=======================================
+ Hits 38050 38058 +8
+ Misses 5371 5369 -2
Partials 1511 1511 ☔ View full report in Codecov by Sentry. |
Except the #3130 there are no related issues.
I agree, we need to do something about it, because it's just unexpected behaviour from the user PoW and hiding the original unmarshalling error doesn't seem to be correct.
I'm afraid we don't have it well-documented. And currently the state is that unwrapper doesn't pay any attention on that.
Some marshalling errors may inevitably occur during stack marshalling, and we have to report about them somehow. Do you suggest to remove stack marshalling errors from FaultException? |
It can just be a semantic correctness check then. Unmarshaling code shouldn't care about it, but
Yes. Treat them similarly to application logs. |
FaultException can be non-empty even in Halt state when there were problems with stack marshaling to JSON. Signed-off-by: Evgenii Stratonikov <fyfyrchik@runbox.com>
8733586
to
1a3a494
Compare
Problem
Consider this test.
It fails with
That is because in
checkResOk
checks only VM state which is HALTneo-go/pkg/rpcclient/unwrap/unwrap.go
Line 401 in 9c83bef
Solution
Communicate the error precisely, otherwise it leads to hard-to-debug failures, requiring moderate knowledge of neo-go internals (it is not obvious that
result stack is empty
just cannot happen with good contracts, unless you know how VM works).