-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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(baseapp): Reset GasMeter before deliverTX #18714
fix(baseapp): Reset GasMeter before deliverTX #18714
Conversation
WalkthroughThe changes address a bug in the Cosmos SDK's Changes
Assessment against linked issues
The code changes appear to address the key objectives outlined in the linked issue, ensuring that gas consumption is tracked and managed correctly within the Cosmos SDK's Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ? TipsChat with CodeRabbit Bot (
|
…ock-gas-usage' into ericw/18609-beginblock-gas-usage
baseapp/abci.go
Outdated
// Reset the gas meter so that the AnteHandlers aren't required to | ||
gasMeter = app.getBlockGasMeter(app.finalizeBlockState.ctx) | ||
app.finalizeBlockState.ctx = app.finalizeBlockState.ctx.WithBlockGasMeter(gasMeter) | ||
app.checkState.ctx = app.checkState.ctx.WithBlockGasMeter(gasMeter) |
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.
sorry, why are we setting CheckTx state here?
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.
Good call out, there's no need to modify the checkTx state's meter here.
@@ -780,6 +780,11 @@ func (app *BaseApp) internalFinalizeBlock(ctx context.Context, req *abci.Request | |||
|
|||
events = append(events, beginBlock.Events...) | |||
|
|||
// Reset the gas meter so that the AnteHandlers aren't required to | |||
gasMeter = app.getBlockGasMeter(app.finalizeBlockState.ctx) | |||
app.finalizeBlockState.ctx = app.finalizeBlockState.ctx.WithBlockGasMeter(gasMeter) |
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
LGTM but I have some questions to fully understand this. This means that we can also remove the gas meter resetting in the ante handlers? Why was this done in ante handlers in the first place? |
@facundomedica it is done in the AnteHandler, specifically the Setup decorator. However, this patch addresses two things:
|
@alexanderbez is it a backportable fix? |
It should be--we found this issue when using 0.47. But the fix is in a different place so I'm thinking it makes sense for me to open a different PR for the backport instead of trying to have mergify/automation do it. I have a branch with changes staged already on my fork. |
For v0.47 that makes sense not to use mergify. For v0.50, if we backport, that will be easier to use it. |
@Mergifyio backport release/v0.50.x |
✅ Backports have been created
|
(cherry picked from commit e7f5c2e) # Conflicts: # CHANGELOG.md
Are you willing to open a PR targeting v0.47? |
++ @Eric-Warehime 🙏 |
Yes I can get it open probably in the next 24-48 hours. |
Cool, that's our only blocker for v0.47.7 ;) |
Opening 0.47.X backport in #18826 |
Description
#18609
Closes: #18609
Resets the BlockGasMeter before deliverTx is called to ensure the AnteHandlers aren't relied upon for that.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...