txpool api: remove_invalid call improved#6661
Merged
Conversation
txpool api: remove invalid call improved
txpool api: remove invalid call improvedtxpool api: remove_invalid call improved
|
All GitHub workflows were cancelled due to failure one of the required jobs. |
skunert
approved these changes
Feb 11, 2025
Contributor
skunert
left a comment
There was a problem hiding this comment.
Left some comments, otherwise looks good
substrate/client/transaction-pool/src/fork_aware_txpool/multi_view_listener.rs
Outdated
Show resolved
Hide resolved
substrate/client/transaction-pool/src/fork_aware_txpool/dropped_watcher.rs
Show resolved
Hide resolved
iulianbarbu
approved these changes
Feb 12, 2025
substrate/client/transaction-pool/src/fork_aware_txpool/multi_view_listener.rs
Show resolved
Hide resolved
clangenb
pushed a commit
to clangenb/polkadot-sdk
that referenced
this pull request
Feb 19, 2025
#### Description Currently the transaction which is reported as invalid by a block builder (or `removed_invalid` by other components) is silently skipped. This PR improves this behavior. The transaction pool `report_invalid` function now accepts optional error associated with every reported transaction, and also the optional block hash which provides hints how reported transaction shall be handled. The following API change is proposed: https://github.com/paritytech/polkadot-sdk/blob/8be5ef3e9a18e873de78aca1b8f834fa554ce9c8/substrate/client/transaction-pool/api/src/lib.rs#L297-L318 Depending on error, the transaction pool can decide if transaction shall be removed from the view only or entirely from the pool. Invalid event will be dispatched if required. #### Notes for reviewers - Actual logic of removing invalid txs is implented in [`ViewStore::report_invalid`](https://github.com/paritytech/polkadot-sdk/blob/0fad26c43a65bfb371d667278981d3c68c3ce9d6/substrate/client/transaction-pool/src/fork_aware_txpool/view_store.rs#L657-L680). Method's doc explains the flow. - This PR changes `HashMap` to `IndexMap` in revalidation logic. This is to preserve the original order of transactions (mainly for purposes of unit tests). - This PR solves the problem mentioned in: paritytech#5477 (comment) (which can now be resolved). The invalid transactions found during mempool revalidation are now also removed from the `view_store`. No dangling invalid transaction shall be left in the pool. (paritytech@bfec262) - The support for dropping invalid transactions reported from the views was also added. This should never happen, but if for any case all views will report invalid transcation (which previously was valid) the transaction will be dropped from the pool (paritytech@48214a3). fixes: paritytech#6008, paritytech#5477 --------- Co-authored-by: command-bot <> Co-authored-by: Sebastian Kunert <skunert49@gmail.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Currently the transaction which is reported as invalid by a block builder (or
removed_invalidby other components) is silently skipped.This PR improves this behavior. The transaction pool
report_invalidfunction now accepts optional error associated with every reported transaction, and also the optional block hash which provides hints how reported transaction shall be handled. The following API change is proposed:polkadot-sdk/substrate/client/transaction-pool/api/src/lib.rs
Lines 297 to 318 in 8be5ef3
Depending on error, the transaction pool can decide if transaction shall be removed from the view only or entirely from the pool. Invalid event will be dispatched if required.
Notes for reviewers
ViewStore::report_invalid. Method's doc explains the flow.HashMaptoIndexMapin revalidation logic. This is to preserve the original order of transactions (mainly for purposes of unit tests).fatxpool: add tests for rejecting invalid transactions #5477 (comment) (which can now be resolved). The invalid transactions found during mempool revalidation are now also removed from theview_store. No dangling invalid transaction shall be left in the pool. (bfec262)fixes: #6008, #5477