mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-20 02:25:53 +00:00
Fix duplicate validation and manifest suppression
RIPD-1636 RIPD-1638 RIPD-1632
This commit is contained in:
@@ -200,6 +200,16 @@ RCLConsensus::Adaptor::propose(RCLCxPeerPos::Proposal const& proposal)
|
|||||||
|
|
||||||
prop.set_signature(sig.data(), sig.size());
|
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);
|
app_.overlay().send(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -710,10 +720,9 @@ RCLConsensus::Adaptor::validate(RCLCxLedger const& ledger,
|
|||||||
fees,
|
fees,
|
||||||
amendments);
|
amendments);
|
||||||
|
|
||||||
|
// suppress it if we receive it
|
||||||
|
app_.getHashRouter().addSuppression(
|
||||||
// suppress it if we receive it - FIXME: wrong suppression
|
sha512Half(makeSlice(v->getSerialized())));
|
||||||
app_.getHashRouter().addSuppression(v->getSigningHash());
|
|
||||||
handleNewValidation(app_, v, "local");
|
handleNewValidation(app_, v, "local");
|
||||||
Blob validation = v->getSerialized();
|
Blob validation = v->getSerialized();
|
||||||
protocol::TMValidation val;
|
protocol::TMValidation val;
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ RCLCxPeerPos::Data::Data(
|
|||||||
Proposal&& proposal)
|
Proposal&& proposal)
|
||||||
: publicKey_{publicKey}
|
: publicKey_{publicKey}
|
||||||
, signature_{signature}
|
, signature_{signature}
|
||||||
, supression_{suppress}
|
, suppression_{suppress}
|
||||||
, proposal_{std::move(proposal)}
|
, proposal_{std::move(proposal)}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
|
|
||||||
@param publicKey Public key of the peer
|
@param publicKey Public key of the peer
|
||||||
@param signature Signature provided with the proposal
|
@param signature Signature provided with the proposal
|
||||||
@param suppress ????
|
@param suppress Unique id used for hash router suppression
|
||||||
@param proposal The consensus proposal
|
@param proposal The consensus proposal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -83,11 +83,11 @@ public:
|
|||||||
return data_->publicKey_;
|
return data_->publicKey_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! ?????
|
//! Unique id used by hash router to suppress duplicates
|
||||||
uint256 const&
|
uint256 const&
|
||||||
suppressionID() const
|
suppressionID() const
|
||||||
{
|
{
|
||||||
return data_->supression_;
|
return data_->suppression_;
|
||||||
}
|
}
|
||||||
|
|
||||||
Proposal const &
|
Proposal const &
|
||||||
@@ -106,7 +106,7 @@ private:
|
|||||||
{
|
{
|
||||||
PublicKey publicKey_;
|
PublicKey publicKey_;
|
||||||
Buffer signature_;
|
Buffer signature_;
|
||||||
uint256 supression_;
|
uint256 suppression_;
|
||||||
Proposal proposal_;
|
Proposal proposal_;
|
||||||
|
|
||||||
Data(
|
Data(
|
||||||
|
|||||||
@@ -155,6 +155,22 @@ enum class ManifestDisposition
|
|||||||
invalid
|
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;
|
class DatabaseCon;
|
||||||
|
|
||||||
/** Remembers manifests with the highest sequence number. */
|
/** Remembers manifests with the highest sequence number. */
|
||||||
|
|||||||
@@ -641,8 +641,10 @@ OverlayImpl::onManifests (
|
|||||||
if (auto mo = Manifest::make_Manifest (s))
|
if (auto mo = Manifest::make_Manifest (s))
|
||||||
{
|
{
|
||||||
uint256 const hash = mo->hash ();
|
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;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (! app_.validators().listed (mo->masterKey))
|
if (! app_.validators().listed (mo->masterKey))
|
||||||
{
|
{
|
||||||
@@ -685,7 +687,8 @@ OverlayImpl::onManifests (
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
JLOG(journal.info()) << "Bad manifest #" << i + 1;
|
JLOG(journal.info()) << "Bad manifest #" << i + 1 <<
|
||||||
|
": " << to_string(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -724,11 +724,12 @@ PeerImp::doProtocolStart()
|
|||||||
|
|
||||||
app_.validatorManifests ().for_each_manifest (
|
app_.validatorManifests ().for_each_manifest (
|
||||||
[&tm](std::size_t s){tm.mutable_list()->Reserve(s);},
|
[&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 const& s = manifest.serialized;
|
||||||
auto& tm_e = *tm.add_list();
|
auto& tm_e = *tm.add_list();
|
||||||
tm_e.set_stobject(s.data(), s.size());
|
tm_e.set_stobject(s.data(), s.size());
|
||||||
|
hr.addSuppression(manifest.hash());
|
||||||
});
|
});
|
||||||
|
|
||||||
if (tm.list_size() > 0)
|
if (tm.list_size() > 0)
|
||||||
@@ -1311,13 +1312,6 @@ PeerImp::onMessage (std::shared_ptr <protocol::TMProposeSet> const& m)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!app_.getValidationPublicKey().empty() &&
|
|
||||||
publicKey == app_.getValidationPublicKey())
|
|
||||||
{
|
|
||||||
JLOG(p_journal_.trace()) << "Proposal: self";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto const isTrusted = app_.validators().trusted (publicKey);
|
auto const isTrusted = app_.validators().trusted (publicKey);
|
||||||
|
|
||||||
if (!isTrusted)
|
if (!isTrusted)
|
||||||
@@ -2046,7 +2040,9 @@ PeerImp::checkValidation (STValidation::pointer val,
|
|||||||
if (app_.getOPs ().recvValidation(val, std::to_string(id())) ||
|
if (app_.getOPs ().recvValidation(val, std::to_string(id())) ||
|
||||||
cluster())
|
cluster())
|
||||||
{
|
{
|
||||||
overlay_.relay(*packet, signingHash);
|
auto const suppression = sha512Half(
|
||||||
|
makeSlice(val->getSerialized()));
|
||||||
|
overlay_.relay(*packet, suppression);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception const&)
|
catch (std::exception const&)
|
||||||
|
|||||||
Reference in New Issue
Block a user