Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
064100a
fix(evo): partition Evo-derived caches by view
PastaPastaPasta Nov 20, 2026
6ebc01c
fix(evo): bind non-active paths and dispatcher boundaries explicitly
PastaPastaPasta Oct 15, 2026
583d7a9
fixup! fix(evo): bind non-active paths and dispatcher boundaries expl…
PastaPastaPasta Nov 28, 2026
97c2ed6
fixup! fix(evo): bind non-active paths and dispatcher boundaries expl…
PastaPastaPasta Nov 28, 2026
0bcdc57
fixup! fix(evo): bind non-active paths and dispatcher boundaries expl…
PastaPastaPasta Nov 28, 2026
b37ca6f
fixup! fix(evo): bind non-active paths and dispatcher boundaries expl…
PastaPastaPasta Nov 28, 2026
06879fe
fixup! fix(evo): bind non-active paths and dispatcher boundaries expl…
PastaPastaPasta Nov 28, 2026
ebbff73
amend! fix(evo): bind non-active paths and dispatcher boundaries expl…
PastaPastaPasta Nov 28, 2026
313f2b6
fixup! fix(evo): bind non-active paths and dispatcher boundaries expl…
PastaPastaPasta Nov 29, 2026
f363b81
fixup! fix(evo): bind non-active paths and dispatcher boundaries expl…
PastaPastaPasta Nov 29, 2026
c9f6c68
feat(evo): reject unbound Evo reads during dual operation
PastaPastaPasta Oct 15, 2026
815787f
fix(validation): stop reading a rejected snapshot when its rejection …
PastaPastaPasta Oct 31, 2026
98a482c
fixup! fix(validation): stop reading a rejected snapshot when its rej…
PastaPastaPasta Nov 28, 2026
3b94cd7
fixup! fix(validation): stop reading a rejected snapshot when its rej…
PastaPastaPasta Nov 28, 2026
1a242ad
fixup! fix(validation): stop reading a rejected snapshot when its rej…
PastaPastaPasta Nov 28, 2026
6a62b6d
fixup! feat(evo): reject unbound Evo reads during dual operation
PastaPastaPasta Nov 28, 2026
50f4ead
fixup! fix(validation): stop reading a rejected snapshot when its rej…
PastaPastaPasta Nov 28, 2026
ad378ef
fixup! fix(validation): stop reading a rejected snapshot when its rej…
PastaPastaPasta Nov 28, 2026
cdeca19
fixup! feat(evo): reject unbound Evo reads during dual operation
PastaPastaPasta Nov 28, 2026
f572ae8
fixup! fix(validation): stop reading a rejected snapshot when its rej…
PastaPastaPasta Nov 28, 2026
c64c0c4
amend! feat(evo): reject unbound Evo reads during dual operation
PastaPastaPasta Nov 28, 2026
7bb5879
amend! fix(validation): stop reading a rejected snapshot when its rej…
PastaPastaPasta Nov 28, 2026
8cc36ee
fixup! feat(evo): reject unbound Evo reads during dual operation
PastaPastaPasta Nov 28, 2026
e342632
fixup! feat(evo): reject unbound Evo reads during dual operation
PastaPastaPasta Nov 29, 2026
8cec98c
feat(evo): v4 snapshot with derived rotation dependencies and bootstr…
PastaPastaPasta Oct 15, 2026
1702146
feat(evo): carry and consume the credit-pool window
PastaPastaPasta Oct 15, 2026
61c5f6e
feat(evo): carry the header-proven base coinbase and use it for B+1 C…
PastaPastaPasta Oct 15, 2026
3ef5405
fix(evo): export the raw MNHF signal record at the base and derive th…
PastaPastaPasta Oct 16, 2026
7ba70bd
fix(evo): carry the snapshot's masternode ids into NORMAL's at promotion
PastaPastaPasta Nov 28, 2026
90b5e8a
fix(evo): number the evo section's masternodes canonically
PastaPastaPasta Nov 28, 2026
4ff33c7
fixup! feat(evo): carry the header-proven base coinbase and use it fo…
PastaPastaPasta Nov 28, 2026
c83d62d
fixup! feat(evo): v4 snapshot with derived rotation dependencies and …
PastaPastaPasta Nov 28, 2026
a62d85c
fixup! feat(evo): carry and consume the credit-pool window
PastaPastaPasta Nov 28, 2026
6bbaf1d
fixup! feat(evo): carry the header-proven base coinbase and use it fo…
PastaPastaPasta Nov 28, 2026
405a70a
fixup! fix(evo): export the raw MNHF signal record at the base and de…
PastaPastaPasta Nov 28, 2026
2a1d8ab
fixup! fix(evo): carry the snapshot's masternode ids into NORMAL's at…
PastaPastaPasta Nov 28, 2026
a34eda0
fixup! fix(evo): number the evo section's masternodes canonically
PastaPastaPasta Nov 28, 2026
58d77a4
fixup! feat(evo): v4 snapshot with derived rotation dependencies and …
PastaPastaPasta Nov 29, 2026
282803d
fixup! feat(evo): carry the header-proven base coinbase and use it fo…
PastaPastaPasta Nov 29, 2026
ce3456c
fixup! feat(evo): v4 snapshot with derived rotation dependencies and …
PastaPastaPasta Nov 29, 2026
07f5e37
fixup! fix(evo): export the raw MNHF signal record at the base and de…
PastaPastaPasta Nov 29, 2026
26a47d2
fixup! fix(evo): export the raw MNHF signal record at the base and de…
PastaPastaPasta Nov 29, 2026
921021b
fixup! feat(evo): v4 snapshot with derived rotation dependencies and …
PastaPastaPasta Nov 29, 2026
bb8c99b
fixup! feat(evo): v4 snapshot with derived rotation dependencies and …
PastaPastaPasta Nov 29, 2026
3018f70
fixup! feat(evo): carry and consume the credit-pool window
PastaPastaPasta Nov 29, 2026
e322eca
fixup! fix(evo): export the raw MNHF signal record at the base and de…
PastaPastaPasta Nov 29, 2026
125b5fe
fix(llmq): exact work modifiers and no silent degradation under the s…
PastaPastaPasta Oct 15, 2026
581e2d9
feat(llmq): prove ChainLock and asset-unlock scan coverage
PastaPastaPasta Nov 20, 2026
d7e2fec
fixup! fix(llmq): exact work modifiers and no silent degradation unde…
PastaPastaPasta Nov 28, 2026
32302a5
fixup! feat(llmq): prove ChainLock and asset-unlock scan coverage
PastaPastaPasta Nov 28, 2026
b9deac4
fixup! feat(llmq): prove ChainLock and asset-unlock scan coverage
PastaPastaPasta Nov 29, 2026
1000658
feat(rpc): emit the v4 evo section in dumptxoutset
PastaPastaPasta Oct 15, 2026
2b3686c
feat(validation): require a matching evo pin; add regtest -assumeutxo…
PastaPastaPasta Oct 15, 2026
d0e65c0
test: suppress a TSan lock-order false positive from a reused stack a…
PastaPastaPasta Nov 19, 2026
5bd76bf
fixup! feat(rpc): emit the v4 evo section in dumptxoutset
PastaPastaPasta Nov 28, 2026
c42534b
fixup! feat(validation): require a matching evo pin; add regtest -ass…
PastaPastaPasta Nov 28, 2026
84521b9
feat(validation): seed into an unpublished generation, dry-run, then …
PastaPastaPasta Oct 15, 2026
b821065
feat(validation): rebuild and compare the full evo section at completion
PastaPastaPasta Nov 10, 2026
b4330b6
fixup! feat(validation): seed into an unpublished generation, dry-run…
PastaPastaPasta Nov 28, 2026
918f649
fixup! feat(validation): rebuild and compare the full evo section at …
PastaPastaPasta Nov 28, 2026
9cbe438
fixup! feat(validation): seed into an unpublished generation, dry-run…
PastaPastaPasta Nov 29, 2026
2bf1541
fixup! feat(validation): rebuild and compare the full evo section at …
PastaPastaPasta Nov 29, 2026
0513cdf
feat(validation): remember Evo state stalls and keep the chain usable…
PastaPastaPasta Nov 28, 2026
ffec133
fix(instantsend): keep the snapshot chain and discard a conflicting l…
PastaPastaPasta Nov 28, 2026
72aea47
Merge bitcoin/bitcoin#27596: assumeutxo (2)
PastaPastaPasta Nov 8, 2026
d3195aa
Merge bitcoin/bitcoin#28589: test: assumeutxo func test race fixes
PastaPastaPasta Nov 8, 2026
eff6795
Merge bitcoin/bitcoin#28590: assumeutxo: change getchainstates RPC to…
PastaPastaPasta Nov 8, 2026
c4bffa0
Merge bitcoin/bitcoin#28562: AssumeUTXO follow-ups
PastaPastaPasta Nov 8, 2026
bf6abdb
Merge bitcoin/bitcoin#28625: test: check that loading snapshot not ma…
PastaPastaPasta Nov 8, 2026
1c620c3
Merge bitcoin/bitcoin#28639: refactor: Remove unused nchaintx from Sn…
PastaPastaPasta Nov 8, 2026
03840d1
Merge bitcoin/bitcoin#28652: assumeutxo: fail early if snapshot block…
PastaPastaPasta Nov 8, 2026
b0d2fab
Merge bitcoin/bitcoin#28647: test: Add assumeutxo test for wrong hash
PastaPastaPasta Nov 8, 2026
0986fee
Merge bitcoin/bitcoin#28666: test: assumeutxo file with unknown block…
PastaPastaPasta Nov 8, 2026
74c769f
Merge bitcoin/bitcoin#28669: test: check assumeutxo file for changed …
PastaPastaPasta Nov 8, 2026
285b823
test: add the feature_assumeutxo.py cases of bitcoin#28685
PastaPastaPasta Nov 8, 2026
45e8010
Merge bitcoin/bitcoin#28698: assumeutxo, blockstorage: Prevent core d…
PastaPastaPasta Nov 8, 2026
daeb7b5
Merge bitcoin/bitcoin#28835: test: Check error details with assert_de…
PastaPastaPasta Nov 8, 2026
0243b51
Merge bitcoin/bitcoin#28838: test: add assumeutxo wallet test
PastaPastaPasta Nov 8, 2026
d80dbf6
Merge bitcoin/bitcoin#31556: validation: Send correct notification du…
PastaPastaPasta Nov 8, 2026
df1189a
Merge bitcoin/bitcoin#29262: rpc: Fix race in loadtxoutset
PastaPastaPasta Nov 24, 2026
955d8d9
Merge bitcoin/bitcoin#30388: validation: Check if mempool exists befo…
PastaPastaPasta Nov 9, 2026
e528d3b
feat(validation): refuse snapshots on pruned nodes, masternodes and w…
PastaPastaPasta Nov 8, 2026
20d3590
fix(init): start the index threads once when snapshot completion come…
PastaPastaPasta Nov 24, 2026
db7548e
fix(validation): tell Dash tip consumers the snapshot tip at activation
PastaPastaPasta Nov 24, 2026
c64e5df
fixup! feat(validation): remember Evo state stalls and keep the chain…
PastaPastaPasta Nov 28, 2026
6894d1a
fixup! fix(validation): tell Dash tip consumers the snapshot tip at a…
PastaPastaPasta Nov 28, 2026
f9eb991
fix(governance): wait for the collateral index to follow the active c…
PastaPastaPasta Nov 8, 2026
9df6982
fix(validation): serialize snapshot activations
PastaPastaPasta Nov 8, 2026
66badfd
fix(validation): replace a leftover chainstate_todelete at promotion
PastaPastaPasta Nov 8, 2026
1d422a7
fix(validation): keep the validated chainstate's block candidates whe…
PastaPastaPasta Nov 9, 2026
cb8f90c
fix(validation): stop loading a mempool file once its chainstate no l…
PastaPastaPasta Nov 9, 2026
7b5e56c
fix(validation): refuse packages through a chainstate that does not h…
PastaPastaPasta Nov 24, 2026
5a47514
fix(validation): detach the mempool when a snapshot is rejected
PastaPastaPasta Nov 9, 2026
ec0d755
test: add an end-to-end AssumeUTXO test on a Dash masternode network
PastaPastaPasta Nov 9, 2026
797e206
fix(qt): clear the wizard's state-unavailable label once masternode s…
PastaPastaPasta Nov 9, 2026
64052e0
fix(validation): refuse a snapshot that omits a known ChainLock, allo…
PastaPastaPasta Nov 28, 2026
68a59c8
test: dump on a node that numbers masternodes differently
PastaPastaPasta Nov 28, 2026
7b7f841
feat(rpc,net): refuse Evo history requests until snapshot background …
PastaPastaPasta Nov 29, 2026
6a8f318
fixup! feat(rpc,net): refuse Evo history requests until snapshot back…
PastaPastaPasta Nov 29, 2026
51aa88d
fixup! feat(rpc,net): refuse Evo history requests until snapshot back…
PastaPastaPasta Nov 29, 2026
0725692
fixup! feat(rpc,net): refuse Evo history requests until snapshot back…
PastaPastaPasta Nov 30, 2026
46fabd7
Merge bitcoin/bitcoin#29215: test: assumeutxo: spend coin from snapsh…
PastaPastaPasta Nov 9, 2026
bafc499
Merge bitcoin/bitcoin#29370: assumeutxo: Get rid of faked nTx and nCh…
PastaPastaPasta Nov 9, 2026
a25d706
fix(validation): forget a rejected snapshot's base in the block index
PastaPastaPasta Nov 9, 2026
f082ee5
Merge bitcoin/bitcoin#29720: rpc: Avoid getchaintxstats invalid results
PastaPastaPasta Nov 9, 2026
eaa8ab5
Merge bitcoin/bitcoin#29726: assumeutxo: Fix -reindex before snapshot…
PastaPastaPasta Nov 9, 2026
0dc2f14
Merge bitcoin/bitcoin#30053: test: added test coverage to loadtxoutse…
PastaPastaPasta Nov 9, 2026
acd73e1
Merge bitcoin/bitcoin#29345: rpc: Do not wait for headers inside load…
PastaPastaPasta Nov 25, 2026
c64fe21
Merge bitcoin/bitcoin#29478: test: Test new header sync behavior in l…
PastaPastaPasta Nov 25, 2026
d6f6017
Merge bitcoin/bitcoin#30267: assumeutxo: Check snapshot base block is…
PastaPastaPasta Nov 9, 2026
1193207
Merge bitcoin/bitcoin#29996: Assumeutxo: bugfix on loadtxoutset with …
PastaPastaPasta Nov 9, 2026
fe78170
fix(validation): restore the best header when blocks are reconsidered
PastaPastaPasta Nov 25, 2026
b8faabe
Merge bitcoin/bitcoin#30320: assumeutxo: Don't load a snapshot if it'…
PastaPastaPasta Nov 9, 2026
5669f3e
Merge bitcoin/bitcoin#29519: p2p: For assumeutxo, download snapshot c…
PastaPastaPasta Nov 9, 2026
54df1ab
Merge bitcoin/bitcoin#30636: test: assumeutxo: check that UTXO-queryi…
PastaPastaPasta Nov 10, 2026
9ac250b
Merge bitcoin/bitcoin#30807: Fix peers abruptly disconnecting from As…
PastaPastaPasta Nov 9, 2026
5c34bd0
Merge bitcoin/bitcoin#30962: validation: Disable CheckForkWarningCond…
PastaPastaPasta Nov 9, 2026
9097b24
partial Merge bitcoin/bitcoin#30909: wallet, assumeutxo: Don't Assume…
PastaPastaPasta Nov 9, 2026
01dbb0c
test: use peers without the snapshot block only after the snapshot is…
PastaPastaPasta Nov 9, 2026
1176a5f
fix(validation): keep a snapshot chainstate on its base until promotion
PastaPastaPasta Nov 25, 2026
f92c96c
Merge bitcoin/bitcoin#34286: test: verify node state after restart in…
PastaPastaPasta Nov 9, 2026
38f9300
Merge bitcoin/bitcoin#34728: test: Fix intermittent issue in wallet_a…
PastaPastaPasta Nov 9, 2026
99ac631
Merge bitcoin/bitcoin#34852: test: Fix intermittent issue in feature_…
PastaPastaPasta Nov 9, 2026
f35e0f2
fixup! Merge bitcoin/bitcoin#30962: validation: Disable CheckForkWarn…
PastaPastaPasta Nov 29, 2026
82c783b
feat(chainparams): pin AssumeUTXO snapshots for mainnet and testnet
PastaPastaPasta Nov 28, 2026
7b62a4a
feat(rpc): make loadtxoutset and getchainstates available on every ne…
PastaPastaPasta Nov 28, 2026
a896e94
doc: describe loading the pinned AssumeUTXO snapshots on mainnet and …
PastaPastaPasta Nov 28, 2026
2d8a07b
doc: name the pins release note after its PR
PastaPastaPasta Nov 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 53 additions & 15 deletions doc/design/assumeutxo.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,50 @@
# assumeutxo

Assumeutxo is a feature that allows fast bootstrapping of a validating dashd
instance with a very similar security model to assumevalid.
instance.

## Loading a snapshot

There is currently no canonical source for snapshots, but any downloaded snapshot
will be checked against a hash that's been hardcoded in source code.

Once you've obtained the snapshot, you can use the RPC command `loadtxoutset`
(yet to be merged) to load it.
Dash Core accepts one snapshot per network:

| network | base height | base block hash | snapshot file size | snapshot file sha256 |
| ------- | ----------- | --------------- | ------------------ | -------------------- |
| mainnet | 2579482 | `000000000000001cfbe4751211d7e753bab093e5d63de1fa947cf20714a0e727` | 289606403 bytes | `bf65a65ef575989e58df25f5781187a6b4dec25e0211b329fb2413b203dc952f` |
| testnet | 1599687 | `0000006e4b85a1f38f3224ead2865de8e7f29d98229b58b00a1b1bedab624872` | 64126131 bytes | `651e5b29b8c9ff9b50606cbd95c515e7877fb0004432bfa9d4bdce228fc99786` |

The snapshot file is deterministic: `dumptxoutset` writes the same bytes at the same
base block on every node, so a file can be checked with `sha256sum` before loading it.
Loading checks the file again, independently of where it came from: the coins against
the pinned UTXO set hash and the Dash evo section (masternode list, quorums, credit
pool and hard-fork signals) against the pinned evo hash.

Once you've obtained the snapshot, start the node and wait until its headers have
passed the base block (`getblockchaininfo` reports `headers` at or above the base
height), then load it with the RPC command `loadtxoutset`, for example

```
dash-cli loadtxoutset /path/to/utxo-2579482.dat
```

The node then syncs to the network tip from the base block, and validates the chain
up to the base block in the background. `getchainstates` shows both chainstates and
whether the snapshot has been validated yet. Once background validation has reached
the base block and a restart has promoted the snapshot chainstate, the node is
indistinguishable from one that synced from genesis.

A masternode does not load snapshots, and a node does not start with
`-masternodeblsprivkey` while it has a snapshot chainstate, validated or not,
until a restart has promoted it.

### Pruning

A pruned node can load a snapshot. To save space, it's possible to delete the
snapshot file as soon as `loadtxoutset` finishes.
A pruned node cannot load a snapshot, and a node does not start with `-prune`
while it has a snapshot chainstate, validated or not, until a restart has
promoted it. It's possible to delete the snapshot file as soon as
`loadtxoutset` finishes.

The minimum `-prune` setting is 550 MiB, but this functionality ignores that
minimum and uses at least 1100 MiB.
Expand All @@ -25,10 +55,17 @@ downloaded snapshot).

### Indexes

Indexes work but don't take advantage of this feature. They always start building
A node with `-addressindex`, `-spentindex` or `-timestampindex` cannot load a
snapshot, and does not start with them while it has a snapshot chainstate.

Other indexes work but don't take advantage of this feature. They always start building
from the genesis block. Once the background validation reaches the snapshot block,
indexes will continue to build all the way to the tip.

Governance waits until background validation has completed and the governance
collateral index has caught up: until then the node neither processes nor relays
governance objects, and `gobject prepare` and `gobject submit` refuse.

For indexes that support pruning, note that no pruning will take place between
the snapshot and the tip, until the background sync has completed - after which
everything is pruned. Depending on how old the snapshot is, this may temporarily
Expand All @@ -40,6 +77,13 @@ The RPC command `dumptxoutset` can be used to generate a snapshot. This can be u
to create a snapshot on one node that you wish to load on another node.
It can also be used to verify the hardcoded snapshot hash in the source code.

`dumptxoutset` writes the snapshot at the node's current tip, and only a snapshot whose
base is pinned can be loaded. To produce the pinned mainnet or testnet file, use a copy
of a synced datadir, disconnect it from the network (`setnetworkactive false`), call
`invalidateblock` on the block after the base, and run `dumptxoutset` there. Its
`txoutset_hash`, `evo.hash` and `nchaintx` fields are the values pinned in
`src/kernel/chainparams.cpp`.

The utility script
`./contrib/devtools/utxo_snapshot.sh` may be of use.

Expand All @@ -51,18 +95,12 @@ The utility script

## Design notes

- A new block index `nStatus` flag is introduced, `BLOCK_ASSUMED_VALID`, to mark block
index entries that are required to be assumed-valid by a chainstate created
from a UTXO snapshot. This flag is used as a way to modify certain
CheckBlockIndex() logic to account for index entries that are pending validation by a
chainstate running asynchronously in the background.

- The concept of UTXO snapshots is treated as an implementation detail that lives
behind the ChainstateManager interface. The external presentation of the changes
required to facilitate the use of UTXO snapshots is the understanding that there are
now certain regions of the chain that can be temporarily assumed to be valid (using
the nStatus flag mentioned above). In certain cases, e.g. wallet rescanning, this is
very similar to dealing with a pruned chain.
now certain regions of the chain that can be temporarily assumed to be valid.
In certain cases, e.g. wallet rescanning, this is very similar to dealing with
a pruned chain.

Logic outside ChainstateManager should try not to know about snapshots, instead
preferring to work in terms of more general states like assumed-valid.
Expand Down
9 changes: 9 additions & 0 deletions doc/release-notes-8078.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Other changes
-------------

- While a loaded AssumeUTXO snapshot has not been validated in the
background, an InstantSend lock that conflicts with a block on the snapshot
chain no longer invalidates that block. The block is kept and the lock is
discarded: it is not applied, announced, relayed or served. Once background
validation completes, such a lock invalidates the conflicting blocks as
before. (#8078)
7 changes: 7 additions & 0 deletions doc/release-notes-8270.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Updated RPCs
------------

- RPC handlers that let a local Evo-state exception reach the RPC dispatcher
now return `RPC_INTERNAL_ERROR` (-32603) instead of `RPC_MISC_ERROR` (-1).
RPCs that handle the failure as a validation result, such as `submitblock`
and the package RPCs, report it through their own error paths. (#8270)
19 changes: 19 additions & 0 deletions doc/release-notes-8271.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Updated RPCs
------------

- On a pruned node, `quorum info`, `quorum memberof` and `quorum selectquorum`
fail with `RPC_INTERNAL_ERROR` for a quorum whose members this node cannot
compute because the block that fixes them was pruned. They used to work with
members computed from a substitute value, which could be wrong. (#8271)

Other changes
-------------

- A pruned node no longer substitutes the block hash for the quorum score
modifier of a pruned work block. It keeps such a quorum's public key, from
its mined commitment, without members, so it still verifies signatures
by that quorum (for example on masternode hard-fork signals) and never
stalls on them. `quorum listextended` and the GUI then compute its health
over its commitment's member slots. Its members are computed again once the
pruned block is downloaded again, for example with `getblockfrompeer`.
(#8271)
11 changes: 11 additions & 0 deletions doc/release-notes-8276.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Updated RPCs
------------

- `loadtxoutset`, `getchainstates` and `dumptxoutset` are no longer hidden, and
`loadtxoutset` and `getchainstates` now work on mainnet and testnet as well as
regtest. `loadtxoutset` loads an AssumeUTXO snapshot so that the node is usable at
the network tip within minutes, while it validates the chain up to the snapshot in
the background. Mainnet accepts the snapshot at height 2579482 and testnet the one
at height 1599687. Pruned nodes, masternodes and nodes with `-addressindex`,
`-spentindex` or `-timestampindex` refuse to load a snapshot. See
`doc/design/assumeutxo.md`. (#8276)
4 changes: 2 additions & 2 deletions doc/zmq.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ Where the 8-byte uints correspond to the mempool sequence number.
| hashtx | <32-byte transaction hash in Little Endian> | <uint32 sequence number in Little Endian>


`rawblock`: Notifies when the chain tip is updated. Messages are ZMQ multipart messages with three parts. The first part is the topic (`rawblock`), the second part is the serialized block, and the last part is a sequence number (representing the message count to detect lost messages).
`rawblock`: Notifies when the chain tip is updated. When assumeutxo is in use, this notification will not be issued for historical blocks connected to the background validation chainstate. Messages are ZMQ multipart messages with three parts. The first part is the topic (`rawblock`), the second part is the serialized block, and the last part is a sequence number (representing the message count to detect lost messages).

| rawblock | <serialized block> | <uint32 sequence number in Little Endian>

`hashblock`: Notifies when the chain tip is updated. Messages are ZMQ multipart messages with three parts. The first part is the topic (`hashblock`), the second part is the 32-byte block hash, and the last part is a sequence number (representing the message count to detect lost messages).
`hashblock`: Notifies when the chain tip is updated. When assumeutxo is in use, this notification will not be issued for historical blocks connected to the background validation chainstate. Messages are ZMQ multipart messages with three parts. The first part is the topic (`hashblock`), the second part is the 32-byte block hash, and the last part is a sequence number (representing the message count to detect lost messages).

| hashblock | <32-byte block hash in Little Endian> | <uint32 sequence number in Little Endian>

Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL
evo/simplifiedmns.cpp
evo/smldiff.cpp
evo/snapshot.cpp
evo/snapshot_chain.cpp
evo/specialtx.cpp
evo/specialtx_filter.cpp
evo/specialtxman.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/bench/wallet_create_tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void generateFakeBlock(const CChainParams& params,

// notify wallet
const auto& pindex = WITH_LOCK(::cs_main, return context.chainman->ActiveChain().Tip());
wallet.blockConnected(kernel::MakeBlockInfo(pindex, &block));
wallet.blockConnected(ChainstateRole::NORMAL, kernel::MakeBlockInfo(pindex, &block));
}

struct PreSelectInputs {
Expand Down
67 changes: 21 additions & 46 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,20 @@ enum BlockStatus : uint32_t {

/**
* Only first tx is coinbase, 2 <= coinbase input script length <= 100, transactions valid, no duplicate txids,
* sigops, size, merkle root. Implies all parents are at least TREE but not necessarily TRANSACTIONS. When all
* parent blocks also have TRANSACTIONS, CBlockIndex::nChainTx will be set.
* sigops, size, merkle root. Implies all parents are at least TREE but not necessarily TRANSACTIONS.
*
* If a block's validity is at least VALID_TRANSACTIONS, CBlockIndex::nTx will be set. If a block and all previous
* blocks back to the genesis block or an assumeutxo snapshot block are at least VALID_TRANSACTIONS,
* CBlockIndex::nChainTx will be set.
*/
BLOCK_VALID_TRANSACTIONS = 3,

//! Outputs do not overspend inputs, no double spends, coinbase output ok, no immature coinbase spends, BIP30.
//! Implies all parents are either at least VALID_CHAIN, or are ASSUMED_VALID
//! Implies all previous blocks back to the genesis block or an assumeutxo snapshot block are at least VALID_CHAIN.
BLOCK_VALID_CHAIN = 4,

//! Scripts & signatures ok. Implies all parents are either at least VALID_SCRIPTS, or are ASSUMED_VALID.
//! Scripts & signatures ok. Implies all previous blocks back to the genesis block or an assumeutxo snapshot block
//! are at least VALID_SCRIPTS.
BLOCK_VALID_SCRIPTS = 5,

//! All validity bits.
Expand All @@ -117,21 +121,8 @@ enum BlockStatus : uint32_t {

BLOCK_CONFLICT_CHAINLOCK = 128, //!< conflicts with chainlock system

/**
* 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
* 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.
*/
BLOCK_ASSUMED_VALID = 256,
BLOCK_STATUS_RESERVED = 256, //!< Unused flag that was previously set on assumeutxo snapshot blocks and their
//!< ancestors before they were validated, and unset when they were validated.
};

/** The block chain is a tree shaped structure starting with the
Expand Down Expand Up @@ -166,21 +157,16 @@ class CBlockIndex
//! (memory only) Total amount of work (expected number of hashes) in the chain up to and including this block
arith_uint256 nChainWork{};

//! Number of transactions in this block.
//! Number of transactions in this block. This will be nonzero if the block
//! reached the VALID_TRANSACTIONS level, and zero otherwise.
//! Note: in a potential headers-first mode, this number cannot be relied upon
//! Note: this value is faked during UTXO snapshot load to ensure that
//! LoadBlockIndex() will load index entries for blocks that we lack data for.
//! @sa ActivateSnapshot
unsigned int nTx{0};

//! (memory only) Number of transactions in the chain up to and including this block.
//! This value will be non-zero only if and only if transactions for this block and all its parents are available.
//! This value will be non-zero if this block and all previous blocks back
//! to the genesis block or an assumeutxo snapshot block have reached the
//! VALID_TRANSACTIONS level.
//! Change to 64-bit type before 2024 (assuming worst case of 60 byte transactions).
//!
//! Note: this value is faked during use of a UTXO snapshot because we don't
//! have the underlying block data available during snapshot load.
//! @sa AssumeutxoData
//! @sa ActivateSnapshot
unsigned int nChainTx{0};

//! Verification status of this block. See enum BlockStatus
Expand Down Expand Up @@ -255,13 +241,16 @@ class CBlockIndex
}

/**
* Check whether this block's and all previous blocks' transactions have been
* downloaded (and stored to disk) at some point.
* Check whether this block and all previous blocks back to the genesis block or an assumeutxo snapshot block have
* reached VALID_TRANSACTIONS and had transactions downloaded (and stored to disk) at some point.
*
* Does not imply the transactions are consensus-valid (ConnectTip might fail)
* Does not imply the transactions are still stored on disk. (IsBlockPruned might return true)
*
* Note that this will be true for the snapshot base block, if one is loaded, since its nChainTx value will have
* been set manually based on the related AssumeutxoData entry.
*/
bool HaveTxsDownloaded() const { return nChainTx != 0; }
bool HaveNumChainTxs() const { return nChainTx != 0; }

NodeSeconds Time() const
{
Expand Down Expand Up @@ -307,14 +296,6 @@ class CBlockIndex
return ((nStatus & BLOCK_VALID_MASK) >= nUpTo);
}

//! @returns true if the block is assumed-valid; this means it is queued to be
//! validated by a background chainstate.
bool IsAssumedValid() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
{
AssertLockHeld(::cs_main);
return nStatus & BLOCK_ASSUMED_VALID;
}

//! Raise the validity level of this block index entry.
//! Returns true if the validity was changed.
bool RaiseValidity(enum BlockStatus nUpTo) EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
Expand All @@ -324,12 +305,6 @@ class CBlockIndex
if (nStatus & BLOCK_FAILED_MASK) return false;

if ((nStatus & BLOCK_VALID_MASK) < nUpTo) {
// If this block had been marked assumed-valid and we're raising
// its validity to a certain point, there is no longer an assumption.
if (nStatus & BLOCK_ASSUMED_VALID && nUpTo >= BLOCK_VALID_SCRIPTS) {
nStatus &= ~BLOCK_ASSUMED_VALID;
}

nStatus = (nStatus & ~BLOCK_VALID_MASK) | nUpTo;
return true;
}
Expand Down
17 changes: 14 additions & 3 deletions src/chainlock/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ ChainlockHandler::ChainlockHandler(chainlock::Chainlocks& chainlocks, Chainstate
std::make_unique<std::thread>(std::thread(util::TraceThread, "cl-schdlr", [&] { scheduler->serviceQueue(); }))},
seenChainLocks{SEEN_CHAINLOCKS_CUTOFF_SIZE, SEEN_CHAINLOCKS_MAX_SIZE}
{
// Tasks are scheduled only from Start(), after this is set.
scheduler->SetTaskWrapper(
[this](const CScheduler::Function& task) { RunActiveEvoRound(m_chainman.EvoDb(), "cl-schdlr", task); });
}

ChainlockHandler::~ChainlockHandler()
Expand Down Expand Up @@ -203,10 +206,14 @@ void ChainlockHandler::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBloc
if (bool expected = false; tryLockChainTipScheduled.compare_exchange_strong(expected, true)) {
scheduler->scheduleFromNow(
[&]() {
// A failed round must still let the next tip schedule one.
const struct Unschedule {
ChainlockHandler& handler;
~Unschedule() { handler.tryLockChainTipScheduled = false; }
} done{*this};
CheckActiveState();
EnforceBestChainLock();
Cleanup();
tryLockChainTipScheduled = false;
},
std::chrono::seconds{0});
}
Expand Down Expand Up @@ -242,8 +249,12 @@ void ChainlockHandler::AcceptedBlockHeader(const CBlockIndex* pindexNew)
m_chainlocks.AcceptedBlockHeader(pindexNew);
}

void ChainlockHandler::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
void ChainlockHandler::BlockConnected(ChainstateRole role, const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
{
// Only the active chainstate's blocks concern this subscriber.
if (role == ChainstateRole::BACKGROUND) {
return;
}
if (!m_mn_sync.IsBlockchainSynced()) {
return;
}
Expand Down Expand Up @@ -300,7 +311,7 @@ void ChainlockHandler::EnforceBestChainLock()
LogPrint(BCLog::CHAINLOCKS, "ChainlockHandler::%s -- enforcing block %s via CLSIG (%s)\n", __func__,
currentBestChainLockBlockIndex->GetBlockHash().ToString(), clsig.ToString());
m_chainman.ActiveChainstate().EnforceBlock(dummy_state, currentBestChainLockBlockIndex);

if (dummy_state.IsError()) return;

if (/*activateNeeded =*/WITH_LOCK(::cs_main, return m_chainman.ActiveTip()->GetAncestor(
currentBestChainLockBlockIndex->nHeight)) !=
Expand Down
2 changes: 1 addition & 1 deletion src/chainlock/handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class ChainlockHandler final : public CValidationInterface
void TransactionAddedToMempool(const CTransactionRef& tx, int64_t nAcceptTime, uint64_t mempool_sequence) override
EXCLUSIVE_LOCKS_REQUIRED(!cs);

void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex) override
void BlockConnected(ChainstateRole role, const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex) override
EXCLUSIVE_LOCKS_REQUIRED(!cs);

private:
Expand Down
Loading
Loading