From b9d842891a361b4b06560aff7c8a5e0946b266c0 Mon Sep 17 00:00:00 2001 From: Brad Chase Date: Mon, 26 Jun 2017 16:33:28 -0700 Subject: [PATCH 1/2] Simplify bow-out handling & dispute updating --- src/ripple/consensus/Consensus.h | 59 +++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/src/ripple/consensus/Consensus.h b/src/ripple/consensus/Consensus.h index 973b2f2c488..8bfe29f8757 100644 --- a/src/ripple/consensus/Consensus.h +++ b/src/ripple/consensus/Consensus.h @@ -371,7 +371,7 @@ class Consensus startRound( NetClock::time_point const& now, typename Ledger_t::ID const& prevLedgerID, - Ledger_t const& prevLedger, + Ledger_t prevLedger, bool proposing); /** A peer has proposed a new position, adjust our tracking. @@ -638,7 +638,7 @@ void Consensus::startRound( NetClock::time_point const& now, typename Ledger_t::ID const& prevLedgerID, - Ledger_t const& prevLedger, + Ledger_t prevLedger, bool proposing) { std::lock_guard _(*lock_); @@ -653,11 +653,31 @@ Consensus::startRound( { prevCloseTime_ = rawCloseTimes_.self; } + + Mode startMode = proposing ? Mode::proposing : Mode::observing; + + // We were handed the wrong ledger + if (prevLedger.id() != prevLedgerID) + { + // try to acquire the correct one + if(auto newLedger = impl().acquireLedger(prevLedgerID)) + { + prevLedger = *newLedger; + } + else // Unable to acquire the correct ledger + { + startMode = Mode::wrongLedger; + JLOG(j_.info()) + << "Entering consensus with: " << previousLedger_.id(); + JLOG(j_.info()) << "Correct LCL is: " << prevLedgerID; + } + } + startRoundInternal( now, prevLedgerID, prevLedger, - proposing ? Mode::proposing : Mode::observing); + startMode); } template void @@ -687,19 +707,6 @@ Consensus::startRoundInternal( previousLedger_.closeAgree(), previousLedger_.seq() + 1); - if (previousLedger_.id() != prevLedgerID_) - { - handleWrongLedger(prevLedgerID_); - - // Unable to acquire the correct ledger - if (mode_ == Mode::wrongLedger) - { - JLOG(j_.info()) - << "Entering consensus with: " << previousLedger_.id(); - JLOG(j_.info()) << "Correct LCL is: " << prevLedgerID; - } - } - playbackProposals(); if (peerProposals_.size() > (prevProposers_ / 2)) { @@ -1005,14 +1012,15 @@ Consensus::handleWrongLedger( { assert(lgrId != prevLedgerID_ || previousLedger_.id() != lgrId); + // Stop proposing because we are out of sync + leaveConsensus(); + + // First time switching to this ledger if (prevLedgerID_ != lgrId) { - // first time switching to this ledger prevLedgerID_ = lgrId; - // Stop proposing because we are out of sync - leaveConsensus(); - + // Clear out state if (result_) { result_->disputes.clear(); @@ -1387,7 +1395,18 @@ Consensus::updateOurPositions() // Share our new transaction set if we haven't already received // it from a peer if (acquired_.emplace(newID, result_->set).second) + { impl().relay(result_->set); + // Update votes for any peers that have also taken this + // transaction set as their position + for (auto const& p : peerProposals_) + { + if (p.second.position() == newID) + { + updateDisputes(p.first, result_->set); + } + } + } if (mode_ == Mode::proposing) impl().propose(result_->position); From 5e2de96ccf83ef3191e38cf4a04ca44d5bace0ae Mon Sep 17 00:00:00 2001 From: Brad Chase Date: Tue, 27 Jun 2017 10:50:55 -0700 Subject: [PATCH 2/2] [FOLD] Filter partial validations --- src/ripple/app/misc/Validations.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ripple/app/misc/Validations.cpp b/src/ripple/app/misc/Validations.cpp index affad344fc1..c52c8b94f2c 100644 --- a/src/ripple/app/misc/Validations.cpp +++ b/src/ripple/app/misc/Validations.cpp @@ -96,6 +96,14 @@ class ValidationsImp : public Validations if (!val->isTrusted() && pubKey) val->setTrusted(); + // Do not process partial validations. + if(!val->isFull()) + { + // Only forward if current + return isCurrent; + } + + if (!val->isTrusted ()) { JLOG (j_.trace()) <<