Skip to content

Commit

Permalink
Merge pull request #1497 from MonsieurNicolas/variousDebugging
Browse files Browse the repository at this point in the history
Improved logging of SCP messages and invariants

Reviewed-by: MonsieurNicolas
  • Loading branch information
latobarita committed Jan 18, 2018
2 parents 37bd354 + 7f074f0 commit a278e95
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/invariant/InvariantManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ InvariantManagerImpl::enableInvariant(std::string const& name)
if (iter == mEnabled.end())
{
mEnabled.push_back(registryIter->second);
CLOG(INFO, "Invariant") << "Enabled invariant '" << name << "'";
}
else
{
Expand Down
15 changes: 9 additions & 6 deletions src/scp/Slot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "util/make_unique.h"
#include "util/types.h"
#include "xdrpp/marshal.h"
#include <ctime>
#include <functional>

namespace stellar
Expand Down Expand Up @@ -100,7 +101,8 @@ Slot::getExternalizingState() const
void
Slot::recordStatement(SCPStatement const& st)
{
mStatementsHistory.emplace_back(std::make_pair(st, mFullyValidated));
mStatementsHistory.emplace_back(
HistoricalStatement{std::time(nullptr), st, mFullyValidated});
}

SCP::EnvelopeState
Expand Down Expand Up @@ -190,8 +192,8 @@ Slot::isNodeInQuorum(NodeID const& node)
// statements for each protocol
for (auto const& e : mStatementsHistory)
{
auto& n = m[e.first.nodeID];
n.emplace_back(&e.first);
auto& n = m[e.mStatement.nodeID];
n.emplace_back(&e.mStatement);
}
return mSCP.getLocalNode()->isNodeInQuorum(
node,
Expand Down Expand Up @@ -305,11 +307,12 @@ Slot::dumpInfo(Json::Value& ret)
for (auto const& item : mStatementsHistory)
{
Json::Value& v = slotValue["statements"][count++];
v.append(mSCP.envToStr(item.first));
v.append(item.second);
v.append((Json::UInt64)item.mWhen);
v.append(mSCP.envToStr(item.mStatement));
v.append(item.mValidated);

Hash const& qSetHash =
getCompanionQuorumSetHashFromStatement(item.first);
getCompanionQuorumSetHashFromStatement(item.mStatement);
auto qSet = getSCPDriver().getQSet(qSetHash);
if (qSet)
{
Expand Down
10 changes: 8 additions & 2 deletions src/scp/Slot.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ class Slot : public std::enable_shared_from_this<Slot>

// keeps track of all statements seen so far for this slot.
// it is used for debugging purpose
// second: if the slot was fully validated at the time
std::vector<std::pair<SCPStatement, bool>> mStatementsHistory;
struct HistoricalStatement
{
time_t mWhen;
SCPStatement mStatement;
bool mValidated;
};

std::vector<HistoricalStatement> mStatementsHistory;

// true if the Slot was fully validated
bool mFullyValidated;
Expand Down

0 comments on commit a278e95

Please sign in to comment.