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): Allow calling back into the application struct in PostSetup. #24047

Open
wants to merge 6 commits into
base: release/v0.53.x
Choose a base branch
from

Conversation

hoangdv2429
Copy link
Contributor

Description

Closes: #23791
Backport


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

@github-actions github-actions bot added the C:CLI label Mar 18, 2025
@hoangdv2429 hoangdv2429 marked this pull request as ready for review March 19, 2025 07:08
@hoangdv2429 hoangdv2429 requested a review from a team as a code owner March 19, 2025 07:08
@hoangdv2429 hoangdv2429 marked this pull request as draft March 19, 2025 08:51
@hoangdv2429 hoangdv2429 marked this pull request as ready for review March 20, 2025 07:04
@hoangdv2429
Copy link
Contributor Author

that test passed local, weird

@@ -21,7 +21,7 @@ const FlagAppDBBackend = "app-db-backend"

// Cmd prunes the sdk root multi store history versions based on the pruning options
// specified by command flags.
func Cmd(appCreator servertypes.AppCreator, defaultNodeHome string) *cobra.Command {
func Cmd[T servertypes.Application](appCreator servertypes.AppCreator[T], defaultNodeHome string) *cobra.Command {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@hoangdv2429 we do not need these uses of generics in here. Can we remove?

@@ -21,7 +21,7 @@ const FlagAppDBBackend = "app-db-backend"

// Cmd prunes the sdk root multi store history versions based on the pruning options
// specified by command flags.
func Cmd(appCreator servertypes.AppCreator, defaultNodeHome string) *cobra.Command {
func Cmd[T servertypes.Application](appCreator servertypes.AppCreator[T], defaultNodeHome string) *cobra.Command {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like the only diff in this PR is the generics. If that is the case, then we can just close

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean the purpose of this pr is to allow calling back into the application struct in PostSetup. If that something we don't want to support in the future for berachain then we can close this.

Copy link
Contributor

Choose a reason for hiding this comment

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

the PR extends the StartCmdOptions struct here: https://github.com/cosmos/cosmos-sdk/pull/24047/files#diff-97289af2ab66016f168df6fccac70626d125f170e5cf0841fcdc8fa624999608R112-R124

the generics help with type safety i believe - so you cannot pass in an AppCreator for a different type than your application.

Comment on lines +118 to +124
PostSetup func(app T, svrCtx *Context, clientCtx client.Context, ctx context.Context, g *errgroup.Group) error
// PostSetupStandalone can be used to setup extra services under the same cancellable context,
PostSetupStandalone func(svrCtx *Context, clientCtx client.Context, ctx context.Context, g *errgroup.Group) error
PostSetupStandalone func(app T, svrCtx *Context, clientCtx client.Context, ctx context.Context, g *errgroup.Group) error
// AddFlags add custom flags to start cmd
AddFlags func(cmd *cobra.Command)
// StartCommandHanlder can be used to customize the start command handler
StartCommandHandler func(svrCtx *Context, clientCtx client.Context, appCreator types.AppCreator, inProcessConsensus bool, opts StartCmdOptions) error
StartCommandHandler func(svrCtx *Context, clientCtx client.Context, appCreator types.AppCreator[T], inProcessConsensus bool, opts StartCmdOptions[T]) error
Copy link
Contributor

Choose a reason for hiding this comment

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

can you explain what the benefit is for app devs with this? i saw you mentioned berachain, but curious what they/others use it for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants