Skip to content

Commit

Permalink
ir: rename morph config section to fschain
Browse files Browse the repository at this point in the history
Rename the `morph` section in the code, config and examples to `fschain`.
Maintain compatibility for the transition and warn if `morph` is used.
Migrate data for deprecated DB key to new.

Closes #3021.

Signed-off-by: Andrey Butusov <[email protected]>
  • Loading branch information
End-rey committed Nov 26, 2024
1 parent ed0261c commit 0d6d425
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 73 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ attribute, which is used for container domain name in NNS contracts (#2954)
- EACL is no longer considered for system role (#2972)
- Deprecate peapod substorage (#3013)
- Node does not stop trying to PUT an object if there are more PUT tasks than configured (#3027)
- `morph` configuration section renamed to `fschain` both in IR and SN (#3028)

### Removed
- Support for node.key configuration (#2959)
Expand All @@ -75,6 +76,10 @@ introduced in version 0.22.3 and support for binary keys was removed from
other components in 0.33.0 and 0.37.0. Please migrate to wallets (see 0.37.0
notes) if you've not done it previously.

The section `morph` in the config has been renamed to `fschain`. This version
still supports the old section name, but this compatibility code will be removed
in the next release. Please rename `morph` to `fschain` in your configuration files.

To migrate data from Peapods to FSTree:
```shell
$ peapod-to-fstree -config </path/to/storage/node/config>
Expand Down
4 changes: 4 additions & 0 deletions cmd/neofs-ir/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ func defaultConfiguration(cfg *viper.Viper) {
cfg.SetDefault("morph.reconnections_number", 5)
cfg.SetDefault("morph.reconnections_delay", 5*time.Second)
cfg.SetDefault("morph.validators", []string{})
cfg.SetDefault("fschain.dial_timeout", time.Minute)
cfg.SetDefault("fschain.reconnections_number", 5)
cfg.SetDefault("fschain.reconnections_delay", 5*time.Second)
cfg.SetDefault("fschain.validators", []string{})

cfg.SetDefault("mainnet.dial_timeout", time.Minute)
cfg.SetDefault("mainnet.reconnections_number", 5)
Expand Down
55 changes: 55 additions & 0 deletions cmd/neofs-ir/internal/validate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,61 @@ type validConfig struct {
} `mapstructure:"consensus"`
} `mapstructure:"morph"`

FSChain struct {
DialTimeout time.Duration `mapstructure:"dial_timeout"`
ReconnectionsNumber int `mapstructure:"reconnections_number"`
ReconnectionsDelay time.Duration `mapstructure:"reconnections_delay"`
Endpoints []string `mapstructure:"endpoints"`
Validators []string `mapstructure:"validators"`
Consensus struct {
Magic uint32 `mapstructure:"magic"`
Committee []string `mapstructure:"committee"`

Storage struct {
Type string `mapstructure:"type"`
Path string `mapstructure:"path"`
} `mapstructure:"storage"`

TimePerBlock time.Duration `mapstructure:"time_per_block"`
MaxTraceableBlocks uint32 `mapstructure:"max_traceable_blocks"`
SeedNodes []string `mapstructure:"seed_nodes"`

Hardforks struct {
Name map[string]uint32 `mapstructure:",remain" prefix:""`
} `mapstructure:"hardforks"`

ValidatorsHistory struct {
Height map[string]int `mapstructure:",remain" prefix:""`
} `mapstructure:"validators_history"`

RPC struct {
Listen []string `mapstructure:"listen"`
TLS struct {
Enabled bool `mapstructure:"enabled"`
Listen []string `mapstructure:"listen"`
CertFile string `mapstructure:"cert_file"`
KeyFile string `mapstructure:"key_file"`
} `mapstructure:"tls"`
} `mapstructure:"rpc"`

P2P struct {
DialTimeout time.Duration `mapstructure:"dial_timeout"`
ProtoTickInterval time.Duration `mapstructure:"proto_tick_interval"`
Listen []string `mapstructure:"listen"`
Peers struct {
Min int `mapstructure:"min"`
Max int `mapstructure:"max"`
Attempts int `mapstructure:"attempts"`
} `mapstructure:"peers"`
Ping struct {
Interval time.Duration `mapstructure:"interval"`
Timeout time.Duration `mapstructure:"timeout"`
} `mapstructure:"ping"`
} `mapstructure:"p2p"`
SetRolesInGenesis bool `mapstructure:"set_roles_in_genesis"`
} `mapstructure:"consensus"`
} `mapstructure:"fschain"`

FSChainAutodeploy bool `mapstructure:"fschain_autodeploy"`

NNS struct {
Expand Down
18 changes: 9 additions & 9 deletions cmd/neofs-ir/internal/validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestCheckForUnknownFields(t *testing.T) {
{
name: "with all right fields",
config: `
morph:
fschain:
dial_timeout: 1m
reconnections_number: 5
reconnections_delay: 5s
Expand All @@ -37,7 +37,7 @@ morph:
- 02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62
storage:
type: boltdb
path: ./db/morph.bolt
path: ./db/fschain.bolt
time_per_block: 1s
max_traceable_blocks: 11520
seed_nodes:
Expand Down Expand Up @@ -78,9 +78,9 @@ morph:
wantErr: false,
},
{
name: "unknown morph.consensus.timeout",
name: "unknown fschain.consensus.timeout",
config: `
morph:
fschain:
consensus:
p2p:
ping:
Expand All @@ -91,20 +91,20 @@ morph:
wantErr: true,
},
{
name: "morph.consensus.storage.type expected type string",
name: "fschain.consensus.storage.type expected type string",
config: `
morph:
fschain:
consensus:
storage:
type:
path: ./db/morph.bolt
path: ./db/fschain.bolt
`,
wantErr: true,
},
{
name: "unknown field morph.attr",
name: "unknown field fschain.attr",
config: `
morph:
fschain:
dial_timeout: 1m
reconnections_number: 5
attr: 123
Expand Down
10 changes: 5 additions & 5 deletions config/example/ir.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ NEOFS_IR_WALLET_PASSWORD=secret

NEOFS_IR_WITHOUT_MAINNET=false

NEOFS_IR_MORPH_DIAL_TIMEOUT=1m
NEOFS_IR_MORPH_RECONNECTIONS_NUMBER=5
NEOFS_IR_MORPH_RECONNECTIONS_DELAY=5s
NEOFS_IR_MORPH_ENDPOINTS="wss://sidechain1.fs.neo.org:30333/ws wss://sidechain2.fs.neo.org:30333/ws"
NEOFS_IR_MORPH_VALIDATORS="0283120f4c8c1fc1d792af5063d2def9da5fddc90bc1384de7fcfdda33c3860170"
NEOFS_IR_FSCHAIN_DIAL_TIMEOUT=1m
NEOFS_IR_FSCHAIN_RECONNECTIONS_NUMBER=5
NEOFS_IR_FSCHAIN_RECONNECTIONS_DELAY=5s
NEOFS_IR_FSCHAIN_ENDPOINTS="wss://sidechain1.fs.neo.org:30333/ws wss://sidechain2.fs.neo.org:30333/ws"
NEOFS_IR_FSCHAIN_VALIDATORS="0283120f4c8c1fc1d792af5063d2def9da5fddc90bc1384de7fcfdda33c3860170"

NEOFS_IR_MAINNET_DIAL_TIMEOUT=1m
NEOFS_IR_MAINNET_RECONNECTIONS_NUMBER=5
Expand Down
2 changes: 1 addition & 1 deletion config/example/ir.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ wallet:

without_mainnet: false # Run application in single chain environment without mainchain

morph:
fschain:
dial_timeout: 1m # Timeout for RPC client connection to sidechain
reconnections_number: 5 # number of reconnection attempts
reconnections_delay: 5s # time delay b/w reconnection attempts
Expand Down
30 changes: 15 additions & 15 deletions pkg/innerring/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
)

// Various configuration paths.
const (
cfgPathFSChain = "morph"
var (
cfgPathFSChain = "fschain"
cfgPathFSChainRPCEndpoints = cfgPathFSChain + ".endpoints"
cfgPathFSChainLocalConsensus = cfgPathFSChain + ".consensus"
cfgPathFSChainValidators = cfgPathFSChain + ".validators"
Expand Down Expand Up @@ -69,15 +69,15 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co
}
c.NetworkMagic = netmode.Magic(_uint)

const storageSection = cfgPathFSChainLocalConsensus + ".storage"
var storageSection = cfgPathFSChainLocalConsensus + ".storage"
if !v.IsSet(storageSection) {
return c, fmt.Errorf("missing storage section '%s'", storageSection)
}
const storageTypeKey = storageSection + ".type"
var storageTypeKey = storageSection + ".type"
if !v.IsSet(storageTypeKey) {
return c, fmt.Errorf("missing storage type '%s'", storageTypeKey)
}
const storagePathKey = storageSection + ".path"
var storagePathKey = storageSection + ".path"
switch typ := v.GetString(storageTypeKey); typ {
default:
return c, fmt.Errorf("unsupported storage type '%s': '%s'", storageTypeKey, typ)
Expand All @@ -95,7 +95,7 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co
c.Storage = blockchain.InMemory()
}

const committeeKey = cfgPathFSChainLocalConsensus + ".committee"
var committeeKey = cfgPathFSChainLocalConsensus + ".committee"
c.Committee, err = parseConfigPublicKeys(v, committeeKey, "committee members")
if err != nil {
return c, err
Expand All @@ -119,15 +119,15 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co
return c, err
}

const hardForksKey = cfgPathFSChainLocalConsensus + ".hardforks"
var hardForksKey = cfgPathFSChainLocalConsensus + ".hardforks"
if v.IsSet(hardForksKey) {
c.HardForks, err = parseConfigMapUint32(v, hardForksKey, "hard forks", math.MaxUint32)
if err != nil {
return c, err
}
}

const validatorsHistoryKey = cfgPathFSChainLocalConsensus + ".validators_history"
var validatorsHistoryKey = cfgPathFSChainLocalConsensus + ".validators_history"
if v.IsSet(validatorsHistoryKey) {
c.ValidatorsHistory = make(map[uint32]uint32)
committeeSize := uint64(c.Committee.Len())
Expand Down Expand Up @@ -157,14 +157,14 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co
}
}

const rpcSection = cfgPathFSChainLocalConsensus + ".rpc"
var rpcSection = cfgPathFSChainLocalConsensus + ".rpc"
if v.IsSet(rpcSection) {
c.RPC.Addresses, err = parseConfigAddressesTCP(v, rpcSection+".listen", "network addresses to listen insecure Neo RPC on", rpcDefaultListenPort)
if err != nil && !errors.Is(err, errMissingConfig) {
return c, err
}

const rpcTLSSection = rpcSection + ".tls"
var rpcTLSSection = rpcSection + ".tls"
if v.GetBool(rpcTLSSection + ".enabled") {
c.RPC.TLSConfig.Enabled = true

Expand All @@ -173,13 +173,13 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co
return c, err
}

const certCfgKey = rpcTLSSection + ".cert_file"
var certCfgKey = rpcTLSSection + ".cert_file"
c.RPC.TLSConfig.CertFile = v.GetString(certCfgKey)
if strings.TrimSpace(c.RPC.TLSConfig.CertFile) == "" {
return c, fmt.Errorf("RPC TLS setup is enabled but no certificate ('%s') is provided", certCfgKey)
}

const keyCfgKey = rpcTLSSection + ".key_file"
var keyCfgKey = rpcTLSSection + ".key_file"
c.RPC.TLSConfig.KeyFile = v.GetString(keyCfgKey)
if strings.TrimSpace(c.RPC.TLSConfig.KeyFile) == "" {
return c, fmt.Errorf("RPC TLS setup is enabled but no key ('%s') is provided", keyCfgKey)
Expand All @@ -188,7 +188,7 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co
}

minPeersConfigured := false
const p2pSection = cfgPathFSChainLocalConsensus + ".p2p"
var p2pSection = cfgPathFSChainLocalConsensus + ".p2p"
if v.IsSet(p2pSection) {
c.P2P.DialTimeout, err = parseConfigDurationPositive(v, p2pSection+".dial_timeout", "P2P dial timeout")
if err != nil && !errors.Is(err, errMissingConfig) {
Expand All @@ -202,7 +202,7 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co
if err != nil && !errors.Is(err, errMissingConfig) {
return c, err
}
const p2pPeersSection = p2pSection + ".peers"
var p2pPeersSection = p2pSection + ".peers"
if v.IsSet(p2pPeersSection) {
minPeers, err := parseConfigUint64Max(v, p2pPeersSection+".min", "minimum number of P2P peers", math.MaxInt32)
if err != nil {
Expand All @@ -226,7 +226,7 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co
}
c.P2P.AttemptConnPeers = uint(attemptConnPeers)
}
const pingSection = p2pSection + ".ping"
var pingSection = p2pSection + ".ping"
if v.IsSet(pingSection) {
c.P2P.Ping.Interval, err = parseConfigDurationPositive(v, pingSection+".interval", "P2P ping interval")
if err != nil {
Expand Down
Loading

0 comments on commit 0d6d425

Please sign in to comment.