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

[TxPool] Introduce limit on enqueued transactions #687

Merged
merged 17 commits into from
Aug 29, 2022

Conversation

dbrajovic
Copy link
Contributor

@dbrajovic dbrajovic commented Aug 16, 2022

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

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the relevant labels
  • I have updated the official documentation
  • I have added sufficient documentation in code

Testing

  • 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

@dbrajovic dbrajovic changed the title Fix/txpool enqueued limit [TxPool] Introduce limit on enqueued transactions Aug 18, 2022
@codecov
Copy link

codecov bot commented Aug 18, 2022

Codecov Report

Merging #687 (3f21675) into develop (de62840) will decrease coverage by 0.15%.
The diff coverage is 23.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%) ⬇️
txpool/account.go 93.25% <100.00%> (+0.19%) ⬆️
txpool/txpool.go 71.04% <100.00%> (ø)
network/server_discovery.go 73.88% <0.00%> (-15.93%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@dbrajovic dbrajovic self-assigned this Aug 18, 2022
@dbrajovic dbrajovic added bug fix Functionality that fixes a bug feature New update to Polygon Edge labels Aug 18, 2022
@dbrajovic dbrajovic marked this pull request as ready for review August 18, 2022 11:40
Copy link
Contributor

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 💯

Tested this out with Pandora's box, works like a charm 👏

Copy link
Contributor

@Aleksao998 Aleksao998 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add doc for this command MaxAccountEnqueued.

Copy link
Contributor

@Aleksao998 Aleksao998 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@Kourin1996 Kourin1996 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small comment

txpool/account.go Show resolved Hide resolved
@zivkovicmilos zivkovicmilos added this to the 0.6 Release milestone Aug 24, 2022
@dbrajovic dbrajovic merged commit f44ce9f into develop Aug 29, 2022
@dbrajovic dbrajovic deleted the fix/txpool-enqueued-limit branch August 29, 2022 09:29
@github-actions github-actions bot locked and limited conversation to collaborators Aug 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fix Functionality that fixes a bug feature New update to Polygon Edge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants