-
Notifications
You must be signed in to change notification settings - Fork 100
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
Fix stack exception name #855
Conversation
a new field? |
Two kind of exception(one from vm, one from applicationlog), but they're using the same trigger. applicationlog exception could rewrite vm exception... |
Now it's the same result as invocation. @roman-khimov |
The behavior we have in NeoGo now is that we return an array of elements in the
With this PR that would be
And this obviously loses more data that can be valuable for debugging, the number of elements left on the stack and all the proper elements can be helpful in many cases. I'd prefer having this kind of output in the end both for application log and test invocations. |
So if 1000 stacks return 1000 error messages? And they are |
One stack item --- one error message, you serialize them one by one anyway, either you get a proper JSON or you get an error. |
@shargon What's your opinion? |
If we add the stack, i prefer to add the stack item type, and the value, otherwise I prefer to use the exception field |
Tested. @shargon @roman-khimov |
Why we don't use the exception field? |
These two exceptions are generated from different place, but applicationlog exception could re-write vm exception which doesn't make sense and can make some Dapp backend confusing a lot for handling these exceptions. For example: Ghostmarket. |
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.
How about test invocations (GetInvokeResult
)?
OK otherwise.
What about change the exception field to be an array, also with type? |
If it'd be separated, you wouldn't know which elements are bad. In some cases it might be useful. Imagine 3 items on the stack, the second one is bad, but the other two are OK and can be serialized, if you get two stack items and one exception, what was the original index of the element that has caused this exception? |
Done. @roman-khimov @shargon |
@AnnaShaleva Could you review again? Any more improvement needed? |
@Liaojinghui @shargon Is it OK for you? |
src/ApplicationLogs/LogReader.cs
Outdated
} | ||
catch (Exception ex) | ||
{ | ||
stack.Add("error: " + ex); |
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 dont think will output will help much. Seeing how the only reason it would fail is because its an interop and cant be serialized. Better to put an empty or null stackitem instead.
src/ApplicationLogs/LogReader.cs
Outdated
} | ||
catch (Exception ex) | ||
{ | ||
stack.Add("error: " + ex); |
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 dont think will output will help much. Seeing how the only reason it would fail is because its an interop and cant be serialized. Better to put an empty or null stackitem instead.
} | ||
catch (Exception ex) | ||
{ | ||
stack.Add("error: " + ex); |
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.
same
Done @shargon |
@@ -147,7 +147,7 @@ public static JObject BlockLogToJson(Block block, IReadOnlyList<Blockchain.Appli | |||
} | |||
catch (Exception ex) | |||
{ | |||
stack.Add("error: " + ex); | |||
stack.Add("error: " + ex.Message); |
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.
stack.Add("error: " + ex.Message); | |
stack.Add(item.GetInterface<object>().GetType().Name); |
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.
The error means that there was a stackitem, but it can't be serialized and therefore can't be presented in JSON output. Replacing it with NULL or any other element (empty/string with a name) would be wrong because that's not what's on the stack. Proper stack item (like suggested) would be misinterpreted as a real output from the execution, it has to be some error string in case of serialization failure.
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.
But the ones that can't be output to json are iterators (storage); at least what i have ran into (on testnet).
@@ -102,7 +102,7 @@ private JObject GetInvokeResult(byte[] script, Signer[] signers = null, Witness[ | |||
} | |||
catch (Exception ex) | |||
{ | |||
stack.Add("error: " + ex); | |||
stack.Add("error: " + ex.Message); |
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.
stack.Add("error: " + ex.Message); | |
stack.Add(item.GetInterface<object>().GetType().Name); |
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.
@@ -99,7 +99,7 @@ public static JObject TxLogToJson(Blockchain.ApplicationExecuted appExec) | |||
} | |||
catch (Exception ex) | |||
{ | |||
stack.Add("error: " + ex); | |||
stack.Add("error: " + ex.Message); |
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.
stack.Add("error: " + ex.Message); | |
stack.Add(item.GetInterface<object>().GetType().Name); |
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.
Maybe add the error description will not be deterministic between neo-go and c#? |
I think we should be doing this the proper way, indicating that there is an valid Edit: |
Yes, it will differ. |
Then is better to change the message |
I think we can settle on the fact that if you're receiving a string instead of a stack item, it's an error string and the original stack item couldn't be represented. And this string can be implementation-specific, just like |
@shargon @roman-khimov need approve |
* 'master' of github.com:neo-project/neo-modules: Fix workflow (neo-project#857) Fix stack exception name (neo-project#855) update workflow (neo-project#856) Refac build configs (neo-project#846) Hotfix for neo-project#850 (neo-project#853) Fix RpcNativeContract (neo-project#851)
Close #854