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(server/v2): add min gas price and check with tx fee #21173

Merged
merged 38 commits into from
Aug 29, 2024

Conversation

akhilkumarpilli
Copy link
Contributor

@akhilkumarpilli akhilkumarpilli commented Aug 5, 2024

Description

Closes: #XXXX

  • Add minimum-gas-prices config in server config
  • Test transaction fee with minimum-gas-prices value in x/auth/tx TxValidator method.
  • Update few commands and confix related to server config

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...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

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.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced minimum gas price validation for transaction processing.
    • Enhanced control flow by adding a validation step for transaction fees.
    • Improved server configuration management with a new structured configuration system.
    • Added methods for better handling of server configuration and command-line flags.
    • Allowed chain developers to overwrite default server configurations.
    • Incorporated a fee transaction validator to manage transaction fees within the application module.
  • Bug Fixes

    • Improved error handling for insufficient transaction fees.
  • Chores

    • Refined dependency management for mathematical operations.
    • Enhanced command-line interface capabilities for server commands.

@github-actions github-actions bot added C:Confix Issues and PR related to Confix C:server/v2 Issues related to server/v2 C:server/v2 cometbft labels Aug 5, 2024
Copy link
Contributor

coderabbitai bot commented Aug 5, 2024

Walkthrough

Walkthrough

The recent changes enhance transaction processing within the CometBFT application by implementing minimum gas price requirements. Key updates include a new method for validating transaction fees, improved error handling for fee-related issues, and refinements to configuration management. These modifications ensure that transactions are economically viable according to validator settings.

Changes

Files Change Summary
server/v2/cometbft/abci.go Introduced minimum gas price validation for transactions via a new method, enhancing fee validation control flow.
server/v2/cometbft/go.mod Added cosmossdk.io/math v1.3.0 as a direct dependency, enhancing handling of mathematical operations.
server/v2/config.go, server/v2/server.go, server/v2/flags.go Improved server configuration management with new struct and validation methods, including dynamic flag handling.
server/v2/commands.go, server/v2/server_test.go Updated command handling and test setup to incorporate server configuration, enhancing initialization consistency.
x/auth/ante/fee.go, x/auth/ante/validator_tx_fee.go, x/auth/tx/config/module.go Modified fee deduction logic and introduced dynamic configuration management for transaction fees based on minimum gas prices.
simapp/v2/simdv2/cmd/commands.go, simapp/v2/simdv2/cmd/config.go, simapp/v2/simdv2/cmd/testnet.go Enhanced command initialization and configuration handling to allow overwriting of default server configuration.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Server
    participant Config
    participant Validator

    User->>Server: Start server with configuration
    Server->>Config: Validate server configuration
    Config-->>Server: Return validation result
    alt Configuration valid
        Server->>Validator: Process transaction with minimum gas prices
        Validator-->>Server: Confirm transaction
    else Configuration invalid
        Server-->>User: Error message
    end
Loading

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:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 testing code 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 and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@akhilkumarpilli akhilkumarpilli marked this pull request as ready for review August 5, 2024 10:54
@akhilkumarpilli akhilkumarpilli requested a review from a team as a code owner August 5, 2024 10:54
Copy link
Contributor

github-actions bot commented Aug 5, 2024

@akhilkumarpilli your pull request is missing a changelog!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 984afb5 and 39d9a69.

Files selected for processing (10)
  • server/v2/cometbft/abci.go (4 hunks)
  • server/v2/cometbft/config.go (3 hunks)
  • server/v2/cometbft/flags.go (1 hunks)
  • server/v2/cometbft/go.mod (2 hunks)
  • server/v2/cometbft/server.go (2 hunks)
  • server/v2/cometbft/types/errors/errors.go (1 hunks)
  • simapp/v2/simdv2/cmd/commands.go (1 hunks)
  • simapp/v2/simdv2/cmd/testnet.go (1 hunks)
  • tools/confix/data/v2-app.toml (1 hunks)
  • tools/confix/migrations.go (1 hunks)
Additional context used
Path-based instructions (8)
server/v2/cometbft/types/errors/errors.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/v2/cometbft/flags.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/v2/cometbft/config.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

simapp/v2/simdv2/cmd/commands.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

tools/confix/migrations.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/v2/cometbft/server.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

simapp/v2/simdv2/cmd/testnet.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/v2/cometbft/abci.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (20)
server/v2/cometbft/types/errors/errors.go (3)

18-19: LGTM!

The error constant ErrTxDecode is correctly defined and follows the existing pattern in the file.


21-22: LGTM!

