0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-04 10:07:27 -05:00
bitcoin-bitcoin-core/src/wallet
Andrew Chow e7b0004b37
Merge bitcoin/bitcoin#27596: assumeutxo (2)
edbed31066 chainparams: add signet assumeutxo param at height 160_000 (Sjors Provoost)
b8cafe3871 chainparams: add testnet assumeutxo param at height 2_500_000 (Sjors Provoost)
99839bbfa7 doc: add note about confusing HaveTxsDownloaded name (James O'Beirne)
7ee46a755f contrib: add script to demo/test assumeutxo (James O'Beirne)
42cae39356 test: add feature_assumeutxo functional test (James O'Beirne)
0f64bac603 rpc: add getchainstates (James O'Beirne)
bb05857794 refuse to activate a UTXO snapshot if mempool not empty (James O'Beirne)
ce585a9a15 rpc: add loadtxoutset (James O'Beirne)
62ac519e71 validation: do not activate snapshot if behind active chain (James O'Beirne)
9511fb3616 validation: assumeutxo: swap m_mempool on snapshot activation (James O'Beirne)
7fcd21544a blockstorage: segment normal/assumedvalid blockfiles (James O'Beirne)
4c3b8ca35c validation: populate nChainTx value for assumedvalid chainstates (James O'Beirne)
49ef778158 test: adjust chainstate tests to use recognized snapshot base (James O'Beirne)
1019c39982 validation: pruning for multiple chainstates (James O'Beirne)
373cf91531 validation: indexing changes for assumeutxo (James O'Beirne)
1fffdd76a1 net_processing: validationinterface: ignore some events for bg chain (James O'Beirne)
fbe0a7d7ca wallet: validationinterface: only handle active chain notifications (James O'Beirne)
f073917a9e validationinterface: only send zmq notifications for active (James O'Beirne)
4d8f4dcb45 validation: pass ChainstateRole for validationinterface calls (James O'Beirne)
1e59acdf17 validation: only call UpdatedBlockTip for active chainstate (James O'Beirne)
c6af23c517 validation: add ChainstateRole (James O'Beirne)
9f2318c76c validation: MaybeRebalanceCaches when chain leaves IBD (James O'Beirne)
434495a8c1 chainparams: add blockhash to AssumeutxoData (James O'Beirne)
c711ca186f assumeutxo: remove snapshot during -reindex{-chainstate} (James O'Beirne)
c93ef43e4f bugfix: correct is_snapshot_cs in VerifyDB (James O'Beirne)
b73d3bbd23 net_processing: Request assumeutxo background chain blocks (Suhas Daftuar)

Pull request description:

  - 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 https://github.com/bitcoin/bitcoin/pull/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` and `net_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.
  ```shell
  ./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`
  - 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`
  - Mainnet: **800'000** (Sjors):
    - Note: this needs the following commit cherry-picked in: 24deb2022b
    - 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:
  ```sh
  $ cd ~/src/bitcoin  # or whatever

  # get the snapshot
  $ curl http://img.jameso.be/utxo-788000.dat > utxo-788000.dat

  # you'll want to do this if you like copy/pasting
  $ export AU_DATADIR=/home/${USER}/au-test # or wherever

  $ mkdir ${AU_DATADIR}
  $ vim ${AU_DATADIR}/bitcoin.conf

  dbcache=8000  # or, you know, something high
  blockfilterindex=1
  coinstatsindex=1
  prune=3000
  logthreadnames=1
  ```
  Obtain this branch, build it, and then start bitcoind:
  ```sh
  $ git remote add jamesob https://github.com/jamesob/bitcoin
  $ git fetch jamesob assumeutxo
  $ git checkout jamesob/assumeutxo

  $ ./configure $conf_args && make  # (whatever you like to do here)

  # start 'er up and watch the logs
  $ ./src/bitcoind -datadir=${AU_DATADIR}
  ```
  Then, in some other window, load the snapshot
  ```sh
  $ ./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
  ```sh
  $ ./src/bitcoin-cli -datadir=${AU_DATADIR} getchainstates
  ```
  as well as usual favorites like `getblockchaininfo`.

ACKs for top commit:
  achow101:
    ACK edbed31066

Tree-SHA512: 6086fb9a38dc7df85fedc76b30084dd8154617a2a91e89a84fb41326d34ef8e7d7ea593107afba01369093bf8cc91770621d98f0ea42a5b3b99db868d2f14dc2
2023-10-02 17:09:44 -04:00
..
rpc rpc: bumpfee, improve doc for 'reduce_output' arg 2023-09-26 20:17:02 -03:00
test Merge bitcoin/bitcoin#27596: assumeutxo (2) 2023-10-02 17:09:44 -04:00
bdb.cpp wallet: bdb: include bdb header from our implementation files only 2023-07-07 14:14:20 +00:00
bdb.h wallet: bdb: include bdb header from our implementation files only 2023-07-07 14:14:20 +00:00
coincontrol.cpp refactor: Make ListSelected return vector 2023-04-26 10:41:10 +02:00
coincontrol.h Clean up things that include script/standard.h 2023-08-14 17:38:27 -04:00
coinselection.cpp Amend bumpfee for inputs with overlapping ancestry 2023-09-13 15:46:59 -04:00
coinselection.h Amend bumpfee for inputs with overlapping ancestry 2023-09-13 15:46:59 -04:00
context.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
context.h
crypter.cpp refactor: Remove unused C-style casts 2023-07-24 15:32:00 +02:00
crypter.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
db.cpp [refactor] Define MessageStartChars as std::array 2023-09-12 22:49:49 +02:00
db.h wallet: Add GetPrefixCursor to DatabaseBatch 2023-06-01 13:09:08 -04:00
dump.cpp Use only Span{} constructor for byte-like types where possible 2023-06-27 10:13:37 +02:00
dump.h refactor: Move fs.* to util/fs.* 2023-03-23 12:55:18 +01:00
external_signer_scriptpubkeyman.cpp refactor: Move system from util to common library 2023-05-20 12:08:13 +02:00
external_signer_scriptpubkeyman.h wallet: set keypool_size instead of access global args manager 2023-02-15 15:49:44 -03:00
feebumper.cpp rpc: bumpfee, improve doc for 'reduce_output' arg 2023-09-26 20:17:02 -03:00
feebumper.h rpc: bumpfee, improve doc for 'reduce_output' arg 2023-09-26 20:17:02 -03:00
fees.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
fees.h
init.cpp move-only: Extract common/args and common/config.cpp from util/system 2023-04-19 10:48:30 +02:00
interfaces.cpp Merge bitcoin-core/gui#119: Replace send-to-self with dual send+receive entries 2023-09-22 18:29:51 +01:00
load.cpp scripted-diff: move settings to common namespace 2023-05-30 17:26:51 +02:00
load.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
receive.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
receive.h wallet: Add wallet/types.h for simple public enum and struct types 2023-04-11 15:52:25 -04:00
salvage.cpp wallet: bdb: include bdb header from our implementation files only 2023-07-07 14:14:20 +00:00
salvage.h refactor: Move fs.* to util/fs.* 2023-03-23 12:55:18 +01:00
scriptpubkeyman.cpp Merge bitcoin/bitcoin#28125: wallet: bugfix, disallow migration of invalid scripts 2023-09-19 13:10:57 -04:00
scriptpubkeyman.h Merge bitcoin/bitcoin#28508: refactor: Remove SER_GETHASH, hard-code client version in CKeyPool serialize 2023-10-02 12:33:54 +02:00
spend.cpp Merge bitcoin/bitcoin#28246: wallet: Use CTxDestination in CRecipient instead of just scriptPubKey 2023-09-19 16:48:43 +00:00
spend.h Amend bumpfee for inputs with overlapping ancestry 2023-09-13 15:46:59 -04:00
sqlite.cpp [refactor] Define MessageStartChars as std::array 2023-09-12 22:49:49 +02:00
sqlite.h wallet: sqlite: force sqlite3.h to be included by the cpp files 2023-07-06 19:53:44 +00:00
transaction.cpp
transaction.h wallet: Add wallet/types.h for simple public enum and struct types 2023-04-11 15:52:25 -04:00
types.h wallet: add AddressPurpose enum to replace string values 2023-04-11 15:52:25 -04:00
wallet.cpp Merge bitcoin/bitcoin#27596: assumeutxo (2) 2023-10-02 17:09:44 -04:00
wallet.h validation: pass ChainstateRole for validationinterface calls 2023-09-30 06:38:47 -04:00
walletdb.cpp Move CScriptID to script.{h/cpp} 2023-08-14 17:38:27 -04:00
walletdb.h Clean up things that include script/standard.h 2023-08-14 17:38:27 -04:00
wallettool.cpp move-only: Extract common/args and common/config.cpp from util/system 2023-04-19 10:48:30 +02:00
wallettool.h
walletutil.cpp move-only: Extract common/args and common/config.cpp from util/system 2023-04-19 10:48:30 +02:00
walletutil.h Merge bitcoin/bitcoin#25634: wallet, tests: Expand and test when the blank wallet flag should be un/set 2023-06-14 09:30:39 -04:00