Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: BlackHatCoiner on June 04, 2024, 07:08:02 PM



Title: How does Bitcoin Core estimate the time left until synced?
Post by: BlackHatCoiner on June 04, 2024, 07:08:02 PM
Given the current block height, and given the announced chain tip from other nodes, how does it estimate when it will finish syncing? There is no known time that it takes to verify a block. It can be filled with lots of complicated scripts like this one (https://bitcointalk.org/index.php?topic=140078.msg1491085#msg1491085) and take up to even 12 minutes, or just by one transaction which is a 4 MB long message, and thus can be verified very quickly.

What's the optimal approach? Average verification time of the past x blocks?

Edit: I'm trying to sync the testnet3. I've reached the recent spam phase, and it went from 89 minutes remaining to 100.  :P


Title: Re: How does Bitcoin Core estimate the time left until synced?
Post by: achow101 on June 04, 2024, 09:30:37 PM
Bitcoin Core has a few hard coded values that are updated each release. The values relevant for this estimate is the number of transactions in the blockchain, the average number of transactions per second for a window of recent blocks (usually 4096), and the timestamp of the block for which this data was generated. Using these values, Bitcoin Core estimates the total number of txs in chain currently, then computes the progress by calculating the percentage of txs that have actually been processed so far.

When the hard coded tx count is passed, the progress estimator switches to using the current tx count and the current block's timestamp, rather than the hard coded tx count and timestamp. It does still use the hard coded tx rate though.