8000 avoid using invalidateblock to directly test reorg behavior · Issue #32531 · bitcoin/bitcoin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
avoid using invalidateblock to directly test reorg behavior #32531
Open
@instagibbs

Description

@instagibbs

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:

  1. Only allows 10 deep reorg before it stops trying to re-enter things into the mempool
  2. 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:

  1. build blockchain of stuff you want re-entry for
  2. invalidatblock to the desired fork off point

One example to look at would be

assert_mempool_contents(self, self.nodes[0], expected=[dusty_tx["tx"], sweep_tx_2["tx"]], sync=False)
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:

  1. Prep fork chain of sufficient length
  2. invalidate the fork chain
  3. do normal test setup
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0