Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: limit max txs in priority mempool #2547

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
* [2396](https://github.com/zeta-chain/node/issues/2386) - special handle bitcoin testnet gas price estimator
* [2434](https://github.com/zeta-chain/node/pull/2434) - the default database when running `zetacored init` is now pebbledb
* [2481](https://github.com/zeta-chain/node/pull/2481) - increase gas limit inbound and outbound vote message to 500k
* [2547](https://github.com/zeta-chain/node/pull/2547) - limit max txs in priority mempool

### CI

Expand Down
6 changes: 5 additions & 1 deletion cmd/zetacored/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,12 @@ func (ac appCreator) newApp(
appOpts servertypes.AppOptions,
) servertypes.Application {
baseappOptions := server.DefaultBaseappOptions(appOpts)
maxTxs := cast.ToInt(appOpts.Get(server.FlagMempoolMaxTxs))
if maxTxs <= 0 {
maxTxs = zetamempool.DefaultMaxTxs
}
baseappOptions = append(baseappOptions, func(app *baseapp.BaseApp) {
app.SetMempool(zetamempool.DefaultPriorityMempool())
app.SetMempool(zetamempool.NewPriorityMempool(zetamempool.PriorityNonceWithMaxTx(maxTxs)))
})
skipUpgradeHeights := make(map[int64]bool)
for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/mempool/priority_nonce_mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ var (
_ mempool.Iterator = (*PriorityNonceIterator)(nil)
)

const DefaultMaxTxs = 3000

// PriorityNonceMempool is a mempool implementation that stores txs
// in a partially ordered set by 2 dimensions: priority, and sender-nonce
// (sequence number). Internally it uses one priority ordered skip list and one
Expand Down
Loading