From 2fc4b8a15b4057270fc64a02c7e42aa092f4e221 Mon Sep 17 00:00:00 2001 From: William Banfield Date: Wed, 17 Aug 2022 10:51:49 -0400 Subject: [PATCH] add deprecation warnings --- cmd/tendermint/commands/root.go | 4 ++++ config/config.go | 33 +++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/cmd/tendermint/commands/root.go b/cmd/tendermint/commands/root.go index 46c9ac7c7..e4061bc28 100644 --- a/cmd/tendermint/commands/root.go +++ b/cmd/tendermint/commands/root.go @@ -53,6 +53,10 @@ func ParseConfig(cmd *cobra.Command) (*cfg.Config, error) { if err := conf.ValidateBasic(); err != nil { return nil, fmt.Errorf("error in config file: %v", err) } + err = conf.CheckDeprecated() + if err != nil { + logger.Info("deprecated usage found in configuration file", "error", err) + } return conf, nil } diff --git a/config/config.go b/config/config.go index 497f80c67..f6bc1dc87 100644 --- a/config/config.go +++ b/config/config.go @@ -68,14 +68,17 @@ type Config struct { BaseConfig `mapstructure:",squash"` // Options for services - RPC *RPCConfig `mapstructure:"rpc"` - P2P *P2PConfig `mapstructure:"p2p"` - Mempool *MempoolConfig `mapstructure:"mempool"` - StateSync *StateSyncConfig `mapstructure:"statesync"` - BlockSync *BlockSyncConfig `mapstructure:"blocksync"` - Consensus *ConsensusConfig `mapstructure:"consensus"` - TxIndex *TxIndexConfig `mapstructure:"tx_index"` - Instrumentation *InstrumentationConfig `mapstructure:"instrumentation"` + RPC *RPCConfig `mapstructure:"rpc"` + P2P *P2PConfig `mapstructure:"p2p"` + Mempool *MempoolConfig `mapstructure:"mempool"` + StateSync *StateSyncConfig `mapstructure:"statesync"` + BlockSync *BlockSyncConfig `mapstructure:"blocksync"` + //TODO(williambanfield): remove this field once v0.37 is released. + // https://github.com/tendermint/tendermint/issues/9279 + DeprecatedFastSyncConfig map[interface{}]interface{} `mapstructure:"fastsync"` + Consensus *ConsensusConfig `mapstructure:"consensus"` + TxIndex *TxIndexConfig `mapstructure:"tx_index"` + Instrumentation *InstrumentationConfig `mapstructure:"instrumentation"` } // DefaultConfig returns a default configuration for a Tendermint node @@ -148,6 +151,16 @@ func (cfg *Config) ValidateBasic() error { return nil } +func (cfg *Config) CheckDeprecated() error { + if cfg.DeprecatedFastSyncConfig != nil { + return errors.New("[fastsync] table detected. This section has been renamed to [blocksync]. The values in this deprecated section will be disregarded.") + } + if cfg.BaseConfig.DeprecatedFastSyncMode != nil { + return errors.New("fast_sync key detected. This key has been renamed to block_sync. The value of this deprecated key will be disregarded.") + } + return nil +} + //----------------------------------------------------------------------------- // BaseConfig @@ -172,6 +185,10 @@ type BaseConfig struct { //nolint: maligned // and verifying their commits BlockSyncMode bool `mapstructure:"block_sync"` + //TODO(williambanfield): remove this field once v0.37 is released. + // https://github.com/tendermint/tendermint/issues/9279 + DeprecatedFastSyncMode interface{} `mapstructure:"fast_sync"` + // Database backend: goleveldb | cleveldb | boltdb | rocksdb // * goleveldb (github.com/syndtr/goleveldb - most popular implementation) // - pure go