|
1 | | -# Assumeutxo Usage |
| 1 | +# Using Assumeutxo |
2 | 2 |
|
3 | | -Assumeutxo is a feature that allows fast bootstrapping of a validating dashd |
4 | | -instance. |
| 3 | +Assumeutxo can make a new Dash Core node usable quickly by loading a recent |
| 4 | +chainstate snapshot. The node syncs forward from the snapshot immediately and, |
| 5 | +at the same time, validates every block from genesis in the background. For |
| 6 | +implementation details, see the [design document](/doc/design/assumeutxo.md). |
5 | 7 |
|
6 | | -For notes on the design of Assumeutxo, please refer to [the design doc](/doc/design/assumeutxo.md). |
| 8 | +## Availability and trust |
7 | 9 |
|
8 | | -## Loading a snapshot |
| 10 | +There is currently no canonical snapshot distribution service and this tree |
| 11 | +has no mainnet or testnet snapshot parameters. Built-in snapshots and the |
| 12 | +`-assumeutxodata` option are for regtest only until release builders generate |
| 13 | +and review production parameters. |
9 | 14 |
|
10 | | -There is currently no canonical source for snapshots, but any downloaded snapshot |
11 | | -will be checked against a hash that's been hardcoded in source code. If there is |
12 | | -no source for the snapshot you need, you can generate it yourself using |
13 | | -`dumptxoutset` on another node that is already synced (see |
14 | | -[Generating a snapshot](#generating-a-snapshot)). |
| 15 | +A snapshot may be transported by an untrusted third party. For production |
| 16 | +parameters, Dash Core accepts it only when its network and base block match an |
| 17 | +authorized entry and both its UTXO hash and Dash evo-state hash match the |
| 18 | +hardcoded values. (Two built-in legacy regtest fixtures retain a test-only null |
| 19 | +evo-hash wildcard.) Dash Core also |
| 20 | +cross-checks the deterministic masternode list, quorum commitments, and credit |
| 21 | +pool against commitments in the base block's CbTx. Background validation then |
| 22 | +re-derives the UTXO set and canonical masternode state from genesis before the |
| 23 | +snapshot is considered fully validated. |
15 | 24 |
|
16 | | -Once you've obtained the snapshot, you can use the RPC command `loadtxoutset` to |
17 | | -load it. |
| 25 | +## Obtain or create a snapshot |
18 | 26 |
|
19 | | -``` |
20 | | -$ dash-cli loadtxoutset /path/to/input |
21 | | -``` |
22 | | - |
23 | | -After the snapshot has loaded, the syncing process of both the snapshot chain |
24 | | -and the background IBD chain can be monitored with the `getchainstates` RPC. |
25 | | - |
26 | | -### Pruning |
27 | | - |
28 | | -A pruned node can load a snapshot. To save space, it's possible to delete the |
29 | | -snapshot file as soon as `loadtxoutset` finishes. |
| 27 | +Obtain a snapshot for an authorized base height from a source you choose, or |
| 28 | +create one on a normally synced node with `dumptxoutset`. A current-tip dump is: |
30 | 29 |
|
31 | | -The minimum `-prune` setting is 550 MiB, but this functionality ignores that |
32 | | -minimum and uses at least 1100 MiB. |
| 30 | +```text |
| 31 | +dash-cli -rpcclienttimeout=0 dumptxoutset /path/to/utxo.dat latest |
| 32 | +``` |
33 | 33 |
|
34 | | -As the background sync continues there will be temporarily two chainstate |
35 | | -directories, each multiple gigabytes in size (likely growing larger than the |
36 | | -downloaded snapshot). |
| 34 | +To dump a particular recent height (or block hash), temporarily roll the node |
| 35 | +back while writing the snapshot: |
37 | 36 |
|
38 | | -### Indexes |
| 37 | +```text |
| 38 | +dash-cli -rpcclienttimeout=0 -named dumptxoutset /path/to/utxo.dat rollback=HEIGHT |
| 39 | +``` |
39 | 40 |
|
40 | | -Indexes work but don't take advantage of this feature. They always start building |
41 | | -from the genesis block and can only apply blocks in order. Once the background |
42 | | -validation reaches the snapshot block, indexes will continue to build all the |
43 | | -way to the tip. |
| 41 | +The positional form `dumptxoutset /path/to/utxo.dat rollback` selects the |
| 42 | +latest base already authorized in chain parameters. A rollback dump requires |
| 43 | +all intervening block and undo data, so it can fail on a pruned node. Network |
| 44 | +activity is suspended and peers are disconnected during rollback; avoid other |
| 45 | +block-storage RPCs until the command finishes. The original tip is reconsidered |
| 46 | +after the dump. Use an unlimited or long RPC timeout because hashing and evo |
| 47 | +snapshot construction can take several minutes. |
44 | 48 |
|
| 49 | +The result includes `base_hash`, `base_height`, `txoutset_hash`, `evo_hash`, |
| 50 | +`nchaintx`, and the written path. Operators can reproduce an authorized dump at |
| 51 | +the same base and compare both hashes. Creating a dump at an arbitrary height |
| 52 | +does not authorize it for loading; authorization is supplied by chain |
| 53 | +parameters (or, on regtest, an exact `-assumeutxodata` entry). |
45 | 54 |
|
46 | | -For indexes that support pruning, note that these indexes only allow blocks that |
47 | | -were already indexed to be pruned. Blocks that are not indexed yet will also |
48 | | -not be pruned. |
| 55 | +## Load and monitor a snapshot |
49 | 56 |
|
50 | | -This means that, if the snapshot is old, then a lot of blocks after the snapshot |
51 | | -block will need to be downloaded, and these blocks can't be pruned until they |
52 | | -are indexed, so they could consume a lot of disk space until indexing catches up |
53 | | -to the snapshot block. |
| 57 | +Wait for the destination node to learn the base block header, ensure its |
| 58 | +mempool is empty, and load the file: |
54 | 59 |
|
55 | | -## Generating a snapshot |
| 60 | +```text |
| 61 | +dash-cli loadtxoutset /path/to/utxo.dat |
| 62 | +``` |
56 | 63 |
|
57 | | -The RPC command `dumptxoutset` can be used to generate a snapshot for the current |
58 | | -tip (using type "latest") or a recent height (using type "rollback"). A generated |
59 | | -snapshot from one node can then be loaded |
60 | | -on any other node. However, keep in mind that the snapshot hash needs to be |
61 | | -listed in the chainparams to make it usable. If there is no snapshot hash for |
62 | | -the height you have chosen already, you will need to change the code there and |
63 | | -re-compile. |
| 64 | +Relative paths are resolved under the network data directory. On success the |
| 65 | +result reports `coins_loaded`, `tip_hash`, `base_height`, and `path`. The input |
| 66 | +file can then be removed; Dash Core has copied its state into |
| 67 | +`chainstate_snapshot` and EvoDB. |
64 | 68 |
|
65 | | -Using the type parameter "rollback", `dumptxoutset` can also be used to verify the |
66 | | -hardcoded snapshot hash in the source code by regenerating the snapshot and |
67 | | -comparing the hash. |
| 69 | +`loadtxoutset` is unavailable when Dash Core is running in masternode mode. |
| 70 | +Stop using `-masternodeblsprivkey` and restart as a regular node before loading |
| 71 | +a snapshot. Quorum signing is also refused whenever an unvalidated snapshot is |
| 72 | +active. |
68 | 73 |
|
69 | | -Example usage: |
| 74 | +Monitor progress with: |
70 | 75 |
|
71 | | -``` |
72 | | -$ dash-cli -rpcclienttimeout=0 dumptxoutset /path/to/output rollback |
| 76 | +```text |
| 77 | +dash-cli getchainstates |
73 | 78 | ``` |
74 | 79 |
|
75 | | -For most of the duration of `dumptxoutset` running the node is in a temporary |
76 | | -state that does not actually reflect reality, i.e. blocks are marked invalid |
77 | | -although we know they are not invalid. Because of this it is discouraged to |
78 | | -interact with the node in any other way during this time to avoid inconsistent |
79 | | -results and race conditions, particularly RPCs that interact with blockstorage. |
80 | | -This inconsistent state is also why network activity is temporarily disabled, |
81 | | -causing us to disconnect from all peers. |
82 | | - |
83 | | -`dumptxoutset` takes some time to complete, independent of hardware and |
84 | | -what parameter is chosen. Because of that it is recommended to increase the RPC |
85 | | -client timeout value (use `-rpcclienttimeout=0` for no timeout). |
| 80 | +During background validation, `chainstates` normally contains two entries. The |
| 81 | +active snapshot entry has `snapshot_blockhash` and `validated: false`; the |
| 82 | +historical entry advances from genesis. The snapshot chain syncs to the network |
| 83 | +tip first, so normal wallet and mempool use can begin before background |
| 84 | +validation finishes. |
| 85 | + |
| 86 | +When the historical entry reaches the snapshot base, Dash Core recomputes the |
| 87 | +UTXO hash, compares the canonical masternode list and required reconstruction |
| 88 | +history, and completes any CbTx/evo checks deferred until the base block was |
| 89 | +available. The active entry then reports `validated: true`. Cleanup and |
| 90 | +promotion are crash-safe and may finish on the next restart, after which only |
| 91 | +one normal chainstate remains. |
| 92 | + |
| 93 | +If any required hash or derived-state comparison fails, Dash Core invalidates |
| 94 | +the snapshot and shuts down rather than continuing on it. Follow the reported |
| 95 | +recovery instruction; a reindex may be required for an EvoDB inconsistency. |
| 96 | + |
| 97 | +## Disk use, pruning, and indexes |
| 98 | + |
| 99 | +A pruned node can use Assumeutxo, but dual-chainstate operation can temporarily |
| 100 | +exceed the configured prune budget. The minimum block-file allowance is needed |
| 101 | +for each chainstate, the snapshot base is retained until deferred checks |
| 102 | +complete, and index builders retain blocks they have not processed. |
| 103 | + |
| 104 | +Indexes still build sequentially from genesis; they do not begin at the |
| 105 | +snapshot base. Expect extra download time and disk use until background |
| 106 | +validation and indexes catch up. Two chainstate databases also remain on disk |
| 107 | +until validation succeeds and cleanup completes. |
0 commit comments