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

fix(server): properly parse multiple gas config #18537

Merged
merged 2 commits into from
Nov 22, 2023
Merged

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Nov 22, 2023

Description

Closes: #18536


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
  • added ! to 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
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • 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.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Summary by CodeRabbit

  • Bug Fixes

    • Resolved a server panic issue related to incorrect minimum gas price configuration.
    • Fixed the use of the correct public key when simulating transactions.
    • Ensured FinalizeBlock calls are now correctly passed to ABCIListeners.
    • Eliminated a data race in BaseApp.getContext as identified by e2e tests.
  • Refactor

    • Updated the newApp function to accept new types of application options and streamlined the passing of arguments.
  • Documentation

    • Modified the configuration file example to use a comma as the delimiter for specifying minimum gas prices.
  • Style

    • Adjusted test function names and expanded test cases to cover new minimum gas price scenarios.

@julienrbrt julienrbrt added backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release labels Nov 22, 2023
@julienrbrt julienrbrt requested a review from a team as a code owner November 22, 2023 09:19
Copy link
Contributor

coderabbitai bot commented Nov 22, 2023

Walkthrough

It looks like you want to generate a summary and a table of changes based on the provided information. Here's the updated content based on your instructions:

Walkthrough

The changes involve bug fixes and refactoring in a Go application related to blockchain or cryptocurrency. A panic issue with gas configuration, a pubkey error in transaction simulation, and a block finalization call issue were fixed. A data race was also resolved. The server's newApp function was refactored to improve the handling of application options. The configuration for minimum gas prices was updated to use a comma delimiter, and the related code and tests were adjusted to reflect this change.

Changes

File(s) Change Summary
CHANGELOG.md Fixed server panic, pubkey error in client/tx, block finalization issue, and a data race in baseapp.
server/README.md, simapp/simd/cmd/commands.go Refactored newApp function to use servertypes.AppOptions and introduced baseappOptions.
server/config/config.go, server/config/config_test.go, server/config/toml.go Updated minimum gas prices parsing to use a comma delimiter and enhanced related tests.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Note: For conversation with the bot, please use the review comments on code diffs or files.

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

@github-actions github-actions bot added the C:Confix Issues and PR related to Confix label Nov 22, 2023
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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8644e6b and 2d6962b.
Files ignored due to filter (2)
  • tools/confix/data/v0.47-app.toml
  • tools/confix/data/v0.50-app.toml
Files selected for processing (6)
  • CHANGELOG.md (1 hunks)
  • server/README.md (1 hunks)
  • server/config/config.go (2 hunks)
  • server/config/config_test.go (1 hunks)
  • server/config/toml.go (1 hunks)
  • simapp/simd/cmd/commands.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • simapp/simd/cmd/commands.go
Additional comments: 5
CHANGELOG.md (1)
  • 70-70:
    The changelog entries are well-documented and include references to the relevant pull requests, which is good for traceability.
server/config/toml.go (1)
server/config/config.go (2)
  • 3-8: The removal of the "strings" package import is appropriate given that the updated code does not use it.

  • 201-215: The GetMinGasPrices function now correctly uses sdk.ParseDecCoins to parse the minimum gas prices. The error handling with a panic is a significant change; ensure that this behavior is documented and that callers are aware that this function can panic.

server/README.md (1)
  • 74-84: - The refactoring of the newApp function to accept servertypes.AppOptions instead of server.AppOptions is a significant change. Ensure that all references to this function are updated accordingly.
  • The introduction of baseappOptions as variadic arguments to simapp.NewSimApp is a good practice for flexibility and maintainability.
  • Verify that the DefaultBaseappOptions function correctly extracts the necessary options from appOpts and that the simapp.NewSimApp function is compatible with the variadic baseappOptions parameter.
  • Ensure that the documentation reflects the correct usage of the new function signature and the rationale behind the changes.

