fix(consensus): refresh extension gates before round cleanup

This commit is contained in:
Nicholas Dudfield
2026-07-02 19:26:32 +07:00
parent 986646ec90
commit ac659faec7
2 changed files with 14 additions and 4 deletions

View File

@@ -1202,6 +1202,10 @@ class ConsensusExtensions_test : public beast::unit_test::suite
disabledEnv.app().getLedgerMaster().getClosedLedger();
ConsensusExtensions ce{enabledEnv.app(), activeNoopJournal()};
auto const tx = makeHash("on-round-start-export-latch");
auto const pk = makeValidatorKeys().front();
std::uint8_t const sigBytes[] = {1, 2, 3};
Buffer const sig{sigBytes, sizeof(sigBytes)};
ce.setRngEnabledThisRound(false);
ce.setExportEnabledThisRound(false);
@@ -1209,11 +1213,17 @@ class ConsensusExtensions_test : public beast::unit_test::suite
BEAST_EXPECT(ce.rngEnabled());
BEAST_EXPECT(ce.exportEnabled());
ce.exportSigCollector().addVerifiedSignature(tx, pk, sig, 10);
BEAST_EXPECT(ce.exportSigCollector().signatureCount(tx) == 1);
ce.onRoundStart(RCLCxLedger{enabledLedger}, {});
BEAST_EXPECT(ce.exportSigCollector().signatureCount(tx) == 1);
ce.setRngEnabledThisRound(true);
ce.setExportEnabledThisRound(true);
ce.onRoundStart(RCLCxLedger{disabledLedger}, {});
BEAST_EXPECT(!ce.rngEnabled());
BEAST_EXPECT(!ce.exportEnabled());
BEAST_EXPECT(ce.exportSigCollector().signatureCount(tx) == 0);
}
void

View File

@@ -1414,9 +1414,9 @@ ConsensusExtensions::clearRngStatePreservingExport()
likelyParticipants_.clear();
commitProofs_.clear();
//@@end round-stop-rng-reset
// Keep the round-level enable latches intact here. Callers either already
// hold a valid snapshot, or onRoundStart() refreshes it from the consensus
// parent ledger after clearing per-round working state.
// Keep the round-level enable latches intact here. onRoundStart() refreshes
// them from the consensus parent before clearing so boundary cleanup, such
// as the export-disabled signature wipe, observes the new round's rules.
}
void
@@ -2234,10 +2234,10 @@ ConsensusExtensions::onRoundStart(
RCLCxLedger const& prevLedger,
hash_set<NodeID> lastProposers)
{
clearRngState();
auto const& rules = prevLedger.ledger_->rules();
setRngEnabledThisRound(rules.enabled(featureConsensusEntropy));
setExportEnabledThisRound(rules.enabled(featureExport));
clearRngState();
roundPrevLedgerHash_ = prevLedger.ledger_->info().hash;
rngRoundSeq_ = prevLedger.ledger_->info().seq + 1;