feat: add tx limit to mempool (#14014)

* feat: add bounding max tx to mempool

* add bounded condition

* sligh improvement on generator

* remove unbouded option

* add test

* added mempool options mechanism

* mising test

* seting mempool

* change function name

* change function name

* failing test

* Revert "failing test"

This reverts commit d527982b0d4ec826ff680afb8f43ac1d71809ccf.

* fix import block

* changelog entries

* add ability to do unbounded mempool

* remove unesesary variable

* small comments

* change 0 to mean unbounded

* t

* small test fix

* add the ability to be bounded unbounded and disabled

* t

* set default maxtx

* Update docs/docs/building-apps/02-app-mempool.md

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* example for opts

* remove superflues logs entry

* add mempool to configurations

* fix more understandable name

* remove table in favor of bulletpoints

* sender nonce to unbounded

* Update docs/docs/building-apps/02-app-mempool.md

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Update types/mempool/sender_nonce.go

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Update types/mempool/sender_nonce.go

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Update docs/docs/building-apps/02-app-mempool.md

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Update server/config/config.go

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* t

* add comment for options

* fix inport

* fix inport

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Emmanuel T Odeke <emmanuel@orijtech.com>
This commit is contained in:
Jeancarlo Barrios
2022-12-02 00:39:55 +00:00
committed by GitHub
co-authored by Aleksandr Bezobchuk Emmanuel T Odeke
parent 3aff993fcb
commit 754ca3169e
9 changed files with 163 additions and 32 deletions
+10
View File
@@ -51,3 +51,13 @@ Now that we have walked through the `PrepareProposal` & `ProcessProposal`, we ca
There are countless designs that an application developer can write for a mempool, the core team opted to provide a simple implementation of a nonce mempool. The nonce mempool is a mempool that keeps transactions from an sorted by nonce in order to avoid the issues with nonces.
It works by storing the transation in a list sorted by the transaction nonce. When the proposer asks for transactions to be included in a block it randomly selects a sender and gets the first transaction in the list. It repeats this until the mempool is empty or the block is full.
### Configurations
#### MaxTxs
Its an integer value that sets the mempool in one of three modes, bounded, unbounded, or disabled.
- **negative**: Disabled, mempool does not insert new tx and return early.
- **zero**: Unbounded mempool has no tx limit and will never fail with ErrMempoolTxMaxCapacity.
- **positive**: Bounded, it fails with ErrMempoolTxMaxCapacity when maxTx value is the same as CountTx()