forked from TrueCloudLab/frostfs-node
[#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:
parent
91a1896b8b
commit
f2562e8c47
16 changed files with 111 additions and 38 deletions
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
SDKClient "github.com/nspcc-dev/neofs-api-go/pkg/client"
|
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/innerring/invoke"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||||
wrapContainer "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
|
wrapContainer "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
|
||||||
|
@ -66,6 +67,7 @@ type (
|
||||||
AuditContract util.Uint160
|
AuditContract util.Uint160
|
||||||
MorphClient *client.Client
|
MorphClient *client.Client
|
||||||
IRList Indexer
|
IRList Indexer
|
||||||
|
FeeProvider *config.FeeConfig
|
||||||
ClientCache NeoFSClientCache
|
ClientCache NeoFSClientCache
|
||||||
RPCSearchTimeout time.Duration
|
RPCSearchTimeout time.Duration
|
||||||
TaskManager TaskManager
|
TaskManager TaskManager
|
||||||
|
@ -94,6 +96,8 @@ func New(p *Params) (*Processor, error) {
|
||||||
return nil, errors.New("ir/audit: neo:morph client is not set")
|
return nil, errors.New("ir/audit: neo:morph client is not set")
|
||||||
case p.IRList == nil:
|
case p.IRList == nil:
|
||||||
return nil, errors.New("ir/audit: global state is not set")
|
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:
|
case p.ClientCache == nil:
|
||||||
return nil, errors.New("ir/audit: neofs RPC client cache is not set")
|
return nil, errors.New("ir/audit: neofs RPC client cache is not set")
|
||||||
case p.TaskManager == nil:
|
case p.TaskManager == nil:
|
||||||
|
@ -110,13 +114,13 @@ func New(p *Params) (*Processor, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// creating enhanced client for getting network map
|
// 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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// creating enhanced client for getting containers
|
// 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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ func (bp *Processor) processLock(lock *balanceEvent.Lock) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := invoke.CashOutCheque(bp.mainnetClient, bp.neofsContract,
|
err := invoke.CashOutCheque(bp.mainnetClient, bp.neofsContract, bp.feeProvider,
|
||||||
&invoke.ChequeParams{
|
&invoke.ChequeParams{
|
||||||
ID: lock.ID(),
|
ID: lock.ID(),
|
||||||
Amount: bp.converter.ToFixed8(lock.Amount()),
|
Amount: bp.converter.ToFixed8(lock.Amount()),
|
||||||
|
|
|
@ -2,6 +2,7 @@ package balance
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
balanceEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/balance"
|
balanceEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/balance"
|
||||||
|
@ -30,6 +31,7 @@ type (
|
||||||
mainnetClient *client.Client
|
mainnetClient *client.Client
|
||||||
alphabetState AlphabetState
|
alphabetState AlphabetState
|
||||||
converter PrecisionConverter
|
converter PrecisionConverter
|
||||||
|
feeProvider *config.FeeConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// Params of the processor constructor.
|
// Params of the processor constructor.
|
||||||
|
@ -41,6 +43,7 @@ type (
|
||||||
MainnetClient *client.Client
|
MainnetClient *client.Client
|
||||||
AlphabetState AlphabetState
|
AlphabetState AlphabetState
|
||||||
Converter PrecisionConverter
|
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")
|
return nil, errors.New("ir/balance: global state is not set")
|
||||||
case p.Converter == nil:
|
case p.Converter == nil:
|
||||||
return nil, errors.New("ir/balance: balance precision converter is not set")
|
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))
|
p.Log.Debug("balance worker pool", zap.Int("size", p.PoolSize))
|
||||||
|
@ -76,6 +81,7 @@ func New(p *Params) (*Processor, error) {
|
||||||
mainnetClient: p.MainnetClient,
|
mainnetClient: p.MainnetClient,
|
||||||
alphabetState: p.AlphabetState,
|
alphabetState: p.AlphabetState,
|
||||||
converter: p.Converter,
|
converter: p.Converter,
|
||||||
|
feeProvider: p.FeeProvider,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ func (cp *Processor) processContainerPut(put *containerEvent.Put) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := invoke.RegisterContainer(cp.morphClient, cp.containerContract,
|
err := invoke.RegisterContainer(cp.morphClient, cp.containerContract, cp.feeProvider,
|
||||||
&invoke.ContainerParams{
|
&invoke.ContainerParams{
|
||||||
Key: put.PublicKey(),
|
Key: put.PublicKey(),
|
||||||
Container: cnrData,
|
Container: cnrData,
|
||||||
|
@ -56,7 +56,7 @@ func (cp *Processor) processContainerDelete(delete *containerEvent.Delete) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := invoke.RemoveContainer(cp.morphClient, cp.containerContract,
|
err := invoke.RemoveContainer(cp.morphClient, cp.containerContract, cp.feeProvider,
|
||||||
&invoke.RemoveContainerParams{
|
&invoke.RemoveContainerParams{
|
||||||
ContainerID: delete.ContainerID(),
|
ContainerID: delete.ContainerID(),
|
||||||
Signature: delete.Signature(),
|
Signature: delete.Signature(),
|
||||||
|
|
|
@ -2,6 +2,7 @@ package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
containerEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/container"
|
containerEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/container"
|
||||||
|
@ -23,6 +24,7 @@ type (
|
||||||
containerContract util.Uint160
|
containerContract util.Uint160
|
||||||
morphClient *client.Client
|
morphClient *client.Client
|
||||||
alphabetState AlphabetState
|
alphabetState AlphabetState
|
||||||
|
feeProvider *config.FeeConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// Params of the processor constructor.
|
// Params of the processor constructor.
|
||||||
|
@ -32,6 +34,7 @@ type (
|
||||||
ContainerContract util.Uint160
|
ContainerContract util.Uint160
|
||||||
MorphClient *client.Client
|
MorphClient *client.Client
|
||||||
AlphabetState AlphabetState
|
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")
|
return nil, errors.New("ir/container: neo:morph client is not set")
|
||||||
case p.AlphabetState == nil:
|
case p.AlphabetState == nil:
|
||||||
return nil, errors.New("ir/container: global state is not set")
|
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))
|
p.Log.Debug("container worker pool", zap.Int("size", p.PoolSize))
|
||||||
|
@ -64,6 +69,7 @@ func New(p *Params) (*Processor, error) {
|
||||||
containerContract: p.ContainerContract,
|
containerContract: p.ContainerContract,
|
||||||
morphClient: p.MorphClient,
|
morphClient: p.MorphClient,
|
||||||
alphabetState: p.AlphabetState,
|
alphabetState: p.AlphabetState,
|
||||||
|
feeProvider: p.FeeProvider,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,12 @@ func (gp *Processor) processAlphabetSync() {
|
||||||
} else {
|
} else {
|
||||||
sort.Sort(newInnerRing)
|
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 {
|
if err != nil {
|
||||||
gp.log.Error("can't update inner ring list with new alphabet keys",
|
gp.log.Error("can't update inner ring list with new alphabet keys",
|
||||||
zap.String("error", err.Error()))
|
zap.String("error", err.Error()))
|
||||||
|
@ -73,11 +78,13 @@ func (gp *Processor) processAlphabetSync() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Update notary role in side chain.
|
if !gp.notaryDisabled {
|
||||||
err = gp.morphClient.UpdateNotaryList(newAlphabet)
|
// 3. Update notary role in side chain.
|
||||||
if err != nil {
|
err = gp.morphClient.UpdateNotaryList(newAlphabet)
|
||||||
gp.log.Error("can't update list of notary nodes in side chain",
|
if err != nil {
|
||||||
zap.String("error", err.Error()))
|
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.
|
// 4. Update NeoFS contract in main net.
|
||||||
|
@ -88,7 +95,7 @@ func (gp *Processor) processAlphabetSync() {
|
||||||
|
|
||||||
id := append([]byte(alphabetUpdateIDPrefix), buf...)
|
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 {
|
if err != nil {
|
||||||
gp.log.Error("can't update list of alphabet nodes in neofs contract",
|
gp.log.Error("can't update list of alphabet nodes in neofs contract",
|
||||||
zap.String("error", err.Error()))
|
zap.String("error", err.Error()))
|
||||||
|
|
|
@ -3,6 +3,7 @@ package governance
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
"github.com/panjf2000/ants/v2"
|
"github.com/panjf2000/ants/v2"
|
||||||
|
@ -33,9 +34,10 @@ type (
|
||||||
|
|
||||||
// Processor of events related to governance in the network.
|
// Processor of events related to governance in the network.
|
||||||
Processor struct {
|
Processor struct {
|
||||||
log *zap.Logger
|
log *zap.Logger
|
||||||
pool *ants.Pool
|
pool *ants.Pool
|
||||||
neofsContract util.Uint160
|
neofsContract util.Uint160
|
||||||
|
netmapContract util.Uint160
|
||||||
|
|
||||||
alphabetState AlphabetState
|
alphabetState AlphabetState
|
||||||
epochState EpochState
|
epochState EpochState
|
||||||
|
@ -43,12 +45,16 @@ type (
|
||||||
|
|
||||||
mainnetClient *client.Client
|
mainnetClient *client.Client
|
||||||
morphClient *client.Client
|
morphClient *client.Client
|
||||||
|
|
||||||
|
notaryDisabled bool
|
||||||
|
feeProvider *config.FeeConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// Params of the processor constructor.
|
// Params of the processor constructor.
|
||||||
Params struct {
|
Params struct {
|
||||||
Log *zap.Logger
|
Log *zap.Logger
|
||||||
NeoFSContract util.Uint160
|
NeoFSContract util.Uint160
|
||||||
|
NetmapContract util.Uint160
|
||||||
|
|
||||||
AlphabetState AlphabetState
|
AlphabetState AlphabetState
|
||||||
EpochState EpochState
|
EpochState EpochState
|
||||||
|
@ -56,6 +62,9 @@ type (
|
||||||
|
|
||||||
MorphClient *client.Client
|
MorphClient *client.Client
|
||||||
MainnetClient *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")
|
return nil, errors.New("ir/governance: global state is not set")
|
||||||
case p.Voter == nil:
|
case p.Voter == nil:
|
||||||
return nil, errors.New("ir/governance: global state is not set")
|
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))
|
pool, err := ants.NewPool(ProcessorPoolSize, ants.WithNonblocking(true))
|
||||||
|
@ -82,14 +93,17 @@ func New(p *Params) (*Processor, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Processor{
|
return &Processor{
|
||||||
log: p.Log,
|
log: p.Log,
|
||||||
pool: pool,
|
pool: pool,
|
||||||
neofsContract: p.NeoFSContract,
|
neofsContract: p.NeoFSContract,
|
||||||
alphabetState: p.AlphabetState,
|
netmapContract: p.NetmapContract,
|
||||||
epochState: p.EpochState,
|
alphabetState: p.AlphabetState,
|
||||||
voter: p.Voter,
|
epochState: p.EpochState,
|
||||||
mainnetClient: p.MainnetClient,
|
voter: p.Voter,
|
||||||
morphClient: p.MorphClient,
|
mainnetClient: p.MainnetClient,
|
||||||
|
morphClient: p.MorphClient,
|
||||||
|
notaryDisabled: p.NotaryDisabled,
|
||||||
|
feeProvider: p.FeeProvider,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ func (np *Processor) processDeposit(deposit *neofsEvent.Deposit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// send transferX to balance contract
|
// send transferX to balance contract
|
||||||
err := invoke.Mint(np.morphClient, np.balanceContract,
|
err := invoke.Mint(np.morphClient, np.balanceContract, np.feeProvider,
|
||||||
&invoke.MintBurnParams{
|
&invoke.MintBurnParams{
|
||||||
ScriptHash: deposit.To().BytesBE(),
|
ScriptHash: deposit.To().BytesBE(),
|
||||||
Amount: np.converter.ToBalancePrecision(deposit.Amount()),
|
Amount: np.converter.ToBalancePrecision(deposit.Amount()),
|
||||||
|
@ -94,7 +94,7 @@ func (np *Processor) processWithdraw(withdraw *neofsEvent.Withdraw) {
|
||||||
|
|
||||||
curEpoch := np.epochState.EpochCounter()
|
curEpoch := np.epochState.EpochCounter()
|
||||||
|
|
||||||
err = invoke.LockAsset(np.morphClient, np.balanceContract,
|
err = invoke.LockAsset(np.morphClient, np.balanceContract, np.feeProvider,
|
||||||
&invoke.LockParams{
|
&invoke.LockParams{
|
||||||
ID: withdraw.ID(),
|
ID: withdraw.ID(),
|
||||||
User: withdraw.User(),
|
User: withdraw.User(),
|
||||||
|
@ -115,7 +115,7 @@ func (np *Processor) processCheque(cheque *neofsEvent.Cheque) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := invoke.Burn(np.morphClient, np.balanceContract,
|
err := invoke.Burn(np.morphClient, np.balanceContract, np.feeProvider,
|
||||||
&invoke.MintBurnParams{
|
&invoke.MintBurnParams{
|
||||||
ScriptHash: cheque.LockAccount().BytesBE(),
|
ScriptHash: cheque.LockAccount().BytesBE(),
|
||||||
Amount: np.converter.ToBalancePrecision(cheque.Amount()),
|
Amount: np.converter.ToBalancePrecision(cheque.Amount()),
|
||||||
|
|
|
@ -14,7 +14,7 @@ func (np *Processor) processConfig(config *neofsEvent.Config) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := invoke.SetConfig(np.morphClient, np.netmapContract,
|
err := invoke.SetConfig(np.morphClient, np.netmapContract, np.feeProvider,
|
||||||
&invoke.SetConfigArgs{
|
&invoke.SetConfigArgs{
|
||||||
ID: config.ID(),
|
ID: config.ID(),
|
||||||
Key: config.Key(),
|
Key: config.Key(),
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
lru "github.com/hashicorp/golang-lru"
|
lru "github.com/hashicorp/golang-lru"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
neofsEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/neofs"
|
neofsEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/neofs"
|
||||||
|
@ -41,6 +42,7 @@ type (
|
||||||
epochState EpochState
|
epochState EpochState
|
||||||
alphabetState AlphabetState
|
alphabetState AlphabetState
|
||||||
converter PrecisionConverter
|
converter PrecisionConverter
|
||||||
|
feeProvider *config.FeeConfig
|
||||||
mintEmitLock *sync.Mutex
|
mintEmitLock *sync.Mutex
|
||||||
mintEmitCache *lru.Cache
|
mintEmitCache *lru.Cache
|
||||||
mintEmitThreshold uint64
|
mintEmitThreshold uint64
|
||||||
|
@ -59,6 +61,7 @@ type (
|
||||||
EpochState EpochState
|
EpochState EpochState
|
||||||
AlphabetState AlphabetState
|
AlphabetState AlphabetState
|
||||||
Converter PrecisionConverter
|
Converter PrecisionConverter
|
||||||
|
FeeProvider *config.FeeConfig
|
||||||
MintEmitCacheSize int
|
MintEmitCacheSize int
|
||||||
MintEmitThreshold uint64 // in epochs
|
MintEmitThreshold uint64 // in epochs
|
||||||
MintEmitValue fixedn.Fixed8
|
MintEmitValue fixedn.Fixed8
|
||||||
|
@ -86,6 +89,8 @@ func New(p *Params) (*Processor, error) {
|
||||||
return nil, errors.New("ir/neofs: global state is not set")
|
return nil, errors.New("ir/neofs: global state is not set")
|
||||||
case p.Converter == nil:
|
case p.Converter == nil:
|
||||||
return nil, errors.New("ir/neofs: balance precision converter is not set")
|
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))
|
p.Log.Debug("neofs worker pool", zap.Int("size", p.PoolSize))
|
||||||
|
@ -110,6 +115,7 @@ func New(p *Params) (*Processor, error) {
|
||||||
epochState: p.EpochState,
|
epochState: p.EpochState,
|
||||||
alphabetState: p.AlphabetState,
|
alphabetState: p.AlphabetState,
|
||||||
converter: p.Converter,
|
converter: p.Converter,
|
||||||
|
feeProvider: p.FeeProvider,
|
||||||
mintEmitLock: new(sync.Mutex),
|
mintEmitLock: new(sync.Mutex),
|
||||||
mintEmitCache: lruCache,
|
mintEmitCache: lruCache,
|
||||||
mintEmitThreshold: p.MintEmitThreshold,
|
mintEmitThreshold: p.MintEmitThreshold,
|
||||||
|
|
|
@ -25,10 +25,11 @@ func (np *Processor) processNetmapCleanupTick(epoch uint64) {
|
||||||
|
|
||||||
np.log.Info("vote to remove node from netmap", zap.String("key", s))
|
np.log.Info("vote to remove node from netmap", zap.String("key", s))
|
||||||
|
|
||||||
err = invoke.UpdatePeerState(np.morphClient, np.netmapContract, &invoke.UpdatePeerArgs{
|
err = invoke.UpdatePeerState(np.morphClient, np.netmapContract, np.feeProvider,
|
||||||
Key: key,
|
&invoke.UpdatePeerArgs{
|
||||||
Status: netmap.NodeStateOffline,
|
Key: key,
|
||||||
})
|
Status: netmap.NodeStateOffline,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
np.log.Error("can't invoke netmap.UpdateState", zap.Error(err))
|
np.log.Error("can't invoke netmap.UpdateState", zap.Error(err))
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,12 @@ func (np *Processor) processNewEpoch(epoch uint64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if epoch > 0 { // estimates are invalid in genesis epoch
|
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 {
|
if err != nil {
|
||||||
np.log.Warn("can't start container size estimation",
|
np.log.Warn("can't start container size estimation",
|
||||||
zap.Uint64("epoch", epoch),
|
zap.Uint64("epoch", epoch),
|
||||||
|
@ -52,7 +57,7 @@ func (np *Processor) processNewEpochTick() {
|
||||||
nextEpoch := np.epochState.EpochCounter() + 1
|
nextEpoch := np.epochState.EpochCounter() + 1
|
||||||
np.log.Debug("next epoch", zap.Uint64("value", nextEpoch))
|
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 {
|
if err != nil {
|
||||||
np.log.Error("can't invoke netmap.NewEpoch", zap.Error(err))
|
np.log.Error("can't invoke netmap.NewEpoch", zap.Error(err))
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,8 @@ func (np *Processor) processAddPeer(node []byte) {
|
||||||
np.log.Info("approving network map candidate",
|
np.log.Info("approving network map candidate",
|
||||||
zap.String("key", keyString))
|
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))
|
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
|
// again before new epoch will tick
|
||||||
np.netmapSnapshot.flag(hex.EncodeToString(ev.PublicKey().Bytes()))
|
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{
|
&invoke.UpdatePeerArgs{
|
||||||
Key: ev.PublicKey(),
|
Key: ev.PublicKey(),
|
||||||
Status: ev.Status(),
|
Status: ev.Status(),
|
||||||
|
|
|
@ -3,6 +3,7 @@ package netmap
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
"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"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||||
container "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
|
container "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
|
@ -64,6 +65,9 @@ type (
|
||||||
handleAlphabetSync event.Handler
|
handleAlphabetSync event.Handler
|
||||||
|
|
||||||
nodeValidator NodeValidator
|
nodeValidator NodeValidator
|
||||||
|
|
||||||
|
notaryDisabled bool
|
||||||
|
feeProvider *config.FeeConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// Params of the processor constructor.
|
// Params of the processor constructor.
|
||||||
|
@ -84,6 +88,9 @@ type (
|
||||||
AlphabetSyncHandler event.Handler
|
AlphabetSyncHandler event.Handler
|
||||||
|
|
||||||
NodeValidator NodeValidator
|
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")
|
return nil, errors.New("ir/netmap: container contract wrapper is not set")
|
||||||
case p.NodeValidator == nil:
|
case p.NodeValidator == nil:
|
||||||
return nil, errors.New("ir/netmap: node validator is not set")
|
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))
|
p.Log.Debug("netmap worker pool", zap.Int("size", p.PoolSize))
|
||||||
|
@ -142,6 +151,9 @@ func New(p *Params) (*Processor, error) {
|
||||||
handleAlphabetSync: p.AlphabetSyncHandler,
|
handleAlphabetSync: p.AlphabetSyncHandler,
|
||||||
|
|
||||||
nodeValidator: p.NodeValidator,
|
nodeValidator: p.NodeValidator,
|
||||||
|
|
||||||
|
notaryDisabled: p.NotaryDisabled,
|
||||||
|
feeProvider: p.FeeProvider,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,14 @@ func (rp *Processor) processPut(epoch uint64, id reputation.PeerID, value reputa
|
||||||
args.SetPeerID(id)
|
args.SetPeerID(id)
|
||||||
args.SetValue(value)
|
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 {
|
if err != nil {
|
||||||
rp.log.Warn("can't send approval tx for reputation value",
|
rp.log.Warn("can't send approval tx for reputation value",
|
||||||
zap.String("peer_id", hex.EncodeToString(id.ToV2().GetValue())),
|
zap.String("peer_id", hex.EncodeToString(id.ToV2().GetValue())),
|
||||||
|
|
|
@ -26,6 +26,8 @@ type (
|
||||||
log *zap.Logger
|
log *zap.Logger
|
||||||
pool *ants.Pool
|
pool *ants.Pool
|
||||||
|
|
||||||
|
notaryDisabled bool
|
||||||
|
|
||||||
reputationContract util.Uint160
|
reputationContract util.Uint160
|
||||||
|
|
||||||
epochState EpochState
|
epochState EpochState
|
||||||
|
@ -38,6 +40,7 @@ type (
|
||||||
Params struct {
|
Params struct {
|
||||||
Log *zap.Logger
|
Log *zap.Logger
|
||||||
PoolSize int
|
PoolSize int
|
||||||
|
NotaryDisabled bool
|
||||||
ReputationContract util.Uint160
|
ReputationContract util.Uint160
|
||||||
EpochState EpochState
|
EpochState EpochState
|
||||||
AlphabetState AlphabetState
|
AlphabetState AlphabetState
|
||||||
|
@ -72,6 +75,7 @@ func New(p *Params) (*Processor, error) {
|
||||||
return &Processor{
|
return &Processor{
|
||||||
log: p.Log,
|
log: p.Log,
|
||||||
pool: pool,
|
pool: pool,
|
||||||
|
notaryDisabled: p.NotaryDisabled,
|
||||||
reputationContract: p.ReputationContract,
|
reputationContract: p.ReputationContract,
|
||||||
epochState: p.EpochState,
|
epochState: p.EpochState,
|
||||||
alphabetState: p.AlphabetState,
|
alphabetState: p.AlphabetState,
|
||||||
|
|
Loading…
Reference in a new issue