HomePhabricator

init: Reset mempool and chainman via reconstruction

Description

init: Reset mempool and chainman via reconstruction

Summary:
Fixes https://github.com/bitcoin/bitcoin/issues/22964

Previously, we used UnloadBlockIndex() in order to reset node.mempool
and node.chainman. However, that has proven to be fragile (see
https://github.com/bitcoin/bitcoin/issues/22964), and requires
UnloadBlockIndex and its callees to be updated manually for each member
that's introduced to the mempool and chainman classes.

In this commit, we stop using the UnloadBlockIndex function and we
simply reconstruct node.mempool and node.chainman.

Since PeerManager needs a valid reference to both node.mempool and
node.chainman, we also move PeerManager's construction via ::make to
after the chainstate activation sequence is complete.

There are no more callers to UnloadBlockIndex after this commit, so it
and its sole callees can be pruned.

This is a partial backport of core#22564
https://github.com/bitcoin/bitcoin/pull/22564/commits/5921b863e39e5c3997895ffee1c87159e37a5d6f

Depends on D13086 and D13081

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, sdulfari

Reviewed By: #bitcoin_abc, sdulfari

Differential Revision: https://reviews.bitcoinabc.org/D13087

Details

Provenance
Carl Dong <contact@carldong.me>Authored on Sep 13 2021, 21:02
PiRKCommitted on Feb 2 2023, 11:30
PiRKPushed on Feb 2 2023, 11:30
Reviewer
Restricted Project
Differential Revision
D13087: init: Reset mempool and chainman via reconstruction
Parents
rABCef3c0ac4242c: validation: default initialize and guard chainman members
Branches
Unknown
Tags
Unknown