mirror of
https://github.com/Xahau/xahaud.git
synced 2026-06-04 09:16:36 +00:00
fix(rng): bounded wait for alignment instead of immediate fallback
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).
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user