-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Account for transaction priority when enforcing limits #10388
Account for transaction priority when enforcing limits #10388
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a test?
It doesn't look like there were tests for previous behavior to replicate, but I will look into adding some tomorrow. |
Could be, but that just emphasis more that we should have tests ;) |
Added a basic test, but there is an opportunity to write a bunch more for various scenarios |
Ty! |
Could you please merge master |
8347af9
to
b3a2849
Compare
b3a2849
to
6011a11
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
/// set. We use a simplified approach to remove the transaction that occupies the pool for the | ||
/// longest time. | ||
/// longest time or has the lowest priority. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually please update the comment, cause we now prefer transaction with the lowest priority and only resolve to insertion_id
in case the priority is exactly the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can remember why it wasn't done like that initially, my only guess is that self.ready.fold
did not traverse the entire set of transactions but rather just a subset (i.e. first-in-row transactions), but now it seems it will go through the list of all possible transactions anyway (which is a bit of a performance hurdle here, when used in the while
loop).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the same concern about performance, but wasn't sure if it is save to sort txs first and then slicing off some of the worst ones until we are withing limits (instead of having quadratic algorithm here) since self.remove_subtree()
below might remove more than one by the looks of it and I wasn't familiar enough with the codebase to make such change yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, in regular circumstances the outer loop should complete quite fast - like we will be removing up to couple of transactions at most, so I think this is fine.
/tip medium |
Please fix the following problems before calling the tip bot again:
|
Thanks, added address 😺 |
/tip medium |
1 similar comment
/tip medium |
A medium tip was successfully submitted for nazar-pc (1vSxzbyz2cJREAuVWjhXUT1ds8vBzoxn2w4asNpusQKwjJd on polkadot). |
bot merge |
Waiting for commit status. |
Merge cancelled due to error. Error: Checks failed for 368f06a |
bot merge |
This extends logic used when enforcing limits on transaction pool by not only accounting for when transaction was inserted, but also what priority it has.
The logic here is that if transaction has higher priority (let's say equivocation report that has highest possible priority configured in BABE), it must not be possible to kick it out of transaction pool with transactions that have lower priority.
Polkadot address: 1vSxzbyz2cJREAuVWjhXUT1ds8vBzoxn2w4asNpusQKwjJd
skip check-dependent-cumulus