-
Notifications
You must be signed in to change notification settings - Fork 379
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: catch the out of gas exception in preprocess #2638
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,57 @@ | ||||||
# ensure users get proper out of gas errors when they add packages | ||||||
|
||||||
# start a new node | ||||||
gnoland start | ||||||
|
||||||
# add foo package | ||||||
gnokey maketx addpkg -pkgdir $WORK/foo -pkgpath gno.land/r/foo -gas-fee 1000000ugnot -gas-wanted 211483 -broadcast -chainid=tendermint_test test1 | ||||||
|
||||||
|
||||||
# add bar package | ||||||
# out of gas at store.GetPackage() with gas 60000 | ||||||
|
||||||
! gnokey maketx addpkg -pkgdir $WORK/bar -pkgpath gno.land/r/bar -gas-fee 1000000ugnot -gas-wanted 60000 -broadcast -chainid=tendermint_test test1 | ||||||
|
||||||
# Out of gas error | ||||||
|
||||||
stderr '--= Error =--' | ||||||
stderr 'Data: out of gas error' | ||||||
stderr 'Msg Traces:' | ||||||
stderr ' 0 /home/runner/work/gno/gno/tm2/pkg/crypto/keys/client/maketx.go:215 - deliver transaction failed: log:out of gas, gasWanted: 60000, gasUsed: 60343 location: ReadFlat' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Same for the other gas used. I'd rather we checked the values of gas in gas_test.go rather than in filetests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The chain consumes gas at multiple points outside the VM before reaching the VM. Even inside the VM, a transaction may run out of gas during preprocessing or runtime. To precisely replicate and verify that the bug is fixed in the preprocessing stage, we need to specify an exact gas amount in the integration test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is checking against the error message. If we change how gas calculated, even slightly, this is yet another file where we need to go update the tests. It's an annoyance. In this case, it's not necessary for the test; this is just checking the error message. |
||||||
stderr '--= /Error =--' | ||||||
|
||||||
|
||||||
|
||||||
# out of gas at store.store.GetTypeSafe() with gas 63000 | ||||||
|
||||||
! gnokey maketx addpkg -pkgdir $WORK/bar -pkgpath gno.land/r/bar -gas-fee 1000000ugnot -gas-wanted 63000 -broadcast -chainid=tendermint_test test1 | ||||||
|
||||||
stderr '--= Error =--' | ||||||
stderr 'Data: out of gas error' | ||||||
stderr 'Msg Traces:' | ||||||
stderr ' 0 /home/runner/work/gno/gno/tm2/pkg/crypto/keys/client/maketx.go:215 - deliver transaction failed: log:out of gas, gasWanted: 63000, gasUsed: 63363 location: ReadFlat' | ||||||
stderr '--= /Error =--' | ||||||
|
||||||
|
||||||
-- foo/foo.gno -- | ||||||
package foo | ||||||
|
||||||
type Counter int | ||||||
|
||||||
func Inc(i Counter) Counter{ | ||||||
i = i+1 | ||||||
return i | ||||||
} | ||||||
|
||||||
-- bar/bar.gno -- | ||||||
package bar | ||||||
|
||||||
import "gno.land/r/foo" | ||||||
|
||||||
type NewCounter foo.Counter | ||||||
|
||||||
func Add2(i NewCounter) NewCounter{ | ||||||
i=i+2 | ||||||
|
||||||
return i | ||||||
} |
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.
like the other comment, let's maybe not make this a test against specific gas results
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 reason as above:
The chain consumes gas at multiple points outside the VM before reaching the VM. Even inside the VM, a transaction may run out of gas during preprocessing or runtime. To precisely replicate and verify that the bug is fixed in the preprocessing stage, we need to specify an exact gas amount in the integration test.
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 here, this command is not supposed fail; in fact it's not prefixed with
!
.