btcsuite / btcd

An alternative full node bitcoin implementation written in Go (golang)
https://github.com/btcsuite/btcd/blob/master/README.md
ISC License
6.2k stars 2.36k forks source link

[question] Syncing so slow? Any better way to get the blockchain data? #1946

Closed jagottsicher closed 1 year ago

jagottsicher commented 1 year ago

I have two raspi, but newly setup an equipped with a usb hdd and a newly compiled btcd.

Syncing is unbelieveable slow, so I tried a bootstrap (which is available up to 30 GB), which worked fine and continued syncing from there. Due to the fact I am in China I tried one node at my workplace, one at home. Both show the same effect not more than processing 1 or two blocks per 10-20 seconds!

Well, So I setup the following experiement: On my NAS I started a bitcoind node (the C implementation), copied the block data from another node (took 2 days only) and the finalisation of the sync took a few hours and I was up and running.

I connected my btcd-raspi node trying both "addnode" and "connect" within a local network, but again after a few thousand blocks everything stahts to become unbelievable slow. Well due to the fact that I cannot copy the leveldb blocks to my ffldb node, there is no conversion possible, and building an old btcd node does not work anymore due to missing dependencies, I started a btcd node in a second docker container on the same NAS as the bitcoind node.

But the sync times are deasaterous. in the beginning it is okay, then becomes more and more stucked. now my sync rate is at 1 block per 30 secs. There is no network transfer anymore involved. Of course data is sent and received over the network but both conatinerized on the same machine.

I have decent knowledge in both C and Go and I don't get why the block confirmation is so slow, if I even turned off tx and addr indexing. It cannot a network issue, nor a raspi problem. seems really block verifying is the bottleneck. For people behind the GFW of China (or other region with internet problems) this is very frustrating. You cannot switch to the btcd (even I am a huge fan of Go and this project) if syncing from scratch takes 6 month.

Anybody an idea, what Is worng about my setup, OR how to get a reasonably secure copy of the ffldb for kind of bootstrapping? OR what the problem may be?

Roasbeef commented 1 year ago

Closing as a duplicate of: https://github.com/btcsuite/btcd/issues/1339

An initial sync takes more like 3 days or so with an SSD. You can also bootstrap your btcd node from a bitcoind node using the addblock CLI. The NAS is likely your issue given all the random I/O needed to manage the UTXO set during initial sync.

We're working on a number of performance updates, including finishing up the UTXO set cache (#1168).