Skip to content

Commit 82be652

Browse files
committed
doc: Improve ChainstateManager documentation, use consistent terms
1 parent af455dc commit 82be652

File tree

2 files changed

+24
-31
lines changed

2 files changed

+24
-31
lines changed

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6120,7 +6120,7 @@ SnapshotCompletionResult ChainstateManager::MaybeValidateSnapshot(Chainstate& va
61206120
return SnapshotCompletionResult::STATS_FAILED;
61216121
}
61226122

6123-
// Compare the background validation chainstate's UTXO set hash against the hard-coded
6123+
// Compare the validated chainstate's UTXO set hash against the hard-coded
61246124
// assumeutxo hash we expect.
61256125
//
61266126
// TODO: For belt-and-suspenders, we could cache the UTXO set

src/validation.h

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -756,9 +756,9 @@ class Chainstate
756756
* validationinterface callback.
757757
*
758758
* Note that if this is called while a snapshot chainstate is active, and if
759-
* it is called on a background chainstate whose tip has reached the base block
760-
* of the snapshot, its execution will take *MINUTES* while it hashes the
761-
* background UTXO set to verify the assumeutxo value the snapshot was activated
759+
* it is called on a validated chainstate whose tip has reached the base
760+
* block of the snapshot, its execution will take *MINUTES* while it hashes
761+
* the UTXO set to verify the assumeutxo value the snapshot was activated
762762
* with. `cs_main` will be held during this time.
763763
*
764764
* @returns true unless a system error occurred
@@ -897,41 +897,34 @@ enum class SnapshotCompletionResult {
897897
// base block.
898898
MISSING_CHAINPARAMS,
899899

900-
// Failed to generate UTXO statistics (to check UTXO set hash) for the background
901-
// chainstate.
900+
// Failed to generate UTXO statistics (to check UTXO set hash) for the
901+
// validated chainstate.
902902
STATS_FAILED,
903903

904-
// The UTXO set hash of the background validation chainstate does not match
905-
// the one expected by assumeutxo chainparams.
904+
// The UTXO set hash of the validated chainstate does not match the one
905+
// expected by assumeutxo chainparams.
906906
HASH_MISMATCH,
907907
};
908908

909909
/**
910-
* Provides an interface for creating and interacting with one or two
911-
* chainstates: an IBD chainstate generated by downloading blocks, and
912-
* an optional snapshot chainstate loaded from a UTXO snapshot. Managed
913-
* chainstates can be maintained at different heights simultaneously.
910+
* Interface for managing multiple \ref Chainstate objects, where each
911+
* chainstate is associated with chainstate* subdirectory in the data directory
912+
* and contains a database of UTXOs existing at a different point in history.
913+
* (See \ref Chainstate class for more information.)
914914
*
915-
* This class provides abstractions that allow the retrieval of the current
916-
* most-work chainstate ("Active") as well as chainstates which may be in
917-
* background use to validate UTXO snapshots.
915+
* Normally there is exactly one Chainstate, which contains the UTXO set of
916+
* chain tip if syncing is completed, or the UTXO set the most recent validated
917+
* block if the initial sync is still in progress.
918918
*
919-
* Definitions:
920-
*
921-
* *IBD chainstate*: a chainstate whose current state has been "fully"
922-
* validated by the initial block download process.
923-
*
924-
* *Snapshot chainstate*: a chainstate populated by loading in an
925-
* assumeutxo UTXO snapshot.
926-
*
927-
* *Active chainstate*: the chainstate containing the current most-work
928-
* chain. Consulted by most parts of the system (net_processing,
929-
* wallet) as a reflection of the current chain and UTXO set.
930-
* This may either be an IBD chainstate or a snapshot chainstate.
931-
*
932-
* *Background IBD chainstate*: an IBD chainstate for which the
933-
* IBD process is happening in the background while use of the
934-
* active (snapshot) chainstate allows the rest of the system to function.
919+
* However, if an assumeutxo snapshot is loaded before syncing is completed,
920+
* there will be two chainstates. The original fully validated chainstate will
921+
* continue to exist and download new blocks in the background. But the new
922+
* snapshot which is loaded will become a second chainstate. The second
923+
* chainstate will be used as the chain tip for the wallet and RPCs even though
924+
* it is only assumed to be valid. When the initial chainstate catches up to the
925+
* snapshot height and confirms that the assumeutxo snapshot is actually valid,
926+
* the second chainstate will be marked validated and become the only chainstate
927+
* again.
935928
*/
936929
class ChainstateManager
937930
{

0 commit comments

Comments
 (0)