From 5b68ff97b58d3464d375f1864df5e117769e6bad Mon Sep 17 00:00:00 2001 From: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com> Date: Sat, 7 Jan 2023 20:26:32 -0600 Subject: [PATCH] fix: avoid re-propogating old qfcommit messages (#5145) ## Issue being fixed or feature implemented This fixes an issue where qfcommit messages can be replayed from the past, then are validated and propagated to other nodes. This patch changes it so that old qfcommits are not relayed. ## What was done? ## How Has This Been Tested? Deployed to a node, and ensured that the log messages are shown. ## Breaking Changes ## Checklist: - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation **For repository code-owners and collaborators only** - [ ] I have assigned this pull request to a milestone --- src/llmq/blockprocessor.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/llmq/blockprocessor.cpp b/src/llmq/blockprocessor.cpp index 6add6aa746..27be179ca7 100644 --- a/src/llmq/blockprocessor.cpp +++ b/src/llmq/blockprocessor.cpp @@ -91,6 +91,19 @@ void CQuorumBlockProcessor::ProcessMessage(CNode* pfrom, const std::string& msg_ Misbehaving(pfrom->GetId(), 100); return; } + if (pQuorumBaseBlockIndex->nHeight < (::ChainActive().Height() - GetLLMQParams(type).dkgInterval)) { + LogPrint(BCLog::LLMQ, "CQuorumBlockProcessor::%s -- block %s is too old, peer=%d\n", __func__, + qc.quorumHash.ToString(), pfrom->GetId()); + // TODO: enable punishment in some future version when all/most nodes are running with this fix + // Misbehaving(peer.GetId(), 100); + return; + } + if (HasMinedCommitment(type, qc.quorumHash)) { + LogPrint(BCLog::LLMQ, "CQuorumBlockProcessor::%s -- commitment for quorum hash[%s], type[%d], quorumIndex[%d] is already mined, peer=%d\n", + __func__, qc.quorumHash.ToString(), uint8_t(type), qc.quorumIndex, pfrom->GetId()); + // NOTE: do not punish here + return; + } } {