diff --git a/chain/messagepool/messagepool.go b/chain/messagepool/messagepool.go index 19168fe9c..8a4229da5 100644 --- a/chain/messagepool/messagepool.go +++ b/chain/messagepool/messagepool.go @@ -50,6 +50,8 @@ var RepublishInterval = pubsub.TimeCacheDuration + time.Duration(5*build.BlockDe var minimumBaseFee = types.NewInt(uint64(build.MinimumBaseFee)) +var MaxActorPendingMessages = 1000 + var ( ErrMessageTooBig = errors.New("message too big") @@ -162,6 +164,11 @@ func (ms *msgSet) add(m *types.SignedMessage, mp *MessagePool) (bool, error) { //ms.requiredFunds.Sub(ms.requiredFunds, exms.Message.Value.Int) } + if !has && len(ms.msgs) > MaxActorPendingMessages { + return false, xerrors.Errorf("too many pending messages for actor in the mpool: %w", + ErrSoftValidationFailure) + } + ms.msgs[m.Message.Nonce] = m ms.requiredFunds.Add(ms.requiredFunds, m.Message.RequiredFunds().Int) //ms.requiredFunds.Add(ms.requiredFunds, m.Message.Value.Int)