Better logging of untrusted validations. (To make sure there's no bug.)

This commit is contained in:
JoelKatz
2013-03-21 06:03:47 -07:00
parent b0c694195c
commit cd14be1afb
6 changed files with 18 additions and 10 deletions

View File

@@ -201,7 +201,7 @@ void LedgerConsensus::checkOurValidation()
v->setTrusted();
v->sign(signingHash, mValPrivate);
theApp->isNew(signingHash);
theApp->getValidations().addValidation(v);
theApp->getValidations().addValidation(v, "localMissing");
std::vector<unsigned char> validation = v->getSigned();
ripple::TMValidation val;
val.set_validation(&validation[0], validation.size());
@@ -1182,7 +1182,7 @@ void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer)
v->sign(signingHash, mValPrivate);
v->setTrusted();
theApp->isNew(signingHash); // suppress it if we receive it
theApp->getValidations().addValidation(v);
theApp->getValidations().addValidation(v, "local");
theApp->getOPs().setLastValidation(v);
std::vector<unsigned char> validation = v->getSigned();
ripple::TMValidation val;

View File

@@ -1164,10 +1164,10 @@ std::vector<RippleAddress>
return accounts;
}
bool NetworkOPs::recvValidation(SerializedValidation::ref val)
bool NetworkOPs::recvValidation(SerializedValidation::ref val, const std::string& source)
{
cLog(lsDEBUG) << "recvValidation " << val->getLedgerHash();
return theApp->getValidations().addValidation(val);
cLog(lsDEBUG) << "recvValidation " << val->getLedgerHash() << " from " << source;
return theApp->getValidations().addValidation(val, source);
}
Json::Value NetworkOPs::getConsensusInfo()

View File

@@ -253,7 +253,7 @@ public:
RippleAddress nodePublic, uint256 checkLedger, bool sigGood);
SMAddNode gotTXData(const boost::shared_ptr<Peer>& peer, const uint256& hash,
const std::list<SHAMapNode>& nodeIDs, const std::list< std::vector<unsigned char> >& nodeData);
bool recvValidation(SerializedValidation::ref val);
bool recvValidation(SerializedValidation::ref val, const std::string& source);
void takePosition(int seq, SHAMap::ref position);
SHAMap::pointer getTXMap(const uint256& hash);
bool hasTXSet(const boost::shared_ptr<Peer>& peer, const uint256& set, ripple::TxSetStatus status);

View File

@@ -1056,8 +1056,16 @@ static void checkValidation(Job&, SerializedValidation::pointer val, uint256 sig
return;
}
std::string source;
Peer::pointer lp = peer.lock();
if (lp)
source = lp->getDisplayName();
else
source = "unknown";
std::set<uint64> peers;
if (theApp->getOPs().recvValidation(val) && theApp->getSuppression().swapSet(signingHash, peers, SF_RELAYED))
if (theApp->getOPs().recvValidation(val, source) &&
theApp->getSuppression().swapSet(signingHash, peers, SF_RELAYED))
{
PackedMessage::pointer message = boost::make_shared<PackedMessage>(*packet, ripple::mtVALIDATION);
theApp->getConnectionPool().relayMessageBut(peers, message);

View File

@@ -34,7 +34,7 @@ VSpointer ValidationCollection::findSet(const uint256& ledgerHash)
return mValidations.fetch(ledgerHash);
}
bool ValidationCollection::addValidation(SerializedValidation::ref val)
bool ValidationCollection::addValidation(SerializedValidation::ref val, const std::string& source)
{
RippleAddress signer = val->getSignerPublic();
bool isCurrent = false;
@@ -53,7 +53,7 @@ bool ValidationCollection::addValidation(SerializedValidation::ref val)
else
{
cLog(lsDEBUG) << "Node " << signer.humanNodePublic() << " not in UNL st=" << val->getSignTime() <<
", hash=" << val->getLedgerHash() << ", shash=" << val->getSigningHash();
", hash=" << val->getLedgerHash() << ", shash=" << val->getSigningHash() << " src=" << source;
}
uint256 hash = val->getLedgerHash();

View File

@@ -37,7 +37,7 @@ public:
ValidationCollection() : mValidations("Validations", 128, 600), mWriting(false)
{ mStaleValidations.reserve(512); }
bool addValidation(SerializedValidation::ref);
bool addValidation(SerializedValidation::ref, const std::string& source);
ValidationSet getValidations(const uint256& ledger);
void getValidationCount(const uint256& ledger, bool currentOnly, int& trusted, int& untrusted);
void getValidationTypes(const uint256& ledger, int& full, int& partial);