mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-30 15:35:49 +00:00
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:
@@ -267,7 +267,7 @@ bool LCTransaction::updateVote(int percentTime, bool proposing)
|
|||||||
|
|
||||||
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),
|
mValPublic(theConfig.VALIDATION_PUB), mValPrivate(theConfig.VALIDATION_PRIV), mConsensusFail(false),
|
||||||
mCurrentMSeconds(0), mClosePercent(0), mHaveCloseTimeConsensus(false),
|
mCurrentMSeconds(0), mClosePercent(0), mHaveCloseTimeConsensus(false),
|
||||||
mConsensusStartTime(boost::posix_time::microsec_clock::universal_time())
|
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;
|
cLog(lsDEBUG) << "Checking for TX consensus: agree=" << agree << ", disagree=" << disagree;
|
||||||
|
|
||||||
return ContinuousLedgerTiming::haveConsensus(mPreviousProposers, agree + disagree, agree, currentValidations,
|
return ContinuousLedgerTiming::haveConsensus(mPreviousProposers, agree + disagree, agree, currentValidations,
|
||||||
mPreviousMSeconds, mCurrentMSeconds, forReal);
|
mPreviousMSeconds, mCurrentMSeconds, forReal, mConsensusFail);
|
||||||
}
|
}
|
||||||
|
|
||||||
SHAMap::pointer LedgerConsensus::getTransactionTree(const uint256& hash, bool doAcquire)
|
SHAMap::pointer LedgerConsensus::getTransactionTree(const uint256& hash, bool doAcquire)
|
||||||
@@ -1224,7 +1224,7 @@ void LedgerConsensus::accept(SHAMap::ref set)
|
|||||||
}
|
}
|
||||||
|
|
||||||
statusChange(ripple::neACCEPTED_LEDGER, *newLCL);
|
statusChange(ripple::neACCEPTED_LEDGER, *newLCL);
|
||||||
if (mValidating)
|
if (mValidating && !mConsensusFail)
|
||||||
{
|
{
|
||||||
uint256 signingHash;
|
uint256 signingHash;
|
||||||
SerializedValidation::pointer v = boost::make_shared<SerializedValidation>
|
SerializedValidation::pointer v = boost::make_shared<SerializedValidation>
|
||||||
@@ -1271,7 +1271,7 @@ void LedgerConsensus::accept(SHAMap::ref set)
|
|||||||
cLog(lsINFO) << "Applying transactions from current ledger";
|
cLog(lsINFO) << "Applying transactions from current ledger";
|
||||||
applyTransactions(theApp->getMasterLedger().getCurrentLedger()->peekTransactionMap(), newOL, newLCL,
|
applyTransactions(theApp->getMasterLedger().getCurrentLedger()->peekTransactionMap(), newOL, newLCL,
|
||||||
failedTransactions, true);
|
failedTransactions, true);
|
||||||
theApp->getMasterLedger().pushLedger(newLCL, newOL, true);
|
theApp->getMasterLedger().pushLedger(newLCL, newOL, !mConsensusFail);
|
||||||
mNewLedgerHash = newLCL->getHash();
|
mNewLedgerHash = newLCL->getHash();
|
||||||
mState = lcsACCEPTED;
|
mState = lcsACCEPTED;
|
||||||
sl.unlock();
|
sl.unlock();
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ protected:
|
|||||||
LedgerAcquire::pointer mAcquiringLedger;
|
LedgerAcquire::pointer mAcquiringLedger;
|
||||||
LedgerProposal::pointer mOurPosition;
|
LedgerProposal::pointer mOurPosition;
|
||||||
RippleAddress mValPublic, mValPrivate;
|
RippleAddress mValPublic, mValPrivate;
|
||||||
bool mProposing, mValidating, mHaveCorrectLCL;
|
bool mProposing, mValidating, mHaveCorrectLCL, mConsensusFail;
|
||||||
|
|
||||||
int mCurrentMSeconds, mClosePercent, mCloseResolution;
|
int mCurrentMSeconds, mClosePercent, mCloseResolution;
|
||||||
bool mHaveCloseTimeConsensus;
|
bool mHaveCloseTimeConsensus;
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ bool ContinuousLedgerTiming::haveConsensus(
|
|||||||
int currentFinished, // proposers who have validated a ledger after this one
|
int currentFinished, // proposers who have validated a ledger after this one
|
||||||
int previousAgreeTime, // how long it took to agree on the last ledger
|
int previousAgreeTime, // how long it took to agree on the last ledger
|
||||||
int currentAgreeTime, // how long we've been trying to agree
|
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") %
|
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 %
|
currentProposers % previousProposers % currentAgree % currentFinished % currentAgreeTime % previousAgreeTime %
|
||||||
@@ -85,13 +86,15 @@ bool ContinuousLedgerTiming::haveConsensus(
|
|||||||
if (((currentAgree * 100 + 100) / (currentProposers + 1)) > 80)
|
if (((currentAgree * 100 + 100) / (currentProposers + 1)) > 80)
|
||||||
{
|
{
|
||||||
tLog(forReal, lsINFO) << "normal consensus";
|
tLog(forReal, lsINFO) << "normal consensus";
|
||||||
|
failed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If 50% of the nodes on your UNL have moved on, you should declare consensus
|
// If 80% of the nodes on your UNL have moved on, you should declare consensus
|
||||||
if (((currentFinished * 100) / (currentProposers + 1)) > 50)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public:
|
|||||||
int previousProposers, int currentProposers,
|
int previousProposers, int currentProposers,
|
||||||
int currentAgree, int currentClosed,
|
int currentAgree, int currentClosed,
|
||||||
int previousAgreeTime, int currentAgreeTime,
|
int previousAgreeTime, int currentAgreeTime,
|
||||||
bool forReal);
|
bool forReal, bool& failed);
|
||||||
|
|
||||||
static int getNextLedgerTimeResolution(int previousResolution, bool previousAgree, int ledgerSeq);
|
static int getNextLedgerTimeResolution(int previousResolution, bool previousAgree, int ledgerSeq);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user