Skip to content

Conversation

hernanmarino
Copy link
Contributor

@hernanmarino hernanmarino commented Feb 13, 2024

This PR adds a test which checks that snapshots with less accumulated work than the node's active chain, should not be loaded and return with an error. Although in a different context of discussion the missing test was detect in a thread in #29394 (see #29394 (comment))

@DrahtBot
Copy link
Contributor

DrahtBot commented Feb 13, 2024

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 maflcko, kevkevinpal, alfonsoromanz, achow101
Stale ACK BrandonOdiwuor, rkrux

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)
  • #29553 (assumeutxo: Add dumptxoutset height param, remove shell scripts by fjahr)

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.

@DrahtBot DrahtBot added the Tests label Feb 13, 2024
@maflcko
Copy link
Member

maflcko commented Feb 14, 2024

@aureleoules
Copy link
Contributor

Looks like corecheck.dev/bitcoin/bitcoin/pulls/29428 is dead?

@maflcko thanks for the ping. The code I added to filter out flaky coverage was too slow and isn't very reliable so I removed it. Unfortunately, the UI will now display flaky coverage.

@maflcko
Copy link
Member

maflcko commented Feb 19, 2024

You'll have to remove the TODO on the top of the file as well, when the test was added?

@hernanmarino
Copy link
Contributor Author

You'll have to remove the TODO on the top of the file as well, when the test was added?

Done. It'll be updated with my next push

Copy link
Contributor

@BrandonOdiwuor BrandonOdiwuor 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 8603741

Should remove the TODO fixed by this commit

@maflcko
Copy link
Member

maflcko commented Apr 23, 2024

Are you still working on this?

@hernanmarino hernanmarino marked this pull request as ready for review April 23, 2024 17:23
@hernanmarino
Copy link
Contributor Author

Are you still working on this?

I haven´t been able to think of / work on other tests to add, but the current commit test is ready for review, so i am taking the PR out of Draft status.

@maflcko
Copy link
Member

maflcko commented Apr 23, 2024

I was asking, because you said you'd update the branch in February: #29428 (comment)

@hernanmarino hernanmarino changed the title test: add missing tests for Assumeutxo test: Assumeutxo: snapshots with less work should not be loaded Apr 23, 2024
@hernanmarino hernanmarino force-pushed the assumeutxo-test-several branch from 8603741 to 4922f56 Compare April 23, 2024 19:39
@hernanmarino
Copy link
Contributor Author

Updated to remove a (no lonnger valid) TODO comment as requested in #29428 (comment). Also updated the PR title and description.

@maflcko
Copy link
Member

maflcko commented Apr 24, 2024

Please delete the hidden comment in the pull description, because this will end up in the merge commit.

@hernanmarino
Copy link
Contributor Author

hernanmarino commented Apr 24, 2024

Please delete the hidden comment in the pull description, because this will end up in the merge commit.

Oh, sorry for that. Deleted.

Copy link
Contributor

@alfonsoromanz alfonsoromanz 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 and tested ACK 4922f56

@DrahtBot DrahtBot requested a review from BrandonOdiwuor April 24, 2024 14:59
@maflcko
Copy link
Member

maflcko commented Apr 29, 2024

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

@aureleoules @adamjonas Looks like this is down again. LambdaTimeout - 2024-04-29T11:09:51.844Z 3957d9f6-7e67-4e79-bf45-9569b4491cd0 Task timed out after 10.01 seconds

Copy link
Contributor

@alfonsoromanz alfonsoromanz left a comment

Choose a reason for hiding this comment

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

Re ACK 2f1b1ee

@hernanmarino
Copy link
Contributor Author

Updated to re add an incorrectly removed TODO comment.

@maflcko
Copy link
Member

maflcko commented May 1, 2024

lgtm ACK 2f1b1ee

Copy link
Contributor

@rkrux rkrux left a comment

Choose a reason for hiding this comment

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

crACK, utACK 2f1b1eee

