Due to the synchronous call of CValidationInterface::BlockChecked a lock order inversion happens:
PeerManagerImpl::m_peer_mutex
|
V
Peer::TxRelay::m_tx_inventory_mutex
|
V
CTxMemPool::cs
|
V
PeerManagerImpl::m_peer_mutex
This PR breaks the last link.
The other possible solution is to move CValidationInterface::BlockChecked to a background thread (see #18963). But this PR is much simpler.
I cannot see any drawbacks of calling MaybePunishNodeForBlock asynchronously. Other opinions are welcome.