diff --git a/pkg/innerring/processors/audit/processor.go b/pkg/innerring/processors/audit/processor.go index 8b29701024..37240e257c 100644 --- a/pkg/innerring/processors/audit/processor.go +++ b/pkg/innerring/processors/audit/processor.go @@ -7,6 +7,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/util" SDKClient "github.com/nspcc-dev/neofs-api-go/pkg/client" + "github.com/nspcc-dev/neofs-node/pkg/innerring/config" "github.com/nspcc-dev/neofs-node/pkg/innerring/invoke" "github.com/nspcc-dev/neofs-node/pkg/morph/client" wrapContainer "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper" @@ -66,6 +67,7 @@ type ( AuditContract util.Uint160 MorphClient *client.Client IRList Indexer + FeeProvider *config.FeeConfig ClientCache NeoFSClientCache RPCSearchTimeout time.Duration TaskManager TaskManager @@ -94,6 +96,8 @@ func New(p *Params) (*Processor, error) { return nil, errors.New("ir/audit: neo:morph client is not set") case p.IRList == nil: return nil, errors.New("ir/audit: global state is not set") + case p.FeeProvider == nil: + return nil, errors.New("ir/audit: fee provider is not set") case p.ClientCache == nil: return nil, errors.New("ir/audit: neofs RPC client cache is not set") case p.TaskManager == nil: @@ -110,13 +114,13 @@ func New(p *Params) (*Processor, error) { } // creating enhanced client for getting network map - netmapClient, err := invoke.NewNetmapClient(p.MorphClient, p.NetmapContract) + netmapClient, err := invoke.NewNetmapClient(p.MorphClient, p.NetmapContract, p.FeeProvider) if err != nil { return nil, err } // creating enhanced client for getting containers - containerClient, err := invoke.NewContainerClient(p.MorphClient, p.ContainerContract) + containerClient, err := invoke.NewContainerClient(p.MorphClient, p.ContainerContract, p.FeeProvider) if err != nil { return nil, err } diff --git a/pkg/innerring/processors/balance/process_assets.go b/pkg/innerring/processors/balance/process_assets.go index d31bc96019..d40649c455 100644 --- a/pkg/innerring/processors/balance/process_assets.go +++ b/pkg/innerring/processors/balance/process_assets.go @@ -14,7 +14,7 @@ func (bp *Processor) processLock(lock *balanceEvent.Lock) { return } - err := invoke.CashOutCheque(bp.mainnetClient, bp.neofsContract, + err := invoke.CashOutCheque(bp.mainnetClient, bp.neofsContract, bp.feeProvider, &invoke.ChequeParams{ ID: lock.ID(), Amount: bp.converter.ToFixed8(lock.Amount()), diff --git a/pkg/innerring/processors/balance/processor.go b/pkg/innerring/processors/balance/processor.go index 070e6c8bbc..a98df4ff6c 100644 --- a/pkg/innerring/processors/balance/processor.go +++ b/pkg/innerring/processors/balance/processor.go @@ -2,6 +2,7 @@ package balance import ( "github.com/nspcc-dev/neo-go/pkg/util" + "github.com/nspcc-dev/neofs-node/pkg/innerring/config" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" balanceEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/balance" @@ -30,6 +31,7 @@ type ( mainnetClient *client.Client alphabetState AlphabetState converter PrecisionConverter + feeProvider *config.FeeConfig } // Params of the processor constructor. @@ -41,6 +43,7 @@ type ( MainnetClient *client.Client AlphabetState AlphabetState Converter PrecisionConverter + FeeProvider *config.FeeConfig } ) @@ -59,6 +62,8 @@ func New(p *Params) (*Processor, error) { return nil, errors.New("ir/balance: global state is not set") case p.Converter == nil: return nil, errors.New("ir/balance: balance precision converter is not set") + case p.FeeProvider == nil: + return nil, errors.New("ir/balance: fee provider is not set") } p.Log.Debug("balance worker pool", zap.Int("size", p.PoolSize)) @@ -76,6 +81,7 @@ func New(p *Params) (*Processor, error) { mainnetClient: p.MainnetClient, alphabetState: p.AlphabetState, converter: p.Converter, + feeProvider: p.FeeProvider, }, nil } diff --git a/pkg/innerring/processors/container/process_container.go b/pkg/innerring/processors/container/process_container.go index 1e985c83a7..b781986f3d 100644 --- a/pkg/innerring/processors/container/process_container.go +++ b/pkg/innerring/processors/container/process_container.go @@ -37,7 +37,7 @@ func (cp *Processor) processContainerPut(put *containerEvent.Put) { return } - err := invoke.RegisterContainer(cp.morphClient, cp.containerContract, + err := invoke.RegisterContainer(cp.morphClient, cp.containerContract, cp.feeProvider, &invoke.ContainerParams{ Key: put.PublicKey(), Container: cnrData, @@ -56,7 +56,7 @@ func (cp *Processor) processContainerDelete(delete *containerEvent.Delete) { return } - err := invoke.RemoveContainer(cp.morphClient, cp.containerContract, + err := invoke.RemoveContainer(cp.morphClient, cp.containerContract, cp.feeProvider, &invoke.RemoveContainerParams{ ContainerID: delete.ContainerID(), Signature: delete.Signature(), diff --git a/pkg/innerring/processors/container/processor.go b/pkg/innerring/processors/container/processor.go index c21208a9e2..84c242a34f 100644 --- a/pkg/innerring/processors/container/processor.go +++ b/pkg/innerring/processors/container/processor.go @@ -2,6 +2,7 @@ package container import ( "github.com/nspcc-dev/neo-go/pkg/util" + "github.com/nspcc-dev/neofs-node/pkg/innerring/config" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" containerEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/container" @@ -23,6 +24,7 @@ type ( containerContract util.Uint160 morphClient *client.Client alphabetState AlphabetState + feeProvider *config.FeeConfig } // Params of the processor constructor. @@ -32,6 +34,7 @@ type ( ContainerContract util.Uint160 MorphClient *client.Client AlphabetState AlphabetState + FeeProvider *config.FeeConfig } ) @@ -49,6 +52,8 @@ func New(p *Params) (*Processor, error) { return nil, errors.New("ir/container: neo:morph client is not set") case p.AlphabetState == nil: return nil, errors.New("ir/container: global state is not set") + case p.FeeProvider == nil: + return nil, errors.New("ir/container: fee provider is not set") } p.Log.Debug("container worker pool", zap.Int("size", p.PoolSize)) @@ -64,6 +69,7 @@ func New(p *Params) (*Processor, error) { containerContract: p.ContainerContract, morphClient: p.MorphClient, alphabetState: p.AlphabetState, + feeProvider: p.FeeProvider, }, nil } diff --git a/pkg/innerring/processors/governance/process_update.go b/pkg/innerring/processors/governance/process_update.go index e865223032..07e7aee897 100644 --- a/pkg/innerring/processors/governance/process_update.go +++ b/pkg/innerring/processors/governance/process_update.go @@ -65,7 +65,12 @@ func (gp *Processor) processAlphabetSync() { } else { sort.Sort(newInnerRing) - err = gp.morphClient.UpdateNeoFSAlphabetList(newInnerRing) + if gp.notaryDisabled { + err = invoke.SetInnerRing(gp.morphClient, gp.netmapContract, gp.feeProvider, newInnerRing) + } else { + err = gp.morphClient.UpdateNeoFSAlphabetList(newInnerRing) + } + if err != nil { gp.log.Error("can't update inner ring list with new alphabet keys", zap.String("error", err.Error())) @@ -73,11 +78,13 @@ func (gp *Processor) processAlphabetSync() { } } - // 3. Update notary role in side chain. - err = gp.morphClient.UpdateNotaryList(newAlphabet) - if err != nil { - gp.log.Error("can't update list of notary nodes in side chain", - zap.String("error", err.Error())) + if !gp.notaryDisabled { + // 3. Update notary role in side chain. + err = gp.morphClient.UpdateNotaryList(newAlphabet) + if err != nil { + gp.log.Error("can't update list of notary nodes in side chain", + zap.String("error", err.Error())) + } } // 4. Update NeoFS contract in main net. @@ -88,7 +95,7 @@ func (gp *Processor) processAlphabetSync() { id := append([]byte(alphabetUpdateIDPrefix), buf...) - err = invoke.AlphabetUpdate(gp.mainnetClient, gp.neofsContract, id, newAlphabet) + err = invoke.AlphabetUpdate(gp.mainnetClient, gp.neofsContract, gp.feeProvider, id, newAlphabet) if err != nil { gp.log.Error("can't update list of alphabet nodes in neofs contract", zap.String("error", err.Error())) diff --git a/pkg/innerring/processors/governance/processor.go b/pkg/innerring/processors/governance/processor.go index 47fe0bdb0b..7c811a055d 100644 --- a/pkg/innerring/processors/governance/processor.go +++ b/pkg/innerring/processors/governance/processor.go @@ -3,6 +3,7 @@ package governance import ( "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/util" + "github.com/nspcc-dev/neofs-node/pkg/innerring/config" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/panjf2000/ants/v2" @@ -33,9 +34,10 @@ type ( // Processor of events related to governance in the network. Processor struct { - log *zap.Logger - pool *ants.Pool - neofsContract util.Uint160 + log *zap.Logger + pool *ants.Pool + neofsContract util.Uint160 + netmapContract util.Uint160 alphabetState AlphabetState epochState EpochState @@ -43,12 +45,16 @@ type ( mainnetClient *client.Client morphClient *client.Client + + notaryDisabled bool + feeProvider *config.FeeConfig } // Params of the processor constructor. Params struct { - Log *zap.Logger - NeoFSContract util.Uint160 + Log *zap.Logger + NeoFSContract util.Uint160 + NetmapContract util.Uint160 AlphabetState AlphabetState EpochState EpochState @@ -56,6 +62,9 @@ type ( MorphClient *client.Client MainnetClient *client.Client + + NotaryDisabled bool + FeeProvider *config.FeeConfig } ) @@ -74,6 +83,8 @@ func New(p *Params) (*Processor, error) { return nil, errors.New("ir/governance: global state is not set") case p.Voter == nil: return nil, errors.New("ir/governance: global state is not set") + case p.FeeProvider == nil: + return nil, errors.New("ir/governance: fee provider is not set") } pool, err := ants.NewPool(ProcessorPoolSize, ants.WithNonblocking(true)) @@ -82,14 +93,17 @@ func New(p *Params) (*Processor, error) { } return &Processor{ - log: p.Log, - pool: pool, - neofsContract: p.NeoFSContract, - alphabetState: p.AlphabetState, - epochState: p.EpochState, - voter: p.Voter, - mainnetClient: p.MainnetClient, - morphClient: p.MorphClient, + log: p.Log, + pool: pool, + neofsContract: p.NeoFSContract, + netmapContract: p.NetmapContract, + alphabetState: p.AlphabetState, + epochState: p.EpochState, + voter: p.Voter, + mainnetClient: p.MainnetClient, + morphClient: p.MorphClient, + notaryDisabled: p.NotaryDisabled, + feeProvider: p.FeeProvider, }, nil } diff --git a/pkg/innerring/processors/neofs/process_assets.go b/pkg/innerring/processors/neofs/process_assets.go index 22a293b171..a4e2571533 100644 --- a/pkg/innerring/processors/neofs/process_assets.go +++ b/pkg/innerring/processors/neofs/process_assets.go @@ -21,7 +21,7 @@ func (np *Processor) processDeposit(deposit *neofsEvent.Deposit) { } // send transferX to balance contract - err := invoke.Mint(np.morphClient, np.balanceContract, + err := invoke.Mint(np.morphClient, np.balanceContract, np.feeProvider, &invoke.MintBurnParams{ ScriptHash: deposit.To().BytesBE(), Amount: np.converter.ToBalancePrecision(deposit.Amount()), @@ -94,7 +94,7 @@ func (np *Processor) processWithdraw(withdraw *neofsEvent.Withdraw) { curEpoch := np.epochState.EpochCounter() - err = invoke.LockAsset(np.morphClient, np.balanceContract, + err = invoke.LockAsset(np.morphClient, np.balanceContract, np.feeProvider, &invoke.LockParams{ ID: withdraw.ID(), User: withdraw.User(), @@ -115,7 +115,7 @@ func (np *Processor) processCheque(cheque *neofsEvent.Cheque) { return } - err := invoke.Burn(np.morphClient, np.balanceContract, + err := invoke.Burn(np.morphClient, np.balanceContract, np.feeProvider, &invoke.MintBurnParams{ ScriptHash: cheque.LockAccount().BytesBE(), Amount: np.converter.ToBalancePrecision(cheque.Amount()), diff --git a/pkg/innerring/processors/neofs/process_config.go b/pkg/innerring/processors/neofs/process_config.go index 815db93a7f..5d04c9d885 100644 --- a/pkg/innerring/processors/neofs/process_config.go +++ b/pkg/innerring/processors/neofs/process_config.go @@ -14,7 +14,7 @@ func (np *Processor) processConfig(config *neofsEvent.Config) { return } - err := invoke.SetConfig(np.morphClient, np.netmapContract, + err := invoke.SetConfig(np.morphClient, np.netmapContract, np.feeProvider, &invoke.SetConfigArgs{ ID: config.ID(), Key: config.Key(), diff --git a/pkg/innerring/processors/neofs/processor.go b/pkg/innerring/processors/neofs/processor.go index d15497d794..c0d7500a27 100644 --- a/pkg/innerring/processors/neofs/processor.go +++ b/pkg/innerring/processors/neofs/processor.go @@ -6,6 +6,7 @@ import ( lru "github.com/hashicorp/golang-lru" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/util" + "github.com/nspcc-dev/neofs-node/pkg/innerring/config" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" neofsEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/neofs" @@ -41,6 +42,7 @@ type ( epochState EpochState alphabetState AlphabetState converter PrecisionConverter + feeProvider *config.FeeConfig mintEmitLock *sync.Mutex mintEmitCache *lru.Cache mintEmitThreshold uint64 @@ -59,6 +61,7 @@ type ( EpochState EpochState AlphabetState AlphabetState Converter PrecisionConverter + FeeProvider *config.FeeConfig MintEmitCacheSize int MintEmitThreshold uint64 // in epochs MintEmitValue fixedn.Fixed8 @@ -86,6 +89,8 @@ func New(p *Params) (*Processor, error) { return nil, errors.New("ir/neofs: global state is not set") case p.Converter == nil: return nil, errors.New("ir/neofs: balance precision converter is not set") + case p.FeeProvider == nil: + return nil, errors.New("ir/neofs: fee provider is not set") } p.Log.Debug("neofs worker pool", zap.Int("size", p.PoolSize)) @@ -110,6 +115,7 @@ func New(p *Params) (*Processor, error) { epochState: p.EpochState, alphabetState: p.AlphabetState, converter: p.Converter, + feeProvider: p.FeeProvider, mintEmitLock: new(sync.Mutex), mintEmitCache: lruCache, mintEmitThreshold: p.MintEmitThreshold, diff --git a/pkg/innerring/processors/netmap/process_cleanup.go b/pkg/innerring/processors/netmap/process_cleanup.go index 06b30ab489..1920c1baea 100644 --- a/pkg/innerring/processors/netmap/process_cleanup.go +++ b/pkg/innerring/processors/netmap/process_cleanup.go @@ -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)) } diff --git a/pkg/innerring/processors/netmap/process_epoch.go b/pkg/innerring/processors/netmap/process_epoch.go index 38781dc507..af29593f49 100644 --- a/pkg/innerring/processors/netmap/process_epoch.go +++ b/pkg/innerring/processors/netmap/process_epoch.go @@ -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)) } diff --git a/pkg/innerring/processors/netmap/process_peers.go b/pkg/innerring/processors/netmap/process_peers.go index 44ee62348d..e0664c0c6f 100644 --- a/pkg/innerring/processors/netmap/process_peers.go +++ b/pkg/innerring/processors/netmap/process_peers.go @@ -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(), diff --git a/pkg/innerring/processors/netmap/processor.go b/pkg/innerring/processors/netmap/processor.go index 2f480665d8..88a37f86b9 100644 --- a/pkg/innerring/processors/netmap/processor.go +++ b/pkg/innerring/processors/netmap/processor.go @@ -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 } diff --git a/pkg/innerring/processors/reputation/process_put.go b/pkg/innerring/processors/reputation/process_put.go index c1f97cfd9a..c346fa7cdf 100644 --- a/pkg/innerring/processors/reputation/process_put.go +++ b/pkg/innerring/processors/reputation/process_put.go @@ -41,7 +41,14 @@ func (rp *Processor) processPut(epoch uint64, id reputation.PeerID, value reputa args.SetPeerID(id) args.SetValue(value) - err := rp.reputationWrp.PutViaNotary(args) + var err error + + if rp.notaryDisabled { + err = rp.reputationWrp.Put(args) + } else { + err = rp.reputationWrp.PutViaNotary(args) + } + if err != nil { rp.log.Warn("can't send approval tx for reputation value", zap.String("peer_id", hex.EncodeToString(id.ToV2().GetValue())), diff --git a/pkg/innerring/processors/reputation/processor.go b/pkg/innerring/processors/reputation/processor.go index 561b221c7e..e5dca8f5a0 100644 --- a/pkg/innerring/processors/reputation/processor.go +++ b/pkg/innerring/processors/reputation/processor.go @@ -26,6 +26,8 @@ type ( log *zap.Logger pool *ants.Pool + notaryDisabled bool + reputationContract util.Uint160 epochState EpochState @@ -38,6 +40,7 @@ type ( Params struct { Log *zap.Logger PoolSize int + NotaryDisabled bool ReputationContract util.Uint160 EpochState EpochState AlphabetState AlphabetState @@ -72,6 +75,7 @@ func New(p *Params) (*Processor, error) { return &Processor{ log: p.Log, pool: pool, + notaryDisabled: p.NotaryDisabled, reputationContract: p.ReputationContract, epochState: p.EpochState, alphabetState: p.AlphabetState,