From f90fc86ec8436d458af007cf9d3818bfadec7838 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 12 May 2021 12:27:12 +0300 Subject: [PATCH] [#493] node: Abolish re-bootstrap configurations From now non-relay node always sends re-bootstrap transaction every 2 epochs starting from the boot-up epoch. Signed-off-by: Leonard Lyubich --- cmd/neofs-node/config.go | 12 +++--------- cmd/neofs-node/netmap.go | 27 ++++++++++++++------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 90541318e..238f2f8b2 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -96,9 +96,7 @@ const ( cfgReplicatorPutTimeout = "replicator.put_timeout" - cfgReBootstrapRelay = "bootstrap.relay_only" - cfgReBootstrapEnabled = "bootstrap.periodic.enabled" - cfgReBootstrapInterval = "bootstrap.periodic.interval" + cfgReBootstrapRelay = "bootstrap.relay_only" cfgObjectPutPoolSize = "pool.object.put.size" cfgObjectGetPoolSize = "pool.object.get.size" @@ -250,7 +248,7 @@ type cfgNetmap struct { reBootstrapEnabled bool reBoostrapTurnedOff *atomic.Bool // managed by control service in runtime - reBootstrapInterval uint64 // in epochs + startEpoch uint64 // epoch number when application is started } type BootstrapType uint32 @@ -377,8 +375,7 @@ func initCfg(path string) *cfg { scriptHash: u160Netmap, state: state, workerPool: netmapWorkerPool, - reBootstrapInterval: viperCfg.GetUint64(cfgReBootstrapInterval), - reBootstrapEnabled: !relayOnly && viperCfg.GetBool(cfgReBootstrapEnabled), + reBootstrapEnabled: !relayOnly, reBoostrapTurnedOff: atomic.NewBool(relayOnly), }, cfgNodeInfo: cfgNodeInfo{ @@ -459,9 +456,6 @@ func defaultConfiguration(v *viper.Viper) { v.SetDefault(cfgReplicatorPutTimeout, 5*time.Second) - v.SetDefault(cfgReBootstrapEnabled, false) // in epochs - v.SetDefault(cfgReBootstrapInterval, 2) // in epochs - v.SetDefault(cfgObjectGetPoolSize, 10) v.SetDefault(cfgObjectHeadPoolSize, 10) v.SetDefault(cfgObjectPutPoolSize, 10) diff --git a/cmd/neofs-node/netmap.go b/cmd/neofs-node/netmap.go index ea803ac26..ba8a98d76 100644 --- a/cmd/neofs-node/netmap.go +++ b/cmd/neofs-node/netmap.go @@ -73,22 +73,22 @@ func initNetmapService(c *cfg) { c.cfgNetmap.state.setCurrentEpoch(ev.(netmapEvent.NewEpoch).EpochNumber()) }) - if c.cfgNetmap.reBootstrapEnabled { - addNewEpochAsyncNotificationHandler(c, func(ev event.Event) { - if c.cfgNetmap.reBoostrapTurnedOff.Load() { // fixes #470 - return - } + addNewEpochAsyncNotificationHandler(c, func(ev event.Event) { + if c.cfgNetmap.reBoostrapTurnedOff.Load() { // fixes #470 + return + } - n := ev.(netmapEvent.NewEpoch).EpochNumber() + n := ev.(netmapEvent.NewEpoch).EpochNumber() - if n%c.cfgNetmap.reBootstrapInterval == 0 { - err := c.cfgNetmap.wrapper.AddPeer(c.toOnlineLocalNodeInfo()) - if err != nil { - c.log.Warn("can't send re-bootstrap tx", zap.Error(err)) - } + const reBootstrapInterval = 2 + + if (n-c.cfgNetmap.startEpoch)%reBootstrapInterval == 0 { + err := c.cfgNetmap.wrapper.AddPeer(c.toOnlineLocalNodeInfo()) + if err != nil { + c.log.Warn("can't send re-bootstrap tx", zap.Error(err)) } - }) - } + } + }) addNewEpochAsyncNotificationHandler(c, func(ev event.Event) { e := ev.(netmapEvent.NewEpoch).EpochNumber() @@ -149,6 +149,7 @@ func initState(c *cfg) { ) c.cfgNetmap.state.setCurrentEpoch(epoch) + c.cfgNetmap.startEpoch = epoch } func (c *cfg) netmapLocalNodeState(epoch uint64) (*netmapSDK.NodeInfo, error) {