Skip to content

Conversation

jamesob
Copy link
Contributor

@jamesob jamesob commented Oct 4, 2023

Fixes #28585.

Fixes a few races within the assumeutxo tests:

  • In general, -stopatheight can't be used with connect_nodes safely because the latter performs blocking assertions that are racy with the stopatheight triggering.
  • Now that the snapshot chainstate is listed as normal after background validation, accept the final height from either chainstate.

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 4, 2023

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

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK MarcoFalke, ryanofsky, fjahr, achow101
Concept ACK hebasto

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

@jamesob jamesob changed the title 2023 10 au test fix assumeutxo -stopatheight func test fix Oct 4, 2023
@fanquake fanquake changed the title assumeutxo -stopatheight func test fix test: assumeutxo -stopatheight func test fix Oct 4, 2023
@DrahtBot DrahtBot added the Tests label Oct 4, 2023
@fjahr
Copy link
Contributor

fjahr commented Oct 4, 2023

Code review ACK 5bd2010

I had just written the same fix essentially. The stopatheight node shuts down before the list of wait_until checks in connect_nodes succeeds. I guess in the python execution is slower in CI but the node and sync is still comparatively fast.

@jamesob jamesob changed the title test: assumeutxo -stopatheight func test fix test: assumeutxo func test race fixes Oct 4, 2023
@hebasto
Copy link
Member

hebasto commented Oct 4, 2023

Concept ACK.

@maflcko
Copy link
Member

maflcko commented Oct 4, 2023

lgtm ACK 5bd2010

@jamesob jamesob force-pushed the 2023-10-au-test-fix branch from eae98cc to 1e4e324 Compare October 4, 2023 15:27
@jamesob
Copy link
Contributor Author

jamesob commented Oct 4, 2023

Even with latest HEAD, still seeing an apparent race. Still investigating.

2023-10-04T15:24:47.476000Z TestFramework (INFO): Restarted node before snapshot validation completed, reloading...
2023-10-04T15:24:47.782000Z TestFramework (INFO): Ensuring snapshot chain syncs to tip. (399)
2023-10-04T15:25:47.828000Z TestFramework.utils (ERROR): wait_until() failed. Predicate: ''''
            lambda: n1.getchainstates().get('snapshot', {}).get('blocks') == FINAL_HEIGHT)
'''
2023-10-04T15:25:47.828000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/home/james/src/bitcoin/test/functional/test_framework/test_framework.py", line 131, in main
    self.run_test()
  File "/home/james/src/bitcoin/./test/functional/feature_assumeutxo.py", line 162, in run_test
    wait_until_helper(
  File "/home/james/src/bitcoin/test/functional/test_framework/util.py", line 276, in wait_until_helper
    raise AssertionError("Predicate {} not true after {} seconds".format(predicate_source, timeout))
AssertionError: Predicate ''''
            lambda: n1.getchainstates().get('snapshot', {}).get('blocks') == FINAL_HEIGHT)
''' not true after 60.0 seconds
2023-10-04T15:25:47.879000Z TestFramework (INFO): Stopping nodes

@jamesob jamesob force-pushed the 2023-10-au-test-fix branch from 1e4e324 to 7e40032 Compare October 4, 2023 15:32
@maflcko
Copy link
Member

maflcko commented Oct 4, 2023

lgtm ACK 7e40032

@DrahtBot DrahtBot requested a review from fjahr October 4, 2023 15:34
@jamesob
Copy link
Contributor Author

jamesob commented Oct 4, 2023

Alright, I'm guessing we're fixed for real this time; 7e40032 accounts for the late change that we made on @ryanofsky's recommendation to list what was the snapshot chainstate as the normal chainstate once background validation completes. There was a race in the test during the first time we check for the final height, which may be done after background validation completed.

I'm going to keep running the test in a loop on my end and will post back in a bit to confirm that I think we're good to go.

@fanquake fanquake added this to the 26.0 milestone Oct 4, 2023
@fjahr fjahr mentioned this pull request Oct 4, 2023
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK 7e40032

(#28590 would allow simplifying the check in 7e40032 as well)

@fjahr
Copy link
Contributor

fjahr commented Oct 4, 2023

Code review ACK 7e40032

@DrahtBot DrahtBot removed the request for review from fjahr October 4, 2023 15:54
@achow101
Copy link
Member

achow101 commented Oct 4, 2023

ACK 7e40032

Gonna let this run in a loop for a bit before merging.

@DrahtBot DrahtBot requested review from achow101 and removed request for achow101 October 4, 2023 16:19
@jamesob
Copy link
Contributor Author

jamesob commented Oct 4, 2023

Test has been running on my machine in a loop without failure for about an hour now.

@achow101 achow101 merged commit cc68a3b into bitcoin:master Oct 4, 2023
Frank-GER pushed a commit to syscoin/syscoin that referenced this pull request Oct 13, 2023
7e40032 tests: assumeutxo: accept final height from either chainstate (James O'Beirne)
5bd2010 test: assumeutxo: avoid race in functional test (James O'Beirne)
7005a01 test: add wait_for_connect to BitcoinTestFramework.connect_nodes (James O'Beirne)

Pull request description:

  Fixes bitcoin#28585.

  Fixes a few races within the assumeutxo tests:
  - In general, `-stopatheight` can't be used with `connect_nodes` safely because the latter performs blocking assertions that are racy with the stopatheight triggering.
  - Now that the snapshot chainstate is listed as `normal` after background validation, accept the final height from either chainstate.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 7e40032
  fjahr:
    Code review ACK 7e40032
  achow101:
    ACK 7e40032
  ryanofsky:
    Code review ACK 7e40032

Tree-SHA512: 8cbd2a0ca8643f94baa0ae3561dcf68c3519d5ba851c6049e1768f28cae6434f47ffc28d404bf38ed11030ce3f00aae0a8be3f6d563e6ae6680d83c928a173d8
@bitcoin bitcoin locked and limited conversation to collaborators Oct 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

qa: feature_assumeutxo.py fails
8 participants