From cddcb83047cbe835e155315cd7ef79833887af88 Mon Sep 17 00:00:00 2001 From: Nicholas Dudfield Date: Fri, 26 Jun 2026 19:22:33 +0700 Subject: [PATCH] refactor(consensus): remove unused reveal proof cache Reveal sidecars intentionally omit proof blobs to keep entropySet hashes deterministic. Remove the write-only proposalProofs_ cache and update the surrounding comments to match the current sidecar format. --- .../app/consensus/ConsensusExtensions.cpp | 31 +++++-------------- src/xrpld/app/consensus/ConsensusExtensions.h | 6 ++-- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/src/xrpld/app/consensus/ConsensusExtensions.cpp b/src/xrpld/app/consensus/ConsensusExtensions.cpp index b1e21b086..22245e053 100644 --- a/src/xrpld/app/consensus/ConsensusExtensions.cpp +++ b/src/xrpld/app/consensus/ConsensusExtensions.cpp @@ -1039,7 +1039,6 @@ ConsensusExtensions::clearRngStatePreservingExport() observedParticipantsBitmapBin_.clear(); likelyParticipants_.clear(); commitProofs_.clear(); - proposalProofs_.clear(); //@@end round-stop-rng-reset // Keep the round-level enable latches intact here. Consensus::startRound() // calls preStartRound() first to snapshot which extensions are enabled for @@ -1460,7 +1459,6 @@ ConsensusExtensions::onAcquiredSidecarSet(std::shared_ptr const& map) // A changed commitment invalidates any previously accepted // reveal for this node in the same round. pendingReveals_.erase(nodeId); - proposalProofs_.erase(nodeId); } } else @@ -1510,10 +1508,6 @@ ConsensusExtensions::onAcquiredSidecarSet(std::shared_ptr const& map) << " seq=" << seq; } } - else if (parsedProof) - { - proposalProofs_.insert_or_assign(nodeId, *parsedProof); - } ++merged; JLOG(j_.trace()) << "RNG: merged acquired entry" @@ -2033,8 +2027,7 @@ ConsensusExtensions::harvestRngData( // Any reveal accepted against the prior commitment is now stale. // Drop it so reveal quorum cannot be satisfied by mismatched data. - if (pendingReveals_.erase(nodeId) > 0) - proposalProofs_.erase(nodeId); + pendingReveals_.erase(nodeId); } else if (inserted) { @@ -2109,11 +2102,10 @@ ConsensusExtensions::harvestRngData( } //@@end rng-harvest-reveal-verification - // Store proposal proofs for embedding in SHAMap entries. - // commitProofs_: only seq=0 (commitments always ride on seq=0, - // so all nodes store the same proof → deterministic commitSet). - // proposalProofs_: latest proof carrying a reveal (for entropySet). - if (position.myCommitment || position.myReveal) + // Store deterministic commit proofs for embedding in commitSet entries. + // Reveal sidecars intentionally omit proofs so entropySet hashes do not + // depend on proposal timing or sequence. + if (position.myCommitment) { auto makeProof = [&]() { ProposalProof proof; @@ -2130,9 +2122,6 @@ ConsensusExtensions::harvestRngData( if (position.myCommitment && proposeSeq == 0) commitProofs_.emplace(nodeId, makeProof()); - - if (position.myReveal) - proposalProofs_[nodeId] = makeProof(); } } @@ -2621,10 +2610,9 @@ ConsensusExtensions::decorateMessage( << " prevLedger=" << proposal.prevLedger(); } - // Store our own proposal proof for embedding in SHAMap entries. - // commitProofs_ gets seq=0 only (deterministic commitSet). - // proposalProofs_ gets the latest with a reveal (for entropySet). - if (signedPosition.myCommitment || signedPosition.myReveal) + // Store our own deterministic commit proof for commitSet entries. + // Reveal sidecars deliberately omit proofs. + if (signedPosition.myCommitment) { auto makeProof = [&]() { ProposalProof proof; @@ -2641,9 +2629,6 @@ ConsensusExtensions::decorateMessage( if (signedPosition.myCommitment && proposal.proposeSeq() == 0) commitProofs_.emplace(valKeys.nodeID, makeProof()); - - if (signedPosition.myReveal) - proposalProofs_[valKeys.nodeID] = makeProof(); } } diff --git a/src/xrpld/app/consensus/ConsensusExtensions.h b/src/xrpld/app/consensus/ConsensusExtensions.h index 2f6ae36f9..304ba7478 100644 --- a/src/xrpld/app/consensus/ConsensusExtensions.h +++ b/src/xrpld/app/consensus/ConsensusExtensions.h @@ -131,11 +131,9 @@ private: void clearRngStatePreservingExport(); - // Proposal proofs keyed by NodeID. - // commitProofs_: only seq=0 proofs (deterministic across all nodes). - // proposalProofs_: latest proof with reveal (for entropySet). + // Commit proofs keyed by NodeID. Only seq=0 proofs are cached because the + // commit sidecar hash must be deterministic across all nodes. hash_map commitProofs_; - hash_map proposalProofs_; public: ConsensusExtensions(Application& app, beast::Journal j);