-
Notifications
You must be signed in to change notification settings - Fork 70
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
Mempool txn prioritization #920
Conversation
viquezclaudio
commented
Jul 5, 2022
•
edited
Loading
edited
- Introduces some priorities (low, medium, high) to transactions when they are added into the mempool.
- Exposes this functionality via RPC
- The unpark transaction is included into the mempool with high priority
Codecov Report
@@ Coverage Diff @@
## albatross #920 +/- ##
==========================================
Coverage 64.27% 64.27%
==========================================
Files 359 359
Lines 42264 42306 +42
==========================================
+ Hits 27167 27194 +27
- Misses 15097 15112 +15
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
ca7297e
to
317458b
Compare
317458b
to
af7660b
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.
Good to go! My comments just to save some code and a question for trannsactions of reverted blocks.
mempool/src/mempool.rs
Outdated
if let Some(priority) = tx_priority { | ||
RwLockUpgradableReadGuard::upgrade(mempool_state_lock) | ||
.put(&transaction, priority); | ||
} else { | ||
//If the priority is not provided we default to medium | ||
RwLockUpgradableReadGuard::upgrade(mempool_state_lock) | ||
.put(&transaction, TxPriority::MediumPriority); | ||
} |
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.
if let Some(priority) = tx_priority { | |
RwLockUpgradableReadGuard::upgrade(mempool_state_lock) | |
.put(&transaction, priority); | |
} else { | |
//If the priority is not provided we default to medium | |
RwLockUpgradableReadGuard::upgrade(mempool_state_lock) | |
.put(&transaction, TxPriority::MediumPriority); | |
} | |
RwLockUpgradableReadGuard::upgrade(mempool_state_lock) | |
.put(&transaction, tx_priority.unwrap_or(TxPriority::MediumPriority)); |
@@ -520,7 +521,7 @@ impl Mempool { | |||
let pending_balance = tx.total_value() + sender_total; | |||
|
|||
if pending_balance <= sender_balance { | |||
mempool_state.put(tx); | |||
mempool_state.put(tx, TxPriority::MediumPriority); |
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.
All reverted transactions are added as MediumPriority
. The fact they might have been added as HighPriority
is lost of course, but potentially we could still add unpark transactions as HighPriority
.
This commit allows one to specify a transaction priority when txns are being addded to the mempool, such that txns with higher priority are returned first. This is exposed to the RPC interface It is also used to prioritize our own unpark transactions
af7660b
to
cf35d46
Compare
When querying mempool state, e.g. via RPC |