Improvements here and there about notary deposits. #184

Merged
fyrchik merged 4 commits from carpawell/frostfs-node:fix/notary-deposit into master 2023-03-29 10:34:55 +00:00
6 changed files with 25 additions and 11 deletions

View file

@ -117,6 +117,14 @@ func makeAndWaitNotaryDeposit(c *cfg) {
tx, err := makeNotaryDeposit(c)
fatalOnErr(err)
if tx.Equals(util.Uint256{}) {
// non-error deposit with an empty TX hash means
// that the deposit has already been made; no
// need to wait it.
c.log.Info("notary deposit has already been made")
return
}
err = waitNotaryDeposit(c, tx)
fatalOnErr(err)
}

View file

@ -13,7 +13,7 @@ import (
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/audit"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/balance"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/container"
frostfs "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/frostfs"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/frostfs"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/governance"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap"
nodevalidator "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap/nodevalidation"
@ -411,8 +411,7 @@ func New(ctx context.Context, log *logger.Logger, cfg *viper.Viper, errChan chan
}
}
server.mainNotaryConfig, server.sideNotaryConfig = parseNotaryConfigs(
cfg,
server.mainNotaryConfig, server.sideNotaryConfig = notaryConfigs(
server.morphClient.ProbeNotary(),
!server.withoutMainNet && server.mainnetClient.ProbeNotary(), // if mainnet disabled then notary flag must be disabled too
)

View file

@ -7,7 +7,6 @@ import (
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/spf13/viper"
"go.uber.org/zap"
)
@ -79,6 +78,14 @@ func (s *Server) initNotary(ctx context.Context, deposit depositor, await awaite
return err
}
if tx.Equals(util.Uint256{}) {
// non-error deposit with an empty TX hash means
// that the deposit has already been made; no
// need to wait it.
s.log.Info("notary deposit has already been made")
return nil
}
s.log.Info(msg)
return await(ctx, tx)
@ -88,7 +95,7 @@ func awaitNotaryDepositInClient(ctx context.Context, cli *client.Client, txHash
for i := 0; i < notaryDepositTimeout; i++ {
select {
case <-ctx.Done():
return nil
return ctx.Err()
default:
}
@ -107,7 +114,7 @@ func awaitNotaryDepositInClient(ctx context.Context, cli *client.Client, txHash
return errDepositTimeout
}
func parseNotaryConfigs(cfg *viper.Viper, withSideNotary, withMainNotary bool) (main, side *notaryConfig) {
func notaryConfigs(withSideNotary, withMainNotary bool) (main, side *notaryConfig) {
fyrchik marked this conversation as resolved Outdated

Is it really parse after this?

Is it really `parse` after this?

dropped "parse" word, think it is the best thing that fits that PR

dropped "parse" word, think it is the best thing that fits that PR
main = new(notaryConfig)
side = new(notaryConfig)

View file

@ -222,7 +222,7 @@ func (e *StorageEngine) processExpiredLocks(ctx context.Context, lockers []oid.A
select {
case <-ctx.Done():
e.log.Info("interrupt processing the expired locks by context")
e.log.Info("interrupt processing the expired locks", zap.Error(ctx.Err()))
return true
default:
return false
@ -236,7 +236,7 @@ func (e *StorageEngine) processDeletedLocks(ctx context.Context, lockers []oid.A
select {
case <-ctx.Done():
e.log.Info("interrupt processing the deleted locks by context")
e.log.Info("interrupt processing the deleted locks", zap.Error(ctx.Err()))
return true
default:
return false

View file

@ -340,7 +340,7 @@ func (c *Client) Wait(ctx context.Context, n uint32) error {
for {
select {
case <-ctx.Done():
return nil
return ctx.Err()
default:
}

View file

@ -202,7 +202,7 @@ func (c *Client) depositNotary(amount fixedn.Fixed8, till int64) (res util.Uint2
// Transaction is already in mempool waiting to be processed.
// This is an expected situation if we restart the service.
c.logger.Debug("notary deposit has already been made",
c.logger.Info("notary deposit has already been made",
zap.Int64("amount", int64(amount)),
zap.Int64("expire_at", till),
zap.Uint32("vub", vub),
@ -210,7 +210,7 @@ func (c *Client) depositNotary(amount fixedn.Fixed8, till int64) (res util.Uint2
return util.Uint256{}, nil
}
c.logger.Debug("notary deposit invoke",
c.logger.Info("notary deposit invoke",
zap.Int64("amount", int64(amount)),
zap.Int64("expire_at", till),
zap.Uint32("vub", vub),