celestiaorg / celestia-app

Celestia consensus node
https://celestiaorg.github.io/celestia-app/
Apache License 2.0
345 stars 292 forks source link

feat(x/minfee): extract go module #4003

Open rootulp opened 4 weeks ago

rootulp commented 4 weeks ago

Motivation

As part of the refactor to a multiplexed app, we want a mechanism to avoid importing state machine modules (e.g. x/minfee) once per state machine version. We want this because each time a state machine module is imported by the multiplexer, it registers proto types in the proto registry and interfaces in the Cosmos SDK interface registry. When we import the same state machine module more than once, we hit duplicate proto registry errors (same for Cosmos SDK interface registry).

This PR is the first of many that spin out a distinct Go module per state machine module. Expect subsequent PRs for x/blob, x/signal, etc.

Note: if we didn't do this for the multiplexed app, it is likely that we would do this as part of an update to new Cosmos SDK versions. For example Cosmos SDK v0.52.x spun out Go modules for all the state machine modules.

Note: the diff of x/minfee from v2.x to main is minimal (see git diff v2.x..main -- x/minfee/) so I choose to do this on main. We'll need to backport this to v2.x as well.

Testing

I did this on my fork and verified that we can:

  1. Publish multiple Go modules from the same repo (i.e. celestia-app, and x/minfee)
  2. From celestia-app import x/minfee. See here

Ref:

coderabbitai[bot] commented 1 week ago
📝 Walkthrough ## Walkthrough The pull request primarily updates the import paths for the `minfee` package across multiple files, changing from a versioned path (`github.com/celestiaorg/celestia-app/v3/x/minfee`) to a non-versioned path (`github.com/celestiaorg/celestia-app/x/minfee`). Additionally, it introduces new constants and functions in the `x/minfee` package, modifies test cases to align with these changes, and updates the `go.mod` file to reflect new dependencies and configurations. The overall functionality and logic of the application remain unchanged. ## Changes | File | Change Summary | |-------------------------------------|------------------------------------------------------------------------------------------------------------------| | app/ante/fee_checker.go | Updated import path for `minfee` package. No logic changes. | | app/ante/min_fee_test.go | Updated import path for `minfee`. Modified `TestValidateTxFee` to use `minfee.DefaultNetworkMinGasPrice`. | | app/app.go | Updated import path for `minfee` package. No logic changes. | | app/app_test.go | Updated import path for `minfee`. No logic changes. | | app/modules.go | Updated import path for `minfee`. No logic changes. | | app/test/query_test.go | Changed package name from `minfee_test` to `app_test`. Updated import path and assertions in `TestQueryNetworkMinGasPrice`. | | app/test/std_sdk_test.go | Updated import path for `minfee`. Modified assertions in `TestGRPCQueries`. | | app/test/upgrade_test.go | Changed import from relative to absolute for `minfee`. Updated `TestAppUpgradeV2` to use `minfee.DefaultNetworkMinGasPriceAsDec()`. | | go.mod | Added new dependency for `minfee`. Updated versions for other dependencies. Added replace directive for `minfee`. | | pkg/appconsts/initial_consts.go | Deprecated `DefaultNetworkMinGasPrice`, suggesting import from `x/minfee`. | | pkg/user/tx_client.go | Updated import path for `minfee`. No logic changes. | | test/tokenfilter/setup.go | Updated import path for `minfee`. No logic changes. | | x/minfee/constants.go | Introduced `DefaultNetworkMinGasPrice` constant and `DefaultNetworkMinGasPriceAsDec()` function. | | x/minfee/constants_test.go | Added `TestDefaultNetworkMinGasPriceAsDec` to validate the new constant's behavior. | | x/minfee/genesis.go | Updated `DefaultGenesis` to use `DefaultNetworkMinGasPriceAsDec()` for `NetworkMinGasPrice`. | | x/minfee/go.mod | Created new module for `minfee` with dependencies and replace directives. | | x/minfee/module_test.go | Updated import path for `minfee`. No logic changes. | | x/minfee/params.go | Removed `DefaultNetworkMinGasPrice` and associated initialization logic. | | x/paramfilter/test/gov_params_test.go | Updated import path for `minfeetypes`. No logic changes. | ## Possibly related PRs - **#3450**: Modifies the `minfee` registration in `app/ante/min_fee_test.go`, directly related to the import path changes. - **#3575**: Renames the global minimum gas price to network minimum gas price, relevant to the changes in the main PR. - **#3661**: Updates specifications for version 2, potentially relating to transaction fee validation logic. - **#3735**: Refactors gas scheduler variables, connecting to transaction fee validation changes. - **#3882**: Introduces versioned timeout settings, which could relate to transaction fee validation logic. - **#3910**: Implements an end-to-end upgrade test for version 3, possibly involving transaction fee validation. - **#3980**: Modifies upgrade height delay logic, relevant to transaction fee validation. - **#4008**: Addresses upgrade delay functionality, critical for transaction fee validation during upgrades. ## Suggested labels `enhancement`, `WS: Maintenance 🔧` ## Suggested reviewers - evan-forbes - staheri14 - cmwaters - ninabarbakadze

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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
🪧 Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): > ‼️ **IMPORTANT** > Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies 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 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. ### Documentation and Community - Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
evan-forbes commented 3 days ago

clear to merge @rootulp