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: abci client type now an explicit config setting #416

Merged
merged 4 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-Agoric.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
13 changes: 13 additions & 0 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -289,6 +301,7 @@ func DefaultConfig() *Config {
IAVLCacheSize: 781250, // 50 MB
IAVLDisableFastNode: false,
IAVLLazyLoading: false,
ABCIClientType: DefaultABCIClientType, // [AGORIC]
AppDBBackend: "",
},
Telemetry: telemetry.Config{
Expand Down
4 changes: 4 additions & 0 deletions server/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
34 changes: 15 additions & 19 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading