forked from TrueCloudLab/frostfs-node
[#484] morph: Add expired tx logging
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
26acf5689e
commit
8d16d95376
3 changed files with 19 additions and 6 deletions
|
@ -365,11 +365,14 @@ func (l *listener) parseAndHandleNotary(nr *result.NotaryRequestEvent) {
|
|||
// prepare the notary event
|
||||
notaryEvent, err := l.notaryEventsPreparator.Prepare(nr.NotaryRequest)
|
||||
if err != nil {
|
||||
var expErr *ExpiredTXError
|
||||
switch {
|
||||
case errors.Is(err, ErrTXAlreadyHandled):
|
||||
case errors.Is(err, ErrMainTXExpired):
|
||||
case errors.As(err, &expErr):
|
||||
l.log.Warn(logs.EventSkipExpiredMainTXNotaryEvent,
|
||||
zap.String("error", err.Error()),
|
||||
zap.Uint32("current_block_height", expErr.CurrentBlockHeight),
|
||||
zap.Uint32("fallback_tx_not_valid_before_height", expErr.FallbackTXNotValidBeforeHeight),
|
||||
)
|
||||
default:
|
||||
l.log.Warn(logs.EventCouldNotPrepareAndValidateNotaryEvent,
|
||||
|
|
|
@ -39,11 +39,18 @@ var (
|
|||
|
||||
// ErrTXAlreadyHandled is returned if received TX has already been signed.
|
||||
ErrTXAlreadyHandled = errors.New("received main tx has already been handled")
|
||||
|
||||
// ErrMainTXExpired is returned if received fallback TX is already valid.
|
||||
ErrMainTXExpired = errors.New("received main tx has expired")
|
||||
)
|
||||
|
||||
// ExpiredTXError is returned if received fallback TX is already valid.
|
||||
type ExpiredTXError struct {
|
||||
CurrentBlockHeight uint32
|
||||
FallbackTXNotValidBeforeHeight uint32
|
||||
}
|
||||
|
||||
func (e *ExpiredTXError) Error() string {
|
||||
return "received main tx has expired"
|
||||
}
|
||||
|
||||
// BlockCounter must return block count of the network
|
||||
// from which notary requests are received.
|
||||
type BlockCounter interface {
|
||||
|
@ -308,7 +315,10 @@ func (p Preparator) validateExpiration(fbTX *transaction.Transaction) error {
|
|||
}
|
||||
|
||||
if currBlock >= nvb.Height {
|
||||
return ErrMainTXExpired
|
||||
return &ExpiredTXError{
|
||||
CurrentBlockHeight: currBlock,
|
||||
FallbackTXNotValidBeforeHeight: nvb.Height,
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -331,7 +331,7 @@ func TestPrepare_IncorrectNR(t *testing.T) {
|
|||
{},
|
||||
},
|
||||
},
|
||||
expErr: ErrMainTXExpired,
|
||||
expErr: &ExpiredTXError{},
|
||||
},
|
||||
{
|
||||
name: "incorrect invoker TX Alphabet witness",
|
||||
|
|
Loading…
Reference in a new issue