diff --git a/runtime/v2/builder.go b/runtime/v2/builder.go index de9535dca257..252076a021b0 100644 --- a/runtime/v2/builder.go +++ b/runtime/v2/builder.go @@ -124,7 +124,7 @@ func (a *AppBuilder[T]) Build(opts ...AppBuilderOption[T]) (*App[T], error) { } a.app.stf = stf - a.app.AppManager = appmanager.New[T]( + a.app.AppManager = appmanager.New( appmanager.Config{ ValidateTxGasLimit: a.app.config.GasConfig.ValidateTxGasLimit, QueryGasLimit: a.app.config.GasConfig.QueryGasLimit, diff --git a/server/v2/appmanager/config.go b/server/v2/appmanager/config.go index fb3c20341f35..350cf5eb432c 100644 --- a/server/v2/appmanager/config.go +++ b/server/v2/appmanager/config.go @@ -2,7 +2,7 @@ package appmanager // Config represents the configuration options for the app manager. type Config struct { - ValidateTxGasLimit uint64 `mapstructure:"validate-tx-gas-limit"` // TODO: check how this works on app mempool + ValidateTxGasLimit uint64 `mapstructure:"validate-tx-gas-limit"` QueryGasLimit uint64 `mapstructure:"query-gas-limit"` SimulationGasLimit uint64 `mapstructure:"simulation-gas-limit"` } diff --git a/simapp/v2/app_config.go b/simapp/v2/app_config.go index 7eb2f5ca68f5..5f8e7c78843c 100644 --- a/simapp/v2/app_config.go +++ b/simapp/v2/app_config.go @@ -31,6 +31,7 @@ import ( validatemodulev1 "cosmossdk.io/api/cosmos/validate/module/v1" vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1" "cosmossdk.io/depinject/appconfig" + runtimev2types "cosmossdk.io/runtime/v2" "cosmossdk.io/x/accounts" "cosmossdk.io/x/authz" _ "cosmossdk.io/x/authz/module" // import for side-effects @@ -66,7 +67,6 @@ import ( _ "cosmossdk.io/x/upgrade" // import for side-effects upgradetypes "cosmossdk.io/x/upgrade/types" - "github.com/cosmos/cosmos-sdk/runtime" _ "github.com/cosmos/cosmos-sdk/x/auth" // import for side-effects authtxconfig "github.com/cosmos/cosmos-sdk/x/auth/tx/config" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -108,7 +108,7 @@ var ( ModuleConfig = &appv1alpha1.Config{ Modules: []*appv1alpha1.ModuleConfig{ { - Name: runtime.ModuleName, + Name: runtimev2types.ModuleName, Config: appconfig.WrapAny(&runtimev2.Module{ AppName: "SimAppV2", // NOTE: upgrade module is required to be prioritized @@ -197,7 +197,8 @@ var ( }, // Uncomment if you want to set a custom migration order here. // OrderMigrations: []string{}, - // TODO GasConfig was added to the config in runtimev2. Where/how was it set in v1? + // GasConfig is used to set the gas configuration for the queries and transactions. + // This config is aimed to app-wide and shouldn't be overridden by individual validators. GasConfig: &runtimev2.GasConfig{ ValidateTxGasLimit: 10_000_000, QueryGasLimit: 100_000, @@ -209,7 +210,7 @@ var ( authtxconfig.DepinjectModuleName, validate.ModuleName, genutiltypes.ModuleName, - runtime.ModuleName, + runtimev2types.ModuleName, vestingtypes.ModuleName, }, }), diff --git a/simapp/v2/simdv2/cmd/commands.go b/simapp/v2/simdv2/cmd/commands.go index f9b9e6ebfc09..cb4cac07790e 100644 --- a/simapp/v2/simdv2/cmd/commands.go +++ b/simapp/v2/simdv2/cmd/commands.go @@ -46,10 +46,7 @@ type CommandDependencies[T transaction.Tx] struct { TxConfig client.TxConfig ModuleManager *runtimev2.MM[T] SimApp *simapp.SimApp[T] - // could generally be more generic with serverv2.ServerComponent[T] - // however, we want to register extra grpc handlers - ConsensusServer *cometbft.CometBFTServer[T] - ClientContext client.Context + ClientContext client.Context } func InitRootCmd[T transaction.Tx]( @@ -76,16 +73,13 @@ func InitRootCmd[T transaction.Tx]( // build CLI skeleton for initial config parsing or a client application invocation if deps.SimApp == nil { - if deps.ConsensusServer == nil { - deps.ConsensusServer = cometbft.NewWithConfigOptions[T](initCometConfig()) - } return serverv2.AddCommands[T]( rootCmd, logger, io.NopCloser(nil), deps.GlobalConfig, initServerConfig(), - deps.ConsensusServer, + cometbft.NewWithConfigOptions[T](initCometConfig()), &grpcserver.Server[T]{}, &serverstore.Server[T]{}, &telemetry.Server[T]{}, @@ -108,26 +102,24 @@ func InitRootCmd[T transaction.Tx]( } // consensus component - if deps.ConsensusServer == nil { - deps.ConsensusServer, err = cometbft.New( - logger, - simApp.Name(), - simApp.Store(), - simApp.App.AppManager, - cometbft.AppCodecs[T]{ - AppCodec: simApp.AppCodec(), - TxCodec: &client.DefaultTxDecoder[T]{TxConfig: deps.TxConfig}, - LegacyAmino: deps.ClientContext.LegacyAmino, - ConsensusAddressCodec: deps.ClientContext.ConsensusAddressCodec, - }, - simApp.App.QueryHandlers(), - simApp.App.SchemaDecoderResolver(), - initCometOptions[T](), - deps.GlobalConfig, - ) - if err != nil { - return nil, err - } + consensusServer, err := cometbft.New( + logger, + simApp.Name(), + simApp.Store(), + simApp.App.AppManager, + cometbft.AppCodecs[T]{ + AppCodec: simApp.AppCodec(), + TxCodec: &client.DefaultTxDecoder[T]{TxConfig: deps.TxConfig}, + LegacyAmino: deps.ClientContext.LegacyAmino, + ConsensusAddressCodec: deps.ClientContext.ConsensusAddressCodec, + }, + simApp.App.QueryHandlers(), + simApp.App.SchemaDecoderResolver(), + initCometOptions[T](), + deps.GlobalConfig, + ) + if err != nil { + return nil, err } telemetryServer, err := telemetry.New[T](deps.GlobalConfig, logger, sdktelemetry.EnableTelemetry) @@ -142,7 +134,7 @@ func InitRootCmd[T transaction.Tx]( simApp.Query, deps.GlobalConfig, grpcserver.WithExtraGRPCHandlers[T]( - deps.ConsensusServer.GRPCServiceRegistrar( + consensusServer.GRPCServiceRegistrar( deps.ClientContext, deps.GlobalConfig, ), @@ -161,7 +153,7 @@ func InitRootCmd[T transaction.Tx]( if err != nil { return nil, err } - registerGRPCGatewayRoutes[T](deps, grpcgatewayServer) + registerGRPCGatewayRoutes(deps.ClientContext, grpcgatewayServer) // wire server commands return serverv2.AddCommands[T]( @@ -170,7 +162,7 @@ func InitRootCmd[T transaction.Tx]( simApp, deps.GlobalConfig, initServerConfig(), - deps.ConsensusServer, + consensusServer, grpcServer, storeComponent, telemetryServer, @@ -268,14 +260,12 @@ func RootCommandPersistentPreRun(clientCtx client.Context) func(*cobra.Command, } // registerGRPCGatewayRoutes registers the gRPC gateway routes for all modules and other components -// TODO(@julienrbrt): Eventually, this should removed and directly done within the grpcgateway.Server -// ref: https://github.com/cosmos/cosmos-sdk/pull/22701#pullrequestreview-2470651390 func registerGRPCGatewayRoutes[T transaction.Tx]( - deps CommandDependencies[T], + clientContext client.Context, server *grpcgateway.Server[T], ) { // those are the extra services that the CometBFT server implements (server/v2/cometbft/grpc.go) - cmtservice.RegisterGRPCGatewayRoutes(deps.ClientContext, server.GRPCGatewayRouter) - _ = nodeservice.RegisterServiceHandlerClient(context.Background(), server.GRPCGatewayRouter, nodeservice.NewServiceClient(deps.ClientContext)) - _ = txtypes.RegisterServiceHandlerClient(context.Background(), server.GRPCGatewayRouter, txtypes.NewServiceClient(deps.ClientContext)) + cmtservice.RegisterGRPCGatewayRoutes(clientContext, server.GRPCGatewayRouter) + _ = nodeservice.RegisterServiceHandlerClient(context.Background(), server.GRPCGatewayRouter, nodeservice.NewServiceClient(clientContext)) + _ = txtypes.RegisterServiceHandlerClient(context.Background(), server.GRPCGatewayRouter, txtypes.NewServiceClient(clientContext)) }