test: Added test to ensure log and failure happen when work is less than active chainstate #30105

pull kevkevinpal wants to merge 1 commits into bitcoin:master from kevkevinpal:assumeutxoExceedActiveChainstatelog changing 1 files +6 −1
  1. kevkevinpal commented at 0:03 am on May 15, 2024: contributor

    This adds coverage to the ActivateSnapshot function asserting that when we try to use a snapshot with too little work done on it, using loadtxoutset. That this log and rpc error are thrown

    log [snapshot] activation failed - work does not exceed active chainstate [snapshot] activation failed - population failed rpc error Unable to load UTXO snapshot

    Adds coverage to this code https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L5659

  2. DrahtBot commented at 0:03 am on May 15, 2024: contributor

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

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK rkrux
    Concept ACK tdb3

    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:

    • #29996 (test: Assumeutxo: import snapshot in a node with a divergent chain by alfonsoromanz)
    • #29681 (test: loading assumeutxo snapshot start states by BrandonOdiwuor)

    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.

  3. DrahtBot added the label Tests on May 15, 2024
  4. kevkevinpal force-pushed on May 15, 2024
  5. kevkevinpal force-pushed on May 15, 2024
  6. kevkevinpal force-pushed on May 15, 2024
  7. kevkevinpal force-pushed on May 15, 2024
  8. DrahtBot added the label CI failed on May 15, 2024
  9. DrahtBot commented at 0:59 am on May 15, 2024: contributor

    🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the documentation.

    Possibly this is 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.

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

    Debug: https://github.com/bitcoin/bitcoin/runs/24977593545

  10. in test/functional/feature_assumeutxo.py:240 in de7ac866cc outdated
    236@@ -237,6 +237,9 @@ def run_test(self):
    237         # will allow us to test n1's sync-to-tip on top of a snapshot.
    238         self.generate(n0, nblocks=100, sync_fun=self.no_op)
    239 
    240+        with n0.assert_debug_log(expected_msgs=["[snapshot] activation failed - work does not exceed active chainstate","[snapshot] activation failed - population failed"]):
    


    tdb3 commented at 1:56 am on May 15, 2024:

    Made a temporary modification of a word in the expected message (of feature_assumeutxo.py to test that a mismatch would be caught (it was, as expected). Restored to original expected message then modified the message in validation.cpp. This mismatch was also detected (as expected)l.

    https://github.com/bitcoin/bitcoin/blob/695d80126f75a99c80d5d6c18ebaaabf7410b989/src/validation.cpp#L5659

    The default timeout for assert_debug_log() is 2 seconds. I haven’t had a chance to dig deeper yet, but are we confident there isn’t a potential timing issue with the message arriving into the debug log later than 2 seconds? (e.g. a late arrival potentially causing an intermittent test failure). I haven’t encountered this, but only ran the tests a few times.

    https://github.com/bitcoin/bitcoin/blob/695d80126f75a99c80d5d6c18ebaaabf7410b989/test/functional/test_framework/test_node.py#L462


    kevkevinpal commented at 10:16 pm on May 15, 2024:

    Thanks for the review!

    I think the timeout should be fine there is even a comment pointing out that we check the work twice because we want to fail fast https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L5655-L5657

  11. DrahtBot removed the label CI failed on May 15, 2024
  12. in test/functional/feature_assumeutxo.py:243 in de7ac866cc outdated
    236@@ -237,6 +237,9 @@ def run_test(self):
    237         # will allow us to test n1's sync-to-tip on top of a snapshot.
    238         self.generate(n0, nblocks=100, sync_fun=self.no_op)
    239 
    240+        with n0.assert_debug_log(expected_msgs=["[snapshot] activation failed - work does not exceed active chainstate","[snapshot] activation failed - population failed"]):
    241+            assert_raises_rpc_error(-32603, "Unable to load UTXO snapshot", n0.loadtxoutset, dump_output['path'])
    


    tdb3 commented at 2:00 am on May 15, 2024:
    Also made a temporary modification to this expected message. Mismatch was caught (as expected).

    rkrux commented at 10:21 am on May 16, 2024:
    @kevkevinpal We are loading the snapshot of n0 in n0 itslelf? Should it not be loaded into n1?

    kevkevinpal commented at 12:13 pm on May 16, 2024:

    Thank you for the review!

    yes, we should be able to remove that TODO: (removed in ac1b0e3)

    I used n0 instead of n1 because if we use n1 it will properly work because n1 is not synced up yet. So I used n0 to loadtxoutset of a chainstate which is certain to be older than its current chainstate


    rkrux commented at 12:28 pm on May 16, 2024:
    I see, though it seemed unusual initially that we are loading a snapshot in the same node. But now that I think more about it - this can happen in a real world scenario as well, right? Eg: When the node is re-started after a long time and needs to catch up to the latest blocks.
  13. tdb3 commented at 2:04 am on May 15, 2024: contributor

    Concept ACK

    Thanks. It’s great to add test coverage. Left a question.

  14. rkrux commented at 10:23 am on May 16, 2024: none
    Make successful, all functional tests also. Asked a question and provided a suggestion. @kevkevinpal Should we get rid of this TODO on line 26 now? https://github.com/bitcoin/bitcoin/blob/master/test/functional/feature_assumeutxo.py#L26
  15. test: Added test to ensure log and failure happen when work is less than active chainstate
    Signed-off-by: kevkevinpal <oapallikunnel@gmail.com>
    ac1b0e3ee9
  16. kevkevinpal force-pushed on May 16, 2024
  17. rkrux approved
  18. rkrux commented at 12:29 pm on May 16, 2024: none

    tACK ac1b0e3

    There’s a lint error though here, but otherwise LGTM.

  19. DrahtBot requested review from tdb3 on May 16, 2024
  20. rkrux commented at 2:05 pm on May 16, 2024: none
    Just realised this is similar to this PR: #29428
  21. DrahtBot commented at 2:55 pm on May 16, 2024: contributor

    🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the documentation.

    Possibly this is 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.

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

    Debug: https://github.com/bitcoin/bitcoin/runs/25050589884

  22. DrahtBot added the label CI failed on May 16, 2024
  23. kevkevinpal commented at 1:46 pm on May 25, 2024: contributor

    Just realised this is similar to this PR: #29428

    Oh nice I didnt see this, closing this now

  24. kevkevinpal closed this on May 25, 2024


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-06-29 07:13 UTC

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