@@ -23,8 +23,8 @@ import (
23
23
engineconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine"
24
24
shardconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard"
25
25
fstreeconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard/blobstor/fstree"
26
+ fschainconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/fschain"
26
27
loggerconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/logger"
27
- morphconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/morph"
28
28
nodeconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/node"
29
29
objectconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/object"
30
30
policerconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/policer"
@@ -110,7 +110,7 @@ type applicationConfiguration struct {
110
110
objectBatchSize uint32
111
111
}
112
112
113
- morph struct {
113
+ fsChain struct {
114
114
endpoints []string
115
115
dialTimeout time.Duration
116
116
cacheTTL time.Duration
@@ -166,13 +166,13 @@ func (a *applicationConfiguration) readConfig(c *config.Config) error {
166
166
a .engine .isIgnoreUninitedShards = engineconfig .IgnoreUninitedShards (c )
167
167
a .engine .objectPutRetryDeadline = engineconfig .ObjectPutRetryDeadline (c )
168
168
169
- // Morph
169
+ // FS chain
170
170
171
- a .morph .endpoints = morphconfig .Endpoints (c )
172
- a .morph .dialTimeout = morphconfig .DialTimeout (c )
173
- a .morph .cacheTTL = morphconfig .CacheTTL (c )
174
- a .morph .reconnectionRetriesNumber = morphconfig .ReconnectionRetriesNumber (c )
175
- a .morph .reconnectionRetriesDelay = morphconfig .ReconnectionRetriesDelay (c )
171
+ a .fsChain .endpoints = fschainconfig .Endpoints (c )
172
+ a .fsChain .dialTimeout = fschainconfig .DialTimeout (c )
173
+ a .fsChain .cacheTTL = fschainconfig .CacheTTL (c )
174
+ a .fsChain .reconnectionRetriesNumber = fschainconfig .ReconnectionRetriesNumber (c )
175
+ a .fsChain .reconnectionRetriesDelay = fschainconfig .ReconnectionRetriesDelay (c )
176
176
177
177
// Contracts
178
178
@@ -522,7 +522,10 @@ type cfgReputation struct {
522
522
localTrustCtrl * trustcontroller.Controller
523
523
}
524
524
525
- var persistateFSChainLastBlockKey = []byte ("fs_chain_last_processed_block" )
525
+ var (
526
+ persistateFSChainLastBlockKey = []byte ("fs_chain_last_processed_block" )
527
+ persistateDeprecatedSidechainLastBlockKey = []byte ("side_chain_last_processed_block" )
528
+ )
526
529
527
530
func initCfg (appCfg * config.Config ) * cfg {
528
531
c := & cfg {}
@@ -649,6 +652,12 @@ func initCfg(appCfg *config.Config) *cfg {
649
652
650
653
c .veryLastClosers = make (map [string ]func ())
651
654
655
+ // warning if there is morph section
656
+
657
+ if c .cfgReader .Value ("morph" ) != nil {
658
+ c .log .Warn ("config section 'morph' is deprecated, use 'fschain'" )
659
+ }
660
+
652
661
c .onShutdown (c .clientCache .CloseAll ) // clean up connections
653
662
c .onShutdown (c .bgClientCache .CloseAll ) // clean up connections
654
663
c .onShutdown (c .putClientCache .CloseAll ) // clean up connections
@@ -660,22 +669,37 @@ func initCfg(appCfg *config.Config) *cfg {
660
669
func initBasics (c * cfg , key * keys.PrivateKey , stateStorage * state.PersistentStorage ) basics {
661
670
b := basics {}
662
671
663
- addresses := c .applicationConfiguration .morph .endpoints
672
+ addresses := c .applicationConfiguration .fsChain .endpoints
664
673
674
+ fromDeprectedSidechanBlock , err := stateStorage .UInt32 (persistateDeprecatedSidechainLastBlockKey )
675
+ if err != nil {
676
+ fromDeprectedSidechanBlock = 0
677
+ }
665
678
fromFSChainBlock , err := stateStorage .UInt32 (persistateFSChainLastBlockKey )
666
679
if err != nil {
667
680
fromFSChainBlock = 0
668
681
c .log .Warn ("can't get last processed FS chain block number" , zap .Error (err ))
669
682
}
670
683
684
+ // migration for deprecated DB key
685
+ if fromFSChainBlock == 0 && fromDeprectedSidechanBlock != fromFSChainBlock {
686
+ fromFSChainBlock = fromDeprectedSidechanBlock
687
+ err = stateStorage .SetUInt32 (persistateFSChainLastBlockKey , fromFSChainBlock )
688
+ if err != nil {
689
+ c .log .Warn ("can't update persistent state" ,
690
+ zap .String ("chain" , "FS" ),
691
+ zap .Uint32 ("block_index" , fromFSChainBlock ))
692
+ }
693
+ }
694
+
671
695
cli , err := client .New (key ,
672
696
client .WithContext (c .internals .ctx ),
673
- client .WithDialTimeout (c .applicationConfiguration .morph .dialTimeout ),
697
+ client .WithDialTimeout (c .applicationConfiguration .fsChain .dialTimeout ),
674
698
client .WithLogger (c .log ),
675
699
client .WithAutoFSChainScope (),
676
700
client .WithEndpoints (addresses ),
677
- client .WithReconnectionRetries (c .applicationConfiguration .morph .reconnectionRetriesNumber ),
678
- client .WithReconnectionsDelay (c .applicationConfiguration .morph .reconnectionRetriesDelay ),
701
+ client .WithReconnectionRetries (c .applicationConfiguration .fsChain .reconnectionRetriesNumber ),
702
+ client .WithReconnectionsDelay (c .applicationConfiguration .fsChain .reconnectionRetriesDelay ),
679
703
client .WithConnSwitchCallback (func () {
680
704
err = c .restartMorph ()
681
705
if err != nil {
@@ -709,12 +733,12 @@ func initBasics(c *cfg, key *keys.PrivateKey, stateStorage *state.PersistentStor
709
733
nmWrap , err := nmClient .NewFromMorph (cli , b .netmapSH , 0 )
710
734
fatalOnErr (err )
711
735
712
- ttl := c .applicationConfiguration .morph .cacheTTL
736
+ ttl := c .applicationConfiguration .fsChain .cacheTTL
713
737
if ttl == 0 {
714
738
msPerBlock , err := cli .MsPerBlock ()
715
739
fatalOnErr (err )
716
740
ttl = time .Duration (msPerBlock ) * time .Millisecond
717
- c .log .Debug ("morph .cache_ttl fetched from network" , zap .Duration ("value" , ttl ))
741
+ c .log .Debug ("fschain .cache_ttl fetched from network" , zap .Duration ("value" , ttl ))
718
742
}
719
743
720
744
var netmapSource netmapCore.Source
@@ -918,7 +942,7 @@ func (c *cfg) configWatcher(ctx context.Context) {
918
942
919
943
// Morph
920
944
921
- c .cli .Reload (client .WithEndpoints (c .morph .endpoints ))
945
+ c .cli .Reload (client .WithEndpoints (c .fsChain .endpoints ))
922
946
923
947
// Node
924
948
0 commit comments