From 2a3f0ec9238003fefd6a9cdd0cbd6d30007ae540 Mon Sep 17 00:00:00 2001 From: Nicholas Dudfield Date: Thu, 9 Apr 2026 17:58:41 +0700 Subject: [PATCH] fix(rng): bounded wait for alignment instead of immediate fallback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When peers have published entropySetHash but none match ours yet (e.g. a subset peer is the only one seen so far), wait for the bounded deadline instead of immediately falling back to zero. Other aligned peers may not have published yet — give them time. Only fall back to zero if no alignment is observed within the deadline (2x rngREVEAL_TIMEOUT). --- src/xrpld/consensus/ConsensusExtensionsTick.h | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/xrpld/consensus/ConsensusExtensionsTick.h b/src/xrpld/consensus/ConsensusExtensionsTick.h index 835ab4108..815fa7c4f 100644 --- a/src/xrpld/consensus/ConsensusExtensionsTick.h +++ b/src/xrpld/consensus/ConsensusExtensionsTick.h @@ -667,14 +667,28 @@ extensionsTick(Ext& ext, Ctx const& ctx) } else if (!conflict && aligned == 0 && peersSeen > 0) { - // Peers published but none match ours — this - // shouldn't happen after merge, but treat as - // conflict and fall back. + // Peers published but none match ours yet. + // This can happen when a peer with a subset + // hash is the only one we've seen so far — + // other aligned peers may not have published + // yet. Wait bounded time for alignment. + auto const entropyElapsed = + ctx.nowSteady - ext.revealPhaseStart_; + auto const entropyDeadline = + ctx.parms.rngREVEAL_TIMEOUT * 2; + if (entropyElapsed <= entropyDeadline) + { + JLOG(ext.j_.debug()) + << "RNG: no aligned peers yet " + << "(peersSeen=" << peersSeen << "), waiting"; + logRngDiag("rng-entropy-hash-no-alignment-wait"); + return {}; + } ext.setEntropyFailed(); JLOG(ext.j_.warn()) - << "RNG: peers published entropySetHash but " - "none align with ours, falling back"; - logRngDiag("rng-entropy-hash-no-alignment"); + << "RNG: no peer alignment within deadline, " + "falling back to zero"; + logRngDiag("rng-entropy-hash-no-alignment-timeout"); } JLOG(ext.j_.debug())