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: Fee market blackberry #277

Merged
merged 9 commits into from
Oct 1, 2024
Merged

fix: Fee market blackberry #277

merged 9 commits into from
Oct 1, 2024

Conversation

faddat
Copy link
Contributor

@faddat faddat commented Aug 23, 2024

This is the blackberry fee market fix.

I didn't write this code, just added a commit to #275

Thanks to Skip!

Summary by CodeRabbit

  • New Features
    • Enhanced transaction handling capabilities with the introduction of a BankKeeper for better banking operations management.
  • Bug Fixes
    • Improved test reliability with updated mock implementations and configurations for bankKeeper interactions.
  • Chores
    • Updated module dependencies, including the Go toolchain and several libraries, to ensure compatibility and security.
  • Refactor
    • Removed the FeeGrantKeeper from post-handler logic, indicating a shift in fee management processes.
  • Style
    • Refinements made to the linting process for improved code quality and maintainability.

Copy link
Contributor

coderabbitai bot commented Aug 23, 2024

Walkthrough

The changes primarily involve enhancements to transaction handling within the application. This includes the addition of a BankKeeper to the HandlerOptions struct, updates to the test suite to incorporate new mocks for the bankKeeper, and the removal of the FeeGrantKeeper from post-handler options. Additionally, the go.mod file has been updated with new dependencies and version changes to improve the overall dependency management.

Changes

Files Change Summary
app/ante/ante.go Added BankKeeper to HandlerOptions; updated NewAnteHandler to include BankKeeper in fee market logic.
app/ante/ante_test.go Modified TestMempoolDecorator to mock bankKeeper, added test account creation, included additional dependencies in FeeMarketCheckDecorator.
app/ante/suite.go Updated bankKeeper to use feemarketmocks.BankKeeper; changed setup functions for improved mock fidelity.
app/app.go Removed FeeGrantKeeper from PostHandlerOptions in setPostHandler and NewPostHandler functions.
go.mod Updated Go toolchain version and added new dependency: github.com/stretchr/objx v0.5.2.

Possibly related PRs

  • feat: integrate x/feemarket #250: This PR modifies the HandlerOptions struct in app/ante.go by adding a FeeMarketKeeper, which is closely related to the changes in the main PR that also involves modifications to the HandlerOptions struct and the NewAnteHandler function, specifically with the addition of the BankKeeper.

Suggested reviewers

  • minhngoc274

Poem

🐇 In the world of code, so bright and new,
Changes are hopping, like morning dew.
BankKeeper's here, to manage the flow,
Fee grants now gone, as we let go.
With mocks and tests, we've set the stage,
A leap for the app, as we turn the page! 🌼✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

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.

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 UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c98a60e and 65b5ec8.

Files selected for processing (5)
  • app/ante/ante.go (2 hunks)
  • app/ante/ante_test.go (4 hunks)
  • app/ante/suite.go (4 hunks)
  • app/app.go (2 hunks)
  • go.mod (1 hunks)
Additional context used
GitHub Check: lint
app/ante/ante_test.go

[failure] 114-114:
too many arguments in call to feemarketante.NewFeeMarketCheckDecorator

app/ante/ante.go

[failure] 69-69:
too many arguments in call to feemarketante.NewFeeMarketCheckDecorator


[failure] 69-69:
too many arguments in call to feemarketante.NewFeeMarketCheckDecorator

GitHub Check: build
app/ante/ante.go

[failure] 69-69:
too many arguments in call to feemarketante.NewFeeMarketCheckDecorator

GitHub Check: run-tests
app/ante/ante.go

[failure] 69-69:
too many arguments in call to feemarketante.NewFeeMarketCheckDecorator

Additional comments not posted (10)
app/ante/ante_test.go (2)

104-105: LGTM! The addition of test accounts enhances test robustness.

The creation of test accounts using CreateTestAccounts ensures valid account data for transaction messages.


51-54: Verify the function signature for NewFeeMarketCheckDecorator.

