Be paranoid about ledger compatibility:

* Consider ledgers incompatible based on last valid ledger
* Test against even ledgers not acquired yet
* Don't validate an incompatible ledger
* Don't switch to an incompatible ledger
* Protect against an unreasonably small quorum
This commit is contained in:
JoelKatz
2015-07-28 15:14:51 -07:00
committed by Nik Bougalis
parent 38c6083a2f
commit 0bb570a36d
6 changed files with 183 additions and 11 deletions

View File

@@ -1262,6 +1262,21 @@ bool NetworkOPsImp::checkLastClosedLedger (
if (!switchLedgers)
return false;
Ledger::pointer consensus = m_ledgerMaster.getLedgerByHash (closedLedger);
if (!consensus)
consensus = getApp().getInboundLedgers().acquire (
closedLedger, 0, InboundLedger::fcCONSENSUS);
if (consensus &&
! m_ledgerMaster.isCompatible (consensus, m_journal.debug,
"Not switching"))
{
// Don't switch to a ledger not on the validated chain
networkClosed = ourClosed->getHash ();
return false;
}
m_journal.warning << "We are not running on the consensus ledger";
m_journal.info << "Our LCL: " << getJson (*ourClosed);
m_journal.info << "Net LCL " << closedLedger;
@@ -1269,12 +1284,6 @@ bool NetworkOPsImp::checkLastClosedLedger (
if ((mMode == omTRACKING) || (mMode == omFULL))
setMode (omCONNECTED);
Ledger::pointer consensus = m_ledgerMaster.getLedgerByHash (closedLedger);
if (!consensus)
consensus = getApp().getInboundLedgers().acquire (
closedLedger, 0, InboundLedger::fcCONSENSUS);
if (consensus)
{
clearNeedNetworkLedger ();