Blockchain sync taking too long, copy blockchain database file to new computer?

Hi

I just had an interesting situation where the blockchain sync was taking too long on a new rig. So I went to my old rig and copied the blockchain DB (that was completely synced through the app) and pasted it into the new rig.

Is this something that is ok to do it?
If so, can I just share the blockchain file (currently at 1.5GB) with someone else and they can use it?
How do we verify is the blockchain DB is legit?

Thanks.

1 Like

It’s perfectly fine to copy it to a new computer. However, I wouldn’t use a blockchain_v1_mainnet.sqlite file from someone else unless I totally trust them.

The best solution is to forward port 8444 from your router to your full node. That should increase your sync speed a lot.

I don’t think that’s currently possible – neither in the GUI nor in the CLI.

2 Likes

Thanks for the reply.

I have forwarded the port 8444 and have more than 50 connections mostly uploading the DB to the network.

What about if the main chia.net website could provide a ceertified nightly backup of the DB? I’m sure this will be needed as the netspace grows and we can’t always rely on open ports.

3 Likes

OK so which of these files do we copy?

Mode           LastWriteTime               Length Name
----           -------------               ------ ----
-a----         4/30/2021     21:48     1847025664 blockchain_v1_mainnet.sqlite
-a----         4/26/2021     14:01          32768 blockchain_v1_mainnet.sqlite-shm
-a----         4/30/2021     21:50        4725672 blockchain_v1_mainnet.sqlite-wal
-a----         4/30/2021     21:46        4751360 peer_table_node.sqlite
-a----         4/26/2021     14:01          32768 peer_table_node.sqlite-shm
-a----         4/30/2021     21:46        7469592 peer_table_node.sqlite-wal

Just the blockchain one?

I copied the entire db directory to a new node and it worked. I won a block after that too.

1 Like

I copied just the blockchain files and that seemed to work as well – I synced instantly.

Bit late, but yes, the blockchain_v1_mainnet.sqlite* files are what you need.

The peer_table_node.sqline* DB is related to the peer connection, so not that important if you have your port 8444 configured.

1 Like

Cool so just to confirm, all you need to copy is these 3 files:

blockchain_v1_mainnet.sqlite
blockchain_v1_mainnet.sqlite-shm
blockchain_v1_mainnet.sqlite-wal

I’m not sure what the shm and wal files are for… indexes?

(Also I edited the title to improve searchability a bit … thank you for posting this, it was my only hit on the topic!)

2 Likes

In reality, you only need the blockchain_v1_mainnet.sqlite file which is the blockchain database.
The other files are just indexes and caching which is recreated if deleted.

EDIT: And thanks for cleaning up the title. Cheers!

1 Like

A few other tips:

  • The first couple times I tried to copy the db file over, I got an error message about the database being malformed. I then tried to incrementally update the files to see if it worked (using rsync --inplace --append) and it did
  • I ran chia start -r <wallet or node> to restart chia afterwards

Also if you happen to be running multiple nodes on your home network, you probably want to disable uPNP on one of them
chia configure --enable-upnp false and then restart as above

1 Like

This definitely works. I had a machine that wouldn’t sync overnight, copied over the

C:\Users\user\.chia\mainnet\db\blockchain_v1_mainnet.sqlite

file from a machine that was synced, and it synced instantly.

2 Likes

Having fun learning blockchain and stuff . I find self in the same predicament and decided to manually move my blockchain file on a drive instead of copy across network to another new PC . That worked. The goal is to play and send mojo between one wallet and another, and have 2 different full_nodes.

Sorry in advance to ramble, but Im trying to understand the why not the how.

Here at start of July , my sql lite file (mainnet/db/block*.sqlite ) is about 6GB on my main node. I periodically copy my mainnet dir off to another HDD as a backup because the thought of having to re-sync from scratch would take what … a week (?) I find my wallet db file ( mainnet/wallet/db/block.sqlite ) is 3GB (? … wtf … why ? ). So the problem of sync just moved from the blockchain file to the wallet file.

I assume that my / our blockchain db file only holds a portion of all the global transactions, it appears to download all the heights from beginning of March 2021. So I gather that earlier adopters with sync’d blockchain DB files are going to be holding up the network in perpetuity … that sort of makes sense.

But still wondering

  • How big that mainnet db file will grow, what happens when the transaction volume takes off ? I cant forsee my home PC being able to keep up when Chia becomes the backbone of the crypto universe ( sarc ).
  • are other blockchains this slow to sync on a new node ?
  • now what about the wallet DB file …

I assume there’s no shortcut for copying the wallet DB from one source to another, if they are different wallets. So, why would a new, fresh wallet DB need to sync ? … There are no transactions in the new wallet. It is currently at height 72 K and I assume will need to sync up to the height of 530k and 3GB (?) . That part makes no sense. I find I need the full_node daemon and the wallet daemon to run minimally on PC2, its connected back to my mainnode:8444, the mainnet DB file is synced ( I copied it ), but the empty wallet is still way behind. After about 4 hrs its at height 230K so about 1/2 way done …

Thanks

It really works!

Last night i had do reinstall Ubuntu, but made a backup copy of the Chia folder.
After installed Chia and run once i stopped it, then i copied the file blockchain_v1_mainnet.sqlite and it synced in a few seconds.
But the wallet was synchronizing too, so i tried to copy the file blockchain_wallet_v1_mainnet.sqlite and its works too! Synced in e few seconds.

1 Like

I am having a problem to find where to put the mainnet file!!! I have 1 pc on windows and 1 on ubuntu and can see the file. I just build and install ubuntu and installed chia… but there is no folder .chia and when i do a search for the blockchain_v1_mainnet.squite…
I did run chia and started to do the sync and still cant find the file!!!

Did you run chia init? This command initializes the directory structure for the .chia folder and sets up certs and config if not present.

Is it Ubuntu where you can’t find the folder? Open a Terminal window and type
ls -A ~/
then press Enter. This will list all of the contents in your user Home folder including hidden files (files beginning with . are hidden files/folders). You should see .chia listed in the output. If it’s not, and your chia executables work (chia start farmer, chia wallet show, etc.), then you’ve done something completely off-instruction.

Thanks for the help…
Yesterday i just gave up and shut down the pc. Today turned on and the file was there!!! Not sure what to think…
Yesterday i did run the chia app and was starting to sync so shouldn’t have been there the .chia folder? Well who said that a good night of sleep doesn’t resolve some problems lol