Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validation: assumeutxo params for testnet and signet #28516

Closed
wants to merge 26 commits into from

Conversation

Sjors
Copy link
Member

@Sjors Sjors commented Sep 21, 2023

Based on #27596. This adds snapshot parameters for testnet block 2,500,000 and signet block 160,000.

You can generate the snapshots yourself using ./contrib/devtools/utxo_snapshot.sh or download my torrent:

  • testnet: magnet:?xt=urn:btih:511e09f4bf853aefab00de5c070b1e031f0ecbe9&dn=utxo-testnet-2500000.dat&tr=udp%3A%2F%2Ftracker.bitcoin.sprovoost.nl%3A6969
  • signet: magnet:?xt=urn:btih:9da986cb27b3980ea7fd06b21e199b148d486880&dn=utxo-signet-160000.dat&tr=udp%3A%2F%2Ftracker.bitcoin.sprovoost.nl%3A6969

It would be a good idea to test:

  1. That you can produce the same snapshot files, sha256 sums:
eeeca845385ba91e84ef58c09d38f98f246a24feadaad57fe1e5874f3f92ef8c utxo-signet-160000.dat
79db4b025448cc0ac388d8589a28eab02de53055d181e34eb47391717aa16388 utxo-testnet-2500000.dat
  1. That the snapshots work

Not part of this PR:

I also have a branch with a mainnet snapshot at height 800,000. It can be used for testing, but I'm not proposing it for merge just yet. I think more testing and conceptual discussion should happen first.

  • branch: 2023/09/assume_mainnet
  • torrent: magnet:?xt=urn:btih:50ee955bef37f5ec3e5b0df4cf0288af3d715a2e&dn=utxo-800000.dat&tr=udp%3A%2F%2Ftracker.bitcoin.sprovoost.nl%3A6969

sdaftuar and others added 26 commits September 17, 2023 18:32
Add new PeerManagerImpl::TryDownloadingHistoricalBlocks method and use it to
request background chain blocks in addition to blocks normally requested by
FindNextBlocksToDownload.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Co-authored-by: James O'Beirne <james.obeirne@gmail.com>
Removing a snapshot chainstate from disk (and memory) is consistent with
existing reindex operations.
This allows us to reference assumeutxo configuration by blockhash as
well as height; this is helpful in future changes when we want to
reference assumeutxo configurations before the block index is loaded.
Check to see if we need to rebalance caches across chainstates when
a chain leaves IBD.
This notification isn't needed for background chainstates.

`kernel::Notifications::blockTip` are also skipped.
This allows consumers to decide how to handle events from background or
assumedvalid chainstates.
When using an assumedvalid chainstate, only process validationinterface
callbacks from the background chainstate within indexes. This ensures
that all indexes are built in-order.

Later, we can possibly designate indexes which can be built out of order
and continue their operation during snapshot use.

Once the background sync has completed, restart the indexes so that
they continue to index the now-validated snapshot chainstate.
Introduces ChainstateManager::GetPruneRange().

The prune budget is split evenly between the number of chainstates,
however the prune budget may be exceeded if the resulting shares are
beneath `MIN_DISK_SPACE_FOR_BLOCK_FILES`.
In future commits, loading the block index while making use of a
snapshot is contingent on the snapshot being recognized by chainparams.

Ensure all existing unittests that use snapshots use a recognized
snapshot (at height 110).

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Use the expected AssumeutxoData in order to bootstrap nChainTx values
for assumedvalid blockindex entries in the snapshot chainstate. This
is necessary because nChainTx is normally built up from nTx values,
which are populated using blockdata which the snapshot chainstate
does not yet have.
When using an assumedvalid (snapshot) chainstate along with a background
chainstate, we are syncing two very different regions of the chain
simultaneously. If we use the same blockfile space for both of these
syncs, wildly different height blocks will be stored alongside one
another, making pruning ineffective.

This change implements a separate blockfile cursor for the assumedvalid
chainstate when one is in use.
Otherwise we will not receive transactions during background sync until
restart.
Most easily reviewed with

  git show --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Co-authored-by: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
This ensures that we avoid any unexpected conditions inherent in
transferring non-empty mempools across chainstates.

Note that this should never happen in practice given that snapshot
activation will not occur outside of IBD, based upon the height checks
in `loadtxoutset`.
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Most ideas for test improvements (TODOs) provided by Russ Yanofsky.
Add the script to the shellcheck exception list since the
quoted variables rule needs to be violated in order to get
bitcoind to pick up on $CHAIN_HACK_FLAGS.
@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 21, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #28550 (Covenant tools softfork by jamesob)
  • #28453 (wallet: Receive silent payment transactions by achow101)
  • #28368 (Fee Estimator updates from Validation Interface/CScheduler thread by ismaelsadeeq)
  • #28120 (p2p: make block download logic aware of limited peers threshold by furszy)
  • #28031 (Package Relay 1/3: Introduce TxDownloadManager and improve orphan-handling by glozow)
  • #27866 (blockstorage: Return on fatal flush errors by TheCharlatan)
  • #27837 (net: introduce block tracker to retry to download blocks after failure by furszy)
  • #27770 (Introduce 'getblockfileinfo' RPC command by furszy)
  • #27039 (blockstorage: do not flush block to disk if it is already there by pinheadmz)
  • #26966 (index: blockfilter initial sync speedup, parallelize process by furszy)
  • #26762 (bugfix: Make CCheckQueue RAII-styled (attempt 2) by hebasto)
  • #26045 (rpc: Optimize serialization disk space of dumptxoutset by aureleoules)

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.

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

@Sjors
Copy link
Member Author

Sjors commented Sep 30, 2023

Testnet and signet params have been absorbed into #27596.

I opened a draft PR for those who want to test mainnet: #28553

@Sjors Sjors closed this Sep 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants