-
Notifications
You must be signed in to change notification settings - Fork 602
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
Make apply func if no err, out of gas panic, match std behavior #3746
Make apply func if no err, out of gas panic, match std behavior #3746
Conversation
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you! |
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.
LGTM!
func IsOutOfGasError(err any) (bool, string) { | ||
switch e := err.(type) { | ||
case types.ErrorOutOfGas: | ||
return true, e.Descriptor | ||
case types.ErrorGasOverflow: | ||
return true, e.Descriptor |
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.
What about types.ErrorNegativeGasConsumed?
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.
oh wow didn't know that existed, let me think about it
great catch
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.
LGTM once @czarcas7ic 's suggestion of negative error has been added!
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you! |
Closes: #2487
What is the purpose of the change
So it turns out that CacheCtx and Ctx bizarrely share the same gas meter. Source: https://github.com/cosmos/cosmos-sdk/blob/main/types/context.go#L289-L303 , and that GasMeter is a pointer. (Otherwise https://github.com/cosmos/cosmos-sdk/blob/main/types/context.go#L58 ctx,GasMeter().ConsumeGas() wouldn't work)
So this PR makes it so that if in apply func if no err block fails due to out of gas, it preserves the standard out of gas behavior flow. This is not an issue for beginblock / endblock code as they should not get panics for out of gas issues. Whereas for txs, right now you get a different error code / distinct flow right now.
This ideally would be handled upstream, but alas.
This is state breaking, as it effects tx execution codes.
Brief Changelog
Testing and Verifying
This change added a test which shows:
The QA requirement for this will be to test a superfluid delegate action with and without this change, in the out of gas behavior setting. (Namely that they should both return an error, just a different error code)
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? yes