test, assumeutxo: Remove resolved todo comments and add new test #30403

pull fjahr wants to merge 2 commits into bitcoin:master from fjahr:2024-07-au-todo changing 1 files +7 −15
  1. fjahr commented at 4:11 pm on July 6, 2024: contributor

    The first commit removes three Todos that have been addressed previously (see commit message for details).

    The second message resolves another todo by adding the missing test case. This is a special case of “the tip has more work than the snapshot” where the tip is the same block as the snapshot base block.

    Related to #28648.

  2. DrahtBot commented at 4:11 pm on July 6, 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 jrakibi, maflcko, alfonsoromanz, achow101
    Stale ACK BrandonOdiwuor, 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:

    • #30497 (rpc: Return errors in loadtxoutset that currently go to logs by maflcko)

    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 Jul 6, 2024
  4. alfonsoromanz commented at 4:52 pm on July 6, 2024: contributor

    ACK 9d5a89509031ce924b9685a6e2e4b19cfef50a9e

    I wonder if this is a good place to discuss other (potentially addressed) TODOs?

    For example, interesting starting states could be loading a snapshot when the current chain tip is:

    - TODO: An ancestor of snapshot block: isn’t this already addressed when successfully loading the snapshot into node1 here? Node1’s chain tip is at START_HEIGTH (199) before loading the snapshot, and the block 199 is an ancestor of the snapshot block (299)

    - TODO: A descendant of the snapshot block: isn’t this addressed by the function test_snapshot_with_less_work? (link). Node0 is at FINAL_HEIGHT (399) with the tip being a descendant of the snapshot block (at 299)

  5. tdb3 approved
  6. tdb3 commented at 6:47 pm on July 6, 2024: contributor
    ACK 9d5a89509031ce924b9685a6e2e4b19cfef50a9e Double checking #30403 (comment) would also be good as well.
  7. fjahr force-pushed on Jul 8, 2024
  8. fjahr commented at 11:13 am on July 8, 2024: contributor

    I wonder if this is a good place to discuss other (potentially addressed) TODOs?

    Right, good idea. I avoided this for a while because I thought I might miss something because I misinterpret them but since we had these detailed discussions in #29996 I am now pretty confident we can remove some that are addressed.

    For example, interesting starting states could be loading a snapshot when the current chain tip is:

    - TODO: An ancestor of snapshot block: isn’t this already addressed when successfully loading the snapshot into node1 here? Node1’s chain tip is at START_HEIGTH (199) before loading the snapshot, and the block 199 is an ancestor of the snapshot block (299)

    I think this is addressed and I am also unsure if this was ever not addressed :) Elsewhere I realized that I am not sure if “chain tip” in this comment refers to sync of headers or of blocks. But either way: If this is about blocks then any successful load is addressing this because if we have synced past the snapshot base block we fail because we don’t need assumeutxo anymore. And if this is about headers then this is the test_headers_not_synced() case.

    - TODO: A descendant of the snapshot block: isn’t this addressed by the function test_snapshot_with_less_work? (link). Node0 is at FINAL_HEIGHT (399) with the tip being a descendant of the snapshot block (at 299)

    Yeah, I agree and if it is just headers in this case again it would be represented in all of the successful loads in the test.

  9. fjahr commented at 11:16 am on July 8, 2024: contributor

    I have amended the commit to remove the previously named comments + made @alfonsoromanz co-author.

    In the second commit I now resolve one of the few remaining cases where the tip is on the same block as the snapshot. This is a special case of the “more work” case so this was quite simple to do.

    I think this means with this and the remaining open test PRs from @alfonsoromanz and @mzumsande we could resolve this list completely :)

  10. fjahr renamed this:
    test: Remove already resolved assumeutxo todo comment
    test, assumeutxo: Remove resolved todo comments and add new test
    on Jul 8, 2024
  11. fjahr commented at 11:27 am on July 8, 2024: contributor

    To give more detail where they are resolved: I think #30320 resolves two of the remaining three, it’s just not part of the PR yet, see: #30320 (review) and #29996 removes the third as already done in the commit here: https://github.com/bitcoin/bitcoin/pull/29996/commits/5b7f70ba2661a194a3c476b81e03785feddb4e1c.

    The last one to get merged gets to remove the whole comment section 🥳

  12. alfonsoromanz approved
  13. alfonsoromanz commented at 12:27 pm on July 8, 2024: contributor

    Re ACK 29d19c414c9e138c99f8de84e398528db92ff07e. The test execution is successful.

    I agree that this PR, along with #30320 and #29996, would resolve the TODO list completely.

    Thanks!

  14. DrahtBot requested review from tdb3 on Jul 8, 2024
  15. BrandonOdiwuor approved
  16. BrandonOdiwuor commented at 4:30 pm on July 8, 2024: contributor

    Code Review ACK 29d19c414c9e138c99f8de84e398528db92ff07e

    I will close PR #29681 in favor of this

  17. fjahr commented at 4:38 pm on July 8, 2024: contributor
    Oh, sorry @BrandonOdiwuor , I missed #29681 😞
  18. in test/functional/feature_assumeutxo.py:265 in 29d19c414c outdated
    260@@ -267,6 +261,12 @@ def run_test(self):
    261         self.log.info(f"Creating a UTXO snapshot at height {SNAPSHOT_BASE_HEIGHT}")
    262         dump_output = n0.dumptxoutset('utxos.dat')
    263 
    264+        # Test special case where the tip of the node is on the same block as
    265+        # the snapshot
    


    tdb3 commented at 1:44 am on July 10, 2024:

    nit: Would be good to make this comment a self.log.info() message instead.

    https://github.com/bitcoin/bitcoin/blob/master/test/functional/README.md#general-test-writing-advice

    Instead of inline comments or no test documentation at all, log the comments to the test log


    fjahr commented at 8:57 am on July 10, 2024:
    Done
  19. in test/functional/feature_assumeutxo.py:307 in 29d19c414c outdated
    260@@ -267,6 +261,12 @@ def run_test(self):
    261         self.log.info(f"Creating a UTXO snapshot at height {SNAPSHOT_BASE_HEIGHT}")
    262         dump_output = n0.dumptxoutset('utxos.dat')
    263 
    264+        # Test special case where the tip of the node is on the same block as
    265+        # the snapshot
    266+        assert_equal(n0.getblockcount(), SNAPSHOT_BASE_HEIGHT)
    267+        assert_equal(n0.getblockchaininfo()["blocks"], SNAPSHOT_BASE_HEIGHT)
    268+        self.test_snapshot_with_less_work(dump_output['path'])
    


    tdb3 commented at 1:54 am on July 10, 2024:
    nit: Would this be less than or equal to? (equal to in this case).

    fjahr commented at 8:57 am on July 10, 2024:
    I think it’s fine to keep the function name as is. The comment (now a log) provides the necessary context and I think it’s just a special edge case of the less work behavior.
  20. in test/functional/feature_assumeutxo.py:21 in 29d19c414c outdated
    18 - TODO: Valid snapshot file and snapshot block, but the block is not on the
    19       most-work chain
    20 
    21 Interesting starting states could be loading a snapshot when the current chain tip is:
    22 
    23-- TODO: An ancestor of snapshot block
    


    tdb3 commented at 1:59 am on July 10, 2024:

    -TODO: An ancestor of snapshot block: isn’t this already addressed when successfully loading the snapshot into node1 here?

    nit: Would be good to be more explicit in the log message near the line (or add one more) to document for future readers what the test covers. This way if there are changes in the future, the changes don’t accidentally remove case coverage.


    fjahr commented at 8:57 am on July 10, 2024:
    I think it’s a bit too verbose for the log but I added a comment. And I think it will be confusing to explicitly say everywhere in the normal case that the tip is an ancestor of the snapshot. But it’s documented in one place now at least.

    tdb3 commented at 0:48 am on July 11, 2024:
    Yup, seems like its the most likely use case for assumeutxo, so I could see how that could be quite verbose.
  21. tdb3 approved
  22. tdb3 commented at 2:02 am on July 10, 2024: contributor

    ACK 29d19c414c9e138c99f8de84e398528db92ff07e

    Left some nits.

  23. fjahr force-pushed on Jul 10, 2024
  24. in test/functional/feature_assumeutxo.py:310 in e523bcfc34 outdated
    305@@ -307,6 +306,8 @@ def run_test(self):
    306         self.test_snapshot_block_invalidated(dump_output['path'])
    307 
    308         self.log.info(f"Loading snapshot into second node from {dump_output['path']}")
    309+        # This node's tip is on an ancestor block of the snapshot, which should
    310+        # the normal case
    


    alfonsoromanz commented at 1:05 pm on July 10, 2024:
    Nit: Missing a “be”, i.e. “which should be the normal case.” Not sure if it’s worth fixing, but just wanted to point it out

    fjahr commented at 2:39 pm on July 10, 2024:
    fixed, thanks!
  25. alfonsoromanz approved
  26. alfonsoromanz commented at 1:07 pm on July 10, 2024: contributor
    Re ACK e523bcfc3403700debe1f286fa8c3db2d347e40b
  27. DrahtBot requested review from tdb3 on Jul 10, 2024
  28. DrahtBot requested review from BrandonOdiwuor on Jul 10, 2024
  29. fjahr force-pushed on Jul 10, 2024
  30. DrahtBot added the label Needs rebase on Jul 10, 2024
  31. fjahr force-pushed on Jul 10, 2024
  32. fjahr commented at 10:29 pm on July 10, 2024: contributor
    Rebased
  33. DrahtBot removed the label Needs rebase on Jul 10, 2024
  34. tdb3 approved
  35. tdb3 commented at 0:48 am on July 11, 2024: contributor
    ACK e1018672672f39910655ab37080bf3213ca55a39
  36. DrahtBot requested review from alfonsoromanz on Jul 11, 2024
  37. alfonsoromanz approved
  38. alfonsoromanz commented at 7:42 am on July 11, 2024: contributor
    Re ACK e1018672672f39910655ab37080bf3213ca55a39
  39. DrahtBot added the label Needs rebase on Jul 18, 2024
  40. test: Remove already resolved assumeutxo todo comments
    - "Valid snapshot file, but referencing a snapshot block that turns out
      to be invalid, or has an invalid parent" has been addressed in #30267
    - "An ancestor of snapshot block" - If chain tip refers to blocks in this context then any successful load is addressing this because if we have synced past the snapshot base block we fail because we don't need assumeutxo anymore. And if this is about headers then this is the `test_headers_not_synced()` case.
    - "A descendant of the snapshot block" - If this refers to blocks the
      `test_snapshot_with_less_work()` addressed this and if it is just headers in this case again it would be represented in all of the successful loads in the test.
    
    Co-authored-by: Alfonso Roman Zubeldia <alfonsoromanz24@gmail.com>
    c2f86d4bcb
  41. test: Add loadtxoutset test with tip on snapshot block
    Also pulls out the guarding assert and calls it explicitly before the test function is called. This is already done before the existing call of the test function so it was not needed there.
    d63ef73800
  42. fjahr force-pushed on Jul 18, 2024
  43. fjahr commented at 11:57 pm on July 18, 2024: contributor
    Rebased and since this is the last of the PRs addressing the TODOs comment in feature_assumeutxo.py, it now removes that whole section.
  44. DrahtBot removed the label Needs rebase on Jul 19, 2024
  45. jrakibi commented at 11:34 am on July 20, 2024: contributor
    ACK d63ef73
  46. DrahtBot requested review from alfonsoromanz on Jul 20, 2024
  47. DrahtBot requested review from tdb3 on Jul 20, 2024
  48. in test/functional/feature_assumeutxo.py:17 in c2f86d4bcb outdated
    10@@ -11,16 +11,9 @@
    11 
    12 ## Possible test improvements
    13 
    14-Interesting test cases could be loading an assumeutxo snapshot file with:
    15-
    16-- TODO: Valid snapshot file, but referencing a snapshot block that turns out to be
    17-      invalid, or has an invalid parent
    


    maflcko commented at 9:07 am on July 23, 2024:
    nit: I think that test in #30267 only checks for a known-invalid header, not for a valid header of a block that later “turns out to be invalid”. Also, a test could be added where a block later turns out to have less work, but this is discussed in https://github.com/bitcoin/bitcoin/issues/30288
  49. maflcko approved
  50. maflcko commented at 9:11 am on July 23, 2024: member

    ACK d63ef738001fb69ce04134cc8645dcd1e1cbccd1

    left a nit (possibly a new test idea, but this can be done later).

  51. alfonsoromanz approved
  52. alfonsoromanz commented at 9:33 am on July 23, 2024: contributor
    Re ACK d63ef738001fb69ce04134cc8645dcd1e1cbccd1
  53. achow101 commented at 5:24 pm on July 23, 2024: member
    ACK d63ef738001fb69ce04134cc8645dcd1e1cbccd1
  54. achow101 merged this on Jul 23, 2024
  55. achow101 closed this on Jul 23, 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-09-29 01:12 UTC

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