-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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): add custom start handler #19854
Conversation
Warning Rate Limit Exceeded@julienrbrt has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 38 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. WalkthroughThe recent updates across various components of the cosmos-sdk focus on simplifying and enhancing customization and consistency. Key changes include the introduction of customizable start command handlers, the removal of the basic manager concept and Changes
Related issues
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
@@ -324,7 +324,7 @@ func interceptConfigs(rootViper *viper.Viper, customAppTemplate string, customCo | |||
} | |||
|
|||
// AddCommands add server commands | |||
func AddCommands[T types.Application](rootCmd *cobra.Command, appCreator types.AppCreator[T], addStartFlags types.ModuleInitFlags) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had two ways to do the same things for flags: Using StartCmdOptions
and setting AddFlags
and then calling StartCmdWithOptions
. Or use AddCommands
with custom flags on the start command. This concatenates the possibilities in one.
Note, the backport to v0.50 won't contain that breaking change ( AddCommandsWithStartCmdOptions
will do what AddCommands does for v0.51)
There was a problem hiding this 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: 7
Configuration used: .coderabbit.yml
Files selected for processing (8)
- CHANGELOG.md (2 hunks)
- docs/build/building-apps/05-app-testnet.md (1 hunks)
- server/start.go (12 hunks)
- server/types/app.go (2 hunks)
- server/util.go (3 hunks)
- simapp/simd/cmd/commands.go (3 hunks)
- simapp/simd/cmd/root.go (1 hunks)
- simapp/simd/cmd/root_di.go (1 hunks)
Additional comments: 12
server/types/app.go (1)
- 8-13: > 📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [1-1]
The removal of
ModuleInitFlags
and thecobra
import aligns with the PR's objectives to simplify the server module's API and reduce dependencies. This change should help in enhancing customization and reducing the need for forking the SDK.simapp/simd/cmd/root_di.go (1)
- 90-90: The modification of the
initRootCmd
call to pass fewer arguments contributes to simplifying the codebase and aligns with the PR's objectives of enhancing maintainability and readability.simapp/simd/cmd/root.go (1)
- 113-113: The modification of the
initRootCmd
call to pass different arguments contributes to simplifying the codebase and aligns with the PR's objectives of enhancing maintainability and readability.simapp/simd/cmd/commands.go (1)
- 50-50: The modification of function calls to use
server.StartCmdOptions
instead oftypes.ModuleInitFlags
contributes to simplifying the codebase and aligns with the PR's objectives of enhancing maintainability and readability.server/util.go (2)
- 327-327: The addition of
opts StartCmdOptions[T]
to theAddCommands
function enhances customization and aligns with the PR's objectives of simplifying the codebase and reducing the need for forking.- 353-357: The introduction of the
AddCommandsWithStartCmdOptions
function, while marked as deprecated, aims to streamline adding server commands withStartCmdOptions
. It's important to clarify the deprecation notice to guide developers towards using the preferredAddCommands
method directly.server/start.go (6)
- 127-128: The addition of
StartCommandHandler
inStartCmdOptions
struct enables customization of the start command handler. This is a key feature for allowing developers to inject custom logic at the application start, aligning with the PR's objectives to enhance flexibility without needing to fork the SDK.- 144-146: The default assignment of
start
toStartCommandHandler
if none is provided ensures backward compatibility and a sensible default behavior. This approach is thoughtful, as it maintains the existing functionality for users who do not need custom start logic.- 196-196: The invocation of
opts.StartCommandHandler
within theRunE
function of thestart
command is correctly implemented. It allows for the execution of either the default or a custom start handler based on the configuration provided inopts
. This is a crucial integration point for the new feature.- 615-615: The removal of the
home
parameter from thetestnetify
function and the enhanced error handling within it are positive changes. They contribute to simplifying the function's interface and improving its robustness. Ensure that all invocations oftestnetify
have been updated accordingly.- 642-644: The default assignment of
start
toStartCommandHandler
in theInPlaceTestnetCreator
function mirrors the approach taken inStartCmdWithOptions
. This consistency in handling default behavior across different commands is commendable.- 710-710: The use of
opts.StartCommandHandler
within theInPlaceTestnetCreator
command ensures that the custom start logic can also be applied to testnet creation. This integration extends the flexibility of the new feature to different aspects of the SDK's functionality.
There was a problem hiding this 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.yml
Files selected for processing (1)
- UPGRADING.md (1 hunks)
Additional comments: 2
UPGRADING.md (2)
- 34-39: The code snippet provided for simplifying the start command is clear and correctly demonstrates the change from a function call to struct initialization. This change should streamline the process for developers and make the codebase more maintainable.
- 31-43: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-1206]
While the document is technically accurate and provides clear upgrade instructions, it's recommended to perform a thorough grammar and spell check outside of code blocks and technical terms. This will enhance the readability and professionalism of the document. Consider using a professional text editor or grammar checking tool to identify and correct these issues.
da62bd6
to
50b4e95
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
(cherry picked from commit def211d) # Conflicts: # CHANGELOG.md # UPGRADING.md # docs/docs/build/building-apps/05-app-testnet.md # server/start.go # server/util.go # simapp/simd/cmd/commands.go # simapp/simd/cmd/root.go # simapp/simd/cmd/root_v2.go
Description
Support custom starting app logic. This allows forks of the SDK only modifying the start command to only replace their start logic. Backport to v0.50 won't contain the api improvements (breakage) but will be additive only.
Use case:
Replace the need a forking the sdk for things like: release/v0.50.x...rollkit:cosmos-sdk:release/v0.50.x
How to use:
Set
StartCommandHandler
andAddFlags
inStartCmdOptions
when callingAddCommands
.Because we do not to provide any api guarantee for those functions. If you are re-implementing SDK's start command, you should know what you are doing and can reimplement those functions yourself.
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...
!
in the type prefix if API or client breaking changeCHANGELOG.md
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...
Summary by CodeRabbit
PreBlock
function by adjusting its return type.ModuleInitFlags
to clean up the codebase.