Motivation
Each release we increase the values of the Headers Sync constants HEADER_COMMITMENT_PERIOD
and REDOWNLOAD_BUFFER_SIZE
as per doc/release-process.md. In the next (v30) or following release, it is very likely that REDOWNLOAD_BUFFER_SIZE
(14827
as of v29) will exceed the target_blocks
value used to test Headers Sync (15000
, headers_sync_chainwork_tests.cpp).
This would result in the HeadersSyncState::m_redownloaded_headers
-buffer not reaching the REDOWNLOAD_BUFFER_SIZE
-threshold during the headers_sync_chainwork_tests.cpp unit tests. Preempt this from happening by making the test depend upon the constant being updated.
Commits
Initial commits refactor and improve the unit tests, we then extract the constants and add the dependency, and finally add tests for the behavior around the threshold.
(It would have been nice to add a test that failed because of not reaching the REDOWNLOAD_BUFFER_SIZE
-threshold, but HeadersSyncState::PopHeadersReadyForAcceptance()
will return all headers anyway due to m_process_all_remaining_headers
being set when we reach the PoW threshold regardless of whether the buffer threshold is met).
Calculation
Date at time of calculation: 2025-05-21
Current block height: 897'662
Avg block time: ~9.8min
(https://mempool.space).
Added 6 months to TIME
constant in contrib/devtools/headerssync-params.py: datetime(2028, 4, 6)
Increased block height in contrib/devtools/headerssync-params.py (MINCHAINWORK_HEADERS
) to: 920'000
Block height difference: 22'338
Days: 22'338 * 9.8min / (60min * 24h) = ~152
Estimated date for block height 920'000
: 2025-10-20
REDOWNLOAD_BUFFER_SIZE
value calculated by contrib/devtools/headerssync-params.py: 15002