mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 05:55:51 +00:00
Fix a half-second race window during which a proposal could cause us to
enter the consensus process with the wrong last closed ledger.
This commit is contained in:
@@ -630,11 +630,15 @@ void NetworkOPs::checkState(const boost::system::error_code& result)
|
|||||||
mConsensus->timerEntry();
|
mConsensus->timerEntry();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
tryStartConsensus();
|
||||||
|
if (mConsensus)
|
||||||
|
mConsensus->timerEntry();
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: Don't check unless last closed ledger is at least some seconds old
|
void NetworkOPs::tryStartConsensus()
|
||||||
// If full or tracking, check only at wobble time!
|
{
|
||||||
uint256 networkClosed;
|
uint256 networkClosed;
|
||||||
bool ledgerChange = checkLastClosedLedger(peerList, networkClosed);
|
bool ledgerChange = checkLastClosedLedger(theApp->getConnectionPool().getPeerVector(), networkClosed);
|
||||||
if(networkClosed.isZero())
|
if(networkClosed.isZero())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -668,8 +672,6 @@ void NetworkOPs::checkState(const boost::system::error_code& result)
|
|||||||
|
|
||||||
if ((!mConsensus) && (mMode != omDISCONNECTED))
|
if ((!mConsensus) && (mMode != omDISCONNECTED))
|
||||||
beginConsensus(networkClosed, mLedgerMaster->getCurrentLedger());
|
beginConsensus(networkClosed, mLedgerMaster->getCurrentLedger());
|
||||||
if (mConsensus)
|
|
||||||
mConsensus->timerEntry();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerList, uint256& networkClosed)
|
bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerList, uint256& networkClosed)
|
||||||
@@ -877,9 +879,13 @@ bool NetworkOPs::haveConsensusObject()
|
|||||||
{
|
{
|
||||||
if (mConsensus)
|
if (mConsensus)
|
||||||
return true;
|
return true;
|
||||||
if (mMode != omFULL)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
|
if ((mMode == omFULL) || (mMode == omTRACKING))
|
||||||
|
{
|
||||||
|
tryStartConsensus();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // we need to get into the consensus process
|
||||||
uint256 networkClosed;
|
uint256 networkClosed;
|
||||||
std::vector<Peer::pointer> peerList = theApp->getConnectionPool().getPeerVector();
|
std::vector<Peer::pointer> peerList = theApp->getConnectionPool().getPeerVector();
|
||||||
bool ledgerChange = checkLastClosedLedger(peerList, networkClosed);
|
bool ledgerChange = checkLastClosedLedger(peerList, networkClosed);
|
||||||
@@ -888,6 +894,7 @@ bool NetworkOPs::haveConsensusObject()
|
|||||||
cLog(lsINFO) << "Beginning consensus due to peer action";
|
cLog(lsINFO) << "Beginning consensus due to peer action";
|
||||||
beginConsensus(networkClosed, mLedgerMaster->getCurrentLedger());
|
beginConsensus(networkClosed, mLedgerMaster->getCurrentLedger());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return mConsensus;
|
return mConsensus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -258,6 +258,7 @@ public:
|
|||||||
void switchLastClosedLedger(Ledger::pointer newLedger, bool duringConsensus); // Used for the "jump" case
|
void switchLastClosedLedger(Ledger::pointer newLedger, bool duringConsensus); // Used for the "jump" case
|
||||||
bool checkLastClosedLedger(const std::vector<Peer::pointer>&, uint256& networkClosed);
|
bool checkLastClosedLedger(const std::vector<Peer::pointer>&, uint256& networkClosed);
|
||||||
int beginConsensus(const uint256& networkClosed, Ledger::ref closingLedger);
|
int beginConsensus(const uint256& networkClosed, Ledger::ref closingLedger);
|
||||||
|
void tryStartConsensus();
|
||||||
void endConsensus(bool correctLCL);
|
void endConsensus(bool correctLCL);
|
||||||
void setStandAlone() { setMode(omFULL); }
|
void setStandAlone() { setMode(omFULL); }
|
||||||
void setStateTimer();
|
void setStateTimer();
|
||||||
|
|||||||
Reference in New Issue
Block a user