[TxPool] Introduce limit on enqueued transactions
Description
This PR introduces a configurable limit on the amount of transactions any account in the TxPool can hold at any given time.
--max-enqueued [DEFAULT= 128]
As the enqueued part of an account just represents future transactions (higher nonce than expected), there are no particular benefits to keeping a large number of them in this queue as much as there are vulnerability risks that all result in an eventually bricked pool full of enqueued transactions.
The limit also enforces a rate limiting on transaction acquisition for any account - in effect, an incoming transaction would be rejected if there is no space for it in its respective enqueued queue. What this means is that aggressive spams are greatly mitigated, delaying the point of pool overflow.
Changes include
- [x] Bugfix (non-breaking change that solves an issue)
- [ ] Hotfix (change that solves an urgent issue, and requires immediate attention)
- [x] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (change that is not backwards-compatible and/or changes current functionality)
Checklist
- [x] I have assigned this PR to myself
- [x] I have added at least 1 reviewer
- [x] I have added the relevant labels
- [ ] I have updated the official documentation
- [x] I have added sufficient documentation in code
Testing
- [x] I have tested this code with the official test suite
- [ ] I have tested this code manually
Documentation update
Please link the documentation update PR in this section if it's present, otherwise delete it
Additional comments
Fixes EDGE-732
Codecov Report
Merging #687 (3f21675) into develop (de62840) will decrease coverage by
0.15%. The diff coverage is23.33%.
@@ Coverage Diff @@
## develop #687 +/- ##
===========================================
- Coverage 48.77% 48.61% -0.16%
===========================================
Files 112 112
Lines 15382 15390 +8
===========================================
- Hits 7502 7482 -20
- Misses 7249 7274 +25
- Partials 631 634 +3
| Impacted Files | Coverage Δ | |
|---|---|---|
| consensus/ibft/consensus_backend.go | 0.00% <0.00%> (ø) |
|
| consensus/ibft/ibft.go | 3.93% <0.00%> (-0.07%) |
:arrow_down: |
| txpool/account.go | 93.25% <100.00%> (+0.19%) |
:arrow_up: |
| txpool/txpool.go | 71.04% <100.00%> (ø) |
|
| network/server_discovery.go | 73.88% <0.00%> (-15.93%) |
:arrow_down: |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more