diff --git a/CHANGELOG-Agoric.md b/CHANGELOG-Agoric.md index 92c2eaf8fff5..175f00ba9463 100644 --- a/CHANGELOG-Agoric.md +++ b/CHANGELOG-Agoric.md @@ -41,6 +41,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (auth) [#407](https://github.com/agoric-labs/cosmos-sdk/pull/407) Configurable fee collector module account in DeductFeeDecorator. * (server) [#409](https://github.com/agoric-labs/cosmos-sdk/pull/409) Flag to select ABCI client type. +* (server) [#416](https://github.com/agoric-labs/cosmos-sdk/pull/416) Config entry to select ABCI client type. * (deps) [#412](https://github.com/agoric-labs/cosmos-sdk/pull/412) Bump iavl to v0.19.7 * (baseapp) [#415](https://github.com/agoric-labs/cosmos-sdk/pull/415) Unit tests and documentation for event history. diff --git a/server/config/config.go b/server/config/config.go index 40087b149603..8c7ffd899d04 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -14,9 +14,18 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) +// [AGORIC] Valid values for FlagAbciClientType +const ( + AbciClientTypeCommitting = "committing" + AbciClientTypeLocal = "local" +) + const ( defaultMinGasPrices = "" + // DefaultABCIClientType defines the default ABCI client type to use with cometbft. + DefaultABCIClientType = AbciClientTypeCommitting // [AGORIC] + // DefaultAPIAddress defines the default address to bind the API server to. DefaultAPIAddress = "tcp://0.0.0.0:1317" @@ -94,6 +103,9 @@ type BaseConfig struct { // IAVLLazyLoading enable/disable the lazy loading of iavl store. IAVLLazyLoading bool `mapstructure:"iavl-lazy-loading"` + // ABCIClientType selects the type of ABCI client. + ABCIClientType string `mapstructure:"abci-client-type"` + // AppDBBackend defines the type of Database to use for the application and snapshots databases. // An empty string indicates that the Tendermint config's DBBackend value should be used. AppDBBackend string `mapstructure:"app-db-backend"` @@ -289,6 +301,7 @@ func DefaultConfig() *Config { IAVLCacheSize: 781250, // 50 MB IAVLDisableFastNode: false, IAVLLazyLoading: false, + ABCIClientType: DefaultABCIClientType, // [AGORIC] AppDBBackend: "", }, Telemetry: telemetry.Config{ diff --git a/server/config/toml.go b/server/config/toml.go index 920201b330e4..a53633cc7e3c 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -82,6 +82,10 @@ iavl-disable-fastnode = {{ .BaseConfig.IAVLDisableFastNode }} # Default is false. iavl-lazy-loading = {{ .BaseConfig.IAVLLazyLoading }} +# ABCIClientType selects the type of ABCI client. +# Default is "committing". +abci-client-type = "{{ .BaseConfig.ABCIClientType }}" + # AppDBBackend defines the database backend type to use for the application and snapshots DBs. # An empty string indicates that a fallback will be used. # First fallback is the deprecated compile-time types.DBBackend value. diff --git a/server/start.go b/server/start.go index b60cbaa9cf55..c6a35ffe8559 100644 --- a/server/start.go +++ b/server/start.go @@ -84,11 +84,6 @@ const ( flagGRPCWebAddress = "grpc-web.address" ) -const ( - abciClientTypeCommitting = "committing" - abciClientTypeLocal = "local" -) - // StartCmd runs the service passed in, either stand-alone or in-process with // Tendermint. func StartCmd(appCreator types.AppCreator, defaultNodeHome string) *cobra.Command { @@ -149,18 +144,9 @@ is performed. Note, when enabled, gRPC will also be automatically enabled. }) } - abciClientType, err := cmd.Flags().GetString(FlagAbciClientType) - if err != nil { - return err - } - clientCreator, err := getAbciClientCreator(abciClientType) - if err != nil { - return err - } - // amino is needed here for backwards compatibility of REST routes err = wrapCPUProfile(serverCtx, func() error { - return startInProcess(serverCtx, clientCtx, appCreator, clientCreator) + return startInProcess(serverCtx, clientCtx, appCreator) }) errCode, ok := err.(ErrorCode) if !ok { @@ -210,7 +196,7 @@ is performed. Note, when enabled, gRPC will also be automatically enabled. cmd.Flags().Uint32(FlagStateSyncSnapshotKeepRecent, 2, "State sync snapshot to keep") cmd.Flags().Bool(FlagDisableIAVLFastNode, false, "Disable fast node for IAVL tree") - cmd.Flags().String(FlagAbciClientType, abciClientTypeCommitting, fmt.Sprintf(`Type of ABCI client ("%s" or "%s")`, abciClientTypeCommitting, abciClientTypeLocal)) + cmd.Flags().String(FlagAbciClientType, serverconfig.DefaultABCIClientType, fmt.Sprintf(`Type of ABCI client ("%s" or "%s")`, serverconfig.AbciClientTypeCommitting, serverconfig.AbciClientTypeLocal)) // add support for all Tendermint-specific command line options tcmd.AddNodeFlags(cmd) @@ -273,7 +259,7 @@ func startStandAlone(ctx *Context, appCreator types.AppCreator) error { type abciClientCreator func(abcitypes.Application) proxy.ClientCreator -func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.AppCreator, clientCreator abciClientCreator) error { +func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.AppCreator) error { cfg := ctx.Config home := cfg.RootDir @@ -306,6 +292,14 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App genDocProvider := node.DefaultGenesisDocProviderFunc(cfg) + // [AGORIC] allow the ABCI client type to be configurable. + abciClientType := config.ABCIClientType + ctx.Logger.Info(fmt.Sprintf("ABCI client type: %s", abciClientType)) + clientCreator, err := getAbciClientCreator(abciClientType) + if err != nil { + return err + } + var ( tmNode *node.Node gRPCOnly = ctx.Viper.GetBool(flagGRPCOnly) @@ -520,11 +514,13 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App return WaitForQuitSignals() } +// getAbciClientCreator dispatches the client type to the right cometbft constructor. +// [AGORIC] Allows us to disable committingClient. func getAbciClientCreator(abciClientType string) (abciClientCreator, error) { switch abciClientType { - case abciClientTypeCommitting: + case serverconfig.AbciClientTypeCommitting: return proxy.NewCommittingClientCreator, nil - case abciClientTypeLocal: + case serverconfig.AbciClientTypeLocal: return proxy.NewLocalClientCreator, nil } return nil, fmt.Errorf(`unknown ABCI client type "%s"`, abciClientType)