mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-01 16:35:53 +00:00
Add new 'consensus_info' RPC command to help troubleshoot consensus convergence issues.
This commit is contained in:
@@ -499,6 +499,7 @@ Json::Value RPCParser::parseCommand(std::string strMethod, Json::Value jvParams)
|
|||||||
{ "account_offers", &RPCParser::parseAccountItems, 1, 2 },
|
{ "account_offers", &RPCParser::parseAccountItems, 1, 2 },
|
||||||
{ "account_tx", &RPCParser::parseAccountTransactions, 2, 3 },
|
{ "account_tx", &RPCParser::parseAccountTransactions, 2, 3 },
|
||||||
{ "connect", &RPCParser::parseConnect, 1, 2 },
|
{ "connect", &RPCParser::parseConnect, 1, 2 },
|
||||||
|
{ "consensus_info", &RPCParser::parseAsIs, 0, 0 },
|
||||||
{ "get_counts", &RPCParser::parseGetCounts, 0, 1 },
|
{ "get_counts", &RPCParser::parseGetCounts, 0, 1 },
|
||||||
{ "ledger", &RPCParser::parseLedger, 0, 2 },
|
{ "ledger", &RPCParser::parseLedger, 0, 2 },
|
||||||
{ "ledger_accept", &RPCParser::parseAsIs, 0, 0 },
|
{ "ledger_accept", &RPCParser::parseAsIs, 0, 0 },
|
||||||
|
|||||||
@@ -267,6 +267,26 @@ bool LCTransaction::updateVote(int percentTime, bool proposing)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Json::Value LCTransaction::getJson()
|
||||||
|
{
|
||||||
|
Json::Value ret(Json::objectValue);
|
||||||
|
|
||||||
|
ret["yays"] = mYays;
|
||||||
|
ret["nays"] = mNays;
|
||||||
|
ret["our_vote"] = mOurVote;
|
||||||
|
if (!mVotes.empty())
|
||||||
|
{
|
||||||
|
Json::Value votesj(Json::objectValue);
|
||||||
|
typedef boost::unordered_map<uint160, bool>::value_type vt;
|
||||||
|
BOOST_FOREACH(vt& vote, mVotes)
|
||||||
|
{
|
||||||
|
votesj[vote.first.GetHex()] = vote.second;
|
||||||
|
}
|
||||||
|
ret["votes"] = votesj;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
LedgerConsensus::LedgerConsensus(const uint256& prevLCLHash, Ledger::ref previousLedger, uint32 closeTime)
|
LedgerConsensus::LedgerConsensus(const uint256& prevLCLHash, Ledger::ref previousLedger, uint32 closeTime)
|
||||||
: mState(lcsPRE_CLOSE), mCloseTime(closeTime), mPrevLedgerHash(prevLCLHash), mPreviousLedger(previousLedger),
|
: mState(lcsPRE_CLOSE), mCloseTime(closeTime), mPrevLedgerHash(prevLCLHash), mPreviousLedger(previousLedger),
|
||||||
mValPublic(theConfig.VALIDATION_PUB), mValPrivate(theConfig.VALIDATION_PRIV), mConsensusFail(false),
|
mValPublic(theConfig.VALIDATION_PUB), mValPrivate(theConfig.VALIDATION_PRIV), mConsensusFail(false),
|
||||||
@@ -1363,7 +1383,7 @@ void LedgerConsensus::simulate()
|
|||||||
cLog(lsINFO) << "Simulation complete";
|
cLog(lsINFO) << "Simulation complete";
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value LedgerConsensus::getJson()
|
Json::Value LedgerConsensus::getJson(bool full)
|
||||||
{
|
{
|
||||||
Json::Value ret(Json::objectValue);
|
Json::Value ret(Json::objectValue);
|
||||||
ret["proposing"] = mProposing;
|
ret["proposing"] = mProposing;
|
||||||
@@ -1388,12 +1408,88 @@ Json::Value LedgerConsensus::getJson()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int v = mDisputes.size();
|
int v = mDisputes.size();
|
||||||
if (v != 0)
|
if ((v != 0) && !full)
|
||||||
ret["disputes"] = v;
|
ret["disputes"] = v;
|
||||||
|
|
||||||
if (mOurPosition)
|
if (mOurPosition)
|
||||||
ret["our_position"] = mOurPosition->getJson();
|
ret["our_position"] = mOurPosition->getJson();
|
||||||
|
|
||||||
|
if (full)
|
||||||
|
{
|
||||||
|
|
||||||
|
ret["current_ms"] = mCurrentMSeconds;
|
||||||
|
ret["close_percent"] = mClosePercent;
|
||||||
|
ret["close_resolution"] = mCloseResolution;
|
||||||
|
ret["have_time_consensus"] = mHaveCloseTimeConsensus;
|
||||||
|
ret["previous_proposers"] = mPreviousProposers;
|
||||||
|
ret["previous_mseconds"] = mPreviousMSeconds;
|
||||||
|
|
||||||
|
if (!mPeerPositions.empty())
|
||||||
|
{
|
||||||
|
typedef boost::unordered_map<uint160, LedgerProposal::pointer>::value_type pp_t;
|
||||||
|
Json::Value ppj(Json::objectValue);
|
||||||
|
BOOST_FOREACH(pp_t& pp, mPeerPositions)
|
||||||
|
{
|
||||||
|
ppj[pp.first.GetHex()] = pp.second->getJson();
|
||||||
|
}
|
||||||
|
ret["peer_positions"] = ppj;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mAcquired.empty())
|
||||||
|
{ // acquired
|
||||||
|
typedef boost::unordered_map<uint256, SHAMap::pointer>::value_type ac_t;
|
||||||
|
Json::Value acq(Json::arrayValue);
|
||||||
|
BOOST_FOREACH(ac_t& at, mAcquired)
|
||||||
|
{
|
||||||
|
acq.append(at.first.GetHex());
|
||||||
|
}
|
||||||
|
ret["acquired"] = acq;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mAcquiring.empty())
|
||||||
|
{
|
||||||
|
typedef boost::unordered_map<uint256, TransactionAcquire::pointer>::value_type ac_t;
|
||||||
|
Json::Value acq(Json::arrayValue);
|
||||||
|
BOOST_FOREACH(ac_t& at, mAcquiring)
|
||||||
|
{
|
||||||
|
acq.append(at.first.GetHex());
|
||||||
|
}
|
||||||
|
ret["acquiring"] = acq;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mDisputes.empty())
|
||||||
|
{
|
||||||
|
typedef boost::unordered_map<uint256, LCTransaction::pointer>::value_type d_t;
|
||||||
|
Json::Value dsj(Json::objectValue);
|
||||||
|
BOOST_FOREACH(d_t& dt, mDisputes)
|
||||||
|
{
|
||||||
|
dsj[dt.first.GetHex()] = dt.second->getJson();
|
||||||
|
}
|
||||||
|
ret["disputes"] = dsj;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mCloseTimes.empty())
|
||||||
|
{
|
||||||
|
typedef std::map<uint32, int>::value_type ct_t;
|
||||||
|
Json::Value ctj(Json::objectValue);
|
||||||
|
BOOST_FOREACH(ct_t& ct, mCloseTimes)
|
||||||
|
{
|
||||||
|
ctj[boost::lexical_cast<std::string>(ct.first)] = ct.second;
|
||||||
|
}
|
||||||
|
ret["close_times"] = ctj;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mDeadNodes.empty())
|
||||||
|
{
|
||||||
|
Json::Value dnj(Json::arrayValue);
|
||||||
|
BOOST_FOREACH(const uint160& dn, mDeadNodes)
|
||||||
|
{
|
||||||
|
dnj.append(dn.GetHex());
|
||||||
|
}
|
||||||
|
ret["dead_nodes"] = dnj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ public:
|
|||||||
void unVote(const uint160& peer);
|
void unVote(const uint160& peer);
|
||||||
|
|
||||||
bool updateVote(int percentTime, bool proposing);
|
bool updateVote(int percentTime, bool proposing);
|
||||||
|
Json::Value getJson();
|
||||||
};
|
};
|
||||||
|
|
||||||
enum LCState
|
enum LCState
|
||||||
@@ -161,7 +162,7 @@ public:
|
|||||||
LedgerConsensus(const uint256& prevLCLHash, Ledger::ref previousLedger, uint32 closeTime);
|
LedgerConsensus(const uint256& prevLCLHash, Ledger::ref previousLedger, uint32 closeTime);
|
||||||
|
|
||||||
int startup();
|
int startup();
|
||||||
Json::Value getJson();
|
Json::Value getJson(bool full);
|
||||||
|
|
||||||
Ledger::ref peekPreviousLedger() { return mPreviousLedger; }
|
Ledger::ref peekPreviousLedger() { return mPreviousLedger; }
|
||||||
uint256 getLCL() { return mPrevLedgerHash; }
|
uint256 getLCL() { return mPrevLedgerHash; }
|
||||||
|
|||||||
@@ -1106,6 +1106,16 @@ bool NetworkOPs::recvValidation(const SerializedValidation::pointer& val)
|
|||||||
return theApp->getValidations().addValidation(val);
|
return theApp->getValidations().addValidation(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Json::Value NetworkOPs::getConsensusInfo()
|
||||||
|
{
|
||||||
|
if (mConsensus)
|
||||||
|
return mConsensus->getJson(true);
|
||||||
|
|
||||||
|
Json::Value info = Json::objectValue;
|
||||||
|
info["consensus"] = "none";
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
Json::Value NetworkOPs::getServerInfo(bool human, bool admin)
|
Json::Value NetworkOPs::getServerInfo(bool human, bool admin)
|
||||||
{
|
{
|
||||||
Json::Value info = Json::objectValue;
|
Json::Value info = Json::objectValue;
|
||||||
|
|||||||
@@ -250,6 +250,7 @@ public:
|
|||||||
int getPreviousConvergeTime() { return mLastCloseConvergeTime; }
|
int getPreviousConvergeTime() { return mLastCloseConvergeTime; }
|
||||||
uint32 getLastCloseTime() { return mLastCloseTime; }
|
uint32 getLastCloseTime() { return mLastCloseTime; }
|
||||||
void setLastCloseTime(uint32 t) { mLastCloseTime = t; }
|
void setLastCloseTime(uint32 t) { mLastCloseTime = t; }
|
||||||
|
Json::Value getConsensusInfo();
|
||||||
Json::Value getServerInfo(bool human, bool admin);
|
Json::Value getServerInfo(bool human, bool admin);
|
||||||
uint32 acceptLedger();
|
uint32 acceptLedger();
|
||||||
boost::unordered_map<uint160,
|
boost::unordered_map<uint160,
|
||||||
|
|||||||
@@ -1343,6 +1343,15 @@ Json::Value RPCHandler::doSubmit(Json::Value jvRequest)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Json::Value RPCHandler::doConsensusInfo(Json::Value)
|
||||||
|
{
|
||||||
|
Json::Value ret(Json::objectValue);
|
||||||
|
|
||||||
|
ret["info"] = theApp->getOPs().getConsensusInfo();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
Json::Value RPCHandler::doServerInfo(Json::Value)
|
Json::Value RPCHandler::doServerInfo(Json::Value)
|
||||||
{
|
{
|
||||||
Json::Value ret(Json::objectValue);
|
Json::Value ret(Json::objectValue);
|
||||||
@@ -2682,6 +2691,7 @@ Json::Value RPCHandler::doCommand(const Json::Value& jvRequest, int iRole)
|
|||||||
{ "account_offers", &RPCHandler::doAccountOffers, false, optCurrent },
|
{ "account_offers", &RPCHandler::doAccountOffers, false, optCurrent },
|
||||||
{ "account_tx", &RPCHandler::doAccountTransactions, false, optNetwork },
|
{ "account_tx", &RPCHandler::doAccountTransactions, false, optNetwork },
|
||||||
{ "connect", &RPCHandler::doConnect, true, optNone },
|
{ "connect", &RPCHandler::doConnect, true, optNone },
|
||||||
|
{ "consensus_info", &RPCHandler::doConsensusInfo, true, optNone },
|
||||||
{ "get_counts", &RPCHandler::doGetCounts, true, optNone },
|
{ "get_counts", &RPCHandler::doGetCounts, true, optNone },
|
||||||
{ "internal", &RPCHandler::doInternal, true, optNone },
|
{ "internal", &RPCHandler::doInternal, true, optNone },
|
||||||
{ "ledger", &RPCHandler::doLedger, false, optNetwork },
|
{ "ledger", &RPCHandler::doLedger, false, optNetwork },
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class RPCHandler
|
|||||||
Json::Value doAccountOffers(Json::Value params);
|
Json::Value doAccountOffers(Json::Value params);
|
||||||
Json::Value doAccountTransactions(Json::Value params);
|
Json::Value doAccountTransactions(Json::Value params);
|
||||||
Json::Value doConnect(Json::Value params);
|
Json::Value doConnect(Json::Value params);
|
||||||
|
Json::Value doConsensusInfo(Json::Value params);
|
||||||
#if ENABLE_INSECURE
|
#if ENABLE_INSECURE
|
||||||
Json::Value doDataDelete(Json::Value params);
|
Json::Value doDataDelete(Json::Value params);
|
||||||
Json::Value doDataFetch(Json::Value params);
|
Json::Value doDataFetch(Json::Value params);
|
||||||
|
|||||||
Reference in New Issue
Block a user