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!: use harcoded global min gas price check in ProcessProposal #2985

Merged
merged 30 commits into from
Jan 19, 2024

Conversation

ninabarbakadze
Copy link
Member

@ninabarbakadze ninabarbakadze commented Jan 5, 2024

Overview

Fixes - #1621

Introducing a global minimum gas price, a consensus change enforcing a lower bound for all transactions.

sidenote - updated the fee markets section in the docs but since I haven't yet been able to thoroughly read the specs section please do point out if I missed something.

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

Copy link
Contributor

coderabbitai bot commented Jan 11, 2024

Walkthrough

The changes primarily introduce a global minimum gas price affecting transaction fee calculations and prioritizations, replacing the previous node-specific minimum gas prices. This new consensus rule aims to standardize transaction costs and prevent undercutting in the blockspace market. Tests are updated to reflect these changes, and a new Multisig feature is documented. The project's Go version is also updated across various configurations and Dockerfiles.

Changes

File Pattern Change Summary
app/ante/ante.go Updated transaction fee logic to use global minimum gas prices.
app/ante/fee_checker.go Renamed and refactored fee checking function to support global gas prices.
app/ante/get_tx_priority_test.go, app/ante/gov_test.go Replaced hardcoded strings with appconsts.BondDenom constant.
app/ante/min_fee_test.go Added a test for global minimum gas price fee validation.
app/process_proposal.go Updated error handling with additional logging and rejection response.
app/test/... Adjusted tests for application versioning and modified fee parameters.
specs/src/... Added Multisig documentation and updated resource pricing to reflect global minimum gas price.
pkg/appconsts/initial_consts.go Introduced GlobalMinGasPrice and MinFee constants.
Dockerfile, Makefile, README.md, .github/workflows/..., docker/Dockerfile_txsim, test/testground/Dockerfile Updated Go version from 1.21.5 to 1.21.6.

Related issues

  • celestiaorg/celestia-app#1621 by cmwaters: The changes in this PR address the objectives of setting a lower bound for transaction gas prices and creating a global minimum gas price as an economic mechanism to distribute value within Celestia's blockspace market.

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 your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

Note: Auto-reply has been disabled for this repository by the repository owner. The CodeRabbit bot will not respond to your comments unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@cmwaters cmwaters left a comment

Choose a reason for hiding this comment

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

Nice work! Almost done, just a few nits

