diff --git a/config/config.go b/config/config.go index bb289037a..14c4d419f 100644 --- a/config/config.go +++ b/config/config.go @@ -840,7 +840,7 @@ func DefaultMempoolConfig() *MempoolConfig { MaxPendingTxsBytes: 1024 * 1024 * 1024, // 1GB PendingTTLDuration: 0 * time.Second, PendingTTLNumBlocks: 0, - RemoveExpiredTxsFromQueue: false, + RemoveExpiredTxsFromQueue: true, } } diff --git a/internal/mempool/mempool.go b/internal/mempool/mempool.go index 25e3aa524..25302cc9c 100644 --- a/internal/mempool/mempool.go +++ b/internal/mempool/mempool.go @@ -308,6 +308,16 @@ func (txmp *TxMempool) CheckTx( return types.ErrTxInCache } + // Check if mempool is full before executing CheckTx + numTxs := txmp.NumTxsNotPending() + if numTxs >= txmp.config.Size-1 && txmp.config.Size > 5000 { + return types.ErrMempoolIsFull{ + NumTxs: numTxs, + MaxTxs: txmp.config.Size, + MaxTxsBytes: txmp.config.MaxTxsBytes, + } + } + res, err := txmp.proxyAppConn.CheckTx(ctx, &abci.RequestCheckTx{Tx: tx}) // when a transaction is removed/expired/rejected, this should be called