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

AVM: report structure txn failure info #5875

Merged
merged 7 commits into from Jan 17, 2024

Conversation

jannotti
Copy link
Contributor

@jannotti jannotti commented Dec 17, 2023

This is a proposal to add structured info (PC, stack, scratch, logs) from failed transactions in the JSON response.

I am less concerned with guaranteeing backward compatibility on this structure until some time and usage has occurred, so it is not codified in an openapi file. I think we should consider the .data field of the returned JSON to fall outside the usual semvar promise --- it is more like an error message that we hope is useful, but is not yet cast in stone. For example, we do not specify the the potential Data returns on error in /v2/applications/{application-id}/boxes and /v2/accounts/{address}.

See avm-failure-info.py and TestAppErrorDetails in evalStateful_test.go for the best examples of the proposed return values.

@jannotti jannotti self-assigned this Dec 17, 2023
@jannotti jannotti force-pushed the avm-failure-info branch 6 times, most recently from 46279ec to 3f54b84 Compare December 18, 2023 21:28
Copy link

codecov bot commented Dec 18, 2023

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (e7aa0d4) 55.95% compared to head (35526b7) 55.97%.
Report is 1 commits behind head on master.

Files Patch % Lines
data/basics/serr.go 82.00% 8 Missing and 1 partial ⚠️
daemon/algod/api/server/v2/utils.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5875      +/-   ##
==========================================
+ Coverage   55.95%   55.97%   +0.02%     
==========================================
  Files         477      478       +1     
  Lines       67436    67535      +99     
==========================================
+ Hits        37736    37805      +69     
- Misses      27149    27174      +25     
- Partials     2551     2556       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jannotti jannotti force-pushed the avm-failure-info branch 2 times, most recently from 7ecdd3e to 926a7e8 Compare December 19, 2023 18:14
@jannotti jannotti marked this pull request as ready for review January 2, 2024 17:09
daemon/algod/api/server/v2/utils.go Outdated Show resolved Hide resolved
data/transactions/logic/eval.go Show resolved Hide resolved
data/transactions/logic/eval.go Show resolved Hide resolved
@nullun
Copy link
Contributor

nullun commented Jan 3, 2024

I've been playing around with this all morning and it helps tremendously with identifying where and in what state something failed at! I briefly thought showing resources like foreign assets/apps and app accounts would be useful too, but those are in the transaction you submit, so there's no real benefit to that.

One thing, which may fall outside of this PR is the contents of the message/inner-msg. Is there any reason to keep appending them if you can see them individually within the inners? For example I created a 8-deep inner transaction call which failed on the deepest one, and this is the bottom of the data, lots of duplicated/appended messages.

Screenshot 2024-01-03 at 13 25 51

@jannotti
Copy link
Contributor Author

jannotti commented Jan 3, 2024

One thing, which may fall outside of this PR is the contents of the message/inner-msg. Is there any reason to keep appending them if you can see them individually within the inners? For example I created a 8-deep inner transaction call which failed on the deepest one, and this is the bottom of the data, lots of duplicated/appended messages.

That does start to look a bit out of hand, but my thinking was that it made the single top-level message (in cases where existing code or UIs only reports that) more useful. It becomes more akin to a stack trace so you can see which inner actually caused a problem. I know I had run into problems where a test with inner fails and it was not immediately obvious which depth had the error.

Your example looks bad, but I think in practice you're only one or two levels deep and so the duplication is not so bad and remains helpful. If we did only report a single error, would it be the top-level message and PC (which would always be on a ixtn_submit), or the deepest?

@nullun
Copy link
Contributor

nullun commented Jan 3, 2024

That makes sense, there's likely systems out there that are already passing the top-level message as it is.

If we did only report a single error, would it be the top-level message and PC (which would always be on a ixtn_submit), or the deepest?

Hmmm, I'd say the inner-most error would be the most useful, as that's where something actually failed. Now I'm thinking about it, if you were just interested in decoding the error to display something to the enduser, you might also want to know the appID of the inner for some more context. Just in case you're expecting multiple different inners to be called, and I assume if the appID is missing then it's more of a "failed to deploy" message.

@jannotti
Copy link
Contributor Author

jannotti commented Jan 3, 2024

Now I'm thinking about it, if you were just interested in decoding the error to display something to the enduser, you might also want to know the appID of the inner for some more context. Just in case you're expecting multiple different inners to be called, and I assume if the appID is missing then it's more of a "failed to deploy" message.

Maybe I can add that in as I concatenate the inner error. It may also be useful enough that it should go in the structured data.

Extend goal.py so it can produce a curl url, rather than rely on the
Python SDK entirely. Thus we can test this feature before SDK support
for the `data` field in the response.
@jannotti jannotti force-pushed the avm-failure-info branch 2 times, most recently from 070412a to cebb28e Compare January 3, 2024 20:17
algorandskiy
algorandskiy previously approved these changes Jan 5, 2024
This will likely cause some CI failures, as it's likely to cause some
churn in e2e tests.
@jannotti jannotti merged commit 434dca0 into algorand:master Jan 17, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants