-
Notifications
You must be signed in to change notification settings - Fork 38.7k
test: Add bitcoin-chainstate test for assumeutxo functionality #33728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
test: Add bitcoin-chainstate test for assumeutxo functionality #33728
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33728. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
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. |
frankomosh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
I think its a nice addition as it adds valuable functional coverage for bitcoin-chainstate.
Few nits and inquiries inline;
src/validation.cpp
Outdated
| @@ -6321,7 +6321,7 @@ Chainstate& ChainstateManager::ActivateExistingSnapshot(uint256 base_blockhash) | |||
| LogInfo("[snapshot] switching active chainstate to %s", m_snapshot_chainstate->ToString()); | |||
|
|
|||
| // Mempool is empty at this point because we're still in IBD. | |||
| Assert(m_active_chainstate->m_mempool->size() == 0); | |||
| Assert(!m_active_chainstate->m_mempool || m_active_chainstate->m_mempool->size() == 0); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this now weaker that the original assertion, because I think it will now silently accepts a null mempool pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is weaker, yes, but we similarly guard in other situations. We also still have the assertion in ActivateSnapshot to guard this condition at a more critical point in time.
sedited
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
Consolidating the tests into the regtest case seems fine to me, especially since this is just a utility to showcase and doogfood some of the kernel work.
src/validation.cpp
Outdated
| @@ -6321,7 +6321,7 @@ Chainstate& ChainstateManager::ActivateExistingSnapshot(uint256 base_blockhash) | |||
| LogInfo("[snapshot] switching active chainstate to %s", m_snapshot_chainstate->ToString()); | |||
|
|
|||
| // Mempool is empty at this point because we're still in IBD. | |||
| Assert(m_active_chainstate->m_mempool->size() == 0); | |||
| Assert(!m_active_chainstate->m_mempool || m_active_chainstate->m_mempool->size() == 0); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is weaker, yes, but we similarly guard in other situations. We also still have the assertion in ActivateSnapshot to guard this condition at a more critical point in time.
986eb77 to
3e7d272
Compare
|
986eb77 to 3e7d272 - reversed the order of |
sedited
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 3e7d272b2747f1937010b8fc1fefafcfa0ce3213
|
Concept ACK |
|
ACK 3e7d272 |
3e7d272 to
67740df
Compare
|
3e7d272 to 67740df - rebased and resolved conflict with #30595. |
sedited
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-ACK 67740dfe6cfe3f3f91aaad41018a7da9004dcd8c
|
re-ACK 67740df |
67740df to
6cb63db
Compare
|
67740df to 6cb63db - Rebased and removed unused variable |
sedited
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-ACK 6cb63db
| // SETUP: Argument parsing and handling | ||
| if (argc != 2) { | ||
| const bool has_regtest_flag{argc == 3 && std::string(argv[1]) == "-regtest"}; | ||
| if (argc < 2 || argc > 3 || (argc == 3 && !has_regtest_flag)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been thinking lately whether we can reuse some of our own common utilities for these small, kernel-based applications. These small, single use applications should be able to use our usual utilities, while still benefiting from a clearer kernel interface. I think we are at a point now, where we can confidently mix between the two without risking introducing an entanglement regression between what the kernel requires and what new code might introduce in it. For this reason, I added some basic argument handling on my branch over here: https://github.com/sedited/bitcoin/tree/bitcoin_chainstate_args , that might be interesting for this change here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks! It seems I can cherry-pick your commit as is to replace bfceb4c?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks! It seems I can cherry-pick your commit as is to replace bfceb4c?
Sure, if you think it is a good idea too :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reviewers:
As discussed offline, adding ArgsManager and the G_TRANSLATION_FUN definition that should be added because of it, is causing different compile/link issues since the symbol is also defined in the kernel library and @sedited is suggesting to have the symbol removed from there.
So it seems adapting bitcoin-chainstate.cpp to use the ArgsManager could be done in a follow-up.
Adds -regtest flag to enable testing with regtest chain parameters.
Check mempool exists before accessing size when prev_chainstate doesn't have initialized mempool.
Adds functional test coverage for bitcoin-chainstate tool loading a datadir initialized with an assumeutxo snapshot
6cb63db to
7b5d256
Compare
theStack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept and code-review ACK 7b5d256
As a follow-up idea, it might make sense to deduplicate the deterministic generation of the snapshot chain between this test and feature_assumeutxo.py, by moving the logic into a test framework module.
sedited
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-ACK 7b5d256
This PR adds functional test coverage for the bitcoin-chainstate tool loading a datadir initialized with an assumeutxo snapshot.
The PR also includes:
ChainstateManager::AddChainstate()whenprev_chainstatehas no initialized mempool (required for the test to pass)-regtestflag support for bitcoin-chainstate to enable the testingThis work started while experimenting with the bitcoin-chainstate tool and how the kernel API (#30595) behaved when loading a datadir containing assumeutxo data, during the time that PR was still under review. @sedited suggested opening a PR to add this test coverage.