-
Notifications
You must be signed in to change notification settings - Fork 35.7k
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
Rework validation logic for assumeutxo #27746
Changes from all commits
fe86a7c
1cfc887
471da5f
10c0571
272fbc3
3cfc753
d0d40ea
d43a1f1
768690b
0ce805b
3556b85
d4a11ab
a733dd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,10 +113,10 @@ enum BlockStatus : uint32_t { | |
BLOCK_VALID_TRANSACTIONS = 3, | ||
|
||
//! Outputs do not overspend inputs, no double spends, coinbase output ok, no immature coinbase spends, BIP30. | ||
//! Implies all parents are also at least CHAIN. | ||
//! Implies all parents are either at least VALID_CHAIN, or are ASSUMED_VALID | ||
BLOCK_VALID_CHAIN = 4, | ||
|
||
//! Scripts & signatures ok. Implies all parents are also at least SCRIPTS. | ||
//! Scripts & signatures ok. Implies all parents are either at least VALID_SCRIPTS, or are ASSUMED_VALID. | ||
BLOCK_VALID_SCRIPTS = 5, | ||
|
||
//! All validity bits. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0ce805b: maybe make this: //! All (non-assumed) validity bits. Which makes functions that use this more readable: ![]() |
||
|
@@ -134,10 +134,18 @@ enum BlockStatus : uint32_t { | |
BLOCK_OPT_WITNESS = 128, //!< block data in blk*.dat was received with a witness-enforcing client | ||
|
||
/** | ||
* If set, this indicates that the block index entry is assumed-valid. | ||
* Certain diagnostics will be skipped in e.g. CheckBlockIndex(). | ||
* It almost certainly means that the block's full validation is pending | ||
* on a background chainstate. See `doc/design/assumeutxo.md`. | ||
* If ASSUMED_VALID is set, it means that this block has not been validated | ||
* and has validity status less than VALID_SCRIPTS. Also that it may have | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0ce805b: why not Same question for I tried changing
That didn't break a test and makes more intuitive sense to me. It also seems more consistent with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I asked myself the same question recently and came to the conclusion that it's because when we finally end up downloading the assumed-valid blocks, there will be a period in time where we've saved the block (and therefore raised its validity to |
||
* descendant blocks with VALID_SCRIPTS set, because they can be validated | ||
* based on an assumeutxo snapshot. | ||
* | ||
* When an assumeutxo snapshot is loaded, the ASSUMED_VALID flag is added to | ||
* unvalidated blocks at the snapshot height and below. Then, as the background | ||
* validation progresses, and these blocks are validated, the ASSUMED_VALID | ||
* flags are removed. See `doc/design/assumeutxo.md` for details. | ||
* | ||
* This flag is only used to implement checks in CheckBlockIndex() and | ||
* should not be used elsewhere. | ||
ryanofsky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
BLOCK_ASSUMED_VALID = 256, | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,7 +221,7 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize | |
|
||
// A reload of the block index is required to recompute setBlockIndexCandidates | ||
// for the fully validated chainstate. | ||
chainman.ActiveChainstate().UnloadBlockIndex(); | ||
chainman.ActiveChainstate().ClearBlockIndexCandidates(); | ||
ryanofsky marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
222
to
+224
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In commit "Move block-arrival information / preciousblock counters to ChainstateManager" (471da5f) The "reload of the block index" comment now seems out of date. And actually I don't see why this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
auto [init_status, init_error] = CompleteChainstateInitialization(chainman, cache_sizes, options); | ||
if (init_status != ChainstateLoadStatus::SUCCESS) { | ||
|
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.
0ce805b: why isn't
BLOCK_VALID_TRANSACTIONS
also alternativelyASSUMED_VALID
?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: #27746 (comment)
I'm not sure what this review comment is asking. The code comment above still seems accurate to me, but it maybe it could be improved.
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's related to #27746 (comment)
(it suggests a further refactor, not changing the comment)