forked from kaspanet/rusty-kaspa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance Mempool performance (kaspanet#226)
* Split mempool atomic validate and insert transaction in 3 steps * Process tx relay flow received txs in batch * Use a single blocking task per MiningManagerProxy fn * Split parallel txs validation in chunks of max block mass * Abstract expire_low_priority_transactions into Pool trait * Making room in the mempool for a new transaction won't remove chained txs nor parent txs of the new transaction * Refine lock granularity on Mempool and Consensus while processing unorphaned transactions (wip) * Fix failing test * Enhance performance & refine lock granularity on Mempool and Consensus while revalidating high priority transactions * Comments * Fix upper bound of transactions chunk * Ensure a chunk has at least 1 tx * Prevent add twice the same tx to the mempool * Clear transaction entries before revalidation * Add some logs and comments * Add logs to debug transactions removals * On accepted block do not remove orphan tx redeemers * Add 2 TODOs * Fix a bug of high priority transactions being unexpectedly orphaned or rejected * Refactor transaction removal reason into an enum * Add an accepted transaction ids cache to the mempool and use it to prevent reentrance in mempool, broadcasting to and asking from peers * Improve the filtering of unknown transactions in tx relay * Enhance tx removal logging * Add mempool stats * Process new and unorphaned blocks in topological order * Run revalidation of HP txs in a dedicated task * Some profiling and debug logs * Run expiration of LP txs in a dedicated task * remove some stopwatch calls which were timing locks * crucial: fix exploding complexity of `handle_new_block_transactions`/`remove_transaction` * fixes in `on_new_block` * refactor block template cache into `Inner` * make `block_template_cache` a non-blocking call (never blocks) * Log build_block_template retries * While revalidating HP txs, only recheck transaction entries * Fix accepted count during revalidation * mempool bmk: use client pools + various improvements * Improve the topological sorting of transactions * Return transaction descendants BFS ordered + some optimizations * Group expiration and revalidation of mempool txs in one task * Refine the schedule of the cleaning task * ignore perf logs * maintain mempool ready transactions in a dedicated set * Bound the returned candidate transactions to a maximum * Reduces the max execution time of build block template * lint * Add mempool lock granularity to get_all_transactions * Restore block template cache lifetime & make it customizable in devnet-prealloc feature * Restore block template cache lifetime & make it customizable in devnet-prealloc feature * Relax a bit the BBT maximum attempts constraint * Refactor multiple `contained_by_txs` fns into one generic * Test selector transaction rejects & fix empty template returned by `select_transactions` upon selector reuse * Log some mempool metrics * Handle new block and then new block template * turn tx selector into an ongoing process with persistent state (wip: some tests are broken; selector is not used correctly by builder) * use tx selector for BBT (wip: virtual processor retry logic) * virtual processor selector retry logic * make BBT fallible by some selector criteria + comments and some docs * add an infallible mode to virtual processor `build_block_template()` * constants for tx selector successful decision * Add e-tps to logged mempool metrics * avoid realloc * Address review comments * Use number of ready txs in e-tps & enhance mempool lock * Ignore failing send for clean tokio shutdown * Log double spends * Log tx script cache stats (wip) * Ease atomic lock ordering & enhance counter updates * Enhance tx throughput stats log line * More robust management of cached data life cycle * Log mempool sampled instead of exact lengths * avoid passing consensus to orphan pool * rename ro `validate_transaction_unacceptance` and move to before the orphan case (accepted txs will usually be orphan) * rename `cleaning` -> `mempool_scanning` * keep intervals aligned using a round-up formula (rather than a loop) * design fix: avoid exposing full collections as mut. This violates encapsulation logic since collections can be completely modified externally; while in tx pools it is important to make sure various internal collections are maintained consistently (for instance the `ready_transactions` field on `TransactionsPool` needs careful maintenance) * minor: close all pool receivers on op error * `remove_transaction`: no need to manually update parent-child relations in the case `remove_redeemers=false`. This is already done via `remove_transaction_from_sets` -> `transaction_pool.remove_transaction`. + a few minor changes * encapsulate `remove_transaction_utxos` into `transaction_pool` * no need to `remove_redeemers_of` for the initial removed tx since this happens as part of: `remove_from_transaction_pool_and_update_orphans` -> `orphan_pool.update_orphans_after_transaction_removed` -> `orphan_pool.remove_redeemers_of` * inline `remove_from_transaction_pool_and_update_orphans` * remove redeemers of expired low-prio txs + register scan time and daa score after collection (bug fix) * change mempool monitor logs to debug * make tps logging more accurate * import bmk improvements from mempool-perf-stats branch * make `config.block_template_cache_lifetime` non-feature dependent --------- Co-authored-by: Michael Sutton <msutton@cs.huji.ac.il>
- Loading branch information
1 parent
51a1240
commit a59214e
Showing
61 changed files
with
3,006 additions
and
728 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.