Skip to content

Commit 7ca1c64

Browse files
committed
Revert "Several changes to improve Consensus stability: (#4505)"
This reverts commit e8a7b2a.
1 parent 300b7e0 commit 7ca1c64

20 files changed

+187
-910
lines changed

Builds/levelization/results/ordering.txt

-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ ripple.consensus > ripple.basics
1414
ripple.consensus > ripple.beast
1515
ripple.consensus > ripple.json
1616
ripple.consensus > ripple.protocol
17-
ripple.consensus > ripple.shamap
1817
ripple.core > ripple.beast
1918
ripple.core > ripple.json
2019
ripple.core > ripple.protocol
@@ -126,13 +125,11 @@ test.core > ripple.server
126125
test.core > test.jtx
127126
test.core > test.toplevel
128127
test.core > test.unit_test
129-
test.csf > ripple.app
130128
test.csf > ripple.basics
131129
test.csf > ripple.beast
132130
test.csf > ripple.consensus
133131
test.csf > ripple.json
134132
test.csf > ripple.protocol
135-
test.csf > test.jtx
136133
test.json > ripple.beast
137134
test.json > ripple.json
138135
test.json > test.jtx

src/ripple/app/consensus/RCLConsensus.cpp

+40-78
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ RCLConsensus::RCLConsensus(
5555
LedgerMaster& ledgerMaster,
5656
LocalTxs& localTxs,
5757
InboundTransactions& inboundTransactions,
58-
Consensus<Adaptor>::clock_type& clock,
58+
Consensus<Adaptor>::clock_type const& clock,
5959
ValidatorKeys const& validatorKeys,
6060
beast::Journal journal)
6161
: adaptor_(
@@ -171,9 +171,6 @@ RCLConsensus::Adaptor::share(RCLCxPeerPos const& peerPos)
171171
auto const sig = peerPos.signature();
172172
prop.set_signature(sig.data(), sig.size());
173173

174-
if (proposal.ledgerSeq().has_value())
175-
prop.set_ledgerseq(*proposal.ledgerSeq());
176-
177174
app_.overlay().relay(prop, peerPos.suppressionID(), peerPos.publicKey());
178175
}
179176

