refactor(server)!: continue server v1 removal (#23238)
This commit is contained in:
@@ -31,6 +31,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
* [#23238](https://github.com/cosmos/cosmos-sdk/pull/23238) Loosen `app.toml` validation for consistency between baseapp chains and v2 chains.
|
||||
|
||||
## [v0.2.0-rc.1](https://github.com/cosmos/cosmos-sdk/releases/tag/tools/confix/v0.2.0-rc.1) - 2024-12-18
|
||||
|
||||
* [#21052](https://github.com/cosmos/cosmos-sdk/pull/21052) Add a migration to v2 config.
|
||||
|
||||
+3
-13
@@ -14,7 +14,6 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
|
||||
clientcfg "github.com/cosmos/cosmos-sdk/client/config"
|
||||
srvcfg "github.com/cosmos/cosmos-sdk/server/config"
|
||||
)
|
||||
|
||||
// Upgrade reads the configuration file at configPath and applies any
|
||||
@@ -43,11 +42,8 @@ func Upgrade(ctx context.Context, plan transform.Plan, doc *tomledit.Document, c
|
||||
return fmt.Errorf("formatting config: %w", err)
|
||||
}
|
||||
|
||||
// ignore validation for serverv2 by checking any default field found in doc
|
||||
isServerV2 := doc.First(strings.Split("store.options.sc-pruning-option", ".")...) != nil
|
||||
|
||||
// allow to skip validation
|
||||
if !skipValidate && !isServerV2 {
|
||||
if !skipValidate {
|
||||
// verify that file is valid after applying fixes
|
||||
if err := CheckValid(configPath, buf.Bytes()); err != nil {
|
||||
return fmt.Errorf("updated config is invalid: %w", err)
|
||||
@@ -76,14 +72,8 @@ func CheckValid(fileName string, data []byte) error {
|
||||
|
||||
switch {
|
||||
case strings.HasSuffix(fileName, AppConfig):
|
||||
var cfg srvcfg.Config
|
||||
if err := v.Unmarshal(&cfg); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal as server config: %w", err)
|
||||
}
|
||||
|
||||
if err := cfg.ValidateBasic(); err != nil {
|
||||
return fmt.Errorf("server config invalid: %w", err)
|
||||
}
|
||||
// no validation of server config as v1 and v2 configs are both valid.
|
||||
// any app.toml is simply considered as a server config.
|
||||
case strings.HasSuffix(fileName, ClientConfig):
|
||||
var cfg clientcfg.ClientConfig
|
||||
if err := v.Unmarshal(&cfg); err != nil {
|
||||
|
||||
@@ -35,9 +35,6 @@ func TestCheckValid(t *testing.T) {
|
||||
err = confix.CheckValid("client.toml", []byte{})
|
||||
assert.Error(t, err, "client config invalid: chain-id is empty")
|
||||
|
||||
err = confix.CheckValid("app.toml", []byte{})
|
||||
assert.ErrorContains(t, err, "server config invalid")
|
||||
|
||||
err = confix.CheckValid("app.toml", mustReadConfig(t, "data/v0.45-app.toml"))
|
||||
assert.NilError(t, err)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user