-
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: x/capability
InitMemStore
should not consume gas
#15030
fix: x/capability
InitMemStore
should not consume gas
#15030
Conversation
I am not sure what is going on with the |
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.
👏
Thanks @prettymuchbryce!
Yeah, you can ignore the lint stuff for now...not sure what's up with that.
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, a nit
x/capability/capability_test.go
Outdated
|
||
suite.Require().Equal(prevBlockGas, blockGasUsed, "beginblocker consumed block gas during execution") |
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.
suite.Require().Equal(prevBlockGas, blockGasUsed, "beginblocker consumed block gas during execution") | |
suite.Require().Equal(prevBlockGas, blockGasUsed, "ensure beginblocker consume no block gas during execution") |
can you update the below check's description as well.
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.
Thanks!
@prettymuchbryce could you merge/rebase main so that our bot automerges this PR? Or altnertively give write access to maintainers |
Head branch was pushed to by a user without write access
0a6c7ae
to
ca7706b
Compare
@AmauryM I rebased onto |
Description
Closes: #15015
The
capability
module'sInitMemStore
function incrementsgasMeter
non-deterministically across validators.When a validator is restarted, InitMemStore is called during
BeginBlock
of the next committed block. This function performs some store operations which incrementGasUsed
on theGasMeter
here.So long as
SetGasMeter
is always called as part of the AnteHandler chain (which is the current behavior of the default AnteHandler chain here), then this is not an issue as theGasMeter
will be reset betweenBeginBlock
and the firstDeliverTx
call.However, if the application uses a custom AnteHandler chain that omits this behavior, the
GasUsed
within each transaction will vary, as theGasMeter
will be the initial meter set duringBeginBlock
here which increments gas differently if the capability module'sMemStore
has not yet been initialized.As a solution, this PR adds
WithGasMeter
to thenoGasCtx
here which ensures thatInitMemStore
consumes no gas fromGasMeter
.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...
!
to 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...
!
in the type prefix if API or client breaking change