-
Notifications
You must be signed in to change notification settings - Fork 37.7k
validation: run VerifyDB on all chainstates #21523
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
Conversation
d758ad1
to
cd93f82
Compare
I guess after rebasing on top of 2bdf37f, most of this is just a name change. But there are still a few changes of substance and the rename is probably worth doing. |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
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.
Code review ACK cd93f82. This seems safe and straightforward. I think it would be good to put the renames in a separate commit from the two more substantive changes, but it's not very important.
re: #21523 (comment)
Two minor tweaks to ensure that
VerifyDB
can be run on multiple chainstates and a corresponding rename.
IIUC the two tweaks are:
- Updating
AppInitMain
to callVerifyDB
on all chainstates, not just the active one - Tweaking
VerifyDB
to treat a snapshot chainstate like a pruned chainstate and not fail trying to read missing blocks
And everything else is cleanups and renames
src/validation.cpp
Outdated
break; | ||
if (fPruneMode && !(pindex->nStatus & BLOCK_HAVE_DATA)) { | ||
if ((fPruneMode || g_chainman.IsSnapshotActive()) && !(pindex->nStatus & BLOCK_HAVE_DATA)) { |
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.
In commit "validation: parameterize VerifyDB by chainstate" (cd93f82)
Could comment below be updated to explain the g_chainman
check?
Also could logprint below be updated to not mention pruning if block isn't pruned?
Also it would seem more direct and less likely to hide errors to check here if chainstate
specifically is an unvalidated snapshot, instead of checking if there is just any snapshot. This would avoid hiding legitimate errors if the background chainstate is missing blocks.
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 would avoid hiding legitimate errors if the background chainstate is missing blocks.
Good catch! Fixed.
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.
Code review ACK cd93f82
But I agree with @ryanofsky that the comment and log message look like they should be updated as mentioned in #21523 (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.
Code Review ACK cd93f82
I agree with other reviewers, would be better to split in its own commit renaming.
54584a6
to
c47a00d
Compare
Thanks for the reviews so far @ryanofsky @fjahr @ariard. I've incorporated your feedback and split out the rename commit. |
Code Review ACK c47a00d |
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.
Code review ACK c47a00d with caveat that first commit currently doesn't compile, but problems are fixed after. Changes since last review: splitting commits, making the BLOCK_HAVE_DATA check a little broader so it doesn't expect blocks from the non-snapshot chainstate, dropping type cast, adding IsSnapshotActive comment
src/validation.cpp
Outdated
if (nCheckLevel >= 3 && (coins.DynamicMemoryUsage() + active_chainstate.CoinsTip().DynamicMemoryUsage()) <= active_chainstate.m_coinstip_cache_size_bytes) { | ||
int64_t curr_coins_usage = coins.DynamicMemoryUsage() + chainstate.CoinsTip().DynamicMemoryUsage(); | ||
|
||
if (nCheckLevel >= 3 && static_cast<unsigned long>(curr_coins_usage) <= chainstate.m_coinstip_cache_size_bytes) { |
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.
In commit "refactor: rename active_chainstate in VerifyDB" (de83651)
It doesn't really matter and this is fixed in the next commit, but there are three different types here: int64_t
for curr_coins_usage
, unsigned long
for the cast, and size_t
for m_coinstip_cache_size_bytes
, and it would be nice to use size_t
for all three from the start.
Code Review ACK c47a00d |
To prepare VerifyDB semantics for multiple chainstate use.
Removes assumptions of use only on the active chainstate.
c47a00d
to
844ad0e
Compare
Rebased and fixed compilation for the first commit. Thanks for the looks all. |
Code review re-ACK 844ad0e |
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.
review ACK 844ad0e 🐥
Show signature and timestamp
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
review ACK 844ad0eccaa1dbfefc30d19804d95d67c3d5f06d 🐥
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUicJAv9ExcrfQAEyZXbnZ9PJ6yiL++S/RdO9zGQpraFXR3geg2Jzez5Lmnj+KYr
+xHKFZVGVFTL1CdmHFivTAe8HRLMoyaGmzQDfwJl8WBm96EKVWg+Gk9gtvWp+6Pl
Qv9M2uyKuKbSCAS/dKBhPzcsK6o41Ji2zrqmc9VhaS3uWA16VxNeaRAAmf0cBymL
pOBb/EbsmgpuxeyefrTgR+bvT/jQ4t15r9TC3QBVVKH6X/bNfB0Tzb1vKv34DmX0
rtGprvutdAgmHwxnsFhyeRT9ZIrasO2/0bMWEuaH/xqbjcDLa98bf7RV/0acPvsp
HQR/iC0xXoGWa4Zj4ydrbGr18HrG9PYc6sAqxG5LQ/KIFgyUco/0PDEDpO35wYEr
3Cv7scuEEoeVBH1tzjss8dp7sCRArnSISzQMm45X9ZqjmsBjjvUtPGzkHgRh8xz/
mgfhIg/V1MNOdCRXxCLnQ8gsw98LiwTMvLXPGSbB66qUACqvBaqCS9bWpdcQByd2
AIGXoVA5
=gUOg
-----END PGP SIGNATURE-----
Timestamp of file with hash 9b4c4c61593ad7aa160c2fb769c97159e09b00e6c5ba6cc0c987f607bb34c988 -
src/validation.cpp
Outdated
|
||
if (nCheckLevel >= 3 && static_cast<unsigned long>(curr_coins_usage) <= chainstate.m_coinstip_cache_size_bytes) { |
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.
9b604c0: Maybe move this hunk to the previous commit?
@@ -4135,8 +4138,9 @@ bool CVerifyDB::VerifyDB( | |||
uiInterface.ShowProgress(_("Verifying blocks...").translated, percentageDone, false); | |||
if (pindex->nHeight <= chainstate.m_chain.Height()-nCheckDepth) | |||
break; | |||
if (fPruneMode && !(pindex->nStatus & BLOCK_HAVE_DATA)) { | |||
// If pruning, only go back as far as we have data. | |||
if ((fPruneMode || is_snapshot_cs) && !(pindex->nStatus & BLOCK_HAVE_DATA)) { |
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.
9b604c0: Wouldn't it be easier to remove the prune and snapshot condition and simply check HAVE_DATA? Performance shouldn't decrease and it would be less code, which is nice.
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 guess your goal is to treat it as error when block data is missing, but pruning is off an no snapshot is loaded?
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.
Right - I think we want to fail here if we're lacking block data when not pruning or operating from snapshot.
Summary: > refactor: rename active_chainstate in VerifyDB > > To prepare VerifyDB semantics for multiple chainstate use. > validation: prepare VerifyDB for assumeutxo > > Removes assumptions of use only on the active chainstate. > doc: IsSnapshotActive This is a backport of [[bitcoin/bitcoin#21523 | core#21523]] Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D11334
This is part of the assumeutxo project (parent PR: #15606)
Pretty cut and dry; parameterizesCVerifyDB
methods so that we can run the verify procedure on multiple chainstates.Two minor tweaks to ensure that
VerifyDB
can be run on multiple chainstates and a corresponding rename.