Skip to content

Commit 0ce805b

Browse files
ryanofskysdaftuar
authored andcommitted
Documentation improvements for assumeutxo
1 parent 768690b commit 0ce805b

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

doc/design/assumeutxo.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ respectively generate and load UTXO snapshots. The utility script
1717

1818
- A new block index `nStatus` flag is introduced, `BLOCK_ASSUMED_VALID`, to mark block
1919
index entries that are required to be assumed-valid by a chainstate created
20-
from a UTXO snapshot. This flag is mostly used as a way to modify certain
20+
from a UTXO snapshot. This flag is used as a way to modify certain
2121
CheckBlockIndex() logic to account for index entries that are pending validation by a
22-
chainstate running asynchronously in the background. We also use this flag to control
23-
which index entries are added to setBlockIndexCandidates during LoadBlockIndex().
22+
chainstate running asynchronously in the background.
2423

2524
- The concept of UTXO snapshots is treated as an implementation detail that lives
2625
behind the ChainstateManager interface. The external presentation of the changes

src/chain.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ enum BlockStatus : uint32_t {
113113
BLOCK_VALID_TRANSACTIONS = 3,
114114

115115
//! Outputs do not overspend inputs, no double spends, coinbase output ok, no immature coinbase spends, BIP30.
116-
//! Implies all parents are also at least CHAIN.
116+
//! Implies all parents are either at least VALID_CHAIN, or are ASSUMED_VALID
117117
BLOCK_VALID_CHAIN = 4,
118118

119-
//! Scripts & signatures ok. Implies all parents are also at least SCRIPTS.
119+
//! Scripts & signatures ok. Implies all parents are either at least VALID_SCRIPTS, or are ASSUMED_VALID.
120120
BLOCK_VALID_SCRIPTS = 5,
121121

122122
//! All validity bits.
@@ -134,10 +134,18 @@ enum BlockStatus : uint32_t {
134134
BLOCK_OPT_WITNESS = 128, //!< block data in blk*.dat was received with a witness-enforcing client
135135

136136
/**
137-
* If set, this indicates that the block index entry is assumed-valid.
138-
* Certain diagnostics will be skipped in e.g. CheckBlockIndex().
139-
* It almost certainly means that the block's full validation is pending
140-
* on a background chainstate. See `doc/design/assumeutxo.md`.
137+
* If ASSUMED_VALID is set, it means that this block has not been validated
138+
* and has validity status less than VALID_SCRIPTS. Also that it may have
139+
* descendant blocks with VALID_SCRIPTS set, because they can be validated
140+
* based on an assumeutxo snapshot.
141+
*
142+
* When an assumeutxo snapshot is loaded, the ASSUMED_VALID flag is added to
143+
* unvalidated blocks at the snapshot height and below. Then, as the background
144+
* validation progresses, and these blocks are validated, the ASSUMED_VALID
145+
* flags are removed. See `doc/design/assumeutxo.md` for details.
146+
*
147+
* This flag is only used to implement checks in CheckBlockIndex() and
148+
* should not be used elsewhere.
141149
*/
142150
BLOCK_ASSUMED_VALID = 256,
143151
};

0 commit comments

Comments
 (0)