Skip to content

Commit f76c659

Browse files
mergify[bot]GAtom22tac0turtlejulienrbrt
authored
fix(mempool): use no-op mempool as default (backport #19970) (#20008)
Co-authored-by: Tom <54514587+GAtom22@users.noreply.github.com> Co-authored-by: marbar3778 <marbar3778@yahoo.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
1 parent 525b720 commit f76c659

File tree

8 files changed

+15
-14
lines changed

8 files changed

+15
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
5656
## Bug Fixes
5757

5858
* (crypto) [#19691](https://github.com/cosmos/cosmos-sdk/pull/19745) Fix tx sign doesn't throw an error when incorrect Ledger is used.
59+
* (baseapp) [#19970](https://github.com/cosmos/cosmos-sdk/pull/19970) Fix default config values to use no-op mempool as default.
5960

6061
## [v0.50.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.5) - 2024-03-12
6162

baseapp/abci_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,7 @@ func TestPrecommiterCalledWithDeliverState(t *testing.T) {
13911391

13921392
func TestABCI_Proposal_HappyPath(t *testing.T) {
13931393
anteKey := []byte("ante-key")
1394-
pool := mempool.NewSenderNonceMempool()
1394+
pool := mempool.NewSenderNonceMempool(mempool.SenderNonceMaxTxOpt(5000))
13951395
anteOpt := func(bapp *baseapp.BaseApp) {
13961396
bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, anteKey))
13971397
}
@@ -1569,7 +1569,7 @@ func TestABCI_Proposals_WithVE(t *testing.T) {
15691569

15701570
func TestABCI_PrepareProposal_ReachedMaxBytes(t *testing.T) {
15711571
anteKey := []byte("ante-key")
1572-
pool := mempool.NewSenderNonceMempool()
1572+
pool := mempool.NewSenderNonceMempool(mempool.SenderNonceMaxTxOpt(5000))
15731573
anteOpt := func(bapp *baseapp.BaseApp) {
15741574
bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, anteKey))
15751575
}
@@ -1599,7 +1599,7 @@ func TestABCI_PrepareProposal_ReachedMaxBytes(t *testing.T) {
15991599

16001600
func TestABCI_PrepareProposal_BadEncoding(t *testing.T) {
16011601
anteKey := []byte("ante-key")
1602-
pool := mempool.NewSenderNonceMempool()
1602+
pool := mempool.NewSenderNonceMempool(mempool.SenderNonceMaxTxOpt(5000))
16031603
anteOpt := func(bapp *baseapp.BaseApp) {
16041604
bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, anteKey))
16051605
}
@@ -1626,7 +1626,7 @@ func TestABCI_PrepareProposal_BadEncoding(t *testing.T) {
16261626
}
16271627

16281628
func TestABCI_PrepareProposal_OverGasUnderBytes(t *testing.T) {
1629-
pool := mempool.NewSenderNonceMempool()
1629+
pool := mempool.NewSenderNonceMempool(mempool.SenderNonceMaxTxOpt(5000))
16301630
suite := NewBaseAppSuite(t, baseapp.SetMempool(pool))
16311631
baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), NoopCounterServerImpl{})
16321632

@@ -1667,7 +1667,7 @@ func TestABCI_PrepareProposal_OverGasUnderBytes(t *testing.T) {
16671667
}
16681668

16691669
func TestABCI_PrepareProposal_MaxGas(t *testing.T) {
1670-
pool := mempool.NewSenderNonceMempool()
1670+
pool := mempool.NewSenderNonceMempool(mempool.SenderNonceMaxTxOpt(5000))
16711671
suite := NewBaseAppSuite(t, baseapp.SetMempool(pool))
16721672
baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), NoopCounterServerImpl{})
16731673

@@ -1705,7 +1705,7 @@ func TestABCI_PrepareProposal_MaxGas(t *testing.T) {
17051705

17061706
func TestABCI_PrepareProposal_Failures(t *testing.T) {
17071707
anteKey := []byte("ante-key")
1708-
pool := mempool.NewSenderNonceMempool()
1708+
pool := mempool.NewSenderNonceMempool(mempool.SenderNonceMaxTxOpt(5000))
17091709
anteOpt := func(bapp *baseapp.BaseApp) {
17101710
bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, anteKey))
17111711
}

server/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func DefaultConfig() *Config {
263263
},
264264
},
265265
Mempool: MempoolConfig{
266-
MaxTxs: 5_000,
266+
MaxTxs: -1,
267267
},
268268
}
269269
}

