-
Notifications
You must be signed in to change notification settings - Fork 38.7k
assumeutxo: Fix -reindex before snapshot was validated #29726
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
assumeutxo: Fix -reindex before snapshot was validated #29726
Conversation
This didn't work for two reasons:
1.) GetSnapshotCoinsDBPath() was used to retrieve the path.
This requires coins_views to exist, but the initialisation only happens later
(in CompleteChainstateInitialization) so the node hits an assert in
CCoinsViewDB& CoinsDB() and crashes.
2.) The snapshot was already activated, so it has the mempool attached.
Therefore, the mempool needs to be transferred back to the ibd
chainstate before deleting the snapshot chainstate.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
BrandonOdiwuor
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
fjahr
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.
tACK cfdef5c
Good catch! I could reproduce the crash and that the change here fixes this.
My suggested test extension can be pulled in here if you retouch or I can add it to one of my outstanding assumeutxo PRs as a small follow-up.
| assert_equal(n1.getblockchaininfo()["blocks"], SNAPSHOT_BASE_HEIGHT) | ||
|
|
||
| self.log.info(f"Check that restarting with -reindex will delete the snapshot chainstate") | ||
| self.restart_node(1, extra_args=['-reindex=1', *self.extra_args[1]]) |
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.
This only covers -reindex but not -reindex-chainstate. It's easily possible when using node 2 for the test instead which is not pruned: fjahr@38c5d80
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.
Thanks! I took your suggestion (with a minor change to logging).
BrandonOdiwuor
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.
crACK cfdef5c
Co-authored-by: Fabian Jahr <fjahr@protonmail.com>
cfdef5c to
b7ba60f
Compare
|
re-ACK b7ba60f |
BrandonOdiwuor
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 b7ba60f
|
crACK b7ba60f . Good fix |
byaye
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.
This didn't work for two reasons:
1.) GetSnapshotCoinsDBPath() was used to retrieve the path.
This requires coins_views to exist, but the initialisation only happens later
(in CompleteChainstateInitialization) so the node hits an assert in
CCoinsViewDB& CoinsDB() and crashes.
2.) The snapshot was already activated, so it has the mempool attached.
Therefore, the mempool needs to be transferred back to the ibd
chainstate before deleting the snapshot chainstate.
Github-Pull: bitcoin#29726
Rebased-From: e57f951
Co-authored-by: Fabian Jahr <fjahr@protonmail.com> Github-Pull: bitcoin#29726 Rebased-From: b7ba60f
This didn't work for two reasons:
1.) GetSnapshotCoinsDBPath() was used to retrieve the path.
This requires coins_views to exist, but the initialisation only happens later
(in CompleteChainstateInitialization) so the node hits an assert in
CCoinsViewDB& CoinsDB() and crashes.
2.) The snapshot was already activated, so it has the mempool attached.
Therefore, the mempool needs to be transferred back to the ibd
chainstate before deleting the snapshot chainstate.
Github-Pull: bitcoin#29726
Rebased-From: e57f951
Co-authored-by: Fabian Jahr <fjahr@protonmail.com> Github-Pull: bitcoin#29726 Rebased-From: b7ba60f
Summary: > validation: assumeutxo: swap m_mempool on snapshot activation > > Otherwise we will not receive transactions during background sync until restart. bitcoin/bitcoin@9511fb3 And swap it back before deleting the snapshot chainstate: > init, validation: Fix -reindex option with an existing snapshot > > This didn't work for two reasons: > 1.) GetSnapshotCoinsDBPath() was used to retrieve the path. > This requires coins_views to exist, but the initialisation only happens later > (in CompleteChainstateInitialization) so the node hits an assert in > CCoinsViewDB& CoinsDB() and crashes. > > 2.) The snapshot was already activated, so it has the mempool attached. > Therefore, the mempool needs to be transferred back to the ibd > chainstate before deleting the snapshot chainstate. bitcoin/bitcoin@e57f951 A functional test for [[bitcoin/bitcoin#29726 | core#29726]] is added later, when we can test assumeutxo (requires loadtxoutset) This is a partial backport of [[bitcoin/bitcoin#27596 | core#27596]] and [[bitcoin/bitcoin#29726 | core#29726]] Depends on D17896 Test Plan: `ninja all check-all` (on my dev branch which has the functional test) Run a full assumeutxo IBD (on my dev branch) Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D17897


In c711ca1 logic was introduced that
-reindexand-reindex-chainstatewill delete the snapshot chainstate.This doesn't work currently, instead of deleting the snapshot chainstate the node crashes with an assert (this can be triggered by applying the added test commit on master).
Fix this, and another bug that would prevent the new active chainstate from having a mempool after
-reindexhas deleted the snapshot (also covered by the test).