@@ -183,7 +180,7 @@ RCLConsensus::Adaptor::share(RCLCxTx const& tx)
183180
// If we didn't relay this transaction recently, relay it to all peers
184181
if (app_.getHashRouter().shouldRelay(tx.id()))
185182
{
186-
JLOG(j_.trace()) << "Relaying disputed tx " << tx.id();
183+
JLOG(j_.debug()) << "Relaying disputed tx " << tx.id();
187184
auto const slice = tx.tx_->slice();
188185
protocol::TMTransaction msg;
189186
msg.set_rawtransaction(slice.data(), slice.size());
@@ -195,13 +192,13 @@ RCLConsensus::Adaptor::share(RCLCxTx const& tx)
195192
}
196193
else
197194
{
198-
JLOG(j_.trace()) << "Not relaying disputed tx " << tx.id();
195+
JLOG(j_.debug()) << "Not relaying disputed tx " << tx.id();
199196
}
200197
}
201198
void
202199
RCLConsensus::Adaptor::propose(RCLCxPeerPos::Proposal const& proposal)
203200
{
204-
JLOG(j_.debug()) << (proposal.isBowOut() ? "We bow out: " : "We propose: ")
201+
JLOG(j_.trace()) << (proposal.isBowOut() ? "We bow out: " : "We propose: ")
205202
<< ripple::to_string(proposal.prevLedger()) << " -> "
206203
<< ripple::to_string(proposal.position());
207204

@@ -215,7 +212,6 @@ RCLConsensus::Adaptor::propose(RCLCxPeerPos::Proposal const& proposal)
215212
prop.set_closetime(proposal.closeTime().time_since_epoch().count());
216213
prop.set_nodepubkey(
217214
validatorKeys_.publicKey.data(), validatorKeys_.publicKey.size());
218-
prop.set_ledgerseq(*proposal.ledgerSeq());
219215

220216
auto sig = signDigest(
221217
validatorKeys_.publicKey,
@@ -301,8 +297,7 @@ auto
301297
RCLConsensus::Adaptor::onClose(
302298
RCLCxLedger const& ledger,
303299
NetClock::time_point const& closeTime,
304-
ConsensusMode mode,
305-
clock_type& clock) -> Result
300+
ConsensusMode mode) -> Result
306301
{
307302
const bool wrongLCL = mode == ConsensusMode::wrongLedger;
308303
const bool proposing = mode == ConsensusMode::proposing;
@@ -384,6 +379,7 @@ RCLConsensus::Adaptor::onClose(
384379

385380
// Needed because of the move below.
386381
auto const setHash = initialSet->getHash().as_uint256();
382+
387383
return Result{
388384
std::move(initialSet),
389385
RCLCxPeerPos::Proposal{
@@ -392,9 +388,7 @@ RCLConsensus::Adaptor::onClose(
392388
setHash,
393389
closeTime,
394390
app_.timeKeeper().closeTime(),
395-
validatorKeys_.nodeID,
396-
initialLedger->info().seq,
397-
clock}};
391+
validatorKeys_.nodeID}};
398392
}
399393

400394
void
@@ -406,43 +400,50 @@ RCLConsensus::Adaptor::onForceAccept(
406400
ConsensusMode const& mode,
407401
Json::Value&& consensusJson)
408402
{
409-
auto txsBuilt = buildAndValidate(
410-
result, prevLedger, closeResolution, mode, std::move(consensusJson));
411-
prepareOpenLedger(std::move(txsBuilt), result, rawCloseTimes, mode);
403+
doAccept(
404+
result,
405+
prevLedger,
406+
closeResolution,
407+
rawCloseTimes,
408+
mode,
409+
std::move(consensusJson));
412410
}
413411

414412
void
415413
RCLConsensus::Adaptor::onAccept(
416414
Result const& result,
415+
RCLCxLedger const& prevLedger,
416+
NetClock::duration const& closeResolution,
417417
ConsensusCloseTimes const& rawCloseTimes,
418418
ConsensusMode const& mode,
419-
Json::Value&& consensusJson,
420-
std::pair<CanonicalTxSet_t, Ledger_t>&& tb)
419+
Json::Value&& consensusJson)
421420
{
422421
app_.getJobQueue().addJob(
423422
jtACCEPT,
424423
"acceptLedger",
425-
[=,
426-
this,
427-
cj = std::move(consensusJson),
428-
txsBuilt = std::move(tb)]() mutable {
424+
[=, this, cj = std::move(consensusJson)]() mutable {
429425
// Note that no lock is held or acquired during this job.
430426
// This is because generic Consensus guarantees that once a ledger
431427
// is accepted, the consensus results and capture by reference state
432428
// will not change until startRound is called (which happens via
433429
// endConsensus).
434-
prepareOpenLedger(std::move(txsBuilt), result, rawCloseTimes, mode);
430+
this->doAccept(
431+
result,
432+
prevLedger,
433+
closeResolution,
434+
rawCloseTimes,
435+
mode,
436+
std::move(cj));
435437
this->app_.getOPs().endConsensus();
436438
});
437439
}
438440

439-
std::pair<
440-
RCLConsensus::Adaptor::CanonicalTxSet_t,
441-
RCLConsensus::Adaptor::Ledger_t>
442-
RCLConsensus::Adaptor::buildAndValidate(
441+
void
442+
RCLConsensus::Adaptor::doAccept(
443443
Result const& result,
444-
Ledger_t const& prevLedger,
445-
NetClock::duration const& closeResolution,
444+
RCLCxLedger const& prevLedger,
445+
NetClock::duration closeResolution,
446+
ConsensusCloseTimes const& rawCloseTimes,
446447
ConsensusMode const& mode,
447448
Json::Value&& consensusJson)
448449
{
@@ -496,12 +497,12 @@ RCLConsensus::Adaptor::buildAndValidate(
496497
{
497498
retriableTxs.insert(
498499
std::make_shared<STTx const>(SerialIter{item.slice()}));
499-
JLOG(j_.trace()) << " Tx: " << item.key();
500+
JLOG(j_.debug()) << " Tx: " << item.key();
500501
}
501502
catch (std::exception const& ex)
502503
{
503504
failed.insert(item.key());
504-
JLOG(j_.trace())
505+
JLOG(j_.warn())
505506
<< " Tx: " << item.key() << " throws: " << ex.what();
506507
}
507508
}
@@ -578,19 +579,6 @@ RCLConsensus::Adaptor::buildAndValidate(
578579
ledgerMaster_.consensusBuilt(
579580
built.ledger_, result.txns.id(), std::move(consensusJson));
580581

581-
return {retriableTxs, built};
582-
}
583-
584-
void
585-
RCLConsensus::Adaptor::prepareOpenLedger(
586-
std::pair<CanonicalTxSet_t, Ledger_t>&& txsBuilt,
587-
Result const& result,
588-
ConsensusCloseTimes const& rawCloseTimes,
589-
ConsensusMode const& mode)
590-
{
591-
auto& retriableTxs = txsBuilt.first;
592-
auto const& built = txsBuilt.second;
593-
594582
//-------------------------------------------------------------------------
595583
{
596584
// Apply disputed transactions that didn't get in
@@ -613,7 +601,7 @@ RCLConsensus::Adaptor::prepareOpenLedger(
613601
// we voted NO
614602
try
615603
{
616-
JLOG(j_.trace())
604+
JLOG(j_.debug())
617605
<< "Test applying disputed transaction that did"
618606
<< " not get in " << dispute.tx().id();
619607

@@ -631,7 +619,7 @@ RCLConsensus::Adaptor::prepareOpenLedger(
631619
}
632620
catch (std::exception const& ex)
633621
{
634-
JLOG(j_.trace()) << "Failed to apply transaction we voted "
622+
JLOG(j_.debug()) << "Failed to apply transaction we voted "
635623
"NO on. Exception: "
636624
<< ex.what();
637625
}
@@ -681,7 +669,6 @@ RCLConsensus::Adaptor::prepareOpenLedger(
681669
// we entered the round with the network,
682670
// see how close our close time is to other node's
683671
// close time reports, and update our clock.
684-
bool const consensusFail = result.state == ConsensusState::MovedOn;
685672
if ((mode == ConsensusMode::proposing ||
686673
mode == ConsensusMode::observing) &&
687674
!consensusFail)
@@ -902,30 +889,12 @@ RCLConsensus::Adaptor::onModeChange(ConsensusMode before, ConsensusMode after)
902889
mode_ = after;
903890
}
904891

905-
bool
906-
RCLConsensus::Adaptor::retryAccept(
907-
Ledger_t const& newLedger,
908-
std::optional<std::chrono::time_point<std::chrono::steady_clock>>& start)
909-
const
910-
{
911-
static bool const standalone = ledgerMaster_.standalone();
912-
auto const& validLedger = ledgerMaster_.getValidatedLedger();
913-
914-
return (app_.getOPs().isFull() && !standalone &&
915-
(validLedger && (newLedger.id() != validLedger->info().hash) &&
916-
(newLedger.seq() >= validLedger->info().seq))) &&
917-
(!start ||
918-
std::chrono::steady_clock::now() - *start < std::chrono::seconds{5});
919-
}
920-
921-
//-----------------------------------------------------------------------------
922-
923892
Json::Value
924893
RCLConsensus::getJson(bool full) const
925894
{
926895
Json::Value ret;
927896
{
928-
std::lock_guard _{adaptor_.peekMutex()};
897+
std::lock_guard _{mutex_};
929898
ret = consensus_.getJson(full);
930899
}
931900
ret["validating"] = adaptor_.validating();
@@ -937,7 +906,7 @@ RCLConsensus::timerEntry(NetClock::time_point const& now)
937906
{
938907
try
939908
{
940-
std::lock_guard _{adaptor_.peekMutex()};
909+
std::lock_guard _{mutex_};
941910
consensus_.timerEntry(now);
942911
}
943912
catch (SHAMapMissingNode const& mn)
@@ -953,7 +922,7 @@ RCLConsensus::gotTxSet(NetClock::time_point const& now, RCLTxSet const& txSet)
953922
{
954923
try
955924
{
956-
std::lock_guard _{adaptor_.peekMutex()};
925+
std::lock_guard _{mutex_};
957926
consensus_.gotTxSet(now, txSet);
958927
}
959928
catch (SHAMapMissingNode const& mn)
@@ -971,7 +940,7 @@ RCLConsensus::simulate(
971940
NetClock::time_point const& now,
972941
std::optional<std::chrono::milliseconds> consensusDelay)
973942
{
974-
std::lock_guard _{adaptor_.peekMutex()};
943+
std::lock_guard _{mutex_};
975944
consensus_.simulate(now, consensusDelay);
976945
}
977946

@@ -980,7 +949,7 @@ RCLConsensus::peerProposal(
980949
NetClock::time_point const& now,
981950
RCLCxPeerPos const& newProposal)
982951
{
983-
std::lock_guard _{adaptor_.peekMutex()};
952+
std::lock_guard _{mutex_};
984953
return consensus_.peerProposal(now, newProposal);
985954
}
986955

@@ -1053,12 +1022,6 @@ RCLConsensus::Adaptor::getQuorumKeys() const
10531022
return app_.validators().getQuorumKeys();
10541023
}
10551024

1056-
std::size_t
1057-
RCLConsensus::Adaptor::quorum() const
1058-
{
1059-
return app_.validators().quorum();
1060-
}
1061-
10621025
std::size_t
10631026
RCLConsensus::Adaptor::laggards(
10641027
Ledger_t::Seq const seq,
@@ -1088,13 +1051,12 @@ RCLConsensus::startRound(
10881051
hash_set<NodeID> const& nowUntrusted,
10891052
hash_set<NodeID> const& nowTrusted)
10901053
{
1091-
std::lock_guard _{adaptor_.peekMutex()};
1054+
std::lock_guard _{mutex_};
10921055
consensus_.startRound(
10931056
now,
10941057
prevLgrId,
10951058
prevLgr,
10961059
nowUntrusted,
10971060
adaptor_.preStartRound(prevLgr, nowTrusted));
10981061
}
1099-
11001062
} // namespace ripple

0 commit comments

Comments
 (0)