mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Make sure we properly handle receiving our own proposals and validations.
This commit is contained in:
@@ -239,6 +239,7 @@ LedgerConsensus::LedgerConsensus(const uint256& prevLCLHash, Ledger::ref previou
|
||||
cLog(lsINFO) << "Entering consensus process, validating";
|
||||
mValidating = true;
|
||||
mProposing = theApp->getOPs().getOperatingMode() == NetworkOPs::omFULL;
|
||||
mValPublic = NewcoinAddress::createNodePublic(mValSeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1139,9 +1140,11 @@ void LedgerConsensus::accept(SHAMap::ref set)
|
||||
statusChange(ripple::neACCEPTED_LEDGER, *newLCL);
|
||||
if (mValidating)
|
||||
{
|
||||
uint256 signingHash;
|
||||
SerializedValidation::pointer v = boost::make_shared<SerializedValidation>
|
||||
(newLCLHash, theApp->getOPs().getValidationTimeNC(), mValSeed, mProposing);
|
||||
(newLCLHash, theApp->getOPs().getValidationTimeNC(), mValSeed, mProposing, boost::ref(signingHash));
|
||||
v->setTrusted();
|
||||
theApp->isNew(signingHash); // suppress it if we receive it
|
||||
theApp->getValidations().addValidation(v);
|
||||
std::vector<unsigned char> validation = v->getSigned();
|
||||
ripple::TMValidation val;
|
||||
|
||||
@@ -87,7 +87,7 @@ protected:
|
||||
Ledger::pointer mPreviousLedger;
|
||||
LedgerAcquire::pointer mAcquiringLedger;
|
||||
LedgerProposal::pointer mOurPosition;
|
||||
NewcoinAddress mValSeed;
|
||||
NewcoinAddress mValSeed, mValPublic;
|
||||
bool mProposing, mValidating, mHaveCorrectLCL;
|
||||
|
||||
int mCurrentMSeconds, mClosePercent, mCloseResolution;
|
||||
@@ -183,6 +183,8 @@ public:
|
||||
bool peerGaveNodes(Peer::ref peer, const uint256& setHash,
|
||||
const std::list<SHAMapNode>& nodeIDs, const std::list< std::vector<unsigned char> >& nodeData);
|
||||
|
||||
bool isOurPubKey(const NewcoinAddress &k) { return k == mValPublic; }
|
||||
|
||||
// test/debug
|
||||
void simulate();
|
||||
};
|
||||
|
||||
@@ -712,6 +712,12 @@ bool NetworkOPs::recvPropose(uint32 proposeSeq, const uint256& proposeHash, cons
|
||||
return mMode != omFULL;
|
||||
}
|
||||
|
||||
if (mConsensus->isOurPubKey(naPeerPublic))
|
||||
{
|
||||
cLog(lsTRACE) << "Received our own validation";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is this node on our UNL?
|
||||
if (!theApp->getUNL().nodeInUNL(naPeerPublic))
|
||||
{
|
||||
|
||||
10
src/Peer.cpp
10
src/Peer.cpp
@@ -758,11 +758,9 @@ void Peer::recvValidation(ripple::TMValidation& packet)
|
||||
return;
|
||||
}
|
||||
|
||||
// The four #ifndef/#endif's are commented out temporarily to avoid
|
||||
// an update hassle. They can be removed once all nodes are running this code
|
||||
//#ifndef TRUST_NETWORK
|
||||
#ifndef TRUST_NETWORK
|
||||
try
|
||||
//#endif
|
||||
#endif
|
||||
{
|
||||
Serializer s(packet.validation());
|
||||
SerializerIterator sit(s);
|
||||
@@ -788,13 +786,13 @@ void Peer::recvValidation(ripple::TMValidation& packet)
|
||||
theApp->getConnectionPool().relayMessage(this, message);
|
||||
}
|
||||
}
|
||||
//#ifndef TRUST_NETWORK
|
||||
#ifndef TRUST_NETWORK
|
||||
catch (...)
|
||||
{
|
||||
cLog(lsWARNING) << "Exception processing validation";
|
||||
punishPeer(PP_UNKNOWN_REQUEST);
|
||||
}
|
||||
//#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void Peer::recvGetValidation(ripple::TMGetValidations& packet)
|
||||
|
||||
@@ -37,7 +37,7 @@ SerializedValidation::SerializedValidation(SerializerIterator& sit, bool checkSi
|
||||
}
|
||||
|
||||
SerializedValidation::SerializedValidation(const uint256& ledgerHash, uint32 signTime,
|
||||
const NewcoinAddress& naSeed, bool isFull)
|
||||
const NewcoinAddress& naSeed, bool isFull, uint256& signingHash)
|
||||
: STObject(sValidationFormat, sfValidation), mTrusted(false)
|
||||
{
|
||||
setFieldH256(sfLedgerHash, ledgerHash);
|
||||
@@ -52,8 +52,9 @@ SerializedValidation::SerializedValidation(const uint256& ledgerHash, uint32 sig
|
||||
if (!isFull)
|
||||
setFlag(sFullFlag);
|
||||
|
||||
signingHash = getSigningHash();
|
||||
std::vector<unsigned char> signature;
|
||||
NewcoinAddress::createNodePrivate(naSeed).signNodePrivate(getSigningHash(), signature);
|
||||
NewcoinAddress::createNodePrivate(naSeed).signNodePrivate(signingHash, signature);
|
||||
setFieldVL(sfSignature, signature);
|
||||
// XXX Check if this can fail.
|
||||
// if (!NewcoinAddress::createNodePrivate(naSeed).signNodePrivate(getSigningHash(), mSignature.peekValue()))
|
||||
|
||||
@@ -21,7 +21,8 @@ public:
|
||||
|
||||
// These throw if the object is not valid
|
||||
SerializedValidation(SerializerIterator& sit, bool checkSignature = true);
|
||||
SerializedValidation(const uint256& ledgerHash, uint32 signTime, const NewcoinAddress& naSeed, bool isFull);
|
||||
SerializedValidation(const uint256& ledgerHash, uint32 signTime, const NewcoinAddress& naSeed, bool isFull,
|
||||
uint256& signingHash);
|
||||
|
||||
uint256 getLedgerHash() const;
|
||||
uint32 getSignTime() const;
|
||||
|
||||
Reference in New Issue
Block a user