diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index b097fb3bfb..4951d05f0c 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -724,7 +724,7 @@ func initBasics(c *cfg, key *keys.PrivateKey, stateStorage *state.PersistentStor lookupScriptHashesInNNS(cli, c.applicationConfiguration, &b) - nState := newNetworkState() + nState := newNetworkState(c.log) currBlock, err := cli.BlockCount() fatalOnErr(err) nState.block.Store(currBlock) @@ -743,7 +743,7 @@ func initBasics(c *cfg, key *keys.PrivateKey, stateStorage *state.PersistentStor eDuration, err := nmWrap.EpochDuration() fatalOnErr(err) - nState.epochDuration.Store(eDuration) + nState.updateEpochDuration(eDuration) ttl := c.applicationConfiguration.fsChain.cacheTTL if ttl == 0 { diff --git a/cmd/neofs-node/netmap.go b/cmd/neofs-node/netmap.go index 3a197ef08b..b54f4e7f5b 100644 --- a/cmd/neofs-node/netmap.go +++ b/cmd/neofs-node/netmap.go @@ -22,8 +22,13 @@ import ( "go.uber.org/zap" ) +// defaultEpochDuration is a default epoch duration to replace zero from FS chain. +const defaultEpochDuration = 240 + // primary solution of local network state dump. type networkState struct { + l *zap.Logger + epoch atomic.Uint64 block atomic.Uint32 epochDuration atomic.Uint64 @@ -35,11 +40,12 @@ type networkState struct { metrics *metrics.NodeMetrics } -func newNetworkState() *networkState { +func newNetworkState(l *zap.Logger) *networkState { var nmStatus atomic.Value nmStatus.Store(control.NetmapStatus_STATUS_UNDEFINED) return &networkState{ + l: l, controlNetStatus: nmStatus, } } @@ -62,6 +68,18 @@ func (s *networkState) setCurrentEpoch(v uint64) { s.metrics.SetEpoch(v) } +func (s *networkState) updateEpochDuration(v uint64) { + if v != 0 { + s.epochDuration.Store(v) + return + } + + s.l.Warn("zero epoch duration received, fallback to default value", zap.Uint64("applied default value", defaultEpochDuration)) + s.epochDuration.Store(defaultEpochDuration) + + return +} + func (s *networkState) setNodeInfo(ni *netmapSDK.NodeInfo) { ctrlNetSt := control.NetmapStatus_STATUS_UNDEFINED diff --git a/cmd/neofs-node/reputation.go b/cmd/neofs-node/reputation.go index d2ea3ad09f..ea4fe0936e 100644 --- a/cmd/neofs-node/reputation.go +++ b/cmd/neofs-node/reputation.go @@ -229,8 +229,7 @@ func initReputationService(c *cfg) { log.Debug("could not fetch epoch duration", zap.Error(err)) return } - - c.networkState.epochDuration.Store(duration) + c.networkState.updateEpochDuration(duration) iterations, err := c.cfgNetmap.wrapper.EigenTrustIterations() if err != nil {