mining: handle negative and NaN wait timeouts

bitcoin/bitcoin: PR #36940

Review failed during source verification.

Earlier concerns neither republished nor resolved: 1 minor finding · 3 suggestions. See the Run archive for their assessments.

Coverage details

Background

Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.

Documented decisions

The earlier negative-timeout change deliberately combined an internal-caller invariant with a fallback: it added both “Assume(timeout >= 0ms); // No internal callers should use a negative timeout” and clamping negative values to zero. It did not document negative values as an IPC error.

The historical implementation distinguishes programmer expectations from fallback handling. It supports describing the current change as making rejection an explicit interface contract, rather than merely restoring an already documented rejection contract. The inspected history does not establish that clients were promised clamping.

Source 1

The historical interface describes the default timeout as “forever,” while the implementation caps very large waitTipChanged timeouts at 100 years explicitly to avoid undefined behavior in std::chrono.

The intended long-wait abstraction was not an unrestricted chrono deadline: an effectively indefinite client request was translated into a bounded internal duration. Both wait methods retain “forever” defaults in the pinned base interface, which provides context for accepting positive infinity without requiring an actually infinite internal deadline.

Source 1

Ralph's inferences

For waitTipChanged, positive infinity fits the existing large-timeout handling: it exceeds the 100-year bound and is replaced with that bound before deadline construction. This is implementation evidence of acceptance, not evidence of an expressly negotiated IPC compatibility guarantee.

The new interface comparison preserves this behavior because positive infinity satisfies the nonnegative check. Its acceptance is consistent with the existing effectively-forever abstraction and overflow protection.

The available evidence suggests inherited implementation-level handling rather than a separately articulated IPC validation policy: the historical check was introduced inside waitTipChanged's implementation, and the pinned base retains it inside BlockTemplateManager. The reason for relying on that handling at the IPC boundary remains unestablished.

This limits the historical conclusion: the old assertion expressed an internal-caller assumption, not a demonstrated policy for arbitrary IPC floating-point inputs. The head now separates boundary rejection from the retained internal invariant.

Source 1