Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: NeonFlash on August 28, 2017, 06:14:17 AM



Title: What exactly happens during Blockchain Synchronization?
Post by: NeonFlash on August 28, 2017, 06:14:17 AM
Hi All,

I am trying to get back into the technical aspects of Bitcoin. I was quite active several years ago however now I would like to understand the ins and outs of Bitcoin and Blockchain technology much better. Also, trying to refresh my knowledge.

So, when we start the Bitcoin Core client (full node), it tries to download the Blocks. I saw it mentioned in several places that the speed at which you synchronize depends not only on your Internet connection speed but also on your Processor speed. I would like to understand what role does the processor speed play here?

Besides downloading the blocks, is the full node client also performing a Digital Signature verification for each transaction included in that block?

Also, I noticed that the newer blocks in the blockchain take longer time to synchronize than the older blocks. Is it because the newer blocks include more number of transactions and so the full node client needs to perform more number of verification per block?

Is there any way to speed up the process of synchronizing the blockchain? Of course, besides buying the latest and fastest processor :D

Thanks.


Title: Re: What exactly happens during Blockchain Synchronization?
Post by: aleksej996 on August 28, 2017, 09:41:07 AM
Yes, Bitcoin Core checks if downloaded blocks are valid and that takes CPU power for checking all those transactions.
Yes, newer blocks have more transactions, so more CPU power is needed.
I am pretty sure that there is a command line option for Bitcoin Core to not verify downloaded blocks, but that is not advisable.


Title: Re: What exactly happens during Blockchain Synchronization?
Post by: achow101 on August 28, 2017, 01:47:12 PM
So, when we start the Bitcoin Core client (full node), it tries to download the Blocks. I saw it mentioned in several places that the speed at which you synchronize depends not only on your Internet connection speed but also on your Processor speed. I would like to understand what role does the processor speed play here?
The CPU has to do all of the work to verify the blocks as they are downloaded. It must hash the blocks and check the proof of work, hash the transactions in the block and compare that with the merkle root, lookup in a database to make sure that transactions are not spending previously spent inputs, etc. A lot of it is calculating hashes, which, given a large number of hashes, can be fairly computationally intensive.

Besides downloading the blocks, is the full node client also performing a Digital Signature verification for each transaction included in that block?
It depends on the block. Bitcoin Core has checkpoints which mean that the block at a certain height must have a certain hash. Blocks prior to that will not have signatures validated. The recent checkpoint was block 250000 which means that for older nodes, they will begin checking signatures after block 250000. However for newer nodes, we introduced a thing called assumevalid which supersedes checkpoints (although checkpoints still exist). Assumevalid has a block hash specified. It is similar to checkpoints; any block in the chain prior to the assumevalid block (we have a best headers chain which has the assumevalid block in it) will have signature validation skipped. Blocks after the assumevalid block will have all signatures verified. The assumevalid block can be set with the -assumevalid=<hash> startup option. The default assumevalid block is updated every release.

Also, I noticed that the newer blocks in the blockchain take longer time to synchronize than the older blocks. Is it because the newer blocks include more number of transactions and so the full node client needs to perform more number of verification per block?
Yes. There are more transactions in newer blocks which requires more hashing, and after the assumevalid block, all signature validation is done.

Is there any way to speed up the process of synchronizing the blockchain? Of course, besides buying the latest and fastest processor :D
One of the bottlenecks is database flushing. To make syncing faster, you can increase the -dbcache=>n> parameter so more of the database is held in memory and does not need to be flushed to disk as often. You can also check the current block hash, and if you trust the block explorer you used, you can set the -assumevalid=<hash> option so that you will skip all signature validation up to the most recent block.