Add Epoch Guards to CTXMemPoolEntry and CTxMemPool, make UpdateTransactionsFromBlock use Epochs
Summary:
UpdateTransactionsFromBlock is called during a re-org. When a re-org occurs, all of the transactions in the mempool may be descendants from a transaction which is in the pre-reorg block. This can cause us to propagate updates, worst case, to every transaction in the mempool.
Because we construct a setEntries setChildren, which is backed by a std::set, it is possible that this algorithm is O(N log N).
By using an Epoch visitor pattern, we can limit this to O(N) worst case behavior.
Epochs are also less resource intensive than almost any set option (e.g., hash set) because they are allocation free.
This is a backport of Core PR17925
Test Plan: ninja && ninja check
Reviewers: #bitcoin_abc, majcosta
Reviewed By: #bitcoin_abc, majcosta
Subscribers: majcosta
Differential Revision: https://reviews.bitcoinabc.org/D8733