feat: default to noop mempool when max-txs is negative (#16071)

This commit is contained in:
Julien Robert 2023-05-09 19:41:20 +02:00 committed by GitHub
parent 2f21cb5050
commit 0da5e83176
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 5 deletions

View File

@ -69,6 +69,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Improvements
* (server) [#16071](https://github.com/cosmos/cosmos-sdk/pull/16071) When `mempool.max-txs` is set to a negative value, use a no-op mempool (effectively disable the app mempool).
* (simapp) [#15958](https://github.com/cosmos/cosmos-sdk/pull/15958) Refactor SimApp for removing the global basic manager.
* (gov) [#15979](https://github.com/cosmos/cosmos-sdk/pull/15979) Improve gov error message when failing to convert v1 proposal to v1beta1.
* (crypto) [#3129](https://github.com/cosmos/cosmos-sdk/pull/3129) New armor and keyring key derivation uses aead and encryption uses chacha20poly

View File

@ -124,6 +124,22 @@ One example config to tweak is the `minimum-gas-prices` field inside `app.toml`,
minimum-gas-prices = "0stake"
```
:::tip
When running a node (not a validator!) and not wanting to run the application mempool, set the `max-txs` field to `-1`.
```toml
[mempool]
# Setting max-txs to 0 will allow for a unbounded amount of transactions in the mempool.
# Setting max_txs to negative 1 (-1) will disable transactions from being inserted into the mempool.
# Setting max_txs to a positive number (> 0) will limit the number of transactions in the mempool, by the specified amount.
#
# Note, this configuration only applies to SDK built-in app-side mempool
# implementations.
max-txs = "-1"
```
:::
## Run a Localnet
Now that everything is set up, you can finally start your node:

View File

@ -487,6 +487,15 @@ func DefaultBaseappOptions(appOpts types.AppOptions) []func(*baseapp.BaseApp) {
cast.ToUint32(appOpts.Get(FlagStateSyncSnapshotKeepRecent)),
)
defaultMempool := baseapp.SetMempool(mempool.NoOpMempool{})
if maxTxs := cast.ToInt(appOpts.Get(FlagMempoolMaxTxs)); maxTxs >= 0 {
defaultMempool = baseapp.SetMempool(
mempool.NewSenderNonceMempool(
mempool.SenderNonceMaxTxOpt(maxTxs),
),
)
}
return []func(*baseapp.BaseApp){
baseapp.SetPruning(pruningOpts),
baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(FlagMinGasPrices))),
@ -499,11 +508,7 @@ func DefaultBaseappOptions(appOpts types.AppOptions) []func(*baseapp.BaseApp) {
baseapp.SetSnapshot(snapshotStore, snapshotOptions),
baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(FlagIAVLCacheSize))),
baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(FlagDisableIAVLFastNode))),
baseapp.SetMempool(
mempool.NewSenderNonceMempool(
mempool.SenderNonceMaxTxOpt(cast.ToInt(appOpts.Get(FlagMempoolMaxTxs))),
),
),
defaultMempool,
baseapp.SetIAVLLazyLoading(cast.ToBool(appOpts.Get(FlagIAVLLazyLoading))),
baseapp.SetChainID(chainID),
}