diff --git a/pkg/morph/event/listener.go b/pkg/morph/event/listener.go index 405165702b..ca5031415f 100644 --- a/pkg/morph/event/listener.go +++ b/pkg/morph/event/listener.go @@ -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, diff --git a/pkg/morph/event/notary_preparator.go b/pkg/morph/event/notary_preparator.go index a8b7376fa6..298a6d574e 100644 --- a/pkg/morph/event/notary_preparator.go +++ b/pkg/morph/event/notary_preparator.go @@ -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 diff --git a/pkg/morph/event/notary_preparator_test.go b/pkg/morph/event/notary_preparator_test.go index b2e46890b5..8da9d868a8 100644 --- a/pkg/morph/event/notary_preparator_test.go +++ b/pkg/morph/event/notary_preparator_test.go @@ -331,7 +331,7 @@ func TestPrepare_IncorrectNR(t *testing.T) { {}, }, }, - expErr: ErrMainTXExpired, + expErr: &ExpiredTXError{}, }, { name: "incorrect invoker TX Alphabet witness",