The static analysis indicates that there might be too many arguments in the call to NewFeeMarketCheckDecorator.

Run the following script to verify the function signature:

app/ante/suite.go (3)

49-49: LGTM! The update to bankKeeper type aligns with recent architectural changes.

The change from *feeabstestutil.MockBankKeeper to *feemarketmocks.BankKeeper suggests an enhancement in the testing framework.


69-69: LGTM! The new mock setup for bankKeeper enhances test fidelity.

The instantiation of bankKeeper using feemarketmocks.NewBankKeeper(t) aligns with recent changes in the fee market's architecture.


103-103: Verify the usage of authKey in authkeeper.NewAccountKeeper.

The change from key to authKey might indicate a change in key management or reference.

Run the following script to verify the usage of authKey:

Verification successful

Verified Usage of authKey in authkeeper.NewAccountKeeper.

The authKey is correctly defined and used as a key in authkeeper.NewAccountKeeper. It is initialized as a NewKVStoreKey with authtypes.StoreKey, aligning with the expected key management practices.

  • authKey is defined as storetypes.NewKVStoreKey(authtypes.StoreKey) in app/ante/suite.go.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `authKey` in `authkeeper.NewAccountKeeper`.

# Test: Search for the function usage. Expect: Correct key management.
rg --type go -A 5 $'authkeeper.NewAccountKeeper'

Length of output: 850


Script:

#!/bin/bash
# Search for the definition and initialization of `authKey` to verify its usage.
rg --type go 'authKey'

Length of output: 307

app/ante/ante.go (2)

35-35: LGTM! The addition of BankKeeper enhances transaction handling capabilities.

The inclusion of BankKeeper in HandlerOptions allows for more comprehensive management of banking-related operations.


67-69: Verify the function signature for NewFeeMarketCheckDecorator.

The static analysis indicates that there might be too many arguments in the call to NewFeeMarketCheckDecorator.

Run the following script to verify the function signature:

Tools
GitHub Check: lint

[failure] 69-69:
too many arguments in call to feemarketante.NewFeeMarketCheckDecorator


[failure] 69-69:
too many arguments in call to feemarketante.NewFeeMarketCheckDecorator

GitHub Check: build

[failure] 69-69:
too many arguments in call to feemarketante.NewFeeMarketCheckDecorator

GitHub Check: run-tests

[failure] 69-69:
too many arguments in call to feemarketante.NewFeeMarketCheckDecorator

go.mod (1)

188-188: Verify the necessity and security of the new dependency.

The addition of github.com/stretchr/objx v0.5.2 suggests enhanced object manipulation capabilities. Ensure this dependency is essential for the project and doesn't introduce security vulnerabilities.

Consider running a security audit on this dependency to ensure it aligns with the project's security standards.

app/app.go (2)

Line range hint 588-597: Verify the impact of removing FeeGrantKeeper from PostHandlerOptions.

The removal of FeeGrantKeeper from PostHandlerOptions might affect the fee grant functionality. Ensure that this change is intentional and does not break existing functionality.

Run the following script to verify the usage of FeeGrantKeeper in the codebase:

Verification successful

To ensure that the removal of FeeGrantKeeper from PostHandlerOptions does not affect the functionality, we need to verify its usage within the post-handler logic. Let's search for any references to FeeGrantKeeper in the post-handler functions.


Removal of FeeGrantKeeper from PostHandlerOptions is Safe

The FeeGrantKeeper is not directly used in the post-handler logic, so its removal from PostHandlerOptions does not impact the post-handler functionality. The fee grant functionality is likely managed elsewhere in the application.

  • Instances of FeeGrantKeeper are found in app/app.go, but none are directly related to post-handler logic.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `FeeGrantKeeper` in the codebase.

# Test: Search for `FeeGrantKeeper` usage. Expect: No critical dependencies on post-handler functionality.
rg --type go 'FeeGrantKeeper'

Length of output: 406


Script:

#!/bin/bash
# Description: Verify the usage of `FeeGrantKeeper` in post-handler logic.

