From 3710f33e14af724ef7aebf541cc2af99e4886bb0 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Sun, 9 Aug 2020 03:17:40 +0200 Subject: [PATCH] Don't reject messages that don't pass RBF, ignore them Signed-off-by: Jakub Sztandera --- chain/messagepool/messagepool.go | 10 ++++++---- chain/sub/incoming.go | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/chain/messagepool/messagepool.go b/chain/messagepool/messagepool.go index 799cb79b5..0d47e488e 100644 --- a/chain/messagepool/messagepool.go +++ b/chain/messagepool/messagepool.go @@ -55,7 +55,8 @@ var ( ErrInvalidToAddr = errors.New("message had invalid to address") - ErrBroadcastAnyway = errors.New("broadcasting message despite validation fail") + ErrBroadcastAnyway = errors.New("broadcasting message despite validation fail") + ErrRBFTooLowPremium = errors.New("replace by fee has too low GasPremium") ) const ( @@ -135,8 +136,9 @@ func (ms *msgSet) add(m *types.SignedMessage, mp *MessagePool) (bool, error) { } else { log.Info("add with duplicate nonce") return false, xerrors.Errorf("message from %s with nonce %d already in mpool,"+ - " increase GasPremium to %s from %s to trigger replace by fee", - m.Message.From, m.Message.Nonce, minPrice, m.Message.GasPremium) + " increase GasPremium to %s from %s to trigger replace by fee: %w", + m.Message.From, m.Message.Nonce, minPrice, m.Message.GasPremium, + ErrRBFTooLowPremium) } } } @@ -517,7 +519,7 @@ func (mp *MessagePool) addLocked(m *types.SignedMessage) error { incr, err := mset.add(m, mp) if err != nil { log.Info(err) - return err // TODO(review): this error return was dropped at some point, was it on purpose? + return err } if incr { diff --git a/chain/sub/incoming.go b/chain/sub/incoming.go index 86f8eeec9..75f23cd3b 100644 --- a/chain/sub/incoming.go +++ b/chain/sub/incoming.go @@ -510,7 +510,7 @@ func (mv *MessageValidator) Validate(ctx context.Context, pid peer.ID, msg *pubs ) stats.Record(ctx, metrics.MessageValidationFailure.M(1)) switch { - case xerrors.Is(err, messagepool.ErrBroadcastAnyway): + case xerrors.Is(err, messagepool.ErrBroadcastAnyway) || xerrors.Is(err, messagepool.ErrRBFTooLowPremium): return pubsub.ValidationIgnore default: return pubsub.ValidationReject