Track when we have to abandon the consensus process because the network has moved on.

Issue partial validation if appropriate later.
Change the consensus abort threshold to 80% of trusted nodes. (Maybe there should be a delay?)
This commit is contained in:
JoelKatz
2012-11-14 08:47:36 -08:00
parent bd44ae1b2b
commit 601db4491a
4 changed files with 13 additions and 10 deletions

View File

@@ -267,7 +267,7 @@ bool LCTransaction::updateVote(int percentTime, bool proposing)
LedgerConsensus::LedgerConsensus(const uint256& prevLCLHash, Ledger::ref previousLedger, uint32 closeTime)
: mState(lcsPRE_CLOSE), mCloseTime(closeTime), mPrevLedgerHash(prevLCLHash), mPreviousLedger(previousLedger),
mValPublic(theConfig.VALIDATION_PUB), mValPrivate(theConfig.VALIDATION_PRIV),
mValPublic(theConfig.VALIDATION_PUB), mValPrivate(theConfig.VALIDATION_PRIV), mConsensusFail(false),
mCurrentMSeconds(0), mClosePercent(0), mHaveCloseTimeConsensus(false),
mConsensusStartTime(boost::posix_time::microsec_clock::universal_time())
{
@@ -800,7 +800,7 @@ bool LedgerConsensus::haveConsensus(bool forReal)
cLog(lsDEBUG) << "Checking for TX consensus: agree=" << agree << ", disagree=" << disagree;
return ContinuousLedgerTiming::haveConsensus(mPreviousProposers, agree + disagree, agree, currentValidations,
mPreviousMSeconds, mCurrentMSeconds, forReal);
mPreviousMSeconds, mCurrentMSeconds, forReal, mConsensusFail);
}
SHAMap::pointer LedgerConsensus::getTransactionTree(const uint256& hash, bool doAcquire)
@@ -1224,7 +1224,7 @@ void LedgerConsensus::accept(SHAMap::ref set)
}
statusChange(ripple::neACCEPTED_LEDGER, *newLCL);
if (mValidating)
if (mValidating && !mConsensusFail)
{
uint256 signingHash;
SerializedValidation::pointer v = boost::make_shared<SerializedValidation>
@@ -1271,7 +1271,7 @@ void LedgerConsensus::accept(SHAMap::ref set)
cLog(lsINFO) << "Applying transactions from current ledger";
applyTransactions(theApp->getMasterLedger().getCurrentLedger()->peekTransactionMap(), newOL, newLCL,
failedTransactions, true);
theApp->getMasterLedger().pushLedger(newLCL, newOL, true);
theApp->getMasterLedger().pushLedger(newLCL, newOL, !mConsensusFail);
mNewLedgerHash = newLCL->getHash();
mState = lcsACCEPTED;
sl.unlock();

View File

@@ -91,7 +91,7 @@ protected:
LedgerAcquire::pointer mAcquiringLedger;
LedgerProposal::pointer mOurPosition;
RippleAddress mValPublic, mValPrivate;
bool mProposing, mValidating, mHaveCorrectLCL;
bool mProposing, mValidating, mHaveCorrectLCL, mConsensusFail;
int mCurrentMSeconds, mClosePercent, mCloseResolution;
bool mHaveCloseTimeConsensus;

View File

@@ -63,7 +63,8 @@ bool ContinuousLedgerTiming::haveConsensus(
int currentFinished, // proposers who have validated a ledger after this one
int previousAgreeTime, // how long it took to agree on the last ledger
int currentAgreeTime, // how long we've been trying to agree
bool forReal) // deciding whether to stop consensus process
bool forReal, // deciding whether to stop consensus process
bool& failed) // we can't reach a consensus
{
cLog(lsTRACE) << boost::str(boost::format("CLC::haveConsensus: prop=%d/%d agree=%d validated=%d time=%d/%d%s") %
currentProposers % previousProposers % currentAgree % currentFinished % currentAgreeTime % previousAgreeTime %
@@ -85,13 +86,15 @@ bool ContinuousLedgerTiming::haveConsensus(
if (((currentAgree * 100 + 100) / (currentProposers + 1)) > 80)
{
tLog(forReal, lsINFO) << "normal consensus";
failed = false;
return true;
}
// If 50% of the nodes on your UNL have moved on, you should declare consensus
if (((currentFinished * 100) / (currentProposers + 1)) > 50)
// If 80% of the nodes on your UNL have moved on, you should declare consensus
if (((currentFinished * 100) / (currentProposers + 1)) > 80)
{
tLog(forReal, lsWARNING) << "We see no consensus, but 50% of nodes have moved on";
tLog(forReal, lsWARNING) << "We see no consensus, but 80% of nodes have moved on";
failed = true;
return true;
}

View File

@@ -66,7 +66,7 @@ public:
int previousProposers, int currentProposers,
int currentAgree, int currentClosed,
int previousAgreeTime, int currentAgreeTime,
bool forReal);
bool forReal, bool& failed);
static int getNextLedgerTimeResolution(int previousResolution, bool previousAgree, int ledgerSeq);
};