Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: should revert tx when block gas limit exceeded #10770
fix: should revert tx when block gas limit exceeded #10770
Changes from all commits
6baba7e
c03ab15
af0cc18
2f24333
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
More tests to add:
5000uatom
in gas but user only has4000uatom
=> transaction should fail and4000uatom
must be charged.Probably we have more holes in the code.
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.
If we fail to charge user the fee specified in tx, we don't charge anything from user, and tx msgs are not executed neither.
MempoolFeeMiddleware
checks incheckTx
that:txFee >= txGasLimit * minGasPrice
, andDeductFeeMiddleware
just deducttxFee
from payer. And it's reasonable since it'll panic immediately when tx gas limit exceeded. and if it fails to deduct fee, tx msgs are not executed at all.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.
This is wrong. We should charge user what's possible.
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.
Re 2. This is about the gas consumed. This is not checked in
CheckTx
. We only know how much gas was consumed after processing a transaction.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 was just describing what's currently implemented in cosmos-sdk, I think you proposed a new design on this, right?
If I understand correctly, the new design should work like this:
It looks like sth good to have, but I'm not sure this PR is a good place to do this change though.
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.
Yes, this is a change in the current functionality that is a good idea but out of scope of this PR. I would be happy if there was a new issue for this and it made it to main eventually. Since we fail fast in the ante handler, this has never been viewed as an attack vector and I see no urgent need for this.
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.
Yes, this is related to the issue I created last week: #10908, so we can continue there.
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.
let's add
txGasLimit
as a test case parameter, and add the following test 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.
User still should be deducted the
feeAmount
, unless we also want to testcheckTx
logic here? I think that maybe should be done in another PR.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.
But the new proposed test is not related to
checkTx
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 mean sender is deducted exactly the fee specified in tx, it's unrelated to gas consumption, we specify 150uatom in tx as fee, it'll deduct exactly that amount regardless of how much gas tx consumed. That's what current implementation does.
Only in checkTx the fee is checked against gasLimit.
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 think, something is wrong here. We started with
150atom
, why it should always be zero?We should test here that the proper amount of fee coins are deduced - this depends on the amount of gas used.
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.
Because the fee in tx is set to a constant for simplicity,
fee >= minGasPrice * gasLimit
should be checked in checkTx, which is not tested 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.
But my question is about the tokens, not the gas. In line 47 we sent 150atoms to the user. Then after the transaction succeeds, some tokens should be debited to pay for the gas. So at the end we should still has some tokens.
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.
Because we specified the 150atom as the tx fee, it deduct exactly the amount of fee specified in tx.
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.
OK 👍