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

Dump and restore Bitcoin Cash Node #26

Open
sajal opened this issue Dec 9, 2021 · 0 comments
Open

Dump and restore Bitcoin Cash Node #26

sajal opened this issue Dec 9, 2021 · 0 comments

Comments

@sajal
Copy link

sajal commented Dec 9, 2021

re: #22

Provide an automated way to bootstrap testnet and mainnet Bitcoin Cash Node from a block file instead of waiting on network.

Bitcoin Cash Node enables us to provide it with a block file bootstrap.dat which it uses for the initial sync instead of fetching the blocks over the network.

How to generate bootstrap.dat?

  1. Prepare python scripts, specifically linearize-data.py and linearize-hashes.py from https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node/-/tree/master/contrib/linearize
  2. Patch linearize-data.py with this upstream commit
  3. create linearize.cfg
# bitcoind RPC settings (linearize-hashes)
rpcuser=FIXME
rpcpassword=FIXME
host=<ip of bchd container>
port=<port>

max_height=<current height of blockchain, optionally round it to something nice>

netmagic=0b110907
genesis=000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943
input=/path/to/bch-toolkit/data/bitcoind/testnet3/blocks/
output_file=/tmp/bootstrap.dat
hashlist=/tmp/hashlist.txt

out_of_order_cache_sz = 100000000
rev_hash_bytes = False
file_timestamp = 0
split_timestamp = 0
debug_output = False
  1. Generate hashlist
./linearize-hashes.py linearize.cfg > /tmp/hashlist.txt
  1. Generate bootstrap.dat
./linearize-data.py linearize.cfg

This results in a 40GB file /tmp/bootstrap.dat

How to restore bootstrap.dat using?

  1. Copy the file into correct place before starting bchd container
cp /tmp/bootstrap.dat data/bitcoind/testnet3/
  1. Start bchd container
  2. Once sync is complete, bchd renames the file to bootstrap.dat.old. This file is safe to delete.

It should take about 40 minutes(on my laptop) to sync testnet.

Action items.

  • Figure out how and where do we store the dumps
  • Figure out automation for restore process
  • Figure out cleanup step to delete bootstrap.dat.old
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant