consensus: gate RNG substates by amendment state

This commit is contained in:
Nicholas Dudfield
2026-03-06 14:09:06 +07:00
parent 90a94294e4
commit bb77c2090b
3 changed files with 645 additions and 561 deletions

View File

@@ -1150,6 +1150,12 @@ RCLConsensus::Adaptor::preStartRound(
RCLCxLedger const& prevLgr,
hash_set<NodeID> const& nowTrusted)
{
rngEnabledThisRound_ =
prevLgr.ledger_->rules().enabled(featureConsensusEntropy);
JLOG(j_.debug()) << "RNGGATE: preStartRound prevSeq=" << prevLgr.seq()
<< " rulesEnabled=" << rngEnabledThisRound_;
// We have a key, we do not want out of sync validations after a restart
// and are not amendment blocked.
validating_ = validatorKeys_.keys &&
@@ -1384,6 +1390,12 @@ RCLConsensus::Adaptor::hasAnyReveals() const
return !pendingReveals_.empty();
}
bool
RCLConsensus::Adaptor::rngEnabled() const
{
return rngEnabledThisRound_;
}
bool
RCLConsensus::Adaptor::shouldSendExplicitFinalProposal() const
{
@@ -1676,6 +1688,11 @@ RCLConsensus::Adaptor::clearRngState()
expectedProposers_.clear();
commitProofs_.clear();
proposalProofs_.clear();
// Keep the round-level enable latch intact here. Consensus::startRound()
// calls preStartRound() first to snapshot whether RNG is enabled for the
// upcoming round, then immediately clears per-round working state.
// Resetting rngEnabledThisRound_ here would wipe that snapshot before
// phaseEstablish() can consult it.
}
void

View File

@@ -105,6 +105,7 @@ class RCLConsensus
// Ephemeral entropy secret (in-memory only, crash = non-revealer)
uint256 myEntropySecret_;
bool entropyFailed_ = false;
bool rngEnabledThisRound_ = false;
// Real SHAMaps for the current round (unbacked, ephemeral)
std::shared_ptr<SHAMap> commitSetMap_;
@@ -267,6 +268,15 @@ class RCLConsensus
bool
hasAnyReveals() const;
/** Whether ConsensusEntropy is enabled for the current round.
Latched from the previous ledger's rules at round start so the
generic consensus engine can skip RNG-specific waiting paths when
the amendment is inactive.
*/
bool
rngEnabled() const;
/** Whether to send an explicit final proposal (seq=4 style). */
bool
shouldSendExplicitFinalProposal() const;

File diff suppressed because it is too large Load Diff