Skip to content
Snippets Groups Projects
Commit c546e08c authored by Michal Kucharczyk's avatar Michal Kucharczyk Committed by Christian Langenbacher
Browse files

`txpool api`: `remove_invalid` call improved (#6661)

#### 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/8be5ef3e/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/0fad26c4/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:
https://github.com/paritytech/polkadot-sdk/issues/5477#issuecomment-2598809344
(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.
(https://github.com/paritytech/polkadot-sdk/pull/6661/commits/bfec2625)
- 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
(https://github.com/paritytech/polkadot-sdk/pull/6661/commits/48214a38

).



fixes: #6008, #5477

---------

Co-authored-by: command-bot <>
Co-authored-by: default avatarSebastian Kunert <skunert49@gmail.com>
parent 1aeb0c94
Showing
with 360 additions and 183 deletions
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment