- Background and FAQ: https://github.com/jamesob/assumeutxo-docs/tree/2019-04-proposal/proposal
- Prior progress/project: https://github.com/bitcoin/bitcoin/projects/11
- Replaces #15606, which was closed due to Github slowness. Original description and commentary can be found there.
This changeset finishes the first phase of the assumeutxo project. It makes UTXO snapshots loadable via RPC (loadtxoutset
) and adds assumeutxo
parameters to chainparams. It contains all the remaining changes necessary to both use an assumedvalid snapshot chainstate and do a full validation sync in the background.
This may look like a lot to review, but note that
- ~200 lines are a (non-essential) demo shell script
- Many lines are functional test, documentation, and relatively dilute RPC code.
So it shouldn’t be as burdensome to review as the linecount might suggest.
- P2P: minor changes are made to
init.cpp
andnet_processing.cpp
to make simultaneous IBD across multiple chainstates work. - Pruning: implement correct pruning behavior when using a background chainstate
- Blockfile separation: to prevent “fragmentation” in blockfile storage, have background chainstates use separate blockfiles from active snapshot chainstates to avoid interleaving heights and impairing pruning.
- Indexing: some
CValidationInterface
events are given with an additional parameter, ChainstateRole, and all indexers ignore events from ChainstateRole::ASSUMEDVALID so that indexation only happens sequentially. - Have
-reindex
properly wipe snapshot chainstates. - RPC: introduce RPC commands
loadtxoutset
and (hidden)getchainstates
. - Release docs & first assumeutxo commitment: add notes and a particular assumeutxo hash value for first AU-enabled release.
- This will complete the project and allow use of UTXO snapshots for faster node bootstrap.
The next phase, if it were to be pursued, would be coming up with a way to distribute the UTXO snapshots over the P2P network.
UTXO snapshots
Create your own with ./contrib/devtools/utxo_snapshot.sh
, e.g.
0./contrib/devtools/utxo_snapshot.sh 788000 utxo.dat ./src/bitcoin-cli -datadir=$(pwd)/testdata`)
or use the pre-generated ones listed below.
- Testnet: 2'500'000 (Sjors):
- torrent:
magnet:?xt=urn:btih:511e09f4bf853aefab00de5c070b1e031f0ecbe9&dn=utxo-testnet-2500000.dat&tr=udp%3A%2F%2Ftracker.bitcoin.sprovoost.nl%3A6969
- sha256:
79db4b025448cc0ac388d8589a28eab02de53055d181e34eb47391717aa16388
- torrent:
- Signet: 160'000 (Sjors):
- torrent:
magnet:?xt=urn:btih:9da986cb27b3980ea7fd06b21e199b148d486880&dn=utxo-signet-160000.dat&tr=udp%3A%2F%2Ftracker.bitcoin.sprovoost.nl%3A6969
- sha256:
eeeca845385ba91e84ef58c09d38f98f246a24feadaad57fe1e5874f3f92ef8c
- torrent:
- Mainnet: 800'000 (Sjors):
- Note: this needs the following commit cherry-picked in: https://github.com/Sjors/bitcoin/commit/24deb2022b822f22fba9fcbee201e37a83225eb2
- torrent:
magnet:?xt=urn:btih:50ee955bef37f5ec3e5b0df4cf0288af3d715a2e&dn=utxo-800000.dat&tr=udp%3A%2F%2Ftracker.bitcoin.sprovoost.nl%3A6969
Testing
For fun (~5min)
If you want to do a quick test, you can run ./contrib/devtools/test_utxo_snapshots.sh
and follow the instructions. This is mostly obviated by the functional tests, though.
For real (longer)
If you’d like to experience a real usage of assumeutxo, you can do that too.
I’ve cut a new snapshot at height 788'000 (http://img.jameso.be/utxo-788000.dat - but you can do it yourself with ./contrib/devtools/utxo_snapshot.sh
if you want). Download that, and then create a datadir for testing:
0$ cd ~/src/bitcoin # or whatever
1
2# get the snapshot
3$ curl http://img.jameso.be/utxo-788000.dat > utxo-788000.dat
4
5# you'll want to do this if you like copy/pasting
6$ export AU_DATADIR=/home/${USER}/au-test # or wherever
7
8$ mkdir ${AU_DATADIR}
9$ vim ${AU_DATADIR}/bitcoin.conf
10
11dbcache=8000 # or, you know, something high
12blockfilterindex=1
13coinstatsindex=1
14prune=3000
15logthreadnames=1
Obtain this branch, build it, and then start bitcoind:
0$ git remote add jamesob https://github.com/jamesob/bitcoin
1$ git fetch jamesob assumeutxo
2$ git checkout jamesob/assumeutxo
3
4$ ./configure $conf_args && make # (whatever you like to do here)
5
6# start 'er up and watch the logs
7$ ./src/bitcoind -datadir=${AU_DATADIR}
Then, in some other window, load the snapshot
0$ ./src/bitcoin-cli -datadir=${AU_DATADIR} loadtxoutset $(pwd)/utxo-788000.dat
You’ll see some log messages about headers retrieval and waiting to see the snapshot in the headers chain. Once you get the full headers chain, you’ll spend a decent amount of time (~10min) loading the snapshot, checking it, and flushing it to disk. After all that happens, you should be syncing to tip in pretty short order, and you’ll see the occasional [background validation]
log message go by.
In yet another window, you can check out chainstate status with
0$ ./src/bitcoin-cli -datadir=${AU_DATADIR} getchainstates
as well as usual favorites like getblockchaininfo
.