Motivation
While working on #32516 I found that for testing mempool entry from reorged blocks, directly using invalidateblock to trigger the reorg has at least a couple behaviors that don’t match real reorgs:
- Only allows 10 deep reorg before it stops trying to re-enter things into the mempool
- doesn’t respect descendant chain limits(Sets of PreChecks isn’t run once per reorg but once per block, letting longer chains slip in)
the code paths greatly diverge from normal re-orgs, which makes this problematic for actual testing.
The setup being used:
- build blockchain of stuff you want re-entry for
- invalidatblock to the desired fork off point
One example to look at would be https://github.com/bitcoin/bitcoin/blob/3f83c744ac28b700090e15b5dda2260724a56f49/test/functional/mempool_ephemeral_dust.py#L350 or any other tests in mempool_*.py
that use invalidateblock to simulate reorgs and mempool re-entry.
Possible solution
We should make sure that in our reorg/mempool tests spread across the codebase that we don’t do it this way and instead:
- Prep fork chain of sufficient length
- invalidate the fork chain
- do normal test setup
- reconsiderblock the previously invalidated chain
This appears to match the intended test coverage.
Useful Skills
Understanding of python test suite
Guidance for new contributors
Want to work on this issue?
For guidance on contributing, please read CONTRIBUTING.md before opening your pull request.