Skip to content

Commit

Permalink
feat: abci client type now an explicit config setting
Browse files Browse the repository at this point in the history
Setting the flag still works and takes precedence.
  • Loading branch information
JimLarson committed Apr 17, 2024
1 parent 6f37f8d commit e4befa6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
4 changes: 4 additions & 0 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,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 +292,7 @@ func DefaultConfig() *Config {
IAVLCacheSize: 781250, // 50 MB
IAVLDisableFastNode: false,
IAVLLazyLoading: false,
ABCIClientType: "committing", // [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
24 changes: 13 additions & 11 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const (
flagGRPCWebAddress = "grpc-web.address"
)

// [AGORIC] Valid values for FlagAbciClientType
const (
abciClientTypeCommitting = "committing"
abciClientTypeLocal = "local"
Expand Down Expand Up @@ -149,18 +150,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 @@ -273,7 +265,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 +298,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,6 +520,8 @@ 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:
Expand Down

0 comments on commit e4befa6

Please sign in to comment.