diff --git a/src/ripple/app/consensus/RCLConsensus.cpp b/src/ripple/app/consensus/RCLConsensus.cpp index 94bff26ab..e59277e09 100644 --- a/src/ripple/app/consensus/RCLConsensus.cpp +++ b/src/ripple/app/consensus/RCLConsensus.cpp @@ -200,6 +200,16 @@ RCLConsensus::Adaptor::propose(RCLCxPeerPos::Proposal const& proposal) prop.set_signature(sig.data(), sig.size()); + auto const suppression = proposalUniqueId( + proposal.position(), + proposal.prevLedger(), + proposal.proposeSeq(), + proposal.closeTime(), + valPublic_, + sig); + + app_.getHashRouter ().addSuppression (suppression); + app_.overlay().send(prop); } @@ -710,10 +720,9 @@ RCLConsensus::Adaptor::validate(RCLCxLedger const& ledger, fees, amendments); - - - // suppress it if we receive it - FIXME: wrong suppression - app_.getHashRouter().addSuppression(v->getSigningHash()); + // suppress it if we receive it + app_.getHashRouter().addSuppression( + sha512Half(makeSlice(v->getSerialized()))); handleNewValidation(app_, v, "local"); Blob validation = v->getSerialized(); protocol::TMValidation val; diff --git a/src/ripple/app/consensus/RCLCxPeerPos.cpp b/src/ripple/app/consensus/RCLCxPeerPos.cpp index 94eddf133..00aa1746d 100644 --- a/src/ripple/app/consensus/RCLCxPeerPos.cpp +++ b/src/ripple/app/consensus/RCLCxPeerPos.cpp @@ -97,7 +97,7 @@ RCLCxPeerPos::Data::Data( Proposal&& proposal) : publicKey_{publicKey} , signature_{signature} - , supression_{suppress} + , suppression_{suppress} , proposal_{std::move(proposal)} { } diff --git a/src/ripple/app/consensus/RCLCxPeerPos.h b/src/ripple/app/consensus/RCLCxPeerPos.h index 04bcd7bb7..773c4cafd 100644 --- a/src/ripple/app/consensus/RCLCxPeerPos.h +++ b/src/ripple/app/consensus/RCLCxPeerPos.h @@ -51,7 +51,7 @@ public: @param publicKey Public key of the peer @param signature Signature provided with the proposal - @param suppress ???? + @param suppress Unique id used for hash router suppression @param proposal The consensus proposal */ @@ -83,11 +83,11 @@ public: return data_->publicKey_; } - //! ????? + //! Unique id used by hash router to suppress duplicates uint256 const& suppressionID() const { - return data_->supression_; + return data_->suppression_; } Proposal const & @@ -106,7 +106,7 @@ private: { PublicKey publicKey_; Buffer signature_; - uint256 supression_; + uint256 suppression_; Proposal proposal_; Data( diff --git a/src/ripple/app/misc/Manifest.h b/src/ripple/app/misc/Manifest.h index a13a244c9..1aaf131ec 100644 --- a/src/ripple/app/misc/Manifest.h +++ b/src/ripple/app/misc/Manifest.h @@ -155,6 +155,22 @@ enum class ManifestDisposition invalid }; +inline std::string +to_string(ManifestDisposition m) +{ + switch (m) + { + case ManifestDisposition::accepted: + return "accepted"; + case ManifestDisposition::stale: + return "stale"; + case ManifestDisposition::invalid: + return "invalid"; + default: + return "unknown"; + } +} + class DatabaseCon; /** Remembers manifests with the highest sequence number. */ diff --git a/src/ripple/overlay/impl/OverlayImpl.cpp b/src/ripple/overlay/impl/OverlayImpl.cpp index 679582425..7ab41607a 100644 --- a/src/ripple/overlay/impl/OverlayImpl.cpp +++ b/src/ripple/overlay/impl/OverlayImpl.cpp @@ -641,8 +641,10 @@ OverlayImpl::onManifests ( if (auto mo = Manifest::make_Manifest (s)) { uint256 const hash = mo->hash (); - if (!hashRouter.addSuppressionPeer (hash, from->id ())) + if (!hashRouter.addSuppressionPeer (hash, from->id ())) { + JLOG(journal.info()) << "Duplicate manifest #" << i + 1; continue; + } if (! app_.validators().listed (mo->masterKey)) { @@ -685,7 +687,8 @@ OverlayImpl::onManifests ( } else { - JLOG(journal.info()) << "Bad manifest #" << i + 1; + JLOG(journal.info()) << "Bad manifest #" << i + 1 << + ": " << to_string(result); } } else diff --git a/src/ripple/overlay/impl/PeerImp.cpp b/src/ripple/overlay/impl/PeerImp.cpp index 22ac787cb..833eec7bd 100644 --- a/src/ripple/overlay/impl/PeerImp.cpp +++ b/src/ripple/overlay/impl/PeerImp.cpp @@ -724,11 +724,12 @@ PeerImp::doProtocolStart() app_.validatorManifests ().for_each_manifest ( [&tm](std::size_t s){tm.mutable_list()->Reserve(s);}, - [&tm](Manifest const& manifest) + [&tm, &hr = app_.getHashRouter()](Manifest const& manifest) { auto const& s = manifest.serialized; auto& tm_e = *tm.add_list(); tm_e.set_stobject(s.data(), s.size()); + hr.addSuppression(manifest.hash()); }); if (tm.list_size() > 0) @@ -1311,13 +1312,6 @@ PeerImp::onMessage (std::shared_ptr const& m) return; } - if (!app_.getValidationPublicKey().empty() && - publicKey == app_.getValidationPublicKey()) - { - JLOG(p_journal_.trace()) << "Proposal: self"; - return; - } - auto const isTrusted = app_.validators().trusted (publicKey); if (!isTrusted) @@ -2046,7 +2040,9 @@ PeerImp::checkValidation (STValidation::pointer val, if (app_.getOPs ().recvValidation(val, std::to_string(id())) || cluster()) { - overlay_.relay(*packet, signingHash); + auto const suppression = sha512Half( + makeSlice(val->getSerialized())); + overlay_.relay(*packet, suppression); } } catch (std::exception const&)