The error constant ErrInsufficientFee is correctly defined and follows the existing pattern in the file.


24-25: LGTM!

The error constant ErrAppConfig is correctly defined and follows the existing pattern in the file.

server/v2/cometbft/flags.go (1)

60-60: LGTM!

The server flag FlagMinGasPrices is correctly defined and follows the existing pattern in the file.

tools/confix/data/v2-app.toml (1)

2-3: LGTM!

The configuration parameter minimum-gas-prices is correctly defined with a default value and a comment explaining its purpose.

server/v2/cometbft/config.go (3)

4-11: Imports look good.

The new imports fmt and cometerrors are necessary and correctly used in the file.


34-34: Field definition and documentation look good.

The new field MinGasPrices is correctly defined and well-documented in the AppTomlConfig struct.


88-95: Validation logic looks good.

The ValidateBasic method correctly checks for the MinGasPrices field and provides a meaningful error message.

simapp/v2/simdv2/cmd/commands.go (1)

73-99: Configuration implementation looks good.

The new configuration for cometAppTomlCfg with MinGasPrices set to "0stake" is correctly implemented and well-documented.

tools/confix/migrations.go (1)

38-39: Key-value pair definition looks good.

The new key-value pair for "minimum-gas-prices" is correctly defined and integrated into the v2KeyChanges variable.

server/v2/cometbft/server.go (2)

226-226: LGTM! The new flag enhances configurability.

The addition of the FlagMinGasPrices flag is a valuable enhancement.


133-136: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to Start correctly handle the new validation step.

Verification successful

LGTM! The function usage correctly handles the new validation step.

The code changes are approved.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `Start` handle the new validation step.

# Test: Search for the function usage. Expect: Proper error handling for the validation step.
rg --type go -A 5 $'Start(ctx context.Context)'

Length of output: 48


Script:

#!/bin/bash
# Description: Verify all function calls to `Start` handle the new validation step.

# Test: Search for all function usages of `Start`. Expect: Proper error handling for the validation step.
rg --type go -A 5 'Start('

Length of output: 91


Script:

#!/bin/bash
# Description: Verify all function calls to `Start` handle the new validation step.

# Test: Search for all function usages of `Start`. Expect: Proper error handling for the validation step.
rg --type go -A 5 'Start\('

Length of output: 22166

server/v2/cometbft/go.mod (1)

28-28: LGTM! The dependency change is appropriate.

The addition of cosmossdk.io/math v1.3.0 as a direct dependency is appropriate and suggests a refinement in dependency management.

simapp/v2/simdv2/cmd/testnet.go (2)

340-342: LGTM! The configuration enhancement is valuable.

The addition of cometAppTomlCfg and updates to the cometbft.New function call enhance the configuration capabilities of the initTestnetFiles function.


348-348: LGTM! The integration of the modified configuration is appropriate.

The integration of cometAppTomlCfg into the cometbft.New function call is appropriate and enhances the server's initialization process.

server/v2/cometbft/abci.go (5)

21-21: New import statement looks good.

The import of sdkmath is necessary for the mathematical operations related to gas calculations.


158-188: New method implementation looks good with a minor improvement suggestion.

The checkTxFeeWithMinGasPrices method correctly ensures that provided fees meet a minimum threshold. Error handling is appropriately managed.

Minor improvement suggestion:

  • Consider adding a comment to explain the purpose of the sdkmath.LegacyNewDec function for better readability.

Line range hint 1-1: File conforms to the Uber Golang style guide.

The file follows the Uber Golang style guide, with clear and concise function implementations, appropriate error handling, and consistent naming conventions.

Also applies to: 31-31, 128-188


Line range hint 1-1: File review complete. No issues or improvements identified.

The file is well-structured and follows best practices.

Also applies to: 31-31, 128-188


128-134: LGTM! Ensure the function usage is verified.

The added validation step in CheckTx ensures transactions meet the minimum gas price requirements. Error handling is appropriately managed.

However, ensure that all function calls to CheckTx are correctly updated.

Verification successful

LGTM! Ensure the function usage is verified.

The added validation step in CheckTx ensures transactions meet the minimum gas price requirements. Error handling is appropriately managed.

However, ensure that all function calls to CheckTx are correctly updated. Based on the search results, the function calls appear to be correctly updated.

  • Verify that checkTxFeeWithMinGasPrices is being used correctly in the CheckTx method.
  • Ensure that all relevant test cases cover the new validation logic.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `CheckTx` are correctly updated.

# Test: Search for the function usage. Expect: Only occurrences of the updated function.
rg --type go -A 5 $'CheckTx'