app/ante/min_fee_test.go Outdated Show resolved Hide resolved
@@ -78,7 +78,7 @@ func (s *MaxTotalBlobSizeSuite) TestErrTotalBlobSizeTooLarge() {

for _, tc := range testCases {
s.Run(tc.name, func() {
blobTx, err := signer.CreatePayForBlob([]*blob.Blob{tc.blob}, user.SetGasLimit(1e9))
blobTx, err := signer.CreatePayForBlob([]*blob.Blob{tc.blob}, user.SetGasLimit(1e9), user.SetFee(2000000))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Since the minimum gas price is hardcoded, you could probably create a function that takes the gas limit and returns the minimum fee instead of having to calculate it yourself

Copy link
Member Author

Choose a reason for hiding this comment

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

do you suggest I put that helper in a separate package or do you have a specific spot in mind?

specs/src/specs/resource_pricing.md Outdated Show resolved Hide resolved
@celestia-bot celestia-bot requested a review from a team January 12, 2024 12:12
app/ante/min_fee_test.go Outdated Show resolved Hide resolved
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.

had one blocking comment, but otherwise LGTM!! great work and debugging 👍

its an optimization and therefore optional, and can be done in a different PR, but if we wanted to fail even faster we could account for the new min fee in the user package.

specs/src/specs/resource_pricing.md Outdated Show resolved Hide resolved
app/ante/fee_checker.go Outdated Show resolved Hide resolved
@celestia-bot celestia-bot requested a review from a team January 12, 2024 14:12
Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

Overall LGTM! Great work. I have a few nits about wording in the specs that are optional and one question about whether we need to preserve the v1 behavior to support single binary syncs.

For context: #1568

Update: disregard I don't think we need to preserve the v1 behavior because when a v2 binary is syncing from genesis and processing v1 blocks, it doesn't have access to the min gas price of various block proposers and their is no validity rule on what the min gas price should be for those blocks.

app/ante/min_fee_test.go Show resolved Hide resolved
app/ante/min_fee_test.go Outdated Show resolved Hide resolved
specs/src/specs/resource_pricing.md Outdated Show resolved Hide resolved
specs/src/specs/resource_pricing.md Outdated Show resolved Hide resolved
specs/src/specs/resource_pricing.md Outdated Show resolved Hide resolved
specs/src/specs/resource_pricing.md Outdated Show resolved Hide resolved
@celestia-bot celestia-bot requested a review from a team January 13, 2024 08:35
@mergify mergify bot mentioned this pull request Jan 15, 2024
5 tasks
@ninabarbakadze ninabarbakadze deleted the nina/min-gas-price branch January 15, 2024 21:28
@ninabarbakadze ninabarbakadze restored the nina/min-gas-price branch January 15, 2024 21:30
@ninabarbakadze
Copy link
Member Author

some of the nits will be addressed in a different pr when I continue working on the second part of this feature. #3016

app/ante/fee_checker.go Outdated Show resolved Hide resolved
app/ante/fee_checker.go Show resolved Hide resolved
@celestia-bot celestia-bot requested a review from a team January 17, 2024 16:29
@ninabarbakadze ninabarbakadze marked this pull request as draft January 17, 2024 16:38
@ninabarbakadze ninabarbakadze force-pushed the nina/min-gas-price branch 2 times, most recently from b317f19 to 5843780 Compare January 17, 2024 16:49
@ninabarbakadze ninabarbakadze force-pushed the nina/min-gas-price branch 2 times, most recently from 0996fd5 to a07b827 Compare January 17, 2024 17:56
@ninabarbakadze ninabarbakadze marked this pull request as ready for review January 17, 2024 18:52
@rootulp rootulp self-requested a review January 17, 2024 19:37
app/ante/fee_checker.go Show resolved Hide resolved
app/ante/fee_checker.go Outdated Show resolved Hide resolved
app/ante/fee_checker.go Outdated Show resolved Hide resolved
specs/src/specs/resource_pricing.md Outdated Show resolved Hide resolved
pkg/appconsts/initial_consts.go Outdated Show resolved Hide resolved
Comment on lines +25 to +27
// GlobalMinGasPrice is used in the processProposal to ensure
// that all transactions have a gas price greater than or equal to this value.
GlobalMinGasPrice = DefaultMinGasPrice
Copy link
Collaborator

Choose a reason for hiding this comment

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

[blocking][question] for @cmwaters. The breakdown of files in pkg/appconsts has me wondering where this constant should be defined. Candidates:

  1. consensus_consts.go because this is a new "consensus constant"
  2. v2/app_consts.go because this is a new param introduced in app version v2

If we do keep this in initial_consts.go then I think we need to update the comment at the top of this file because this constant can't be modified via on-chain governance or the node's local config.

// The following defaults correspond to initial parameters of the network that can be changed, not via app versions
// but other means such as on-chain governance, or the nodes local config

Copy link
Contributor

Choose a reason for hiding this comment

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

This should be viewed as a temporary home for now as we will want to either make it a governance parameter or have some other mechanism which picks this value. I don't think v2 will simply have this hardcoded value.

If we want to move it, we can shift it to the v2 directory. I'm easy either way

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good, I like v2/app_consts.go.

I think I'd rather it not be a governance modifiable param but I think we can discuss that as a follow up. Mostly b/c I don't think we should have any governance params long term and instead we should modify params via hard-forks after reaching rough consensus off-chain. So eventually we would move from governance params to versioned params.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this PR already has two approvals, I don't think we need to block on just this constant move. We can move the constant in a follow up PR if that's easier

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll make this change in a follow-up pr @rootulp @cmwaters

app/ante/min_fee_test.go Show resolved Hide resolved
@@ -39,7 +39,7 @@ func NewAnteHandler(
ante.NewConsumeGasForTxSizeDecorator(accountKeeper),
// Ensure the feepayer (fee granter or first signer) has enough funds to pay for the tx.
// Side effect: deducts fees from the fee payer. Sets the tx priority in context.
ante.NewDeductFeeDecorator(accountKeeper, bankKeeper, feegrantKeeper, checkTxFeeWithValidatorMinGasPrices),
ante.NewDeductFeeDecorator(accountKeeper, bankKeeper, feegrantKeeper, CheckTxFeeWithGlobalMinGasPrices),
Copy link
Collaborator

Choose a reason for hiding this comment

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

[question] for @cmwaters @evan-forbes for single binary syncs and rolling upgrades, do we need to make the NewAnteHandler invocation version aware?

Copy link
Member

@evan-forbes evan-forbes Jan 17, 2024

Choose a reason for hiding this comment

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

I don't think we will ever be able to to remove an antehandler, so I don't think that we need to.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking about having a generic version wrapper that wraps the decorator and only executes it for certain versions. This might be more cleaner than having version checks sporadically added to every decorator

Comment on lines 31 to 45
// convert the global minimum gas price to a big.Int
globalMinGasPrice, err := sdk.NewDecFromStr(fmt.Sprintf("%f", appconsts.GlobalMinGasPrice))
if err != nil {
return nil, 0, errors.Wrap(err, "invalid GlobalMinGasPrice")
}

gasInt := sdk.NewIntFromUint64(gas)
minFee := globalMinGasPrice.MulInt(gasInt).TruncateInt()

// Determine the required fees by multiplying each required minimum gas
// price by the gas limit, where fee = ceil(minGasPrice * gasLimit).
glDec := sdk.NewDec(int64(gas))
for i, gp := range minGasPrices {
fee := gp.Amount.Mul(glDec)
requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt())
}
// if min fee truncates to zero, set it to one
if minFee.LT(sdk.NewInt(appconsts.MinFee)) {
minFee = sdk.NewInt(appconsts.MinFee)
}

if !feeCoins.IsAnyGTE(requiredFees) {
return nil, 0, errors.Wrapf(sdkerror.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees)
}
if !fee.GTE(minFee) {
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] we may want to compare / contrast this implementation with https://github.com/skip-mev/feemarket/blob/e6f642fbeac30f78ec7061e2f7b23a6371bf0e85/x/feemarket/ante/fee.go#L76-L103

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the main thing we should be wary of is this implementation assumes only a single token whereas skip's implementation allows for multiple native tokens. At the moment we only have one token and I don't see that changing in the foreseeable future but maybe we want to avoid the footgun in the future

app/ante/min_fee_test.go Outdated Show resolved Hide resolved
Co-authored-by: Rootul P <[email protected]>
@celestia-bot celestia-bot requested a review from a team January 17, 2024 22:07
Copy link
Contributor

@cmwaters cmwaters left a comment

Choose a reason for hiding this comment

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

thumbs up from me 👍

app/ante/fee_checker.go Show resolved Hide resolved
@celestia-bot celestia-bot requested a review from a team January 18, 2024 12:26
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.

perfect!

@celestia-bot celestia-bot requested a review from a team January 19, 2024 17:49
@ninabarbakadze ninabarbakadze merged commit e05d105 into celestiaorg:main Jan 19, 2024
30 checks passed
@ninabarbakadze ninabarbakadze deleted the nina/min-gas-price branch January 19, 2024 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants