From f09ee27af937cb6608e24a95030db79ceb508ffb Mon Sep 17 00:00:00 2001
From: Pavel Karpy
Date: Thu, 30 Mar 2023 18:24:07 +0300
Subject: [PATCH] [#181] ir: Do not process container estimations by
non-alphabet nodes
Signed-off-by: Pavel Karpy
---
pkg/innerring/blocktimer.go | 11 +++++++++++
pkg/innerring/processors/netmap/process_epoch.go | 2 +-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/pkg/innerring/blocktimer.go b/pkg/innerring/blocktimer.go
index 747f36fdf..eb74e44d4 100644
--- a/pkg/innerring/blocktimer.go
+++ b/pkg/innerring/blocktimer.go
@@ -20,6 +20,10 @@ type (
EpochDuration() uint64
}
+ alphaState interface {
+ IsAlphabet() bool
+ }
+
subEpochEventHandler struct {
handler event.Handler // handle to execute
durationMul uint32 // X: X/Y of epoch in blocks
@@ -31,6 +35,8 @@ type (
epochTimerArgs struct {
l *logger.Logger
+ alphabetState alphaState
+
newEpochHandlers []newEpochHandler
cnrWrapper *container.Client // to invoke stop container estimation
@@ -91,6 +97,11 @@ func newEpochTimer(args *epochTimerArgs) *timer.BlockTimer {
args.stopEstimationDMul,
args.stopEstimationDDiv,
func() {
+ if !args.alphabetState.IsAlphabet() {
+ args.l.Debug("non-alphabet mode, do not stop container estimations")
+ return
+ }
+
epochN := args.epoch.EpochCounter()
if epochN == 0 { // estimates are invalid in genesis epoch
return
diff --git a/pkg/innerring/processors/netmap/process_epoch.go b/pkg/innerring/processors/netmap/process_epoch.go
index 48de528e1..ffcddc497 100644
--- a/pkg/innerring/processors/netmap/process_epoch.go
+++ b/pkg/innerring/processors/netmap/process_epoch.go
@@ -50,7 +50,7 @@ func (np *Processor) processNewEpoch(ev netmapEvent.NewEpoch) {
prm.SetEpoch(epoch - 1)
prm.SetHash(ev.TxHash())
- if epoch > 0 { // estimates are invalid in genesis epoch
+ if epoch > 0 && np.alphabetState.IsAlphabet() { // estimates are invalid in genesis epoch
err = np.containerWrp.StartEstimation(prm)
if err != nil {