@@ -55,7 +55,7 @@ RCLConsensus::RCLConsensus(
55
55
LedgerMaster& ledgerMaster,
56
56
LocalTxs& localTxs,
57
57
InboundTransactions& inboundTransactions,
58
- Consensus<Adaptor>::clock_type& clock,
58
+ Consensus<Adaptor>::clock_type const & clock,
59
59
ValidatorKeys const & validatorKeys,
60
60
beast::Journal journal)
61
61
: adaptor_(
@@ -171,9 +171,6 @@ RCLConsensus::Adaptor::share(RCLCxPeerPos const& peerPos)
171
171
auto const sig = peerPos.signature ();
172
172
prop.set_signature (sig.data (), sig.size ());
173
173
174
- if (proposal.ledgerSeq ().has_value ())
175
- prop.set_ledgerseq (*proposal.ledgerSeq ());
176
-
177
174
app_.overlay ().relay (prop, peerPos.suppressionID (), peerPos.publicKey ());
178
175
}
179
176
@@ -183,7 +180,7 @@ RCLConsensus::Adaptor::share(RCLCxTx const& tx)
183
180
// If we didn't relay this transaction recently, relay it to all peers
184
181
if (app_.getHashRouter ().shouldRelay (tx.id ()))
185
182
{
186
- JLOG (j_.trace ()) << " Relaying disputed tx " << tx.id ();
183
+ JLOG (j_.debug ()) << " Relaying disputed tx " << tx.id ();
187
184
auto const slice = tx.tx_ ->slice ();
188
185
protocol::TMTransaction msg;
189
186
msg.set_rawtransaction (slice.data (), slice.size ());
@@ -195,13 +192,13 @@ RCLConsensus::Adaptor::share(RCLCxTx const& tx)
195
192
}
196
193
else
197
194
{
198
- JLOG (j_.trace ()) << " Not relaying disputed tx " << tx.id ();
195
+ JLOG (j_.debug ()) << " Not relaying disputed tx " << tx.id ();
199
196
}
200
197
}
201
198
void
202
199
RCLConsensus::Adaptor::propose (RCLCxPeerPos::Proposal const & proposal)
203
200
{
204
- JLOG (j_.debug ()) << (proposal.isBowOut () ? " We bow out: " : " We propose: " )
201
+ JLOG (j_.trace ()) << (proposal.isBowOut () ? " We bow out: " : " We propose: " )
205
202
<< ripple::to_string (proposal.prevLedger ()) << " -> "
206
203
<< ripple::to_string (proposal.position ());
207
204
@@ -215,7 +212,6 @@ RCLConsensus::Adaptor::propose(RCLCxPeerPos::Proposal const& proposal)
215
212
prop.set_closetime (proposal.closeTime ().time_since_epoch ().count ());
216
213
prop.set_nodepubkey (
217
214
validatorKeys_.publicKey .data (), validatorKeys_.publicKey .size ());
218
- prop.set_ledgerseq (*proposal.ledgerSeq ());
219
215
220
216
auto sig = signDigest (
221
217
validatorKeys_.publicKey ,
301
297
RCLConsensus::Adaptor::onClose (
302
298
RCLCxLedger const & ledger,
303
299
NetClock::time_point const & closeTime,
304
- ConsensusMode mode,
305
- clock_type& clock) -> Result
300
+ ConsensusMode mode) -> Result
306
301
{
307
302
const bool wrongLCL = mode == ConsensusMode::wrongLedger;
308
303
const bool proposing = mode == ConsensusMode::proposing;
@@ -384,6 +379,7 @@ RCLConsensus::Adaptor::onClose(
384
379
385
380
// Needed because of the move below.
386
381
auto const setHash = initialSet->getHash ().as_uint256 ();
382
+
387
383
return Result{
388
384
std::move (initialSet),
389
385
RCLCxPeerPos::Proposal{
@@ -392,9 +388,7 @@ RCLConsensus::Adaptor::onClose(
392
388
setHash,
393
389
closeTime,
394
390
app_.timeKeeper ().closeTime (),
395
- validatorKeys_.nodeID ,
396
- initialLedger->info ().seq ,
397
- clock }};
391
+ validatorKeys_.nodeID }};
398
392
}
399
393
400
394
void
@@ -406,43 +400,50 @@ RCLConsensus::Adaptor::onForceAccept(
406
400
ConsensusMode const & mode,
407
401
Json::Value&& consensusJson)
408
402
{
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));
412
410
}
413
411
414
412
void
415
413
RCLConsensus::Adaptor::onAccept (
416
414
Result const & result,
415
+ RCLCxLedger const & prevLedger,
416
+ NetClock::duration const & closeResolution,
417
417
ConsensusCloseTimes const & rawCloseTimes,
418
418
ConsensusMode const & mode,
419
- Json::Value&& consensusJson,
420
- std::pair<CanonicalTxSet_t, Ledger_t>&& tb)
419
+ Json::Value&& consensusJson)
421
420
{
422
421
app_.getJobQueue ().addJob (
423
422
jtACCEPT,
424
423
" acceptLedger" ,
425
- [=,
426
- this ,
427
- cj = std::move (consensusJson),
428
- txsBuilt = std::move (tb)]() mutable {
424
+ [=, this , cj = std::move (consensusJson)]() mutable {
429
425
// Note that no lock is held or acquired during this job.
430
426
// This is because generic Consensus guarantees that once a ledger
431
427
// is accepted, the consensus results and capture by reference state
432
428
// will not change until startRound is called (which happens via
433
429
// 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));
435
437
this ->app_ .getOPs ().endConsensus ();
436
438
});
437
439
}
438
440
439
- std::pair<
440
- RCLConsensus::Adaptor::CanonicalTxSet_t,
441
- RCLConsensus::Adaptor::Ledger_t>
442
- RCLConsensus::Adaptor::buildAndValidate (
441
+ void
442
+ RCLConsensus::Adaptor::doAccept (
443
443
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,
446
447
ConsensusMode const & mode,
447
448
Json::Value&& consensusJson)
448
449
{
@@ -496,12 +497,12 @@ RCLConsensus::Adaptor::buildAndValidate(
496
497
{
497
498
retriableTxs.insert (
498
499
std::make_shared<STTx const >(SerialIter{item.slice ()}));
499
- JLOG (j_.trace ()) << " Tx: " << item.key ();
500
+ JLOG (j_.debug ()) << " Tx: " << item.key ();
500
501
}
501
502
catch (std::exception const & ex)
502
503
{
503
504
failed.insert (item.key ());
504
- JLOG (j_.trace ())
505
+ JLOG (j_.warn ())
505
506
<< " Tx: " << item.key () << " throws: " << ex.what ();
506
507
}
507
508
}
@@ -578,19 +579,6 @@ RCLConsensus::Adaptor::buildAndValidate(
578
579
ledgerMaster_.consensusBuilt (
579
580
built.ledger_ , result.txns .id (), std::move (consensusJson));
580
581
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
-
594
582
// -------------------------------------------------------------------------
595
583
{
596
584
// Apply disputed transactions that didn't get in
@@ -613,7 +601,7 @@ RCLConsensus::Adaptor::prepareOpenLedger(
613
601
// we voted NO
614
602
try
615
603
{
616
- JLOG (j_.trace ())
604
+ JLOG (j_.debug ())
617
605
<< " Test applying disputed transaction that did"
618
606
<< " not get in " << dispute.tx ().id ();
619
607
@@ -631,7 +619,7 @@ RCLConsensus::Adaptor::prepareOpenLedger(
631
619
}
632
620
catch (std::exception const & ex)
633
621
{
634
- JLOG (j_.trace ()) << " Failed to apply transaction we voted "
622
+ JLOG (j_.debug ()) << " Failed to apply transaction we voted "
635
623
" NO on. Exception: "
636
624
<< ex.what ();
637
625
}
@@ -681,7 +669,6 @@ RCLConsensus::Adaptor::prepareOpenLedger(
681
669
// we entered the round with the network,
682
670
// see how close our close time is to other node's
683
671
// close time reports, and update our clock.
684
- bool const consensusFail = result.state == ConsensusState::MovedOn;
685
672
if ((mode == ConsensusMode::proposing ||
686
673
mode == ConsensusMode::observing) &&
687
674
!consensusFail)
@@ -902,30 +889,12 @@ RCLConsensus::Adaptor::onModeChange(ConsensusMode before, ConsensusMode after)
902
889
mode_ = after;
903
890
}
904
891
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
-
923
892
Json::Value
924
893
RCLConsensus::getJson (bool full) const
925
894
{
926
895
Json::Value ret;
927
896
{
928
- std::lock_guard _{adaptor_. peekMutex () };
897
+ std::lock_guard _{mutex_ };
929
898
ret = consensus_.getJson (full);
930
899
}
931
900
ret[" validating" ] = adaptor_.validating ();
@@ -937,7 +906,7 @@ RCLConsensus::timerEntry(NetClock::time_point const& now)
937
906
{
938
907
try
939
908
{
940
- std::lock_guard _{adaptor_. peekMutex () };
909
+ std::lock_guard _{mutex_ };
941
910
consensus_.timerEntry (now);
942
911
}
943
912
catch (SHAMapMissingNode const & mn)
@@ -953,7 +922,7 @@ RCLConsensus::gotTxSet(NetClock::time_point const& now, RCLTxSet const& txSet)
953
922
{
954
923
try
955
924
{
956
- std::lock_guard _{adaptor_. peekMutex () };
925
+ std::lock_guard _{mutex_ };
957
926
consensus_.gotTxSet (now, txSet);
958
927
}
959
928
catch (SHAMapMissingNode const & mn)
@@ -971,7 +940,7 @@ RCLConsensus::simulate(
971
940
NetClock::time_point const & now,
972
941
std::optional<std::chrono::milliseconds> consensusDelay)
973
942
{
974
- std::lock_guard _{adaptor_. peekMutex () };
943
+ std::lock_guard _{mutex_ };
975
944
consensus_.simulate (now, consensusDelay);
976
945
}
977
946
@@ -980,7 +949,7 @@ RCLConsensus::peerProposal(
980
949
NetClock::time_point const & now,
981
950
RCLCxPeerPos const & newProposal)
982
951
{
983
- std::lock_guard _{adaptor_. peekMutex () };
952
+ std::lock_guard _{mutex_ };
984
953
return consensus_.peerProposal (now, newProposal);
985
954
}
986
955
@@ -1053,12 +1022,6 @@ RCLConsensus::Adaptor::getQuorumKeys() const
1053
1022
return app_.validators ().getQuorumKeys ();
1054
1023
}
1055
1024
1056
- std::size_t
1057
- RCLConsensus::Adaptor::quorum () const
1058
- {
1059
- return app_.validators ().quorum ();
1060
- }
1061
-
1062
1025
std::size_t
1063
1026
RCLConsensus::Adaptor::laggards (
1064
1027
Ledger_t::Seq const seq,
@@ -1088,13 +1051,12 @@ RCLConsensus::startRound(
1088
1051
hash_set<NodeID> const & nowUntrusted,
1089
1052
hash_set<NodeID> const & nowTrusted)
1090
1053
{
1091
- std::lock_guard _{adaptor_. peekMutex () };
1054
+ std::lock_guard _{mutex_ };
1092
1055
consensus_.startRound (
1093
1056
now,
1094
1057
prevLgrId,
1095
1058
prevLgr,
1096
1059
nowUntrusted,
1097
1060
adaptor_.preStartRound (prevLgr, nowTrusted));
1098
1061
}
1099
-
1100
1062
} // namespace ripple
0 commit comments