Thanks for adding the test, it's short and to the point. However, I've not been able to build the branch because it fails on my system (MAC i7) with the following error. I understand it is because this branch doesn't contain the latest changes of the master branch, notably this one: #29081.

util/time.cpp:54:9: error: use of undeclared identifier 'gmtime_s'; did you mean 'gmtime_r'?
    if (gmtime_s(&epoch, &time_val) != 0) {
        ^~~~~~~~
        gmtime_r

@achow101
Copy link
Member

achow101 commented May 9, 2024

Needs rebase (for some reason Drahtbot isn't detecting this)

@hernanmarino hernanmarino force-pushed the assumeutxo-test-several branch from 3e11746 to df6dc2a Compare May 23, 2024 00:08
@hernanmarino
Copy link
Contributor Author

Needs rebase (for some reason Drahtbot isn't detecting this)

Rebased. Also deleted a couple of redundant comment as suggested by @maflcko to retrigger the false negative CI

assert_equal(node.getblockcount(), FINAL_HEIGHT)
with node.assert_debug_log(expected_msgs=["[snapshot] activation failed - work does not exceed active chainstate"]):
assert_raises_rpc_error(-32603, "Unable to load UTXO snapshot", node.loadtxoutset, dump_output_path)
self.restart_node(0, extra_args=self.extra_args[0])
Copy link
Member

Choose a reason for hiding this comment

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

why restart if you aren't doing anything with the node?

@maflcko
Copy link
Member

maflcko commented May 23, 2024

utACK df6dc2a

@DrahtBot DrahtBot requested review from rkrux and alfonsoromanz May 23, 2024 08:20
@kevkevinpal
Copy link
Contributor

utACK df6dc2a

Copy link
Contributor

@alfonsoromanz alfonsoromanz left a comment

Choose a reason for hiding this comment

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

Re ACK df6dc2a. Make is successful and the test passes.

Screenshot 2024-05-28 at 09 55 15 Screenshot 2024-05-28 at 09 58 39

@achow101
Copy link
Member

achow101 commented Jun 4, 2024

ACK df6dc2a

@achow101 achow101 merged commit 56ea8ed into bitcoin:master Jun 4, 2024
achow101 added a commit that referenced this pull request Jul 2, 2024
… chain

2f9bde6 test: Remove unnecessary restart in assumeutxo test (Fabian Jahr)
19ce3d4 assumeutxo: Check snapshot base block is not marked invalid (Fabian Jahr)
80315c0 refactor: Move early loadtxoutset checks into ActiveSnapshot (Fabian Jahr)

Pull request description:

  This was discovered in a discussion in #29996

  If the base block of the snapshot is marked invalid or part of an invalid chain, we currently still load the snapshot and get stuck in a weird state where we have the snapshot chainstate but it will never connect to our valid chain.

  While this scenario is highly unlikely to occur on mainnet, it still seems good to prevent this inconsistent state.

  The behavior change described above is in the second commit.

  The first commit refactors the early checks in the `loadtxoutset` RPC by moving them into `ActivateSnapshot()` in order to have the chance to cover them by unit tests in the future and have a more consistent interface. Previously checks were spread out between `rpc/blockchain.cpp` and `validation.cpp`. In order to be able to return the error message to users of the RPC, the return type of `ActivateSnapshot()` is changed from `bool` to `util::Result`.

  The third commit removes an unnecessary restart introduced in #29428.

ACKs for top commit:
  mzumsande:
    re-ACK 2f9bde6
  alfonsoromanz:
    Re-ACK 2f9bde6. The RPC code looks much cleaner after the refactor. Also, it seems very useful to get the error message in the RPC response rather than having to rely on the logs in some scenarios if you are an RPC user.
  achow101:
    ACK 2f9bde6

Tree-SHA512: 5328dd88c3c7be3f1be97c9eef52ac3666c27188c30a798b3e949f3ffcb83be075127c107e4046f7f39f961a79911ea3d61b61f3c11e451b3e4c541c264eeed4
@bitcoin bitcoin locked and limited conversation to collaborators Jun 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants