Page MenuHomePhabricator

validation: add randomness to periodic write interval
ClosedPublic

Authored by PiRK on Sep 16 2025, 13:02.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCf13ec8de4134: validation: add randomness to periodic write interval
Summary

From the PR discussion:

One related idea: maybe we should randomize the sync event times a bit (say, uniformly random intervals between 50 and 70 minutes) to prevent a situation where the network over time settles into a few cohorts of synchronized syncers (think like communicating metronomes: they start randomly, but have synchronized events (blocks arriving) that slightly delay sync events if they were to coincide).

Co-Authored-By: Pieter Wuille <pieter@wuille.net>
Co-Authored-By: l0rinc <pap.lorinc@gmail.com>

This concludes backport of core#30611
https://github.com/bitcoin/bitcoin/pull/30611/commits/e976bd3045010ee217aa0f2dca4c962aabb789d5
Depends on D18642

Test Plan

ninja all check-all

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Sep 16 2025, 13:02
PiRK planned changes to this revision.Sep 16 2025, 13:23

Tail of the build log:

2025-09-16T13:40:53.094565Z (mocktime: 2020-08-31T15:34:10Z) [/work/src/validation.cpp:2312] [ConnectBlock] [bench]     - Fork checks: 0.06ms [0.03s (0.07ms/blk)]
2025-09-16T13:40:53.094607Z (mocktime: 2020-08-31T15:34:10Z) [/work/src/validation.cpp:2452] [ConnectBlock] [bench]       - Connect 1 transactions: 0.04ms (0.041ms/tx, 0.000ms/txin) [0.02s (0.05ms/blk)]
2025-09-16T13:40:53.094643Z (mocktime: 2020-08-31T15:34:10Z) [/work/src/validation.cpp:2481] [ConnectBlock] [bench]     - Verify 0 txins: 0.08ms (0.000ms/txin) [0.04s (0.10ms/blk)]
2025-09-16T13:40:53.094729Z (mocktime: 2020-08-31T15:34:10Z) [/work/src/validation.cpp:2506] [ConnectBlock] [bench]     - Index writing: 0.08ms [0.02s (0.04ms/blk)]
2025-09-16T13:40:53.094763Z (mocktime: 2020-08-31T15:34:10Z) [/work/src/validationinterface.cpp:280] [BlockChecked] [validation] BlockChecked: block hash=503efa2972a84af06cafc9829d4eaf8c3a6bc057a05e41075e8a221b3be4d8e0 state=Valid
2025-09-16T13:40:53.094839Z (mocktime: 2020-08-31T15:34:10Z) [/work/src/validation.cpp:3053] [ConnectTip] [bench]   - Connect total: 0.40ms [0.10s (0.23ms/blk)]
2025-09-16T13:40:53.094902Z (mocktime: 2020-08-31T15:34:10Z) [/work/src/validation.cpp:3063] [ConnectTip] [bench]   - Flush: 0.06ms [0.02s (0.04ms/blk)]
2025-09-16T13:40:53.094948Z (mocktime: 2020-08-31T15:34:10Z) [/work/src/validation.cpp:3074] [ConnectTip] [bench]   - Writing chainstate: 0.05ms [0.01s (0.02ms/blk)]
2025-09-16T13:40:53.095026Z (mocktime: 2020-08-31T15:34:10Z) [/work/src/validation.cpp:2772] [UpdateTipLog] UpdateTip: new best=503efa2972a84af06cafc9829d4eaf8c3a6bc057a05e41075e8a221b3be4d8e0 height=99 version=0x20000000 log2_work=7.643856 tx=100 date='2020-08-31T15:34:10Z' progress=1.000000 cache=0.3MiB(99txo)
2025-09-16T13:40:53.095053Z (mocktime: 2020-08-31T15:34:10Z) [/work/src/validation.cpp:3103] [ConnectTip] [bench]   - Connect postprocess: 0.10ms [0.03s (0.06ms/blk)]
2025-09-16T13:40:53.095076Z (mocktime: 2020-08-31T15:34:10Z) [/work/src/validation.cpp:3107] [ConnectTip] [bench] - Connect block: 0.61ms [0.15s (0.36ms/blk)]
2025-09-16T13:40:53.095110Z (mocktime: 2020-08-31T15:34:10Z) [/work/src/validationinterface.cpp:251] [BlockConnected] [validation] Enqueuing BlockConnected: block hash=503efa2972a84af06cafc9829d4eaf8c3a6bc057a05e41075e8a221b3be4d8e0 block height=99
2025-09-16T13:40:53.095167Z (mocktime: 2020-08-31T15:34:10Z) [/work/src/txmempool.cpp:402] [check] [mempool] Checking mempool with 0 transactions and 0 inputs
2025-09-16T13:40:53.095218Z (mocktime: 2020-08-31T15:34:10Z) [/work/src/validationinterface.cpp:251] [operator()] [validation] BlockConnected: block hash=503efa2972a84af06cafc9829d4eaf8c3a6bc057a05e41075e8a221b3be4d8e0 block height=99
2025-09-16T13:40:53.095811Z (mocktime: 2020-08-31T15:34:10Z) [/work/src/validationinterface.cpp:208] [UpdatedBlockTip] [validation] Enqueuing UpdatedBlockTip: new block hash=503efa2972a84af06cafc9829d4eaf8c3a6bc057a05e41075e8a221b3be4d8e0 fork block hash=6e44ad3536dcd969c6be91d0da635b4f0b35c94ea148b365e9b946a0df934aa2 (in IBD=false)
2025-09-16T13:40:53.095920Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validationinterface.cpp:208] [operator()] [validation] UpdatedBlockTip: new block hash=503efa2972a84af06cafc9829d4eaf8c3a6bc057a05e41075e8a221b3be4d8e0 fork block hash=6e44ad3536dcd969c6be91d0da635b4f0b35c94ea148b365e9b946a0df934aa2 (in IBD=false)
2025-09-16T13:40:53.096051Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/node/miner.cpp:206] [CreateNewBlock] CreateNewBlock(): total size: 181 txs: 0 fees: 0 sigChecks 100
2025-09-16T13:40:53.096149Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validation.cpp:2192] [ConnectBlock] [bench]     - Sanity checks: 0.01ms [0.00s (0.00ms/blk)]
2025-09-16T13:40:53.096204Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validation.cpp:2312] [ConnectBlock] [bench]     - Fork checks: 0.06ms [0.03s (0.07ms/blk)]
2025-09-16T13:40:53.096245Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validation.cpp:2452] [ConnectBlock] [bench]       - Connect 1 transactions: 0.04ms (0.039ms/tx, 0.000ms/txin) [0.02s (0.05ms/blk)]
2025-09-16T13:40:53.096280Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validation.cpp:2481] [ConnectBlock] [bench]     - Verify 0 txins: 0.08ms (0.000ms/txin) [0.04s (0.10ms/blk)]
2025-09-16T13:40:53.096312Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/node/miner.cpp:232] [CreateNewBlock] [bench] CreateNewBlock() addTxs: 0.02ms, validity: 0.31ms (total 0.32ms)
2025-09-16T13:40:53.096433Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validation.cpp:4762] [AcceptBlockHeader] Saw new header hash=5afde277a26b6f36aee8f61a1dbf755587e1c6be63e654a88abe2a1ff0fbfb05 height=100
2025-09-16T13:40:53.096967Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validationinterface.cpp:289] [NewPoWValidBlock] [validation] NewPoWValidBlock: block hash=5afde277a26b6f36aee8f61a1dbf755587e1c6be63e654a88abe2a1ff0fbfb05
2025-09-16T13:40:53.097624Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validation.cpp:2957] [ConnectTip] [bench]   - Load block from disk: 0.00ms [0.00s]
2025-09-16T13:40:53.097687Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validation.cpp:2192] [ConnectBlock] [bench]     - Sanity checks: 0.00ms [0.00s (0.00ms/blk)]
2025-09-16T13:40:53.097743Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validation.cpp:2312] [ConnectBlock] [bench]     - Fork checks: 0.06ms [0.03s (0.07ms/blk)]
2025-09-16T13:40:53.097790Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validation.cpp:2452] [ConnectBlock] [bench]       - Connect 1 transactions: 0.04ms (0.044ms/tx, 0.000ms/txin) [0.02s (0.05ms/blk)]
2025-09-16T13:40:53.097826Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validation.cpp:2481] [ConnectBlock] [bench]     - Verify 0 txins: 0.08ms (0.000ms/txin) [0.04s (0.10ms/blk)]
2025-09-16T13:40:53.097911Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validation.cpp:2506] [ConnectBlock] [bench]     - Index writing: 0.08ms [0.02s (0.04ms/blk)]
2025-09-16T13:40:53.097945Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validationinterface.cpp:280] [BlockChecked] [validation] BlockChecked: block hash=5afde277a26b6f36aee8f61a1dbf755587e1c6be63e654a88abe2a1ff0fbfb05 state=Valid
2025-09-16T13:40:53.098017Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validation.cpp:3053] [ConnectTip] [bench]   - Connect total: 0.40ms [0.10s (0.23ms/blk)]
2025-09-16T13:40:53.098074Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validation.cpp:3063] [ConnectTip] [bench]   - Flush: 0.06ms [0.02s (0.04ms/blk)]
2025-09-16T13:40:53.098115Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validation.cpp:3074] [ConnectTip] [bench]   - Writing chainstate: 0.04ms [0.01s (0.02ms/blk)]
2025-09-16T13:40:53.098190Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validation.cpp:2772] [UpdateTipLog] UpdateTip: new best=5afde277a26b6f36aee8f61a1dbf755587e1c6be63e654a88abe2a1ff0fbfb05 height=100 version=0x20000000 log2_work=7.658211 tx=101 date='2020-08-31T15:34:11Z' progress=1.000000 cache=0.3MiB(100txo)
2025-09-16T13:40:53.098216Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validation.cpp:3103] [ConnectTip] [bench]   - Connect postprocess: 0.10ms [0.03s (0.06ms/blk)]
2025-09-16T13:40:53.098241Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validation.cpp:3107] [ConnectTip] [bench] - Connect block: 0.60ms [0.15s (0.36ms/blk)]
2025-09-16T13:40:53.098274Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validationinterface.cpp:251] [BlockConnected] [validation] Enqueuing BlockConnected: block hash=5afde277a26b6f36aee8f61a1dbf755587e1c6be63e654a88abe2a1ff0fbfb05 block height=100
2025-09-16T13:40:53.098334Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/txmempool.cpp:402] [check] [mempool] Checking mempool with 0 transactions and 0 inputs
2025-09-16T13:40:53.098384Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validationinterface.cpp:251] [operator()] [validation] BlockConnected: block hash=5afde277a26b6f36aee8f61a1dbf755587e1c6be63e654a88abe2a1ff0fbfb05 block height=100
2025-09-16T13:40:53.098973Z (mocktime: 2020-08-31T15:34:11Z) [/work/src/validationinterface.cpp:208] [UpdatedBlockTip] [validation] Enqueuing UpdatedBlockTip: new block hash=5afde277a26b6f36aee8f61a1dbf755587e1c6be63e654a88abe2a1ff0fbfb05 fork block hash=503efa2972a84af06cafc9829d4eaf8c3a6bc057a05e41075e8a221b3be4d8e0 (in IBD=false)
2025-09-16T13:40:53.099085Z (mocktime: 2020-08-31T15:34:12Z) [/work/src/validationinterface.cpp:208] [operator()] [validation] UpdatedBlockTip: new block hash=5afde277a26b6f36aee8f61a1dbf755587e1c6be63e654a88abe2a1ff0fbfb05 fork block hash=503efa2972a84af06cafc9829d4eaf8c3a6bc057a05e41075e8a221b3be4d8e0 (in IBD=false)
2025-09-16T13:40:53.099188Z (mocktime: 2020-08-31T15:34:12Z) [/work/src/validation.cpp:7152] [MaybeRebalanceCaches] [snapshot] allocating all cache to the IBD chainstate
2025-09-16T13:40:53.099226Z (mocktime: 2020-08-31T15:34:12Z) [/work/src/validation.cpp:6414] [ResizeCoinsCaches] [Chainstate [ibd] @ height 100 (5afde277a26b6f36aee8f61a1dbf755587e1c6be63e654a88abe2a1ff0fbfb05)] resized coinsdb cache to 0.0 MiB
2025-09-16T13:40:53.099258Z (mocktime: 2020-08-31T15:34:12Z) [/work/src/validation.cpp:6416] [ResizeCoinsCaches] [Chainstate [ibd] @ height 100 (5afde277a26b6f36aee8f61a1dbf755587e1c6be63e654a88abe2a1ff0fbfb05)] resized coinstip cache to 0.0 MiB
2025-09-16T13:40:53.099320Z (mocktime: 2020-08-31T15:34:12Z) [/work/src/./logging/timer.h:48] [Log] [bench] FlushStateToDisk: write block and undo data to disk started
2025-09-16T13:40:53.102383Z (mocktime: 2020-08-31T15:34:12Z) [/work/src/./logging/timer.h:48] [Log] [bench] FlushStateToDisk: write block and undo data to disk completed (0.00ms)
2025-09-16T13:40:53.102422Z (mocktime: 2020-08-31T15:34:12Z) [/work/src/./logging/timer.h:48] [Log] [bench] FlushStateToDisk: write block index to disk started
2025-09-16T13:40:53.104899Z (mocktime: 2020-08-31T15:34:12Z) [/work/src/./logging/timer.h:48] [Log] [bench] FlushStateToDisk: write block index to disk completed (0.00ms)
test_bitcoin: /work/src/txdb.cpp:124: virtual bool CCoinsViewDB::BatchWrite(CoinsViewCacheCursor&, const BlockHash&): Assertion `!hashBlock.IsNull()' failed.
Aborted (core dumped)
[506/538] Running avalanche test suite
PASSED: avalanche test suite
[508/538] Running pow test suite
PASSED: pow test suite
[529/538] Running bitcoin-qt test suite
PASSED: bitcoin-qt test suite
[535/538] Running utility command for check-bitcoin-coins_tests
ninja: build stopped: cannot make progress due to previous errors.
Build build-debug failed with exit code 1

the failure is from before the rebase, I missed that build when i killed all the pending job

This revision is now accepted and ready to land.Sep 17 2025, 16:24