server/config/toml.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ stop-node-on-err = {{ .Streaming.ABCI.StopNodeOnErr }}
240240
241241
[mempool]
242242
# Setting max-txs to 0 will allow for a unbounded amount of transactions in the mempool.
243-
# Setting max_txs to negative 1 (-1) will disable transactions from being inserted into the mempool.
243+
# Setting max_txs to negative 1 (-1) will disable transactions from being inserted into the mempool (no-op mempool).
244244
# Setting max_txs to a positive number (> 0) will limit the number of transactions in the mempool, by the specified amount.
245245
#
246246
# Note, this configuration only applies to SDK built-in app-side mempool

tools/confix/data/v0.50-app.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ stop-node-on-err = true
227227

228228
[mempool]
229229
# Setting max-txs to 0 will allow for a unbounded amount of transactions in the mempool.
230-
# Setting max_txs to negative 1 (-1) will disable transactions from being inserted into the mempool.
230+
# Setting max_txs to negative 1 (-1) will disable transactions from being inserted into the mempool (no-op mempool).
231231
# Setting max_txs to a positive number (> 0) will limit the number of transactions in the mempool, by the specified amount.
232232
#
233233
# Note, this configuration only applies to SDK built-in app-side mempool
234234
# implementations.
235-
max-txs = 5000
235+
max-txs = -1

types/mempool/mempool_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ type MempoolTestSuite struct {
210210

211211
func (s *MempoolTestSuite) resetMempool() {
212212
s.iterations = 0
213-
s.mempool = mempool.NewSenderNonceMempool()
213+
s.mempool = mempool.NewSenderNonceMempool(mempool.SenderNonceMaxTxOpt(5000))
214214
}
215215

216216
func (s *MempoolTestSuite) SetupTest() {

types/mempool/sender_nonce.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var (
1919
_ Iterator = (*senderNonceMempoolIterator)(nil)
2020
)
2121

22-
var DefaultMaxTx = 0
22+
var DefaultMaxTx = -1
2323

2424
// SenderNonceMempool is a mempool that prioritizes transactions within a sender
2525
// by nonce, the lowest first, but selects a random sender on each iteration.

types/mempool/sender_nonce_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func (s *MempoolTestSuite) TestTxOrder() {
115115
}
116116
for i, tt := range tests {
117117
t.Run(fmt.Sprintf("case %d", i), func(t *testing.T) {
118-
pool := mempool.NewSenderNonceMempool(mempool.SenderNonceSeedOpt(tt.seed))
118+
pool := mempool.NewSenderNonceMempool(mempool.SenderNonceMaxTxOpt(5000), mempool.SenderNonceSeedOpt(tt.seed))
119119
// create test txs and insert into mempool
120120
for i, ts := range tt.txs {
121121
tx := testTx{id: i, priority: int64(ts.p), nonce: uint64(ts.n), address: ts.a}
@@ -173,7 +173,7 @@ func (s *MempoolTestSuite) TestTxNotFoundOnSender() {
173173
t := s.T()
174174
ctx := sdk.NewContext(nil, cmtproto.Header{}, false, log.NewNopLogger())
175175
accounts := simtypes.RandomAccounts(rand.New(rand.NewSource(0)), 1)
176-
mp := mempool.NewSenderNonceMempool()
176+
mp := mempool.NewSenderNonceMempool(mempool.SenderNonceMaxTxOpt(5000))
177177

178178
txSender := testTx{
179179
nonce: 0,

0 commit comments

Comments
 (0)