Length of output: 43976

Comment on lines 73 to 86
// GetMinGasPrices returns the validator's minimum gas prices based on the set configuration.
func (c Config) GetMinGasPrices() sdk.DecCoins {
minGasPricesStr := c.AppTomlConfig.MinGasPrices
if minGasPricesStr == "" {
return sdk.DecCoins{}
}

gasPrices, err := sdk.ParseDecCoins(minGasPricesStr)
if err != nil {
panic(fmt.Sprintf("invalid minimum gas prices: %v", err))
}

return gasPrices
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling in GetMinGasPrices.

The GetMinGasPrices method is well-implemented, but consider handling errors more gracefully rather than panicking.

-  panic(fmt.Sprintf("invalid minimum gas prices: %v", err))
+  return sdk.DecCoins{}, fmt.Errorf("invalid minimum gas prices: %v", err)

Committable suggestion was skipped due to low confidence.

func (c *Consensus[T]) checkTxFeeWithMinGasPrices(tx transaction.Tx) error {
feeTx, ok := tx.(sdk.FeeTx)
if !ok {
return errorsmod.Wrap(cometerrors.ErrTxDecode, "tx must be a feeTx")
Copy link
Member

Choose a reason for hiding this comment

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

We should avoid the error here. Forcing users that don't use our tx to implement an interface specific to our implementation seems like a code smell

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (1)
server/v2/cometbft/abci.go (1)

128-134: Ensure proper error handling and logging.

The new validation step in CheckTx method correctly checks the transaction fees against the minimum gas price. However, it would be beneficial to include more detailed logging for better traceability.

-    return &abciproto.CheckTxResponse{
+    c.logger.Error("Transaction fee validation failed", "error", err)
+    return &abciproto.CheckTxResponse{
Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 39d9a69 and 1fe5674.

Files selected for processing (2)
  • server/v2/cometbft/abci.go (4 hunks)
  • server/v2/cometbft/go.mod (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • server/v2/cometbft/go.mod
Additional context used
Path-based instructions (1)
server/v2/cometbft/abci.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/v2/cometbft/abci.go Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (3)
server/v2/cometbft/abci.go (3)

128-134: Ensure correct error handling in CheckTx.

The error handling for the checkTxFeeWithMinGasPrices call is appropriate, but consider logging the error for better traceability.

+ c.logger.Error("tx fee validation failed", "err", err)

158-160: Clarify the method's scope and usage in the comment.

The comment should explicitly mention that this method is intended for use in CheckTx only and is not meant for other types of transactions.

// checkTxFeeWithMinGasPrices ensures that the provided fees meet a minimum threshold for the validator,
// if this is a CheckTx. This is only for local mempool purposes, and thus
// is only run on check tx.

175-183: Optimize fee calculation loop.

The fee calculation loop is correctly implemented, but consider adding a comment explaining the logic for better readability.

// Determine the required fees by multiplying each required minimum gas
// price by the gas limit, where fee = ceil(minGasPrice * gasLimit).
Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1fe5674 and 36e4aed.

Files selected for processing (1)
  • server/v2/cometbft/abci.go (4 hunks)
Additional context used
Path-based instructions (1)
server/v2/cometbft/abci.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (3)
server/v2/cometbft/abci.go (3)

162-164: Avoid forcing users to implement specific interfaces.

The current implementation correctly avoids forcing users to implement the sdk.FeeTx interface. This is a good practice to maintain flexibility.


170-173: Optimize early return for zero minimum gas prices.

The early return for zero minimum gas prices is correctly implemented, ensuring that unnecessary computations are avoided.


185-187: Ensure detailed error messages for insufficient fees.

The error message for insufficient fees is detailed and informative, which is good for debugging and user feedback.

@akhilkumarpilli akhilkumarpilli marked this pull request as draft August 7, 2024 10:22
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 36e4aed and bc8ad35.

Files selected for processing (4)
  • server/v2/config.go (1 hunks)
  • server/v2/flags.go (1 hunks)
  • server/v2/server.go (6 hunks)
  • simapp/v2/simdv2/cmd/testnet.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • simapp/v2/simdv2/cmd/testnet.go
Additional context used
Path-based instructions (3)
server/v2/flags.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/v2/config.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/v2/server.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (11)
server/v2/flags.go (2)

9-11: LGTM!

The prefix function is correctly implemented to concatenate the server name with a given flag name.


13-13: LGTM!

The FlagMinGasPrices variable is correctly defined using the prefix function.

server/v2/config.go (4)

11-13: LGTM!

The ServerConfig struct is correctly defined with the MinGasPrices field and appropriate annotations.


16-22: LGTM!

The ValidateBasic method correctly implements basic validation for the MinGasPrices field.


25-27: LGTM!

The DefaultMainServerConfig function correctly initializes and returns a default ServerConfig instance.


30-32: LGTM!

The OverwriteDefaultConfig method correctly updates the server's configuration with the provided ServerConfig instance.

server/v2/server.go (5)

60-60: LGTM!

The serverName constant is correctly defined to standardize the server name.


67-68: LGTM!

The addition of the config field to the Server struct enhances its configuration management.


87-91: LGTM!

The validation step in the Start method ensures the server does not start with an invalid configuration, enhancing robustness.


165-167: LGTM!

The Config method correctly provides access to the server's configuration.


187-191: LGTM!

The StartCmdFlags method correctly facilitates the creation of command-line flags specific to the server.

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Aug 27, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 50e95fe and e8365f5.

Files selected for processing (2)
  • tests/systemtests/staking_test.go (1 hunks)
  • x/auth/ante/fee.go (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/auth/ante/fee.go
Additional context used
Path-based instructions (1)
tests/systemtests/staking_test.go (3)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

Additional comments not posted (1)
tests/systemtests/staking_test.go (1)

Line range hint 1-1: LGTM! Ensure comprehensive test coverage.

The removal of the skip line indicates that the test is now relevant for execution. The function appears to be well-structured and covers the key aspects of staking and unstaking. However, ensure that the test covers all edge cases and handles potential errors.

The code changes are approved.

Run the following script to verify the test coverage:

x/auth/ante/fee.go Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range, codebase verification and nitpick comments (3)
x/auth/tx/config/depinject.go (1)

116-144: Function Implementation Approved with Suggestions

The ProvideModule function correctly sets up the module configurations and validators, including the new minimum gas prices feature. Consider adding more detailed error logging around the minimum gas prices parsing to aid in debugging potential configuration issues in production environments.

simapp/v2/simdv2/cmd/testnet.go (2)

131-131: Function Modification Approved with Suggestions

The update to retrieve minimum gas prices using serverv2.FlagMinGasPrices in testnetInitFilesCmd function is correctly implemented. Consider adding validation for the retrieved gas prices to ensure they are within expected ranges and formats to prevent runtime issues.


Line range hint 339-350: Function Modification Approved with Suggestions

The integration of minimum gas prices into the server configuration in initTestnetFiles function is well-implemented. Recommend thorough testing to ensure that the configuration behaves as expected under various network conditions and transaction volumes.

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e8365f5 and 8e966e6.

Files selected for processing (8)
  • server/v2/server_test.go (1 hunks)
  • simapp/v2/simdv2/cmd/commands.go (1 hunks)
  • simapp/v2/simdv2/cmd/config.go (2 hunks)
  • simapp/v2/simdv2/cmd/testnet.go (5 hunks)
  • x/auth/ante/fee.go (5 hunks)
  • x/auth/ante/validator_tx_fee.go (3 hunks)
  • x/auth/tx/config/depinject.go (5 hunks)
  • x/auth/tx/config/module.go (2 hunks)
Files skipped from review as they are similar to previous changes (3)
  • server/v2/server_test.go
  • simapp/v2/simdv2/cmd/commands.go
  • x/auth/ante/fee.go
Additional context used
Path-based instructions (5)
x/auth/tx/config/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/auth/ante/validator_tx_fee.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

simapp/v2/simdv2/cmd/config.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/auth/tx/config/depinject.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

simapp/v2/simdv2/cmd/testnet.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (5)
x/auth/tx/config/module.go (1)

22-22: Addition of feeTxValidator field to AppModule struct is well-placed.

This new field aligns with the PR's objective to enhance transaction fee validation capabilities.

x/auth/ante/validator_tx_fee.go (1)

17-17: Refactoring of checkTxFeeWithValidatorMinGasPrices enhances functionality.

The method now properly utilizes the DeductFeeDecorator's state and methods, improving context-awareness and integration. The shift to context.Context is a positive change towards standardizing context handling in Go.

Also applies to: 29-30

x/auth/tx/config/depinject.go (2)

38-39: Constant Definition Approved

The constant flagMinGasPricesV2 is correctly defined and follows Go naming conventions.


57-68: Struct Modification Approved

The addition of the Viper field in ModuleInputs struct is appropriate for dynamic configuration management. Ensure that the Viper instance is properly initialized and used wherever necessary to avoid runtime panics.

simapp/v2/simdv2/cmd/testnet.go (1)

74-74: Function Modification Approved

The update to use serverv2.FlagMinGasPrices in addTestnetFlagsToCmd function enhances consistency in flag management. Ensure that all references to the old flag are updated across the entire codebase to avoid configuration errors.

@@ -28,6 +29,7 @@ type AppModule struct {
// NewAppModule creates a new AppModule object.
func NewAppModule(
sigVerification ante.SigVerificationDecorator,
feeTxValidator *ante.DeductFeeDecorator,
Copy link
Contributor

Choose a reason for hiding this comment

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

Constructor does not initialize feeTxValidator.

The feeTxValidator parameter is accepted in the constructor but is not assigned to the AppModule struct. This looks like an oversight.

Consider adding the following line in the constructor to fix this issue:

+ feeTxValidator:  feeTxValidator,

Also applies to: 40-40

Comment on lines +56 to +70
func initServerConfig() serverv2.ServerConfig {
serverCfg := serverv2.DefaultServerConfig()
// The server's default minimum gas price is set to "0stake" inside
// app.toml. However, the chain developer can set a default app.toml value for their
// validators here. Please update value based on chain denom.
//
// In summary:
// - if you set serverCfg.MinGasPrices value, validators CAN tweak their
// own app.toml to override, or use this default value.
//
// In simapp, we set the min gas prices to 0.
serverCfg.MinGasPrices = "0stake"

return serverCfg
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Addition of initServerConfig function enhances configurability.

The function allows chain developers to set a default MinGasPrices value, enhancing flexibility. However, consider making the MinGasPrices value configurable to accommodate different chain denominations more effectively.

Consider adding a parameter to the initServerConfig function to allow passing the default MinGasPrices value, making it more adaptable to different chains.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8e966e6 and 2c3b9d8.

Files selected for processing (1)
  • x/auth/tx/config/module.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/auth/tx/config/module.go

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2c3b9d8 and 0c5f774.

Files selected for processing (3)
  • x/auth/ante/fee.go (5 hunks)
  • x/auth/ante/validator_tx_fee.go (3 hunks)
  • x/auth/tx/config/module.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/auth/tx/config/module.go
Additional context used
Path-based instructions (2)
x/auth/ante/validator_tx_fee.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/auth/ante/fee.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (12)
x/auth/ante/validator_tx_fee.go (4)

4-7: LGTM!

The new imports are necessary for the changes made in the file.

The code changes are approved.


Line range hint 17-29: LGTM!

The changes enhance the method's integration with the surrounding architecture, allowing for more flexible and context-aware fee validation logic.

The code changes are approved.


Line range hint 29-36: LGTM!

The changes improve the fee validation logic by integrating it with the DeductFeeDecorator struct.

The code changes are approved.


Line range hint 38-54: LGTM!

The function is correctly implemented and does not require any changes.

The code changes are approved.

x/auth/ante/fee.go (8)

5-8: LGTM!

The new imports are necessary for the changes made in the file.

The code changes are approved.


19-19: LGTM!

The change enhances the flexibility of the context being used, allowing for better integration with standard Go context handling.

The code changes are approved.


30-30: LGTM!

The addition of the minGasPrices field improves the state management of the decorator.

The code changes are approved.


33-46: LGTM!

The change ensures that the state is maintained correctly across invocations.

The code changes are approved.


49-52: LGTM!

The function is correctly implemented and does not require any changes.

The code changes are approved.


54-64: LGTM!

The changes improve the modularity and clarity of the fee deduction logic.

The code changes are approved.


66-91: LGTM!

The function is correctly implemented and does not require any changes.

The code changes are approved.


Line range hint 101-145: LGTM!

The changes simplify the logic for fee deduction and ensure that the correct accounts are used for fee processing.

The code changes are approved.

@julienrbrt julienrbrt added this pull request to the merge queue Aug 29, 2024
Merged via the queue into main with commit 81a225e Aug 29, 2024
78 checks passed
@julienrbrt julienrbrt deleted the akhil/min-gas-price-config branch August 29, 2024 07:51
mergify bot pushed a commit that referenced this pull request Aug 29, 2024
Co-authored-by: Julien Robert <[email protected]>
(cherry picked from commit 81a225e)

# Conflicts:
#	server/v2/commands.go
#	server/v2/config.go
#	server/v2/flags.go
#	server/v2/server.go
#	server/v2/server_test.go
#	server/v2/testdata/app.toml
julienrbrt added a commit that referenced this pull request Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release C:Confix Issues and PR related to Confix C:server/v2 Issues related to server/v2 C:x/auth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants