mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 14:35:52 +00:00
Rework how we declare a close time consensus to prevent stalls.
This commit is contained in:
@@ -762,47 +762,58 @@ void LedgerConsensus::updateOurPositions()
|
|||||||
|
|
||||||
|
|
||||||
int neededWeight;
|
int neededWeight;
|
||||||
|
|
||||||
if (mClosePercent < AV_MID_CONSENSUS_TIME)
|
if (mClosePercent < AV_MID_CONSENSUS_TIME)
|
||||||
neededWeight = AV_INIT_CONSENSUS_PCT;
|
neededWeight = AV_INIT_CONSENSUS_PCT;
|
||||||
else if (mClosePercent < AV_LATE_CONSENSUS_TIME)
|
else if (mClosePercent < AV_LATE_CONSENSUS_TIME)
|
||||||
neededWeight = AV_MID_CONSENSUS_PCT;
|
neededWeight = AV_MID_CONSENSUS_PCT;
|
||||||
else
|
else if (mClosePercent < AV_STUCK_CONSENSUS_TIME)
|
||||||
neededWeight = AV_LATE_CONSENSUS_PCT;
|
neededWeight = AV_LATE_CONSENSUS_PCT;
|
||||||
|
else
|
||||||
|
neededWeight = AV_STUCK_CONSENSUS_PCT;
|
||||||
|
|
||||||
uint32 closeTime = 0;
|
uint32 closeTime = 0;
|
||||||
mHaveCloseTimeConsensus = false;
|
mHaveCloseTimeConsensus = false;
|
||||||
|
|
||||||
int thresh = mPeerPositions.size();
|
if (mPeerPositions.empty())
|
||||||
if (thresh == 0)
|
|
||||||
{ // no other times
|
{ // no other times
|
||||||
mHaveCloseTimeConsensus = true;
|
mHaveCloseTimeConsensus = true;
|
||||||
closeTime = roundCloseTime(mOurPosition->getCloseTime());
|
closeTime = roundCloseTime(mOurPosition->getCloseTime());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int threshVote = mPeerPositions.size(); // Threshold for non-zero vote
|
||||||
|
int threshConsensus = mPeerPositions.size(); // Threshold to declare consensus
|
||||||
if (mProposing)
|
if (mProposing)
|
||||||
{
|
{
|
||||||
++closeTimes[roundCloseTime(mOurPosition->getCloseTime())];
|
++closeTimes[roundCloseTime(mOurPosition->getCloseTime())];
|
||||||
++thresh;
|
++threshVote;
|
||||||
|
++threshConsensus;
|
||||||
}
|
}
|
||||||
thresh = ((thresh * neededWeight) + (neededWeight / 2)) / 100;
|
threshVote = ((threshVote * neededWeight) + (neededWeight / 2)) / 100;
|
||||||
if (thresh == 0)
|
threshConsensus = ((threshConsensus * AV_CT_CONSENSUS_PCT) + (AV_CT_CONSENSUS_PCT / 2)) / 100;
|
||||||
thresh = 1;
|
|
||||||
cLog(lsINFO) << "Proposers:" << mPeerPositions.size() << " nw:" << neededWeight << " thr:" << thresh;
|
if (threshVote == 0)
|
||||||
|
threshVote = 1;
|
||||||
|
if (threshConsensus == 0)
|
||||||
|
threshConsensus = 1;
|
||||||
|
cLog(lsINFO) << "Proposers:" << mPeerPositions.size() << " nw:" << neededWeight
|
||||||
|
<< " thrV:" << threshVote << " thrC:" << threshConsensus;
|
||||||
|
|
||||||
for (std::map<uint32, int>::iterator it = closeTimes.begin(), end = closeTimes.end(); it != end; ++it)
|
for (std::map<uint32, int>::iterator it = closeTimes.begin(), end = closeTimes.end(); it != end; ++it)
|
||||||
{
|
{
|
||||||
cLog(lsDEBUG) << "CCTime: " << it->first << " has " << it->second << ", " << thresh << " required";
|
cLog(lsDEBUG) << "CCTime: " << it->first << " has " << it->second << ", " << threshVote << " required";
|
||||||
if (it->second >= thresh)
|
if (it->second >= threshVote)
|
||||||
{
|
{
|
||||||
cLog(lsDEBUG) << "Close time consensus reached: " << it->first;
|
cLog(lsDEBUG) << "Close time consensus reached: " << it->first;
|
||||||
mHaveCloseTimeConsensus = true;
|
|
||||||
closeTime = it->first;
|
closeTime = it->first;
|
||||||
thresh = it->second;
|
threshVote = it->second;
|
||||||
|
if (threshVote >= threshConsensus)
|
||||||
|
mHaveCloseTimeConsensus = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tLog(!mHaveCloseTimeConsensus, lsDEBUG) << "No CT consensus: Proposers:" << mPeerPositions.size()
|
tLog(!mHaveCloseTimeConsensus, lsDEBUG) << "No CT consensus: Proposers:" << mPeerPositions.size()
|
||||||
<< " Proposing:" << (mProposing ? "yes" : "no") << " Thresh:" << thresh << " Pos:" << closeTime;
|
<< " Proposing:" << (mProposing ? "yes" : "no") << " Thresh:" << threshConsensus << " Pos:" << closeTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!changes &&
|
if (!changes &&
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
# define AV_STUCK_CONSENSUS_TIME 200
|
# define AV_STUCK_CONSENSUS_TIME 200
|
||||||
# define AV_STUCK_CONSENSUS_PCT 95
|
# define AV_STUCK_CONSENSUS_PCT 95
|
||||||
|
|
||||||
|
# define AV_CT_CONSENSUS_PCT 75
|
||||||
|
|
||||||
class ContinuousLedgerTiming
|
class ContinuousLedgerTiming
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user