Skip to content
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

feat!: run min gas pfb decorator in process proposal #1985

Merged
merged 1 commit into from
Jun 23, 2023

Conversation

cmwaters
Copy link
Contributor

Closes: #1971

Yes, I'm aware that there's a lot of redundancy in the checks across the different stages in committing and executing a block. My plan is to start at a point of restrictiveness and then slowly remove redundancy rather than add more restrictiveness (which would be breaking)

@MSevey MSevey requested a review from a team June 22, 2023 15:12
@cmwaters cmwaters self-assigned this Jun 22, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #1985 (4af8999) into main (d326697) will not change coverage.
The diff coverage is 0.00%.

@@           Coverage Diff           @@
##             main    #1985   +/-   ##
=======================================
  Coverage   21.60%   21.60%           
=======================================
  Files         122      122           
  Lines       13724    13724           
=======================================
  Hits         2965     2965           
  Misses      10470    10470           
  Partials      289      289           
Impacted Files Coverage Δ
x/blob/ante/ante.go 88.46% <0.00%> (ø)

@rootulp rootulp added the consensus breaking modifies block validity rules in a way that will break consensus unless all nodes update their rules label Jun 22, 2023
func (d MinGasPFBDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
if !ctx.IsCheckTx() {
if ctx.IsReCheckTx() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[non blocking][question] how does modifying this line make the antehandler run in ProcessProposal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProcessProposal uses a context that has isCheckTx as false. Prior this would only run if the context was CheckTx now that this is removed it will run the handler in ProcessProposal. The reason for changing it to IsReCheckTx is that it doesn't make sense to re run this in ReCheckTx as nothing has changed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does modifying this line make the antehandler run in ProcessProposal?

in #1984 we use the same antehandler for all things, which will then call the above handler as well if I'm not mistaken

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[no change needed][for my understanding] is there a downside to running this ante handler when ctx.IsReCheckTx? Is there a significant performance impact?

The reason for changing it to IsReCheckTx is that it doesn't make sense to re run this in ReCheckTx as nothing has changed

To clarify, this ante handler is checking that the gas included the transaction exceeds the amount of gas expected to be consumed. Since it does not check that an account actually has the the amount of gas included in the transaction, this ante handler doesn't depend on state. Therefore the boolean result from this ante handler should be consistent before / after a new block is added even if that new block included a transaction that spent all of an account's funds.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good point @rootulp, but this ante handler works in tandem with the DeductFeeDecorator which runs before this one. So we actually first check if the account has enough funds, then we check that the fee is large enough for the PFB

Copy link
Collaborator

@rootulp rootulp Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the deduct fee decorator should be re-executed on ReCheckTx but the MinGasPFBDecorator in this PR shouldn't?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhpaps that's just prematurely optimal, but yeah

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a significant performance impact?

Probably not

@evan-forbes
Copy link
Member

evan-forbes commented Jun 22, 2023

I'm okay with merging this on the condition that we also get consensus over adding a currently unplanned block validity rule.

we will need each pfb to be able to pay for gas should we enable fee burning or some sort of min fee, which was originally planned for #49 #49 (comment) #48 (comment), but has since been removed from mainnet.

after merging this, there will be an extra check that each PFB will have to have enough funds to pay for gas. While this is trivial for a validator to bypass by simply accepting 0 fee transactions (which is also a valid behavior), this is preparing us for whenever we do implement fee burning.

cc @musalbas @adlerjohn @liamsi

@musalbas
Copy link
Member

Is this a bug fix, or a new feature?

I feel it's important that we're disciplined with release candidates, and make sure that new release candidates only have bug fixes, and do not introduce new features that need to be additionally tested.

This looks like a trivial change - is there a reason that we cannot simply add this when we implement fee burning?

@musalbas
Copy link
Member

My plan is to start at a point of restrictiveness and then slowly remove redundancy rather than add more restrictiveness (which would be breaking)

If there is an argument that this is actually a bug fix or security improvement due to the above - then I'm also fine with this being included, as that rationale makes sense.

@cmwaters
Copy link
Contributor Author

I would classify this as a bug fix but not an important one. Currently a validator could propose a block with a PFB that fills the entire block and instead of specifying the 20 million gas it would require to execute, only setting 100k. The tx would pass the validity checks in ProcessProposal but would run out of gas when it was executed in DeliverTx. However it doesn't matter if a PFB doesn't execute successfully, the data has already been published and the block proposer has got DA basically for free. The reason why this is not important is because regardless if the gas is correctly calculated or not, a user can always set a gas price of 0, and thus a fee of 0 (fee = gas * gas price) so long as the proposers min gas price that it will accept is 0 (default is non-zero). In other words you can get DA for free anyway. My understanding is that we will want to implement a proper and robust fee market relatively soon. Having this bug fixed will mean it's done now instead of later but given that a fee market implementation will likely be breaking in any case I think it's also fine if we punt on this change until v2.

Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per sync discussion: 👍

@cmwaters cmwaters merged commit 4248170 into main Jun 23, 2023
@cmwaters cmwaters deleted the cal/pfb-decorator branch June 23, 2023 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus breaking modifies block validity rules in a way that will break consensus unless all nodes update their rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MinGasPFBDecorator should also be run in ProcessProposal
5 participants