[#486] innerring: Use fee provider and notary disabled flag in processors

Processors that use `invoke` package to make chain invocation should provide
fee config and client with enabled or disabled notary support. If notary
support is disabled, then functions from `invoke` package will perform
ordinary method invocation with extra fee.

Processors that use `morph/client` wrappers should check `notaryDisabled`
flag to call corresponding wrapper function.

Netmap processor omits some actions during validator syncronization
if notary is disabled.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-04-29 16:40:34 +03:00 committed by Alex Vanin
parent 91a1896b8b
commit f2562e8c47
16 changed files with 111 additions and 38 deletions

View file

@ -25,10 +25,11 @@ func (np *Processor) processNetmapCleanupTick(epoch uint64) {
np.log.Info("vote to remove node from netmap", zap.String("key", s))
err = invoke.UpdatePeerState(np.morphClient, np.netmapContract, &invoke.UpdatePeerArgs{
Key: key,
Status: netmap.NodeStateOffline,
})
err = invoke.UpdatePeerState(np.morphClient, np.netmapContract, np.feeProvider,
&invoke.UpdatePeerArgs{
Key: key,
Status: netmap.NodeStateOffline,
})
if err != nil {
np.log.Error("can't invoke netmap.UpdateState", zap.Error(err))
}

View file

@ -27,7 +27,12 @@ func (np *Processor) processNewEpoch(epoch uint64) {
}
if epoch > 0 { // estimates are invalid in genesis epoch
err = np.containerWrp.StartEstimationNotary(epoch - 1)
if np.notaryDisabled {
err = np.containerWrp.StartEstimation(epoch - 1)
} else {
err = np.containerWrp.StartEstimationNotary(epoch - 1)
}
if err != nil {
np.log.Warn("can't start container size estimation",
zap.Uint64("epoch", epoch),
@ -52,7 +57,7 @@ func (np *Processor) processNewEpochTick() {
nextEpoch := np.epochState.EpochCounter() + 1
np.log.Debug("next epoch", zap.Uint64("value", nextEpoch))
err := invoke.SetNewEpoch(np.morphClient, np.netmapContract, nextEpoch)
err := invoke.SetNewEpoch(np.morphClient, np.netmapContract, np.feeProvider, nextEpoch)
if err != nil {
np.log.Error("can't invoke netmap.NewEpoch", zap.Error(err))
}

View file

@ -66,7 +66,8 @@ func (np *Processor) processAddPeer(node []byte) {
np.log.Info("approving network map candidate",
zap.String("key", keyString))
if err := invoke.ApprovePeer(np.morphClient, np.netmapContract, node); err != nil {
err := invoke.ApprovePeer(np.morphClient, np.netmapContract, np.feeProvider, node)
if err != nil {
np.log.Error("can't invoke netmap.AddPeer", zap.Error(err))
}
}
@ -92,7 +93,7 @@ func (np *Processor) processUpdatePeer(ev netmapEvent.UpdatePeer) {
// again before new epoch will tick
np.netmapSnapshot.flag(hex.EncodeToString(ev.PublicKey().Bytes()))
err := invoke.UpdatePeerState(np.morphClient, np.netmapContract,
err := invoke.UpdatePeerState(np.morphClient, np.netmapContract, np.feeProvider,
&invoke.UpdatePeerArgs{
Key: ev.PublicKey(),
Status: ev.Status(),

View file

@ -3,6 +3,7 @@ package netmap
import (
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
"github.com/nspcc-dev/neofs-node/pkg/innerring/config"
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
container "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
@ -64,6 +65,9 @@ type (
handleAlphabetSync event.Handler
nodeValidator NodeValidator
notaryDisabled bool
feeProvider *config.FeeConfig
}
// Params of the processor constructor.
@ -84,6 +88,9 @@ type (
AlphabetSyncHandler event.Handler
NodeValidator NodeValidator
NotaryDisabled bool
FeeProvider *config.FeeConfig
}
)
@ -116,6 +123,8 @@ func New(p *Params) (*Processor, error) {
return nil, errors.New("ir/netmap: container contract wrapper is not set")
case p.NodeValidator == nil:
return nil, errors.New("ir/netmap: node validator is not set")
case p.FeeProvider == nil:
return nil, errors.New("ir/netmap: fee provider is not set")
}
p.Log.Debug("netmap worker pool", zap.Int("size", p.PoolSize))
@ -142,6 +151,9 @@ func New(p *Params) (*Processor, error) {
handleAlphabetSync: p.AlphabetSyncHandler,
nodeValidator: p.NodeValidator,
notaryDisabled: p.NotaryDisabled,
feeProvider: p.FeeProvider,
}, nil
}