Skip to content

Conversation

yuvicc
Copy link
Contributor

@yuvicc yuvicc commented May 22, 2025

Updated functional tests to replace direct use of invalidateblock with proper fork-based reorg behaviour. The direct invalidation approach bypasses important validation checks and has depth limitations(10 block) that don't match real-world reorg scenarios. For more details see #32531.

Fixes #32531

@DrahtBot
Copy link
Contributor

DrahtBot commented May 22, 2025

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32587.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK BrandonOdiwuor, enirox001
Stale ACK Prabhat1308, itokichi7777, instagibbs

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #33629 (Cluster mempool by sdaftuar)
  • #33616 (policy: don't CheckEphemeralSpends on reorg by instagibbs)
  • #33591 (Cluster mempool followups by sdaftuar)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@instagibbs
Copy link
Member

feel free to ping me when it's ready

@yuvicc
Copy link
Contributor Author

yuvicc commented May 22, 2025

feel free to ping me when it's ready

Sure!

@yuvicc yuvicc force-pushed the 2025-05-update_test_reorg_behaviour branch 3 times, most recently from 7bbdba1 to 516c6ce Compare May 30, 2025 06:35
@DrahtBot
Copy link
Contributor

🚧 At least one of the CI tasks failed.
Task lint: https://github.com/bitcoin/bitcoin/runs/43164565056
LLM reason (✨ experimental): The CI failure is primarily due to errors from the lint check, specifically from ruff, which identified and flagged Python code issues such as unused imports and trailing whitespace.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

@yuvicc yuvicc force-pushed the 2025-05-update_test_reorg_behaviour branch from 516c6ce to b70c907 Compare June 2, 2025 16:19
@DrahtBot DrahtBot removed the CI failed label Jun 2, 2025
@yuvicc yuvicc marked this pull request as ready for review June 3, 2025 07:08
@yuvicc
Copy link
Contributor Author

yuvicc commented Jun 3, 2025

@instagibbs can you review this, will add other tests once this one gets ACK'ed

@yuvicc yuvicc changed the title [WIP] test: Fix reorg patterns in mempool tests to use proper fork-based approach test: Fix reorg patterns in mempool tests to use proper fork-based approach Jun 3, 2025
@DrahtBot DrahtBot added the Tests label Jun 3, 2025
@yuvicc yuvicc force-pushed the 2025-05-update_test_reorg_behaviour branch from b70c907 to 9565415 Compare June 4, 2025 07:21
Copy link
Contributor

@Prabhat1308 Prabhat1308 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK with the approach . Left some nits

@yuvicc yuvicc force-pushed the 2025-05-update_test_reorg_behaviour branch from 9565415 to 45fad54 Compare June 10, 2025 13:39
@yuvicc
Copy link
Contributor Author

yuvicc commented Jun 10, 2025

Addressed some nits and rebased with master!

@yuvicc yuvicc force-pushed the 2025-05-update_test_reorg_behaviour branch 2 times, most recently from 35414a8 to c98f361 Compare June 10, 2025 20:54
Copy link
Member

@instagibbs instagibbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM c98f361

feel free to add more cases

@yuvicc yuvicc force-pushed the 2025-05-update_test_reorg_behaviour branch from c98f361 to 3012d6d Compare June 15, 2025 17:12
@yuvicc yuvicc changed the title test: Fix reorg patterns in mempool tests to use proper fork-based approach test: Fix reorg patterns in tests to use proper fork-based approach Jun 16, 2025
@yuvicc yuvicc force-pushed the 2025-05-update_test_reorg_behaviour branch 2 times, most recently from e186193 to f079571 Compare June 18, 2025 07:25
@yuvicc
Copy link
Contributor Author

yuvicc commented Jul 18, 2025

Fixed conflicts and rebased to master.

Copy link
Contributor

@Prabhat1308 Prabhat1308 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK cec7ce0

changes since I last reviewed

  • the PR has been extended to 5 more tests other than mempool_reorg.py
  • Tested and reviewed the added tests.

@instagibbs
Copy link
Member

forgot about this, definitely worthwhile to get merged soon

@fanquake fanquake added this to the 31.0 milestone Sep 29, 2025
@yuvicc yuvicc force-pushed the 2025-05-update_test_reorg_behaviour branch from cec7ce0 to e4c4d7f Compare October 3, 2025 13:03
@yuvicc
Copy link
Contributor Author

yuvicc commented Oct 3, 2025

Rebased to 1ed00a0.

@yuvicc yuvicc force-pushed the 2025-05-update_test_reorg_behaviour branch from e4c4d7f to 0f1f029 Compare October 3, 2025 13:40
@yuvicc
Copy link
Contributor Author

yuvicc commented Oct 3, 2025

Fixed some linter errors. No change in tests.

@fanquake
Copy link
Member

fanquake commented Oct 3, 2025

@instagibbs @mzumsande want to circle back here for a look?

@instagibbs
Copy link
Member

ACK 0f1f029

git range-diff master a161f058089dfe5f3aa7d3b9635f0400f0147b5d 0f1f02995b715a83f71b1b8fc92fa520625ec427

@itokichi7777
Copy link

itokichi7777 commented Oct 11, 2025

tACK 0f1f029

@instagibbs
Copy link
Member

#33616 (comment)

looks like you forgot to remove the definition from mempool_updatefromblock.py

Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good, just a few comments.

A nice-to-have: in the functional tests with multiple nodes, it would be a bit more realistic / interesting if the two forks were mined by different nodes.

assert_equal(entry1['fees']['base'], entry0['fees']['base'])
assert_equal(entry1['vsize'], entry0['vsize'])
assert_equal(entry1['depends'], entry0['depends'])

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is still an invalidateblock in this test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping, could you respond to this @yuvicc

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you had a chance to look at this?

@yuvicc yuvicc force-pushed the 2025-05-update_test_reorg_behaviour branch from 0f1f029 to 48b3819 Compare October 15, 2025 06:28
…py module to enable reuse across multiple tests.
@yuvicc yuvicc force-pushed the 2025-05-update_test_reorg_behaviour branch from 48b3819 to 7defbc7 Compare October 15, 2025 06:54
@yuvicc
Copy link
Contributor Author

yuvicc commented Oct 15, 2025

Thank you @glozow and @instagibbs for the review.

Addressed feedback:

  • Removed the create_empty_fork method per @instagibbs's comment
  • Modified changes in the next commit as suggested by @glozow (comment)
  • Made FORK_LENGTH a default argument per @glozow's comment
  • Removed duplicate trigger re-org for both nodes; now asserting they are on the same chain per @glozow's comment

Additionally, updated the mempool_updatefromblock test to use the trigger_reorg method for consistency with other tests.

@DrahtBot DrahtBot mentioned this pull request Oct 15, 2025
Copy link
Member

@instagibbs instagibbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reACK 7defbc7 modulo question about remaining invalidateblock usages.

git range-diff master 0f1f029 7defbc7

assert_equal(entry1['fees']['base'], entry0['fees']['base'])
assert_equal(entry1['vsize'], entry0['vsize'])
assert_equal(entry1['depends'], entry0['depends'])

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping, could you respond to this @yuvicc

@yuvicc yuvicc force-pushed the 2025-05-update_test_reorg_behaviour branch from 7defbc7 to f0717d0 Compare October 16, 2025 04:51
@yuvicc
Copy link
Contributor Author

yuvicc commented Oct 16, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

avoid using invalidateblock to directly test reorg behavior

10 participants