forked from TrueCloudLab/frostfs-node
Move to frostfs-node
Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
This commit is contained in:
parent
42554a9298
commit
923f84722a
934 changed files with 3470 additions and 3451 deletions
|
@ -1,16 +1,16 @@
|
|||
package neofs
|
||||
package frostfs
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
|
||||
"github.com/TrueCloudLab/frostfs-node/pkg/morph/event"
|
||||
frostfsEvent "github.com/TrueCloudLab/frostfs-node/pkg/morph/event/neofs"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util/slice"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
neofsEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/neofs"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func (np *Processor) handleDeposit(ev event.Event) {
|
||||
deposit := ev.(neofsEvent.Deposit)
|
||||
deposit := ev.(frostfsEvent.Deposit)
|
||||
np.log.Info("notification",
|
||||
zap.String("type", "deposit"),
|
||||
zap.String("id", hex.EncodeToString(slice.CopyReverse(deposit.ID()))))
|
||||
|
@ -20,13 +20,13 @@ func (np *Processor) handleDeposit(ev event.Event) {
|
|||
err := np.pool.Submit(func() { np.processDeposit(&deposit) })
|
||||
if err != nil {
|
||||
// there system can be moved into controlled degradation stage
|
||||
np.log.Warn("neofs processor worker pool drained",
|
||||
np.log.Warn("frostfs processor worker pool drained",
|
||||
zap.Int("capacity", np.pool.Cap()))
|
||||
}
|
||||
}
|
||||
|
||||
func (np *Processor) handleWithdraw(ev event.Event) {
|
||||
withdraw := ev.(neofsEvent.Withdraw)
|
||||
withdraw := ev.(frostfsEvent.Withdraw)
|
||||
np.log.Info("notification",
|
||||
zap.String("type", "withdraw"),
|
||||
zap.String("id", hex.EncodeToString(slice.CopyReverse(withdraw.ID()))))
|
||||
|
@ -36,13 +36,13 @@ func (np *Processor) handleWithdraw(ev event.Event) {
|
|||
err := np.pool.Submit(func() { np.processWithdraw(&withdraw) })
|
||||
if err != nil {
|
||||
// there system can be moved into controlled degradation stage
|
||||
np.log.Warn("neofs processor worker pool drained",
|
||||
np.log.Warn("frostfs processor worker pool drained",
|
||||
zap.Int("capacity", np.pool.Cap()))
|
||||
}
|
||||
}
|
||||
|
||||
func (np *Processor) handleCheque(ev event.Event) {
|
||||
cheque := ev.(neofsEvent.Cheque)
|
||||
cheque := ev.(frostfsEvent.Cheque)
|
||||
np.log.Info("notification",
|
||||
zap.String("type", "cheque"),
|
||||
zap.String("id", hex.EncodeToString(cheque.ID())))
|
||||
|
@ -52,13 +52,13 @@ func (np *Processor) handleCheque(ev event.Event) {
|
|||
err := np.pool.Submit(func() { np.processCheque(&cheque) })
|
||||
if err != nil {
|
||||
// there system can be moved into controlled degradation stage
|
||||
np.log.Warn("neofs processor worker pool drained",
|
||||
np.log.Warn("frostfs processor worker pool drained",
|
||||
zap.Int("capacity", np.pool.Cap()))
|
||||
}
|
||||
}
|
||||
|
||||
func (np *Processor) handleConfig(ev event.Event) {
|
||||
cfg := ev.(neofsEvent.Config)
|
||||
cfg := ev.(frostfsEvent.Config)
|
||||
np.log.Info("notification",
|
||||
zap.String("type", "set config"),
|
||||
zap.String("key", hex.EncodeToString(cfg.Key())),
|
||||
|
@ -69,13 +69,13 @@ func (np *Processor) handleConfig(ev event.Event) {
|
|||
err := np.pool.Submit(func() { np.processConfig(&cfg) })
|
||||
if err != nil {
|
||||
// there system can be moved into controlled degradation stage
|
||||
np.log.Warn("neofs processor worker pool drained",
|
||||
np.log.Warn("frostfs processor worker pool drained",
|
||||
zap.Int("capacity", np.pool.Cap()))
|
||||
}
|
||||
}
|
||||
|
||||
func (np *Processor) handleBind(ev event.Event) {
|
||||
e := ev.(neofsEvent.Bind)
|
||||
e := ev.(frostfsEvent.Bind)
|
||||
np.log.Info("notification",
|
||||
zap.String("type", "bind"),
|
||||
)
|
||||
|
@ -85,13 +85,13 @@ func (np *Processor) handleBind(ev event.Event) {
|
|||
err := np.pool.Submit(func() { np.processBind(e) })
|
||||
if err != nil {
|
||||
// there system can be moved into controlled degradation stage
|
||||
np.log.Warn("neofs processor worker pool drained",
|
||||
np.log.Warn("frostfs processor worker pool drained",
|
||||
zap.Int("capacity", np.pool.Cap()))
|
||||
}
|
||||
}
|
||||
|
||||
func (np *Processor) handleUnbind(ev event.Event) {
|
||||
e := ev.(neofsEvent.Unbind)
|
||||
e := ev.(frostfsEvent.Unbind)
|
||||
np.log.Info("notification",
|
||||
zap.String("type", "unbind"),
|
||||
)
|
||||
|
@ -101,7 +101,7 @@ func (np *Processor) handleUnbind(ev event.Event) {
|
|||
err := np.pool.Submit(func() { np.processBind(e) })
|
||||
if err != nil {
|
||||
// there system can be moved into controlled degradation stage
|
||||
np.log.Warn("neofs processor worker pool drained",
|
||||
np.log.Warn("frostfs processor worker pool drained",
|
||||
zap.Int("capacity", np.pool.Cap()))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package neofs
|
||||
package frostfs
|
||||
|
||||
import (
|
||||
"github.com/TrueCloudLab/frostfs-node/pkg/morph/client/balance"
|
||||
frostfsEvent "github.com/TrueCloudLab/frostfs-node/pkg/morph/event/neofs"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
|
||||
neofsEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/neofs"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@ -14,7 +14,7 @@ const (
|
|||
|
||||
// Process deposit event by invoking a balance contract and sending native
|
||||
// gas in the sidechain.
|
||||
func (np *Processor) processDeposit(deposit *neofsEvent.Deposit) {
|
||||
func (np *Processor) processDeposit(deposit *frostfsEvent.Deposit) {
|
||||
if !np.alphabetState.IsAlphabet() {
|
||||
np.log.Info("non alphabet mode, ignore deposit")
|
||||
return
|
||||
|
@ -79,7 +79,7 @@ func (np *Processor) processDeposit(deposit *neofsEvent.Deposit) {
|
|||
}
|
||||
|
||||
// Process withdraw event by locking assets in the balance account.
|
||||
func (np *Processor) processWithdraw(withdraw *neofsEvent.Withdraw) {
|
||||
func (np *Processor) processWithdraw(withdraw *frostfsEvent.Withdraw) {
|
||||
if !np.alphabetState.IsAlphabet() {
|
||||
np.log.Info("non alphabet mode, ignore withdraw")
|
||||
return
|
||||
|
@ -110,7 +110,7 @@ func (np *Processor) processWithdraw(withdraw *neofsEvent.Withdraw) {
|
|||
|
||||
// Process cheque event by transferring assets from the lock account back to
|
||||
// the reserve account.
|
||||
func (np *Processor) processCheque(cheque *neofsEvent.Cheque) {
|
||||
func (np *Processor) processCheque(cheque *frostfsEvent.Cheque) {
|
||||
if !np.alphabetState.IsAlphabet() {
|
||||
np.log.Info("non alphabet mode, ignore cheque")
|
||||
return
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package neofs
|
||||
package frostfs
|
||||
|
||||
import (
|
||||
"crypto/elliptic"
|
||||
"fmt"
|
||||
|
||||
"github.com/TrueCloudLab/frostfs-node/pkg/morph/client/neofsid"
|
||||
frostfs "github.com/TrueCloudLab/frostfs-node/pkg/morph/event/neofs"
|
||||
"github.com/TrueCloudLab/frostfs-sdk-go/user"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/neofsid"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event/neofs"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@ -28,7 +28,7 @@ func (np *Processor) processBind(e bindCommon) {
|
|||
bindCommon: e,
|
||||
}
|
||||
|
||||
_, c.bind = e.(neofs.Bind)
|
||||
_, c.bind = e.(frostfs.Bind)
|
||||
|
||||
err := np.checkBindCommon(c)
|
||||
if err != nil {
|
||||
|
@ -95,10 +95,10 @@ func (np *Processor) approveBindCommon(e *bindCommonContext) {
|
|||
var typ string
|
||||
if e.bind {
|
||||
typ = "bind"
|
||||
err = np.neofsIDClient.AddKeys(prm)
|
||||
err = np.frostfsIDClient.AddKeys(prm)
|
||||
} else {
|
||||
typ = "unbind"
|
||||
err = np.neofsIDClient.RemoveKeys(prm)
|
||||
err = np.frostfsIDClient.RemoveKeys(prm)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package neofs
|
||||
package frostfs
|
||||
|
||||
import (
|
||||
nmClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
||||
neofsEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/neofs"
|
||||
nmClient "github.com/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
||||
frostfsEvent "github.com/TrueCloudLab/frostfs-node/pkg/morph/event/neofs"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// Process config event by setting configuration value from the mainchain in
|
||||
// the sidechain.
|
||||
func (np *Processor) processConfig(config *neofsEvent.Config) {
|
||||
func (np *Processor) processConfig(config *frostfsEvent.Config) {
|
||||
if !np.alphabetState.IsAlphabet() {
|
||||
np.log.Info("non alphabet mode, ignore config")
|
||||
return
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
package neofs
|
||||
package frostfs
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||
"github.com/TrueCloudLab/frostfs-node/pkg/morph/client/balance"
|
||||
"github.com/TrueCloudLab/frostfs-node/pkg/morph/client/neofsid"
|
||||
nmClient "github.com/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
||||
"github.com/TrueCloudLab/frostfs-node/pkg/morph/event"
|
||||
frostfsEvent "github.com/TrueCloudLab/frostfs-node/pkg/morph/event/neofs"
|
||||
"github.com/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||
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/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/neofsid"
|
||||
nmClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
neofsEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/neofs"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
||||
"github.com/panjf2000/ants/v2"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@ -35,11 +35,11 @@ type (
|
|||
ToBalancePrecision(int64) int64
|
||||
}
|
||||
|
||||
// Processor of events produced by neofs contract in main net.
|
||||
// Processor of events produced by frostfs contract in main net.
|
||||
Processor struct {
|
||||
log *logger.Logger
|
||||
pool *ants.Pool
|
||||
neofsContract util.Uint160
|
||||
frostfsContract util.Uint160
|
||||
balanceClient *balance.Client
|
||||
netmapClient *nmClient.Client
|
||||
morphClient *client.Client
|
||||
|
@ -52,7 +52,7 @@ type (
|
|||
mintEmitValue fixedn.Fixed8
|
||||
gasBalanceThreshold int64
|
||||
|
||||
neofsIDClient *neofsid.Client
|
||||
frostfsIDClient *neofsid.Client
|
||||
}
|
||||
|
||||
// Params of the processor constructor.
|
||||
|
@ -83,37 +83,37 @@ const (
|
|||
unbindNotification = "Unbind"
|
||||
)
|
||||
|
||||
// New creates neofs mainnet contract processor instance.
|
||||
// New creates frostfs mainnet contract processor instance.
|
||||
func New(p *Params) (*Processor, error) {
|
||||
switch {
|
||||
case p.Log == nil:
|
||||
return nil, errors.New("ir/neofs: logger is not set")
|
||||
return nil, errors.New("ir/frostfs: logger is not set")
|
||||
case p.MorphClient == nil:
|
||||
return nil, errors.New("ir/neofs: neo:morph client is not set")
|
||||
return nil, errors.New("ir/frostfs: neo:morph client is not set")
|
||||
case p.EpochState == nil:
|
||||
return nil, errors.New("ir/neofs: global state is not set")
|
||||
return nil, errors.New("ir/frostfs: global state is not set")
|
||||
case p.AlphabetState == nil:
|
||||
return nil, errors.New("ir/neofs: global state is not set")
|
||||
return nil, errors.New("ir/frostfs: global state is not set")
|
||||
case p.Converter == nil:
|
||||
return nil, errors.New("ir/neofs: balance precision converter is not set")
|
||||
return nil, errors.New("ir/frostfs: balance precision converter is not set")
|
||||
}
|
||||
|
||||
p.Log.Debug("neofs worker pool", zap.Int("size", p.PoolSize))
|
||||
p.Log.Debug("frostfs worker pool", zap.Int("size", p.PoolSize))
|
||||
|
||||
pool, err := ants.NewPool(p.PoolSize, ants.WithNonblocking(true))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ir/neofs: can't create worker pool: %w", err)
|
||||
return nil, fmt.Errorf("ir/frostfs: can't create worker pool: %w", err)
|
||||
}
|
||||
|
||||
lruCache, err := lru.New(p.MintEmitCacheSize)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ir/neofs: can't create LRU cache for gas emission: %w", err)
|
||||
return nil, fmt.Errorf("ir/frostfs: can't create LRU cache for gas emission: %w", err)
|
||||
}
|
||||
|
||||
return &Processor{
|
||||
log: p.Log,
|
||||
pool: pool,
|
||||
neofsContract: p.NeoFSContract,
|
||||
frostfsContract: p.NeoFSContract,
|
||||
balanceClient: p.BalanceClient,
|
||||
netmapClient: p.NetmapClient,
|
||||
morphClient: p.MorphClient,
|
||||
|
@ -126,7 +126,7 @@ func New(p *Params) (*Processor, error) {
|
|||
mintEmitValue: p.MintEmitValue,
|
||||
gasBalanceThreshold: p.GasBalanceThreshold,
|
||||
|
||||
neofsIDClient: p.NeoFSIDClient,
|
||||
frostfsIDClient: p.NeoFSIDClient,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -138,36 +138,36 @@ func (np *Processor) ListenerNotificationParsers() []event.NotificationParserInf
|
|||
p event.NotificationParserInfo
|
||||
)
|
||||
|
||||
p.SetScriptHash(np.neofsContract)
|
||||
p.SetScriptHash(np.frostfsContract)
|
||||
|
||||
// deposit event
|
||||
p.SetType(event.TypeFromString(depositNotification))
|
||||
p.SetParser(neofsEvent.ParseDeposit)
|
||||
p.SetParser(frostfsEvent.ParseDeposit)
|
||||
parsers = append(parsers, p)
|
||||
|
||||
// withdraw event
|
||||
p.SetType(event.TypeFromString(withdrawNotification))
|
||||
p.SetParser(neofsEvent.ParseWithdraw)
|
||||
p.SetParser(frostfsEvent.ParseWithdraw)
|
||||
parsers = append(parsers, p)
|
||||
|
||||
// cheque event
|
||||
p.SetType(event.TypeFromString(chequeNotification))
|
||||
p.SetParser(neofsEvent.ParseCheque)
|
||||
p.SetParser(frostfsEvent.ParseCheque)
|
||||
parsers = append(parsers, p)
|
||||
|
||||
// config event
|
||||
p.SetType(event.TypeFromString(configNotification))
|
||||
p.SetParser(neofsEvent.ParseConfig)
|
||||
p.SetParser(frostfsEvent.ParseConfig)
|
||||
parsers = append(parsers, p)
|
||||
|
||||
// bind event
|
||||
p.SetType(event.TypeFromString(bindNotification))
|
||||
p.SetParser(neofsEvent.ParseBind)
|
||||
p.SetParser(frostfsEvent.ParseBind)
|
||||
parsers = append(parsers, p)
|
||||
|
||||
// unbind event
|
||||
p.SetType(event.TypeFromString(unbindNotification))
|
||||
p.SetParser(neofsEvent.ParseUnbind)
|
||||
p.SetParser(frostfsEvent.ParseUnbind)
|
||||
parsers = append(parsers, p)
|
||||
|
||||
return parsers
|
||||
|
@ -181,7 +181,7 @@ func (np *Processor) ListenerNotificationHandlers() []event.NotificationHandlerI
|
|||
h event.NotificationHandlerInfo
|
||||
)
|
||||
|
||||
h.SetScriptHash(np.neofsContract)
|
||||
h.SetScriptHash(np.frostfsContract)
|
||||
|
||||
// deposit handler
|
||||
h.SetType(event.TypeFromString(depositNotification))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue