forked from TrueCloudLab/frostfs-node
[#873] morph/notary: Not warn
at "low till
value" notary deposit error
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
14f01fa953
commit
505d92bb06
1 changed files with 24 additions and 3 deletions
|
@ -186,9 +186,17 @@ func (c *Client) DepositNotary(amount fixedn.Fixed8, delta uint32) (res util.Uin
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if !tillShouldNotBeLessError(err) {
|
||||||
return util.Uint256{}, fmt.Errorf("can't make notary deposit: %w", err)
|
return util.Uint256{}, fmt.Errorf("can't make notary deposit: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.logger.Debug("notary deposit invoke failed due to low `till` value",
|
||||||
|
zap.Int64("amount", int64(amount)),
|
||||||
|
zap.Uint32("till", bc+delta))
|
||||||
|
|
||||||
|
return util.Uint256{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
c.logger.Debug("notary deposit invoke",
|
c.logger.Debug("notary deposit invoke",
|
||||||
zap.Int64("amount", int64(amount)),
|
zap.Int64("amount", int64(amount)),
|
||||||
zap.Uint32("expire_at", bc+delta),
|
zap.Uint32("expire_at", bc+delta),
|
||||||
|
@ -704,8 +712,6 @@ func WithProxyContract(h util.Uint160) NotaryOption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const alreadyOnChainErrorMessage = "already on chain"
|
|
||||||
|
|
||||||
// Neo RPC node can return `core.ErrInvalidAttribute` error with
|
// Neo RPC node can return `core.ErrInvalidAttribute` error with
|
||||||
// `conflicting transaction <> is already on chain` message. This
|
// `conflicting transaction <> is already on chain` message. This
|
||||||
// error is expected and ignored. As soon as main tx persisted on
|
// error is expected and ignored. As soon as main tx persisted on
|
||||||
|
@ -713,9 +719,24 @@ const alreadyOnChainErrorMessage = "already on chain"
|
||||||
// requires 5 out of 7 signatures to send main tx, thus last two
|
// requires 5 out of 7 signatures to send main tx, thus last two
|
||||||
// notary requests may be processed after main tx appeared on chain.
|
// notary requests may be processed after main tx appeared on chain.
|
||||||
func alreadyOnChainError(err error) bool {
|
func alreadyOnChainError(err error) bool {
|
||||||
|
const alreadyOnChainErrorMessage = "already on chain"
|
||||||
|
|
||||||
return strings.Contains(err.Error(), alreadyOnChainErrorMessage)
|
return strings.Contains(err.Error(), alreadyOnChainErrorMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Neo RPC node can return "`till` shouldn't be less then the
|
||||||
|
// previous value <>" message. This error is expected and ignored.
|
||||||
|
// This happens because previous `till` value could be bigger
|
||||||
|
// than the current one due to significant epoch duration decrease.
|
||||||
|
// Theoretically, balance should not run out so fast and such
|
||||||
|
// errors are ignored(at least for now; there is #910 issue
|
||||||
|
// for it).
|
||||||
|
func tillShouldNotBeLessError(err error) bool {
|
||||||
|
const tillTooLowErrorMessage = "less then the previous value"
|
||||||
|
|
||||||
|
return strings.Contains(err.Error(), tillTooLowErrorMessage)
|
||||||
|
}
|
||||||
|
|
||||||
// CalculateNotaryDepositAmount calculates notary deposit amount
|
// CalculateNotaryDepositAmount calculates notary deposit amount
|
||||||
// using the rule:
|
// using the rule:
|
||||||
// IF notaryBalance < gasBalance * gasMul {
|
// IF notaryBalance < gasBalance * gasMul {
|
||||||
|
|
Loading…
Reference in a new issue