Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upUTXO snapshot creation (dumptxoutset) #16899
Conversation
fd56894
to
e30e3a4
. |
This comment has been minimized.
This comment has been minimized.
What was the conclusion on the question whether the dump should include all headers? |
e30e3a4
to
0705b18
This comment has been minimized.
This comment has been minimized.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
a71a387
to
6452a87
We need to connect to peers to make the node usable anyway, and headers take very little time to sync, so I don't see much benefit to bundling the headers with the snapshot. Though if anyone thinks differently I'd be curious to hear why. |
6452a87
to
52bba3c
|
||
# TODO I'd like to make assertions about the contents of the file | ||
# (ideally its hash), but because we can't get a deterministic block | ||
# header (we'd need to mock time) and we have no way of deserializing |
This comment has been minimized.
This comment has been minimized.
MarcoFalke
Sep 24, 2019
Member
Why can't you use mock time here?
Also, the test isn't running (see travis)
This comment has been minimized.
This comment has been minimized.
jamesob
Sep 25, 2019
Author
Member
To get a deterministic blockheader, we'd need to use GetTime<...>()
here: https://github.com/bitcoin/bitcoin/blob/master/src/miner.cpp#L93
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
{ | ||
RPCHelpMan{ | ||
"dumptxoutset", | ||
"\nWrite the serialized UTXO set to disk.\n" |
This comment has been minimized.
This comment has been minimized.
ryanofsky
Sep 24, 2019
Contributor
In commit "rpc: add dumptxoutset" (b6af8f5)
Up to you, but I think documentation could say more about
- Data format
- What you'd use this function for, or it's mostly meant to be useful for developers
- Status of the implementation. If this is experimental, whether the data format might change, if there's going to be a corresponding load rpc method
pcursor->Next(); | ||
} | ||
|
||
afile.fclose(); |
This comment has been minimized.
This comment has been minimized.
ryanofsky
Sep 24, 2019
Contributor
In commit "rpc: add dumptxoutset" (b6af8f5)
Implementation seems fine for now. Unclear if in the future we might want to:
- Put some magic bytes in snapshot header so to make it easier to recognize a snapshot file
- Add version or length fields to make it possible to extend the format and include additional data
- Write to temporary file and then rename in case theres a shutdown or crash in the middle of writing so you can distinguish an incomplete snapshot from a complete one
2894d3e
to
c2830a9
This comment has been minimized.
This comment has been minimized.
A progress indicator would be nice. If it wasn't for the system activity monitor showing CPU and disk write activity I would have interrupted the script somewhere during the ~ half an hour Maybe the script should call Checksum on macOS 10.14.6 for block 597000: {
"coins_written": 62228899,
"base_hash": "0000000000000000000eadb01d27f7b6ca1c17e71f0ff33853de9d3b25c57e55",
} |
utACK c2830a9. Changes since last review: new utxo_snapshot.h file, removed hash and validation_complete snapshot metadata fields, fixed dumptxoutset base_height documentation, dumped to temporary file and renamed instead of writing directly, extended rpc_dumptxoutset test removing todo |
2a4e60b Fix block index inconsistency in InvalidateBlock() (Suhas Daftuar) Pull request description: Previously, we could release `cs_main` while leaving the block index in a state that would fail `CheckBlockIndex()`, because `setBlockIndexCandidates` was not being fully populated before releasing `cs_main`. ACKs for top commit: TheBlueMatt: utACK 2a4e60b. I also discovered another issue in InvalidateBlock while reviewing, see #16856. Sjors: ACK 2a4e60b. Tested on top of #16899. Also tested `invalidateblock` with `-checkblockindex=1`. fjahr: ACK 2a4e60b. Ran tests, reviewed code, inspected behavior while manually testing `invalidateblock`. Tree-SHA512: ced12f9dfff0d413258c709921543fb154789898165590b30d1ee0cdc72863382f189744f7669a7c924d3689a1cc623efdf4e5ae3efc60054572c1e6826de612
4e60702
to
95beaf6
95beaf6
to
0efd43d
0efd43d
to
95c7f5e
Coin coin; | ||
|
||
while (pcursor->Valid()) { | ||
boost::this_thread::interruption_point(); |
This comment has been minimized.
This comment has been minimized.
laanwj
Oct 30, 2019
•
Member
There's no point in adding a boost interruption point here. RPC threads aren't managed by a boost thread group.
Check IsRPCRunning()
instead.
This comment has been minimized.
This comment has been minimized.
jamesob
Nov 4, 2019
Author
Member
Ah if that's the case then we should fix FindScriptPubKey
at some point too. https://github.com/bitcoin/bitcoin/blob/master/src/rpc/blockchain.cpp#L1970-L1978
This comment has been minimized.
This comment has been minimized.
MarcoFalke
Nov 5, 2019
Member
I wouldn't mind fixing it in this pull in a new commit. It seem like you copy-pasted the code from there, so it wouldn't hurt review if people saw where the code came from
95c7f5e test: add dumptxoutset RPC test (James O'Beirne) ddc90a8 devtools: add utxo_snapshot.sh (James O'Beirne) 49f281b rpc: add dumptxoutset (James O'Beirne) 644c7e7 coinstats: add coins_count (James O'Beirne) 707fde7 add unused SnapshotMetadata class (James O'Beirne) Pull request description: This is part of the [assumeutxo project](https://github.com/bitcoin/bitcoin/projects/11): Parent PR: bitcoin#15606 Issue: bitcoin#15605 Specification: https://github.com/jamesob/assumeutxo-docs/tree/master/proposal --- This changeset defines the serialization format for UTXO snapshots and adds an RPC command for creating them, `dumptxoutset`. It also adds a convenience script for generating and verifying snapshots at a certain height, since that requires doing a hacky rewind of the chain via `invalidateblock`. All of this is unused at the moment.
This comment has been minimized.
This comment has been minimized.
Removed used of |
Also changes existing CCoinsStats attributes to be C++11 initialized.
This comment has been minimized.
This comment has been minimized.
We should remove all uses of ACK 92b2f53 |
92b2f53 test: add dumptxoutset RPC test (James O'Beirne) c1ccbc3 devtools: add utxo_snapshot.sh (James O'Beirne) 57cf74c rpc: add dumptxoutset (James O'Beirne) 92fafb3 coinstats: add coins_count (James O'Beirne) 707fde7 add unused SnapshotMetadata class (James O'Beirne) Pull request description: This is part of the [assumeutxo project](https://github.com/bitcoin/bitcoin/projects/11): Parent PR: #15606 Issue: #15605 Specification: https://github.com/jamesob/assumeutxo-docs/tree/master/proposal --- This changeset defines the serialization format for UTXO snapshots and adds an RPC command for creating them, `dumptxoutset`. It also adds a convenience script for generating and verifying snapshots at a certain height, since that requires doing a hacky rewind of the chain via `invalidateblock`. All of this is unused at the moment. ACKs for top commit: laanwj: ACK 92b2f53 Tree-SHA512: 200dff87767f157d627e99506ec543465d9329860a6cd49363081619c437163a640a46d008faa92b1f44fd403bfc7a7c9e851c658b5a4849efa9a34ca976bf31
echo | ||
echo 'Examples:' | ||
echo | ||
echo " ./contrib/devtools/utxo_snapshot.sh 570000 utxo.dat ./src/bitcoin-cli -datadir=\$(pwd)/testdata" |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Post merge ACK. Good stuff @jamesob |
PIVOT_BLOCKHASH=$($BITCOIN_CLI_CALL getblockhash $(( GENERATE_AT_HEIGHT + 1 )) ) | ||
|
||
(>&2 echo "Rewinding chain back to height ${GENERATE_AT_HEIGHT} (by invalidating ${PIVOT_BLOCKHASH}); this may take a while") | ||
${BITCOIN_CLI_CALL} invalidateblock "${PIVOT_BLOCKHASH}" |
This comment has been minimized.
This comment has been minimized.
92b2f53 test: add dumptxoutset RPC test (James O'Beirne) c1ccbc3 devtools: add utxo_snapshot.sh (James O'Beirne) 57cf74c rpc: add dumptxoutset (James O'Beirne) 92fafb3 coinstats: add coins_count (James O'Beirne) 707fde7 add unused SnapshotMetadata class (James O'Beirne) Pull request description: This is part of the [assumeutxo project](https://github.com/bitcoin/bitcoin/projects/11): Parent PR: bitcoin#15606 Issue: bitcoin#15605 Specification: https://github.com/jamesob/assumeutxo-docs/tree/master/proposal --- This changeset defines the serialization format for UTXO snapshots and adds an RPC command for creating them, `dumptxoutset`. It also adds a convenience script for generating and verifying snapshots at a certain height, since that requires doing a hacky rewind of the chain via `invalidateblock`. All of this is unused at the moment. ACKs for top commit: laanwj: ACK 92b2f53 Tree-SHA512: 200dff87767f157d627e99506ec543465d9329860a6cd49363081619c437163a640a46d008faa92b1f44fd403bfc7a7c9e851c658b5a4849efa9a34ca976bf31
jamesob commentedSep 17, 2019
This is part of the assumeutxo project:
Parent PR: #15606
Issue: #15605
Specification: https://github.com/jamesob/assumeutxo-docs/tree/master/proposal
This changeset defines the serialization format for UTXO snapshots and adds an RPC command for creating them,
dumptxoutset
. It also adds a convenience script for generating and verifying snapshots at a certain height, since that requires doing a hacky rewind of the chain viainvalidateblock
.All of this is unused at the moment.