# Test: Search for `FeeGrantKeeper` usage in post-handler functions.
rg --type go 'FeeGrantKeeper' -A 10

Length of output: 3248


Line range hint 1022-1034: Verify the impact of removing FeeGrantKeeper from PostHandlerOptions.

The removal of FeeGrantKeeper from PostHandlerOptions might affect the fee grant functionality. Ensure that this change is intentional and does not break existing functionality.

Run the following script to verify the usage of FeeGrantKeeper in the codebase:

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 UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e9fef52 and 2a5acd9.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • app/ante/ante_test.go (4 hunks)
  • go.mod (4 hunks)
🔇 Additional comments (10)
app/ante/ante_test.go (6)

8-8: Necessary import added for mocking functionalities

The import of "github.com/stretchr/testify/mock" is required for setting up mocks in your test cases.


15-15: Import added for test data utilities

The import of "github.com/cosmos/cosmos-sdk/testutil/testdata" is necessary for creating test messages used in the tests.


49-52: Properly mocking SendCoinsFromAccountToModule in test case

The mock expectation for suite.bankKeeper.On("SendCoinsFromAccountToModule", ...) is correctly set up to ensure that the method is called once during the test execution.


63-64: Added mock for SendCoinsFromAccountToModule in IBC fee test case

Including the mock expectation for suite.bankKeeper.SendCoinsFromAccountToModule ensures that the IBC fee handling is correctly tested.


102-104: Setting up test accounts and messages in transaction builder

By creating test accounts and setting a message in the transaction builder, you ensure that the transaction is properly constructed before processing.


109-114: Updated instantiation of FeeMarketCheckDecorator with additional dependencies

Including suite.accountKeeper, suite.bankKeeper, and suite.feeGrantKeeper in the instantiation of FeeMarketCheckDecorator ensures that all necessary dependencies are provided, reflecting changes in the decorator's constructor.

go.mod (4)

5-5: Confirm toolchain update to Go 1.23.1

The toolchain directive has been updated to go1.23.1. Verify that all development and deployment environments are using this toolchain version to prevent discrepancies.


189-189: New indirect dependency added: github.com/stretchr/objx

A new indirect dependency github.com/stretchr/objx v0.5.2 has been added. Confirm that this library is necessary and does not introduce any security vulnerabilities.

#!/bin/bash
# Description: Determine which package requires `github.com/stretchr/objx`.

# Identify dependencies that import `objx`.
go mod why github.com/stretchr/objx

# Expected: Output shows which direct dependency is pulling in `objx`.

57-57: Ensure compatibility with feemarket v1.1.1

The github.com/skip-mev/feemarket module has been updated to v1.1.1. Verify that any API changes are accommodated in the code.

#!/bin/bash
# Description: Find all usages of the `feemarket` module to check for compatibility issues.

# Search for import statements of `feemarket`.
rg 'import.*feemarket' --type go

# Search for all references to `feemarket` in the codebase.
rg 'feemarket\.' --type go

# Expected: Review these instances to ensure they align with the updated API.

3-3: Verify compatibility with Go version 1.22.6

The Go version in go.mod has been updated to 1.22.6. Ensure that the codebase is compatible with this version and that no deprecated features are used.

✅ Verification successful

Compatibility Verified with Go 1.22.6

All checks passed. The codebase is compatible with Go version 1.22.6, and no deprecated features are used.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for usage of deprecated Go features.

# Example: Check for usage of the deprecated 'io/ioutil' package.
rg 'io/ioutil' --type go

# Expected: No matches if all usages have been updated to 'io' or 'os' packages.

Length of output: 24


Script:

#!/bin/bash
# Description: Verify Go version and search for deprecated Go features.

# Check the Go version specified in go.mod
go_version=$(grep '^go ' go.mod)
echo "Go version in go.mod: $go_version"

# Search for usage of the deprecated 'io/ioutil' package
echo "Searching for 'io/ioutil' usage..."
rg 'io/ioutil' --type go

