test: assumeutxo func test race fixes #28589

pull jamesob wants to merge 3 commits into bitcoin:master from jamesob:2023-10-au-test-fix changing 2 files +24 −3
  1. jamesob commented at 3:05 pm on October 4, 2023: member

    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.
  2. test: add wait_for_connect to BitcoinTestFramework.connect_nodes 7005a01c19
  3. test: assumeutxo: avoid race in functional test 5bd2010f02
  4. DrahtBot commented at 3:05 pm on October 4, 2023: contributor

    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.

  5. jamesob renamed this:
    2023 10 au test fix
    assumeutxo -stopatheight func test fix
    on Oct 4, 2023
  6. fanquake renamed this:
    assumeutxo -stopatheight func test fix
    test: assumeutxo -stopatheight func test fix
    on Oct 4, 2023
  7. DrahtBot added the label Tests on Oct 4, 2023
  8. fjahr commented at 3:09 pm on October 4, 2023: contributor

    Code review ACK 5bd2010f024b5bcccf1d57bae6fc36c53f5facc5

    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.

  9. jamesob renamed this:
    test: assumeutxo -stopatheight func test fix
    test: assumeutxo func test race fixes
    on Oct 4, 2023
  10. in test/functional/feature_assumeutxo.py:134 in eae98ccef5 outdated
    129@@ -130,8 +130,8 @@ def no_sync():
    130 
    131         monitor = n1.getchainstates()
    132         assert_equal(monitor['normal']['blocks'], START_HEIGHT)
    133-        assert_equal(monitor['snapshot']['blocks'], SNAPSHOT_BASE_HEIGHT)
    134-        assert_equal(monitor['snapshot']['snapshot_blockhash'], dump_output['base_hash'])
    135+        assert_equal(monitor.get('snapshot', {}).get('blocks'), SNAPSHOT_BASE_HEIGHT)
    136+        assert_equal(monitor.get('snapshot', {}).get('snapshot_blockhash'), dump_output['base_hash'])
    


    MarcoFalke commented at 3:20 pm on October 4, 2023:
    not sure. What is the goal of those changes, other than making the code more verbose and harder to read?

    jamesob commented at 3:21 pm on October 4, 2023:
    snapshot is an optional key in the RPC’s return value, so if the above call returns before a snapshot chainstate is loaded, it will KeyError as I’ve shown in #28585.

    jamesob commented at 3:23 pm on October 4, 2023:
    Oh I see what you’re saying - the test will still fail; of course… Reverting those.

    MarcoFalke commented at 3:24 pm on October 4, 2023:
    But then the assert_equal will fail anyway later on, no?
  11. hebasto commented at 3:25 pm on October 4, 2023: member
    Concept ACK.
  12. MarcoFalke commented at 3:26 pm on October 4, 2023: member
    lgtm ACK 5bd2010f024b5bcccf1d57bae6fc36c53f5facc5
  13. jamesob force-pushed on Oct 4, 2023
  14. jamesob commented at 3:28 pm on October 4, 2023: member

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

     02023-10-04T15:24:47.476000Z TestFramework (INFO): Restarted node before snapshot validation completed, reloading...
     12023-10-04T15:24:47.782000Z TestFramework (INFO): Ensuring snapshot chain syncs to tip. (399)
     22023-10-04T15:25:47.828000Z TestFramework.utils (ERROR): wait_until() failed. Predicate: ''''
     3            lambda: n1.getchainstates().get('snapshot', {}).get('blocks') == FINAL_HEIGHT)
     4'''
     52023-10-04T15:25:47.828000Z TestFramework (ERROR): Assertion failed
     6Traceback (most recent call last):
     7  File "/home/james/src/bitcoin/test/functional/test_framework/test_framework.py", line 131, in main
     8    self.run_test()
     9  File "/home/james/src/bitcoin/./test/functional/feature_assumeutxo.py", line 162, in run_test
    10    wait_until_helper(
    11  File "/home/james/src/bitcoin/test/functional/test_framework/util.py", line 276, in wait_until_helper
    12    raise AssertionError("Predicate {} not true after {} seconds".format(predicate_source, timeout))
    13AssertionError: Predicate ''''
    14            lambda: n1.getchainstates().get('snapshot', {}).get('blocks') == FINAL_HEIGHT)
    15''' not true after 60.0 seconds
    162023-10-04T15:25:47.879000Z TestFramework (INFO): Stopping nodes
    
  15. jamesob force-pushed on Oct 4, 2023
  16. tests: assumeutxo: accept final height from either chainstate 7e40032260
  17. MarcoFalke commented at 3:34 pm on October 4, 2023: member
    lgtm ACK 7e4003226030a04a19c718a4b1b83b4ca40ca33f
  18. DrahtBot requested review from fjahr on Oct 4, 2023
  19. jamesob commented at 3:35 pm on October 4, 2023: member

    Alright, I’m guessing we’re fixed for real this time; https://github.com/bitcoin/bitcoin/pull/28589/commits/7e4003226030a04a19c718a4b1b83b4ca40ca33f 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.

  20. fanquake added this to the milestone 26.0 on Oct 4, 2023
  21. ryanofsky approved
  22. ryanofsky commented at 3:52 pm on October 4, 2023: contributor

    Code review ACK 7e4003226030a04a19c718a4b1b83b4ca40ca33f

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

  23. fjahr commented at 3:54 pm on October 4, 2023: contributor
    Code review ACK 7e4003226030a04a19c718a4b1b83b4ca40ca33f
  24. DrahtBot removed review request from fjahr on Oct 4, 2023
  25. achow101 commented at 4:19 pm on October 4, 2023: member

    ACK 7e4003226030a04a19c718a4b1b83b4ca40ca33f

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

  26. DrahtBot requested review from achow101 on Oct 4, 2023
  27. DrahtBot removed review request from achow101 on Oct 4, 2023
  28. jamesob commented at 4:57 pm on October 4, 2023: member
    Test has been running on my machine in a loop without failure for about an hour now.
  29. achow101 merged this on Oct 4, 2023
  30. achow101 closed this on Oct 4, 2023


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-03 07:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me