Thursday, November 21, 2024

bitcoin core – Does bitcoind validate each block for each time it begins?


When operating bitcoind, it begins downloading the blockchain and validate each block in a row. It shops the blockchain within the ~/.bitcoin/blocks listing. And after we break daemon and restart it, begins downloading from the final block it downloaded from the earlier execution and never from the primary block once more. This was one thing I understood from logs.

2022-06-11T16:51:56Z dnsseed thread begin
2022-06-11T16:51:56Z addcon thread begin
2022-06-11T16:51:56Z init message: Finished loading
2022-06-11T16:51:56Z opencon thread begin
2022-06-11T16:51:56Z msghand thread begin
2022-06-11T16:51:56Z Ready 300 seconds earlier than querying DNS seeds.
2022-06-11T16:51:57Z New outbound peer linked: model: 70016, blocks=740373, peer=0 (outbound-full-relay)
2022-06-11T16:51:58Z Synchronizing blockheaders, peak: 740373 (~100.00%)
2022-06-11T16:51:59Z UpdateTip: new greatest=0000000000000533f02f775db4176ec57012c76c6dc56fa3debf5f307da3d758 peak=139238 model=0x00000001 log2_work=65.854192 tx=1188914 date="2011-08-02T05:59:57Z" progress=0.001607 cache=0.0MiB(308txo)
2022-06-11T16:51:59Z UpdateTip: new greatest=0000000000000264f2835263bdfcae0a8a4185b781fa980d0eae3e88ee4effa9 peak=139239 model=0x00000001 log2_work=65.854368 tx=1189040 date="2011-08-02T06:01:53Z" progress=0.001607 cache=0.1MiB(621txo)
2022-06-11T16:51:59Z UpdateTip: new greatest=00000000000008ae748a17911f5d56ac7e5ede06586d98d7d6aa83ce8bda5237 peak=139240 model=0x00000001 log2_work=65.854543 tx=1189100 date="2011-08-02T06:11:42Z" progress=0.001607 cache=0.1MiB(793txo)

As proven in logs above, it is downloading from peak 139238. However beside downloading, does it validate the downloaded blocks once more? The factor I seen whereas operating this system step-by-step utilizing gdb, was that it calls the GetBlockProof from the primary block.

(gdb) break GetBlockProof
Breakpoint 1 at 0x31be40: file chain.cpp, line 126.
(gdb) run
Beginning program: /usr/native/bin/bitcoind 
Lacking separate debuginfos, use: dnf debuginfo-install glibc-2.31-2.fc32.x86_64
[Thread debugging using libthread_db enabled]
Utilizing host libthread_db library "/lib64/libthread_db.so.1".
2022-06-11T16:58:20Z Bitcoin Core model v23.0 (launch construct)
2022-06-11T16:58:20Z Assuming ancestors of block 000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091 have legitimate signatures.

...

Thread 1 "bitcoind" hit Breakpoint 1, GetBlockProof (block=...) at chain.cpp:126
126 {
Lacking separate debuginfos, use: dnf debuginfo-install libevent-2.1.8-8.fc32.x86_64 libgcc-10.3.1-1.fc32.x86_64 openssl-libs-1.1.1d-7.fc32.x86_64 zlib-1.2.11-21.fc32.x86_64
(gdb) p block.nHeight 
$1 = 0
(gdb) proceed 
Persevering with.

Thread 1 "bitcoind" hit Breakpoint 1, GetBlockProof (block=...) at chain.cpp:126
126 {
(gdb) p block.nHeight 
$2 = 1
(gdb) proceed 
Persevering with.

Thread 1 "bitcoind" hit Breakpoint 1, GetBlockProof (block=...) at chain.cpp:126
126 {
(gdb) p block.nHeight 
$3 = 2
(gdb) 

Is that this true that’s begins validating blocks from the genesis block? Or my conclusion is incorrect? And if no, why the GetBlockProof is known as from the primary block?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles