7 suggestions
Earlier concerns neither republished nor resolved: 1 minor finding · 1 suggestion. See the Run archive for their assessments.
Optional improvements
[suggestion] · Options-clock test does not protect load-time clock initialization
The test only observes header validation after construction, so installing the options clock after startup verification would still satisfy its assertions.
Location: src/test/kernel/test_kernel.cpp:1607 (head).
Details and suggested fix
The fresh in-memory coins database makes startup skip LoadChainTip and the populated-tip check in VerifyLoadedChainstate. The first time-dependent assertion is ProcessBlockHeader after construction. Moving clock installation until after loading and verification, or reverting the startup check to GetTime(), would therefore go undetected. Add a file-backed reopen test: process a regtest block, destroy the manager to force-flush it, then reopen with an options clock more than two hours before the persisted tip and expect creation to fail. Reopen with the clock at or after the tip and expect success. Hold the global mock at an accepting time so an accidental global read produces the wrong result. Do not use the initial LoadChainTip notification to assert a post-IBD state, because it explicitly passes init=true.
[suggestion] · Clock documentation omits override precedence and maintenance timers
Zero falls back to the global mock when set, nonzero overrides that mock, and periodic flush scheduling remains outside the scoped clock despite the broader documentation.
Location: src/kernel/bitcoinkernel.h:1353 (head).
Details and suggested fix
ChainstateManager::Now() uses a nonzero instance value before consulting NodeClock, which itself prefers btck_set_mock_time over system time. Both new setters should document this precedence and describe zero as restoring that fallback, not necessarily the system clock. Update the global setter's claim that it affects all kernel time reads accordingly. Also replace “all time-sensitive operations” with the explicit validation-operation list: FlushStateToDisk still checks and schedules periodic writes using NodeClock. Note that maintenance-timer boundary in validation.h rather than recommending Now() for every validation-path read. This documents the existing behavior without moving persistence scheduling onto a frozen validation clock.
[suggestion] · Clock tests do not check isolation between managers
The single-manager future-time assertions would also pass with shared clock storage, leaving the API's per-manager isolation unprotected.
Location: src/test/kernel/test_kernel.cpp:1571 (head).
Details and suggested fix
Keep two managers alive in separate test directories. Set A to three hours before an unseen fixture header, then set B to that header's time before submitting it to either manager. Expect TIME_FUTURE from A and VALID from B. This catches shared clock storage without threads. To also detect an extra write to the global mock alongside correct instance storage, observe a manager with no override under a controlled global mock and verify that another manager's setter does not change its result. Use an unseen header for each time-sensitive observation, because AcceptBlockHeader returns early for known headers.
[suggestion] · Fuzz clock comment names an absent helper and omits template creation
The retained global mock covers direct NodeClock reads in both flushing and block-template creation, not the nonexistent _now_nondet() helper.
Location: src/test/fuzz/utxo_total_supply.cpp:39 (head).
Details and suggested fix
_now_nondet appears only in this comment. FlushStateToDisk, CreateNewBlock and UpdateTime still read NodeClock directly. Template creation also runs its default validity check against chainman.Now() before PrepareBlock overwrites the timestamp. Keep FakeNodeClock and reword the comment to identify these remaining reads and the need for a global mock compatible with the scoped clock. Removing it would expose system-time reads that the fuzz global-state guard rejects. Giving both clocks the same fuzzed_time keeps the target consistent, but does not distinguish validation using the scoped clock from validation using the global mock.
[suggestion] · Scoped-clock tests miss IBD, reset and callback-progress regressions
The IBD test does not reliably distinguish clock sources, and the kernel tests leave reset fallback and scoped callback progress unasserted.
Location: src/test/validation_chainstatemanager_tests.cpp:192 (head).
Details and suggested fix
- IBD: The fixture copies
Now<NodeSeconds>()into the manager, andIsTipRecenttruncates its input to seconds. A regression to the global clock normally gives the same result, except across a second boundary. Hold a RAII global clock at a fixed time plus 100 hours, set the manager to that fixed time, and derive the tip-age boundary from it. The recent-tip case will then distinguish the sources deterministically. - Reset: The kernel test ends immediately after
SetClockTime(std::nullopt), so ignoring zero would pass. Set a controlled global mock three hours before the next unseen fixture header, clear the override, and expectTIME_FUTURE. Reusing the accepted header would bypass contextual validation. - Progress: Record
BlockTipHandlernotifications. With no higher header loaded, hold the global clock well past the first regtest fixture block, set the manager clock to that block's time, process it, and assert progress1.0for that block's notification. The current receiver never observes this documented output.
[suggestion] · Templates use the global clock but validate against the scoped clock
A harness that sets only the manager clock more than two hours behind NodeClock can make template creation throw time-too-new during its default validity check.
Location: src/validation.cpp:4189 (head).
Details and suggested fix
CreateNewBlock and UpdateTime stamp templates from NodeClock::now(), while their default TestBlockValidity call now reaches the future-time check using chainman.Now(). A sufficiently earlier manager override therefore makes template creation reject its own timestamp and throw before helpers such as PrepareBlock can replace it. Use the manager clock for template timestamp reads, including UpdateTime, so construction and validation agree. No current caller producing this mismatch was found: utxo_total_supply sets both clocks equally, and the IBD test does not mine. The kernel API does not expose mining and bitcoind never sets this override, so production impact is unconfirmed.
[suggestion] · Explicit epoch values silently clear the C++ clock override
An engaged sys_seconds{} becomes the C reset sentinel, so a default-constructed time point enables global-mock or system-clock behavior without an error.
Location: src/kernel/bitcoinkernel_wrapper.h:1505 (head).
Details and suggested fix
Both SetClockTime wrappers take std::optional<std::chrono::sys_seconds>, making std::nullopt the natural request for clock fallback. They also forward an engaged epoch value as zero, which the C API correctly accepts as its reset sentinel. A caller accidentally passing a default-constructed time point therefore loses deterministic clock behavior instead of receiving an error. Reject an engaged epoch in the wrappers, throwing from ChainMan::SetClockTime and returning false from the options setter, so only std::nullopt requests fallback. This is a C++ API-ergonomics suggestion, not a violation of the documented C contract.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [minor]: Clarify whether the clock-time override is fixed or advancing
- [suggestion]: Add a release note for the exported clock API