From 285bcb099571eb1ed528feeaec2ae6cddf061fe4 Mon Sep 17 00:00:00 2001 From: William Banfield Date: Tue, 29 Mar 2022 20:34:20 -0400 Subject: [PATCH] add deprecated field warning --- cmd/tendermint/commands/root.go | 4 ++- config/config.go | 52 +++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/cmd/tendermint/commands/root.go b/cmd/tendermint/commands/root.go index 3c9b7d049..fdee638bc 100644 --- a/cmd/tendermint/commands/root.go +++ b/cmd/tendermint/commands/root.go @@ -51,10 +51,12 @@ func RootCommand(conf *config.Config, logger log.Logger) *cobra.Command { } *conf = *pconf config.EnsureRoot(conf.RootDir) - if err := log.OverrideWithNewLogger(logger, conf.LogFormat, conf.LogLevel); err != nil { return err } + if warning := pconf.DeprecatedFieldWarning(); warning != nil { + logger.Info("WARNING", "deprecated field warning", warning) + } return nil }, diff --git a/config/config.go b/config/config.go index fd4923cce..a5287fc11 100644 --- a/config/config.go +++ b/config/config.go @@ -8,6 +8,7 @@ import ( "net/http" "os" "path/filepath" + "strings" "time" "github.com/tendermint/tendermint/libs/log" @@ -145,6 +146,10 @@ func (cfg *Config) ValidateBasic() error { return nil } +func (cfg *Config) DeprecatedFieldWarning() error { + return cfg.Consensus.DeprecatedFieldWarning() +} + //----------------------------------------------------------------------------- // BaseConfig @@ -998,6 +1003,15 @@ type ConsensusConfig struct { // If it is set to true, the consensus engine will proceed to the next height // as soon as the node has gathered votes from all of the validators on the network. UnsafeBypassCommitTimeoutOverride *bool `mapstructure:"unsafe-bypass-commit-timeout-override"` + + DeprecatedTimeoutPropose *interface{} `mapstructure:"timeout-propose"` + DeprecatedTimeoutProposeDelta *interface{} `mapstructure:"timeout-propose-delta"` + DeprecatedTimeoutPrevote *interface{} `mapstructure:"timeout-prevote"` + DeprecatedTimeoutPrevoteDelta *interface{} `mapstructure:"timeout-prevote-delta"` + DeprecatedTimeoutPrecommit *interface{} `mapstructure:"timeout-precommit"` + DeprecatedTimeoutPrecommitDelta *interface{} `mapstructure:"timeout-precommit-delta"` + DeprecatedTimeoutCommit *interface{} `mapstructure:"timeout-commit"` + DeprecatedSkipTimeoutCommit *interface{} `mapstructure:"skip-timeout-commit"` } // DefaultConsensusConfig returns a default configuration for the consensus service @@ -1072,6 +1086,44 @@ func (cfg *ConsensusConfig) ValidateBasic() error { return nil } +func (cfg *ConsensusConfig) DeprecatedFieldWarning() error { + var fields []string + if cfg.DeprecatedSkipTimeoutCommit != nil { + fields = append(fields, "skip-timeout-commit") + } + if cfg.DeprecatedTimeoutPropose != nil { + fields = append(fields, "timeout-propose") + } + if cfg.DeprecatedTimeoutProposeDelta != nil { + fields = append(fields, "timeout-propose-delta") + } + if cfg.DeprecatedTimeoutPrevote != nil { + fields = append(fields, "timeout-prevote") + } + if cfg.DeprecatedTimeoutPrevoteDelta != nil { + fields = append(fields, "timeout-prevote-delta") + } + if cfg.DeprecatedTimeoutPrecommit != nil { + fields = append(fields, "timeout-precommit") + } + if cfg.DeprecatedTimeoutPrecommitDelta != nil { + fields = append(fields, "timeout-precommit-delta") + } + if cfg.DeprecatedTimeoutCommit != nil { + fields = append(fields, "timeout-commit") + } + if cfg.DeprecatedSkipTimeoutCommit != nil { + fields = append(fields, "skip-timeout-commit") + } + if len(fields) != 0 { + return fmt.Errorf("The following deprecated fields were set in the "+ + "configuration file: %s. These fields were removed in v0.36. Timeout "+ + "configuration has been moved to the ConsensusParams. For more information see "+ + "https://tinyurl.com/adr074", strings.Join(fields, ", ")) + } + return nil +} + //----------------------------------------------------------------------------- // TxIndexConfig // Remember that Event has the following structure: