mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-25 13:35:54 +00:00
Fix proposal relaying (RIPD-1057):
Stash the signature so we can relay a proposal later
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
|
// Used to construct received proposals
|
||||||
LedgerProposal::LedgerProposal (
|
LedgerProposal::LedgerProposal (
|
||||||
uint256 const& pLgr,
|
uint256 const& pLgr,
|
||||||
std::uint32_t seq,
|
std::uint32_t seq,
|
||||||
@@ -47,6 +48,8 @@ LedgerProposal::LedgerProposal (
|
|||||||
mTime = std::chrono::steady_clock::now ();
|
mTime = std::chrono::steady_clock::now ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used to construct local proposals
|
||||||
|
// CAUTION: publicKey_ not set
|
||||||
LedgerProposal::LedgerProposal (
|
LedgerProposal::LedgerProposal (
|
||||||
RippleAddress const& publicKey,
|
RippleAddress const& publicKey,
|
||||||
uint256 const& prevLgr,
|
uint256 const& prevLgr,
|
||||||
@@ -74,10 +77,10 @@ uint256 LedgerProposal::getSigningHash () const
|
|||||||
mCurrentHash);
|
mCurrentHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LedgerProposal::checkSign (std::string const& signature) const
|
bool LedgerProposal::checkSign () const
|
||||||
{
|
{
|
||||||
return mPublicKey.verifyNodePublic(
|
return mPublicKey.verifyNodePublic(
|
||||||
getSigningHash(), signature, ECDSA::not_strict);
|
getSigningHash(), signature_, ECDSA::not_strict);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LedgerProposal::changePosition (
|
bool LedgerProposal::changePosition (
|
||||||
@@ -100,13 +103,12 @@ void LedgerProposal::bowOut ()
|
|||||||
mProposeSeq = seqLeave;
|
mProposeSeq = seqLeave;
|
||||||
}
|
}
|
||||||
|
|
||||||
Blob LedgerProposal::sign (RippleAddress const& privateKey)
|
Blob const& LedgerProposal::sign (RippleAddress const& privateKey)
|
||||||
{
|
{
|
||||||
Blob ret;
|
privateKey.signNodePrivate (getSigningHash (), signature_);
|
||||||
privateKey.signNodePrivate (getSigningHash (), ret);
|
|
||||||
mSuppression = proposalUniqueId (mCurrentHash, mPreviousLedger, mProposeSeq,
|
mSuppression = proposalUniqueId (mCurrentHash, mPreviousLedger, mProposeSeq,
|
||||||
mCloseTime, mPublicKey.getNodePublic (), ret);
|
mCloseTime, mPublicKey.getNodePublic (), signature_);
|
||||||
return ret;
|
return signature_;
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value LedgerProposal::getJson () const
|
Json::Value LedgerProposal::getJson () const
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public:
|
|||||||
NetClock::time_point closeTime);
|
NetClock::time_point closeTime);
|
||||||
|
|
||||||
uint256 getSigningHash () const;
|
uint256 getSigningHash () const;
|
||||||
bool checkSign (std::string const& signature) const;
|
bool checkSign () const;
|
||||||
|
|
||||||
NodeID const& getPeerID () const
|
NodeID const& getPeerID () const
|
||||||
{
|
{
|
||||||
@@ -82,6 +82,10 @@ public:
|
|||||||
{
|
{
|
||||||
return mPreviousLedger;
|
return mPreviousLedger;
|
||||||
}
|
}
|
||||||
|
RippleAddress const& getPublicKey () const
|
||||||
|
{
|
||||||
|
return mPublicKey;
|
||||||
|
}
|
||||||
uint256 const& getSuppressionID () const
|
uint256 const& getSuppressionID () const
|
||||||
{
|
{
|
||||||
return mSuppression;
|
return mSuppression;
|
||||||
@@ -95,7 +99,17 @@ public:
|
|||||||
return mCloseTime;
|
return mCloseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
Blob sign (RippleAddress const& privateKey);
|
Blob const& sign (RippleAddress const& privateKey);
|
||||||
|
|
||||||
|
void setSignature (Blob sig)
|
||||||
|
{
|
||||||
|
signature_ = sig;
|
||||||
|
}
|
||||||
|
|
||||||
|
Blob const& getSignature () const
|
||||||
|
{
|
||||||
|
return signature_;
|
||||||
|
}
|
||||||
|
|
||||||
bool isPrevLedger (uint256 const& pl) const
|
bool isPrevLedger (uint256 const& pl) const
|
||||||
{
|
{
|
||||||
@@ -139,7 +153,8 @@ private:
|
|||||||
|
|
||||||
NodeID mPeerID;
|
NodeID mPeerID;
|
||||||
RippleAddress mPublicKey;
|
RippleAddress mPublicKey;
|
||||||
PublicKey publicKey_;
|
PublicKey publicKey_;
|
||||||
|
Blob signature_;
|
||||||
|
|
||||||
std::chrono::steady_clock::time_point mTime;
|
std::chrono::steady_clock::time_point mTime;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1324,7 +1324,7 @@ void LedgerConsensusImp::propose ()
|
|||||||
Blob const pubKey = mValPublic.getNodePublic ();
|
Blob const pubKey = mValPublic.getNodePublic ();
|
||||||
prop.set_nodepubkey (&pubKey[0], pubKey.size ());
|
prop.set_nodepubkey (&pubKey[0], pubKey.size ());
|
||||||
|
|
||||||
Blob const sig = mOurPosition->sign (mValPrivate);
|
Blob const& sig = mOurPosition->sign (mValPrivate);
|
||||||
prop.set_signature (&sig[0], sig.size ());
|
prop.set_signature (&sig[0], sig.size ());
|
||||||
|
|
||||||
app_.overlay().send(prop);
|
app_.overlay().send(prop);
|
||||||
@@ -1650,7 +1650,28 @@ void LedgerConsensusImp::playbackProposals ()
|
|||||||
if (proposal->isPrevLedger (mPrevLedgerHash) &&
|
if (proposal->isPrevLedger (mPrevLedgerHash) &&
|
||||||
peerPosition (proposal))
|
peerPosition (proposal))
|
||||||
{
|
{
|
||||||
// FIXME: Should do delayed relay
|
// Now that we know this proposal
|
||||||
|
// is useful, relay it
|
||||||
|
protocol::TMProposeSet prop;
|
||||||
|
|
||||||
|
prop.set_proposeseq (
|
||||||
|
proposal->getProposeSeq ());
|
||||||
|
prop.set_closetime (
|
||||||
|
proposal->getCloseTime ().time_since_epoch().count());
|
||||||
|
|
||||||
|
prop.set_currenttxhash (
|
||||||
|
proposal->getCurrentHash().begin(), 256 / 8);
|
||||||
|
prop.set_previousledger (
|
||||||
|
proposal->getPrevLedger().begin(), 256 / 8);
|
||||||
|
|
||||||
|
auto const pubKey = proposal->getPublicKey().getNodePublic ();
|
||||||
|
prop.set_nodepubkey (&pubKey[0], pubKey.size());
|
||||||
|
|
||||||
|
auto const& signature = proposal->getSignature();
|
||||||
|
prop.set_signature (&signature[0], signature.size());
|
||||||
|
|
||||||
|
app_.overlay().relay (
|
||||||
|
prop, proposal->getSuppressionID ());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1289,6 +1289,7 @@ PeerImp::onMessage (std::shared_ptr <protocol::TMProposeSet> const& m)
|
|||||||
NetClock::time_point{NetClock::duration{set.closetime()}},
|
NetClock::time_point{NetClock::duration{set.closetime()}},
|
||||||
signerPublic, PublicKey(makeSlice(set.nodepubkey())),
|
signerPublic, PublicKey(makeSlice(set.nodepubkey())),
|
||||||
suppression);
|
suppression);
|
||||||
|
proposal->setSignature (Blob (set.signature().begin(), set.signature().end()));
|
||||||
|
|
||||||
std::weak_ptr<PeerImp> weak = shared_from_this();
|
std::weak_ptr<PeerImp> weak = shared_from_this();
|
||||||
app_.getJobQueue ().addJob (
|
app_.getJobQueue ().addJob (
|
||||||
@@ -1902,7 +1903,7 @@ PeerImp::checkPropose (Job& job,
|
|||||||
assert (packet);
|
assert (packet);
|
||||||
protocol::TMProposeSet& set = *packet;
|
protocol::TMProposeSet& set = *packet;
|
||||||
|
|
||||||
if (! cluster() && ! proposal->checkSign (set.signature ()))
|
if (! cluster() && ! proposal->checkSign ())
|
||||||
{
|
{
|
||||||
p_journal_.warning <<
|
p_journal_.warning <<
|
||||||
"Proposal fails sig check";
|
"Proposal fails sig check";
|
||||||
|
|||||||
Reference in New Issue
Block a user