Fix duplicate validation and manifest suppression

RIPD-1636
RIPD-1638
RIPD-1632
This commit is contained in:
wilsonianb
2018-05-31 17:19:42 -05:00
committed by Mike Ellery
parent f0cc7c4c8d
commit 31e511afcf
6 changed files with 44 additions and 20 deletions

View File

@@ -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;

View File

@@ -97,7 +97,7 @@ RCLCxPeerPos::Data::Data(
Proposal&& proposal)
: publicKey_{publicKey}
, signature_{signature}
, supression_{suppress}
, suppression_{suppress}
, proposal_{std::move(proposal)}
{
}

View File

@@ -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(

View File

@@ -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. */

View File

@@ -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

View File

@@ -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 <protocol::TMProposeSet> 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&)