# Search for other common deprecated packages (add more patterns as needed)
echo "Searching for other deprecated packages..."
rg 'golang.org/x/net/context|github.com/golang/net|github.com/gorilla/context' --type go

Length of output: 415

@@ -28,7 +28,7 @@ require (
github.com/stretchr/testify v1.9.0
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/grpc v1.64.1 // indirect
google.golang.org/grpc v1.65.0 // indirect
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Action Required: Investigate feemarket API Usage Impacting gRPC v1.65.0 Update

  • Confirm if feemarket.NewAppModule and FeeMarketKeeper are affected by gRPC v1.65.0 changes.
🔗 Analysis chain

Review gRPC dependency update to v1.65.0

The google.golang.org/grpc dependency has been updated to v1.65.0. Check for any breaking changes or deprecations that might affect the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Identify usage of deprecated gRPC APIs.

# Replace 'DeprecatedAPI' with actual deprecated APIs as per gRPC release notes.
rg 'DeprecatedAPI' --type go

# Expected: No matches if deprecated APIs have been refactored.

Length of output: 132

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 and nitpick comments (1)
.golangci.yml (1)

Line range hint 63-64: Consider lowering the maximum issue thresholds

The max-issues-per-linter and max-same-issues parameters are set to 10000, which is an extremely high value. This effectively disables the limit on the number of issues a linter can report.

  max-issues-per-linter: 10000
  max-same-issues: 10000

While this ensures all issues are reported, it may lead to an overwhelming number of linter messages, potentially obscuring critical issues. Consider lowering these values to a more manageable number (e.g., 50 or 100) to maintain a balance between comprehensive linting and focused issue resolution.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2a5acd9 and 7352f15.

📒 Files selected for processing (3)
  • .golangci.yml (1 hunks)
  • app/ante/ante_test.go (4 hunks)
  • app/upgrades.go (0 hunks)
💤 Files with no reviewable changes (1)
  • app/upgrades.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/ante/ante_test.go
🔇 Additional comments (4)
.golangci.yml (4)

12-12: Approval: Addition of copyloopvar linter

The addition of the copyloopvar linter is a good improvement. This linter helps catch subtle bugs related to loop variable scoping in Go, which can be easy to overlook. This change will enhance the overall code quality and reduce the likelihood of related issues.


Line range hint 33-62: Approval: Addition of specific linter exclusion rules

The new exclusion rules added to the issues section are well-defined and address specific concerns such as deprecated code usage and weak random number generator warnings. These exclusions appear to be intentional and likely necessary for the current state of the project.


Line range hint 84-124: Approval: Comprehensive gosec security checks

The expansion of the gosec linter settings with a detailed list of included rules is an excellent improvement. This configuration now covers a wide range of security-related checks, including:

  • Potential vulnerabilities like SQL injection, command execution, and directory traversal
  • Insecure cryptographic practices
  • File permission issues
  • Potential DoS vulnerabilities

This comprehensive set of security checks will significantly enhance the project's ability to detect and prevent security issues early in the development process.


Line range hint 1-150: Overall improvement in linting configuration

The changes made to .golangci.yml represent a significant improvement in the project's linting configuration:

  1. The addition of the copyloopvar linter will help catch subtle bugs related to loop variable scoping.
  2. The new exclusion rules in the issues section address specific concerns while maintaining a high standard of code quality.
  3. The expanded gosec settings provide a comprehensive set of security checks, enhancing the project's ability to detect and prevent security vulnerabilities.

These changes demonstrate a commitment to code quality and security. The only suggestion for further improvement is to consider lowering the max-issues-per-linter and max-same-issues thresholds to ensure critical issues are not obscured by an overwhelming number of linter messages.

Overall, these modifications to the linter configuration should lead to more robust, secure, and maintainable code.

@faddat faddat merged commit cda8019 into main Oct 1, 2024
10 checks passed
@faddat faddat deleted the faddat/fix/feemarket branch October 1, 2024 09:02
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.

2 participants