Comment on lines +21 to 33
func TestGetAndSetMinimumGas(t *testing.T) {
cfg := DefaultConfig()
cfg.SetMinGasPrices(sdk.DecCoins{sdk.NewInt64DecCoin("foo", 5)})

input := sdk.DecCoins{sdk.NewInt64DecCoin("foo", 5)}
cfg.SetMinGasPrices(input)
require.Equal(t, "5.000000000000000000foo", cfg.MinGasPrices)
require.EqualValues(t, cfg.GetMinGasPrices(), input)

input = sdk.DecCoins{sdk.NewInt64DecCoin("bar", 1), sdk.NewInt64DecCoin("foo", 5)}
cfg.SetMinGasPrices(input)
require.Equal(t, "1.000000000000000000bar,5.000000000000000000foo", cfg.MinGasPrices)
require.EqualValues(t, cfg.GetMinGasPrices(), input)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The test cases in TestGetAndSetMinimumGas have been updated to include scenarios with multiple minimum gas prices. However, the assertions for cfg.MinGasPrices are directly comparing the string representation of DecCoins which might not be robust if the string representation changes in the future. It would be better to compare DecCoins directly.

- require.Equal(t, "5.000000000000000000foo", cfg.MinGasPrices)
+ require.EqualValues(t, input.String(), cfg.MinGasPrices)
- require.Equal(t, "1.000000000000000000bar,5.000000000000000000foo", cfg.MinGasPrices)
+ require.EqualValues(t, input.String(), cfg.MinGasPrices)

Commitable suggestion

[!IMPORTANT]
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func TestGetAndSetMinimumGas(t *testing.T) {
cfg := DefaultConfig()
cfg.SetMinGasPrices(sdk.DecCoins{sdk.NewInt64DecCoin("foo", 5)})
input := sdk.DecCoins{sdk.NewInt64DecCoin("foo", 5)}
cfg.SetMinGasPrices(input)
require.Equal(t, "5.000000000000000000foo", cfg.MinGasPrices)
require.EqualValues(t, cfg.GetMinGasPrices(), input)
input = sdk.DecCoins{sdk.NewInt64DecCoin("bar", 1), sdk.NewInt64DecCoin("foo", 5)}
cfg.SetMinGasPrices(input)
require.Equal(t, "1.000000000000000000bar,5.000000000000000000foo", cfg.MinGasPrices)
require.EqualValues(t, cfg.GetMinGasPrices(), input)
}
func TestGetAndSetMinimumGas(t *testing.T) {
cfg := DefaultConfig()
input := sdk.DecCoins{sdk.NewInt64DecCoin("foo", 5)}
cfg.SetMinGasPrices(input)
require.EqualValues(t, input.String(), cfg.MinGasPrices)
require.EqualValues(t, cfg.GetMinGasPrices(), input)
input = sdk.DecCoins{sdk.NewInt64DecCoin("bar", 1), sdk.NewInt64DecCoin("foo", 5)}
cfg.SetMinGasPrices(input)
require.EqualValues(t, input.String(), cfg.MinGasPrices)
require.EqualValues(t, cfg.GetMinGasPrices(), input)
}

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2d6962b and 28da976.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Additional comments: 1
CHANGELOG.md (1)
  • 70-70:
    The changelog entries are well-documented and include references to the relevant pull requests, which is good for traceability.

@julienrbrt julienrbrt added this pull request to the merge queue Nov 22, 2023
Merged via the queue into main with commit 875a71c Nov 22, 2023
63 of 64 checks passed
@julienrbrt julienrbrt deleted the julien/fix-mingas branch November 22, 2023 15:15
mergify bot pushed a commit that referenced this pull request Nov 22, 2023
mergify bot pushed a commit that referenced this pull request Nov 22, 2023
(cherry picked from commit 875a71c)

# Conflicts:
#	simapp/simd/cmd/commands.go
#	tools/confix/data/v0.47-app.toml
#	tools/confix/data/v0.50-app.toml
julienrbrt added a commit that referenced this pull request Nov 22, 2023
julienrbrt added a commit that referenced this pull request Nov 22, 2023
rkollar pushed a commit to sagaxyz/cosmos-sdk that referenced this pull request Feb 26, 2024
@faddat faddat mentioned this pull request Mar 20, 2024
12 tasks
emidev98 pushed a commit to terra-money/cosmos-sdk that referenced this pull request Mar 21, 2024
jaeseung-bae added a commit to Finschia/finschia-sdk that referenced this pull request Apr 26, 2024
…s-sdk#18537) (#1337)

* fix(server): properly parse multiple gas config(backport cosmos-sdk#18537)

* chore: update changelog

* chore: add missing PR link
mergify bot pushed a commit to Finschia/finschia-sdk that referenced this pull request Apr 26, 2024
…s-sdk#18537) (#1337)

* fix(server): properly parse multiple gas config(backport cosmos-sdk#18537)

* chore: update changelog

* chore: add missing PR link

(cherry picked from commit 7849929)
mergify bot pushed a commit to Finschia/finschia-sdk that referenced this pull request Apr 26, 2024
…s-sdk#18537) (#1337)

* fix(server): properly parse multiple gas config(backport cosmos-sdk#18537)

* chore: update changelog

* chore: add missing PR link

(cherry picked from commit 7849929)

# Conflicts:
#	CHANGELOG.md
jaeseung-bae added a commit to Finschia/finschia-sdk that referenced this pull request May 6, 2024
…s-sdk#18537) (#1337) (#1343)

* fix(server): properly parse multiple gas config(backport cosmos-sdk#18537)

* chore: update changelog

* chore: add missing PR link

(cherry picked from commit 7849929)

Co-authored-by: jaeseung-bae <119839167+jaeseung-bae@users.noreply.github.com>
0Tech added a commit to Finschia/finschia-sdk that referenced this pull request May 24, 2024
…s-sdk#18537) (backport #1337) (#1344)

* fix(server): properly parse multiple gas config(backport cosmos/cosmos-sdk#18537) (#1337)

* fix(server): properly parse multiple gas config(backport cosmos-sdk#18537)

* chore: update changelog

* chore: add missing PR link

(cherry picked from commit 7849929)

# Conflicts:
#	CHANGELOG.md

* Update CHANGELOG.md

---------

Co-authored-by: jaeseung-bae <119839167+jaeseung-bae@users.noreply.github.com>
Co-authored-by: Youngtaek Yoon <noreply@yoon.mailer.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release C:Confix Issues and PR related to Confix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Incorrect example to set multiple denoms for mininum-gas-prices
4 participants