-
Notifications
You must be signed in to change notification settings - Fork 378
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(gnovm): show "out of gas" errors (#2365) #2368
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2368 +/- ##
==========================================
- Coverage 54.68% 54.65% -0.03%
==========================================
Files 583 584 +1
Lines 78503 78670 +167
==========================================
+ Hits 42928 42997 +69
- Misses 32368 32458 +90
- Partials 3207 3215 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
just curious, is it only happening with |
I am not sure, that's why I will try to add many packages. |
Fixes #2368 |
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.
Can you add a test (I'd say txtar test is better here) which currently leads to an unclear error, but then returns an appropriate message?
Also, I think it's better if, instead of having this at the level of preprocess, we switched the type assertion in keeper.go to use errors.As
instead.
tm2/pkg/errors
supports the standard Unwrap function, so errors.As should work here.
Yep, however this issue2365.txtar.txt now seems rather pointless, |
Took a look, think you mean here, in gno/gno.land/pkg/sdk/vm/keeper.go Lines 391 to 460 in fadf622
Line 391 is where the panic happened (a parent branch that is). I suggest we close this PR, and keep your idea until we get a new reproducible issue. It's going to be tough otherwise to make sure it's correctly implemented. |
Probably related to changing gas values? Try lowering the
Okay, I think I understand why it was happening here. With lazy stdlib loading (before #2504), GetPackage could be called by the type checker, invoking a I think more generally we can hit this condition if there is an OutOfGas panic in predefine (and consequently, Preprocess). Both predefine and Preprocess capture and wrap errors. So it's good if we catch any out of gas errors and unwrap them. So what I'm suggesting is to change all blocks like this one in keeper.go:
to use errors.As instead of the type assertion; so it should be able to return a correct error in case of a Preprocess OutOfGas. |
Tried a variety of gas values but since #2504 it's only the regular "out of gas error" that is shown.
Thanks, good explanation! It explains what I observed: much lower gas consumption (2-3 times less), and no seemingly unrelated panics anymore when running out of gas. |
Perhaps this is the part which I didn't understand though. OK! Think I know what you mean now. |
Do you think you can find a case where this bug happens? I expect this to be replicable with low gas values; like between 5k and 500k. |
I already tried with like 20 different low values the other day. Besides, after #2504 it should not happen in this case ( |
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 reproduced it and fixed it in a separate PR #2638
The following should fix #2365 when adding a package.
Problem
#2365 (and before it, #1205) described a way where adding packages with insufficient gas very often lead to hard to read errors such as:
Diagnostic
Using the call stack in #2365, the following seems to happen.
While preprocessing some file, a panic with
OutOfGasException
occurs:gno/tm2/pkg/store/types/gas.go
Lines 96 to 98 in e7e47d2
Upper level recovers and repanics with error:
gno/gnovm/pkg/gnolang/preprocess.go
Lines 3057 to 3070 in e7e47d2
Upper level treats it as a banal error (falling in
default:
rather thanOutOfGasException
, this snippet is longer, make sure to scroll down):gno/tm2/pkg/sdk/baseapp.go
Lines 733 to 752 in e7e47d2
Proposed fix
Just add a couple of lines in gno/gnovm/pkg/gnolang/preprocess.go:
After recompiling and testing with the modus operandi described in #2365, the error message is now:
Repeatedly calling with fresh
gnodev -minimal
each time and adding package now consistently shows this message.Discussion
There still remains a question about the "NOTE: gotuna/gorilla expects error exceptions".
Think it has to do with gnoweb ability to print failures, e.g.
gnoweb
usesfunc makeRequest(log *slog.Logger, cfg *Config, qpath string, data []byte) (res *abci.ResponseQuery, err error)
.However
BaseApp.runTx
will turn the OutOfGasException to a niceABCIError(std.ErrOutOfGas())
.So, in theory, it should do.
I will do some more test tonight adding many packages from
/p/demo
.