rippled
Loading...
Searching...
No Matches
Application.cpp
1#include <xrpld/app/consensus/RCLValidations.h>
2#include <xrpld/app/ledger/InboundLedgers.h>
3#include <xrpld/app/ledger/InboundTransactions.h>
4#include <xrpld/app/ledger/LedgerCleaner.h>
5#include <xrpld/app/ledger/LedgerMaster.h>
6#include <xrpld/app/ledger/LedgerReplayer.h>
7#include <xrpld/app/ledger/LedgerToJson.h>
8#include <xrpld/app/ledger/OpenLedger.h>
9#include <xrpld/app/ledger/OrderBookDB.h>
10#include <xrpld/app/ledger/PendingSaves.h>
11#include <xrpld/app/ledger/TransactionMaster.h>
12#include <xrpld/app/main/Application.h>
13#include <xrpld/app/main/BasicApp.h>
14#include <xrpld/app/main/DBInit.h>
15#include <xrpld/app/main/GRPCServer.h>
16#include <xrpld/app/main/LoadManager.h>
17#include <xrpld/app/main/NodeIdentity.h>
18#include <xrpld/app/main/NodeStoreScheduler.h>
19#include <xrpld/app/misc/AmendmentTable.h>
20#include <xrpld/app/misc/HashRouter.h>
21#include <xrpld/app/misc/LoadFeeTrack.h>
22#include <xrpld/app/misc/NetworkOPs.h>
23#include <xrpld/app/misc/SHAMapStore.h>
24#include <xrpld/app/misc/TxQ.h>
25#include <xrpld/app/misc/ValidatorKeys.h>
26#include <xrpld/app/misc/ValidatorSite.h>
27#include <xrpld/app/paths/PathRequests.h>
28#include <xrpld/app/rdb/RelationalDatabase.h>
29#include <xrpld/app/rdb/Wallet.h>
30#include <xrpld/app/tx/apply.h>
31#include <xrpld/core/DatabaseCon.h>
32#include <xrpld/overlay/Cluster.h>
33#include <xrpld/overlay/PeerReservationTable.h>
34#include <xrpld/overlay/PeerSet.h>
35#include <xrpld/overlay/make_Overlay.h>
36#include <xrpld/perflog/PerfLog.h>
37#include <xrpld/shamap/NodeFamily.h>
38
39#include <xrpl/basics/ByteUtilities.h>
40#include <xrpl/basics/ResolverAsio.h>
41#include <xrpl/basics/random.h>
42#include <xrpl/beast/asio/io_latency_probe.h>
43#include <xrpl/beast/core/LexicalCast.h>
44#include <xrpl/crypto/csprng.h>
45#include <xrpl/json/json_reader.h>
46#include <xrpl/nodestore/DummyScheduler.h>
47#include <xrpl/protocol/ApiVersion.h>
48#include <xrpl/protocol/BuildInfo.h>
49#include <xrpl/protocol/Feature.h>
50#include <xrpl/protocol/Protocol.h>
51#include <xrpl/protocol/STParsedJSON.h>
52#include <xrpl/resource/Fees.h>
53
54#include <boost/algorithm/string/predicate.hpp>
55#include <boost/asio/steady_timer.hpp>
56#include <boost/system/error_code.hpp>
57
58#include <date/date.h>
59
60#include <chrono>
61#include <condition_variable>
62#include <cstring>
63#include <fstream>
64#include <limits>
65#include <mutex>
66#include <optional>
67#include <utility>
68
69namespace ripple {
70
71static void
72fixConfigPorts(Config& config, Endpoints const& endpoints);
73
74// VFALCO TODO Move the function definitions into the class declaration
75class ApplicationImp : public Application, public BasicApp
76{
77private:
79 {
80 private:
85
86 public:
91 boost::asio::io_context& ios)
92 : m_event(ev)
94 , m_probe(interval, ios)
95 , lastSample_{}
96 {
97 }
98
99 void
101 {
102 m_probe.sample(std::ref(*this));
103 }
104
105 template <class Duration>
106 void
107 operator()(Duration const& elapsed)
108 {
109 using namespace std::chrono;
110 auto const lastSample = ceil<milliseconds>(elapsed);
111
112 lastSample_ = lastSample;
113
114 if (lastSample >= 10ms)
115 m_event.notify(lastSample);
116 if (lastSample >= 500ms)
117 {
118 JLOG(m_journal.warn())
119 << "io_context latency = " << lastSample.count();
120 }
121 }
122
124 get() const
125 {
126 return lastSample_.load();
127 }
128
129 void
131 {
132 m_probe.cancel();
133 }
134
135 void
137 {
139 }
140 };
141
142public:
146
148
152
153 // Required by the SHAMapStore
155
162
167
169
172 // VFALCO TODO Make OrderBookDB abstract
196 boost::asio::steady_timer sweepTimer_;
197 boost::asio::steady_timer entropyTimer_;
198
203
204 boost::asio::signal_set m_signals;
205
206 // Once we get C++20, we could use `std::atomic_flag` for `isTimeToStop`
207 // and eliminate the need for the condition variable and the mutex.
211
213
215
217
219
220 //--------------------------------------------------------------------------
221
222 static std::size_t
224 {
225#if XRPL_SINGLE_IO_SERVICE_THREAD
226 return 1;
227#else
228
229 if (config.IO_WORKERS > 0)
230 return config.IO_WORKERS;
231
232 auto const cores = std::thread::hardware_concurrency();
233
234 // Use a single thread when running on under-provisioned systems
235 // or if we are configured to use minimal resources.
236 if ((cores == 1) || ((config.NODE_SIZE == 0) && (cores == 2)))
237 return 1;
238
239 // Otherwise, prefer six threads.
240 return 6;
241#endif
242 }
243
244 //--------------------------------------------------------------------------
245
251 , config_(std::move(config))
252 , logs_(std::move(logs))
253 , timeKeeper_(std::move(timeKeeper))
255 1 +
256 rand_int(
257 crypto_prng(),
258 std::numeric_limits<std::uint64_t>::max() - 1))
259 , m_journal(logs_->journal("Application"))
260
261 // PerfLog must be started before any other threads are launched.
262 , perfLog_(perf::make_PerfLog(
263 perf::setup_PerfLog(
264 config_->section("perf"),
265 config_->CONFIG_DIR),
266 *this,
267 logs_->journal("PerfLog"),
268 [this] { signalStop("PerfLog"); }))
269
270 , m_txMaster(*this)
271
273 config_->section(SECTION_INSIGHT),
274 logs_->journal("Collector")))
275
279 return 1;
280
281 if (config->WORKERS)
282 return config->WORKERS;
283
284 auto count =
285 static_cast<int>(std::thread::hardware_concurrency());
286
287 // Be more aggressive about the number of threads to use
288 // for the job queue if the server is configured as
289 // "large" or "huge" if there are enough cores.
290 if (config->NODE_SIZE >= 4 && count >= 16)
291 count = 6 + std::min(count, 8);
292 else if (config->NODE_SIZE >= 3 && count >= 8)
293 count = 4 + std::min(count, 6);
294 else
295 count = 2 + std::min(count, 4);
296
297 return count;
298 }(config_),
299 m_collectorManager->group("jobq"),
300 logs_->journal("JobQueue"),
301 *logs_,
302 *perfLog_))
303
305
307 *this,
309 logs_->journal("SHAMapStore")))
310
312 "NodeCache",
313 16384,
315 stopwatch(),
316 logs_->journal("TaggedCache"))
317
318 , cachedSLEs_(
319 "Cached SLEs",
320 0,
322 stopwatch(),
323 logs_->journal("CachedSLEs"))
324
326
328 m_collectorManager->collector(),
329 logs_->journal("Resource")))
330
331 , m_nodeStore(m_shaMapStore->makeNodeStore(
332 config_->PREFETCH_WORKERS > 0 ? config_->PREFETCH_WORKERS : 4))
333
335
336 , m_orderBookDB(*this)
337
338 , m_pathRequests(std::make_unique<PathRequests>(
339 *this,
340 logs_->journal("PathRequest"),
341 m_collectorManager->collector()))
342
343 , m_ledgerMaster(std::make_unique<LedgerMaster>(
344 *this,
345 stopwatch(),
346 m_collectorManager->collector(),
347 logs_->journal("LedgerMaster")))
348
350 make_LedgerCleaner(*this, logs_->journal("LedgerCleaner")))
351
352 // VFALCO NOTE must come before NetworkOPs to prevent a crash due
353 // to dependencies in the destructor.
354 //
356 *this,
357 stopwatch(),
358 m_collectorManager->collector()))
359
361 *this,
362 m_collectorManager->collector(),
363 [this](std::shared_ptr<SHAMap> const& set, bool fromAcquire) {
364 gotTXSet(set, fromAcquire);
365 }))
366
368 *this,
370 make_PeerSetBuilder(*this)))
371
373 "AcceptedLedger",
374 4,
376 stopwatch(),
377 logs_->journal("TaggedCache"))
378
380 *this,
381 stopwatch(),
382 config_->standalone(),
383 config_->NETWORK_QUORUM,
384 config_->START_VALID,
385 *m_jobQueue,
389 logs_->journal("NetworkOPs"),
390 m_collectorManager->collector()))
391
392 , cluster_(std::make_unique<Cluster>(logs_->journal("Overlay")))
393
395 logs_->journal("PeerReservationTable")))
396
398 std::make_unique<ManifestCache>(logs_->journal("ManifestCache")))
399
401 std::make_unique<ManifestCache>(logs_->journal("ManifestCache")))
402
407 config_->legacy("database_path"),
408 logs_->journal("ValidatorList"),
409 config_->VALIDATION_QUORUM))
410
412
414 *this,
416 *m_jobQueue,
420
421 , mFeeTrack(
422 std::make_unique<LoadFeeTrack>(logs_->journal("LoadManager")))
423
426 stopwatch()))
427
428 , mValidations(
429 ValidationParms(),
430 stopwatch(),
431 *this,
432 logs_->journal("Validations"))
433
434 , m_loadManager(make_LoadManager(*this, logs_->journal("LoadManager")))
435
436 , txQ_(
437 std::make_unique<TxQ>(setup_TxQ(*config_), logs_->journal("TxQ")))
438
440
442
444
445 , checkSigs_(true)
446
447 , m_resolver(
448 ResolverAsio::New(get_io_context(), logs_->journal("Resolver")))
449
451 m_collectorManager->collector()->make_event("ios_latency"),
452 logs_->journal("Application"),
456 {
458
459 add(m_resourceManager.get());
460
461 //
462 // VFALCO - READ THIS!
463 //
464 // Do not start threads, open sockets, or do any sort of "real work"
465 // inside the constructor. Put it in start instead. Or if you must,
466 // put it in setup (but everything in setup should be moved to start
467 // anyway.
468 //
469 // The reason is that the unit tests require an Application object to
470 // be created. But we don't actually start all the threads, sockets,
471 // and services when running the unit tests. Therefore anything which
472 // needs to be stopped will not get stopped correctly if it is
473 // started in this constructor.
474 //
475
476 add(ledgerCleaner_.get());
477 }
478
479 //--------------------------------------------------------------------------
480
481 bool
482 setup(boost::program_options::variables_map const& cmdline) override;
483 void
484 start(bool withTimers) override;
485 void
486 run() override;
487 void
488 signalStop(std::string msg) override;
489 bool
490 checkSigs() const override;
491 void
492 checkSigs(bool) override;
493 bool
494 isStopping() const override;
495 int
496 fdRequired() const override;
497
498 //--------------------------------------------------------------------------
499
501 instanceID() const override
502 {
503 return instanceCookie_;
504 }
505
506 Logs&
507 logs() override
508 {
509 return *logs_;
510 }
511
512 Config&
513 config() override
514 {
515 return *config_;
516 }
517
520 {
521 return *m_collectorManager;
522 }
523
524 Family&
525 getNodeFamily() override
526 {
527 return nodeFamily_;
528 }
529
531 timeKeeper() override
532 {
533 return *timeKeeper_;
534 }
535
536 JobQueue&
537 getJobQueue() override
538 {
539 return *m_jobQueue;
540 }
541
543 nodeIdentity() override
544 {
545 if (nodeIdentity_)
546 return *nodeIdentity_;
547
549 "Accessing Application::nodeIdentity() before it is initialized.");
550 }
551
553 getValidationPublicKey() const override
554 {
555 if (!validatorKeys_.keys)
556 return {};
557
558 return validatorKeys_.keys->publicKey;
559 }
560
562 getOPs() override
563 {
564 return *m_networkOPs;
565 }
566
567 virtual ServerHandler&
569 {
570 XRPL_ASSERT(
572 "ripple::ApplicationImp::getServerHandler : non-null server "
573 "handle");
574 return *serverHandler_;
575 }
576
577 boost::asio::io_context&
578 getIOContext() override
579 {
580 return get_io_context();
581 }
582
584 getIOLatency() override
585 {
586 return m_io_latency_sampler.get();
587 }
588
591 {
592 return *m_ledgerMaster;
593 }
594
597 {
598 return *ledgerCleaner_;
599 }
600
603 {
604 return *m_ledgerReplayer;
605 }
606
609 {
610 return *m_inboundLedgers;
611 }
612
615 {
616 return *m_inboundTransactions;
617 }
618
621 {
623 }
624
625 void
626 gotTXSet(std::shared_ptr<SHAMap> const& set, bool fromAcquire)
627 {
628 if (set)
629 m_networkOPs->mapComplete(set, fromAcquire);
630 }
631
634 {
635 return m_txMaster;
636 }
637
639 getPerfLog() override
640 {
641 return *perfLog_;
642 }
643
644 NodeCache&
646 {
647 return m_tempNodeCache;
648 }
649
651 getNodeStore() override
652 {
653 return *m_nodeStore;
654 }
655
657 getMasterMutex() override
658 {
659 return m_masterMutex;
660 }
661
663 getLoadManager() override
664 {
665 return *m_loadManager;
666 }
667
670 {
671 return *m_resourceManager;
672 }
673
675 getOrderBookDB() override
676 {
677 return m_orderBookDB;
678 }
679
682 {
683 return *m_pathRequests;
684 }
685
687 cachedSLEs() override
688 {
689 return cachedSLEs_;
690 }
691
694 {
695 return *m_amendmentTable;
696 }
697
699 getFeeTrack() override
700 {
701 return *mFeeTrack;
702 }
703
705 getHashRouter() override
706 {
707 return *hashRouter_;
708 }
709
711 getValidations() override
712 {
713 return mValidations;
714 }
715
717 validators() override
718 {
719 return *validators_;
720 }
721
723 validatorSites() override
724 {
725 return *validatorSites_;
726 }
727
730 {
731 return *validatorManifests_;
732 }
733
736 {
737 return *publisherManifests_;
738 }
739
740 Cluster&
741 cluster() override
742 {
743 return *cluster_;
744 }
745
748 {
749 return *peerReservations_;
750 }
751
753 getSHAMapStore() override
754 {
755 return *m_shaMapStore;
756 }
757
759 pendingSaves() override
760 {
761 return pendingSaves_;
762 }
763
765 openLedger() override
766 {
767 return *openLedger_;
768 }
769
770 OpenLedger const&
771 openLedger() const override
772 {
773 return *openLedger_;
774 }
775
776 Overlay&
777 overlay() override
778 {
779 XRPL_ASSERT(
780 overlay_, "ripple::ApplicationImp::overlay : non-null overlay");
781 return *overlay_;
782 }
783
784 TxQ&
785 getTxQ() override
786 {
787 XRPL_ASSERT(
788 txQ_,
789 "ripple::ApplicationImp::getTxQ : non-null transaction queue");
790 return *txQ_;
791 }
792
795 {
796 XRPL_ASSERT(
798 "ripple::ApplicationImp::getRelationalDatabase : non-null "
799 "relational database");
800 return *mRelationalDatabase;
801 }
802
804 getWalletDB() override
805 {
806 XRPL_ASSERT(
807 mWalletDB,
808 "ripple::ApplicationImp::getWalletDB : non-null wallet database");
809 return *mWalletDB;
810 }
811
812 bool
813 serverOkay(std::string& reason) override;
814
816 journal(std::string const& name) override;
817
818 //--------------------------------------------------------------------------
819
820 bool
822 {
823 XRPL_ASSERT(
824 mWalletDB.get() == nullptr,
825 "ripple::ApplicationImp::initRelationalDatabase : null wallet "
826 "database");
827
828 try
829 {
832
833 // wallet database
835 setup.useGlobalPragma = false;
836
838 }
839 catch (std::exception const& e)
840 {
841 JLOG(m_journal.fatal())
842 << "Failed to initialize SQL databases: " << e.what();
843 return false;
844 }
845
846 return true;
847 }
848
849 bool
851 {
852 if (config_->doImport)
853 {
854 auto j = logs_->journal("NodeObject");
855 NodeStore::DummyScheduler dummyScheduler;
858 megabytes(config_->getValueFor(
860 dummyScheduler,
861 0,
863 j);
864
865 JLOG(j.warn()) << "Starting node import from '" << source->getName()
866 << "' to '" << m_nodeStore->getName() << "'.";
867
868 using namespace std::chrono;
869 auto const start = steady_clock::now();
870
871 m_nodeStore->importDatabase(*source);
872
873 auto const elapsed =
874 duration_cast<seconds>(steady_clock::now() - start);
875 JLOG(j.warn()) << "Node import from '" << source->getName()
876 << "' took " << elapsed.count() << " seconds.";
877 }
878
879 return true;
880 }
881
882 //--------------------------------------------------------------------------
883 //
884 // PropertyStream
885 //
886
887 void
889 {
890 }
891
892 //--------------------------------------------------------------------------
893
894 void
896 {
897 // Only start the timer if waitHandlerCounter_ is not yet joined.
898 if (auto optionalCountedHandler = waitHandlerCounter_.wrap(
899 [this](boost::system::error_code const& e) {
900 if (e.value() == boost::system::errc::success)
901 {
902 m_jobQueue->addJob(
903 jtSWEEP, "sweep", [this]() { doSweep(); });
904 }
905 // Recover as best we can if an unexpected error occurs.
906 if (e.value() != boost::system::errc::success &&
907 e.value() != boost::asio::error::operation_aborted)
908 {
909 // Try again later and hope for the best.
910 JLOG(m_journal.error())
911 << "Sweep timer got error '" << e.message()
912 << "'. Restarting timer.";
913 setSweepTimer();
914 }
915 }))
916 {
917 using namespace std::chrono;
918 sweepTimer_.expires_after(seconds{config_->SWEEP_INTERVAL.value_or(
919 config_->getValueFor(SizedItem::sweepInterval))});
920 sweepTimer_.async_wait(std::move(*optionalCountedHandler));
921 }
922 }
923
924 void
926 {
927 // Only start the timer if waitHandlerCounter_ is not yet joined.
928 if (auto optionalCountedHandler = waitHandlerCounter_.wrap(
929 [this](boost::system::error_code const& e) {
930 if (e.value() == boost::system::errc::success)
931 {
932 crypto_prng().mix_entropy();
933 setEntropyTimer();
934 }
935 // Recover as best we can if an unexpected error occurs.
936 if (e.value() != boost::system::errc::success &&
937 e.value() != boost::asio::error::operation_aborted)
938 {
939 // Try again later and hope for the best.
940 JLOG(m_journal.error())
941 << "Entropy timer got error '" << e.message()
942 << "'. Restarting timer.";
943 setEntropyTimer();
944 }
945 }))
946 {
947 using namespace std::chrono_literals;
948 entropyTimer_.expires_after(5min);
949 entropyTimer_.async_wait(std::move(*optionalCountedHandler));
950 }
951 }
952
953 void
955 {
956 if (!config_->standalone() &&
957 !getRelationalDatabase().transactionDbHasSpace(*config_))
958 {
959 signalStop("Out of transaction DB space");
960 }
961
962 // VFALCO NOTE Does the order of calls matter?
963 // VFALCO TODO fix the dependency inversion using an observer,
964 // have listeners register for "onSweep ()" notification.
965
966 {
967 std::shared_ptr<FullBelowCache const> const fullBelowCache =
968 nodeFamily_.getFullBelowCache();
969
970 std::shared_ptr<TreeNodeCache const> const treeNodeCache =
971 nodeFamily_.getTreeNodeCache();
972
973 std::size_t const oldFullBelowSize = fullBelowCache->size();
974 std::size_t const oldTreeNodeSize = treeNodeCache->size();
975
976 nodeFamily_.sweep();
977
978 JLOG(m_journal.debug())
979 << "NodeFamily::FullBelowCache sweep. Size before: "
980 << oldFullBelowSize
981 << "; size after: " << fullBelowCache->size();
982
983 JLOG(m_journal.debug())
984 << "NodeFamily::TreeNodeCache sweep. Size before: "
985 << oldTreeNodeSize << "; size after: " << treeNodeCache->size();
986 }
987 {
988 TaggedCache<uint256, Transaction> const& masterTxCache =
989 getMasterTransaction().getCache();
990
991 std::size_t const oldMasterTxSize = masterTxCache.size();
992
993 getMasterTransaction().sweep();
994
995 JLOG(m_journal.debug())
996 << "MasterTransaction sweep. Size before: " << oldMasterTxSize
997 << "; size after: " << masterTxCache.size();
998 }
999 {
1000 // Does not appear to have an associated cache.
1001 getNodeStore().sweep();
1002 }
1003 {
1004 std::size_t const oldLedgerMasterCacheSize =
1005 getLedgerMaster().getFetchPackCacheSize();
1006
1007 getLedgerMaster().sweep();
1008
1009 JLOG(m_journal.debug())
1010 << "LedgerMaster sweep. Size before: "
1011 << oldLedgerMasterCacheSize << "; size after: "
1012 << getLedgerMaster().getFetchPackCacheSize();
1013 }
1014 {
1015 // NodeCache == TaggedCache<SHAMapHash, Blob>
1016 std::size_t const oldTempNodeCacheSize = getTempNodeCache().size();
1017
1018 getTempNodeCache().sweep();
1019
1020 JLOG(m_journal.debug())
1021 << "TempNodeCache sweep. Size before: " << oldTempNodeCacheSize
1022 << "; size after: " << getTempNodeCache().size();
1023 }
1024 {
1025 std::size_t const oldCurrentCacheSize =
1026 getValidations().sizeOfCurrentCache();
1027 std::size_t const oldSizeSeqEnforcesSize =
1028 getValidations().sizeOfSeqEnforcersCache();
1029 std::size_t const oldByLedgerSize =
1030 getValidations().sizeOfByLedgerCache();
1031 std::size_t const oldBySequenceSize =
1032 getValidations().sizeOfBySequenceCache();
1033
1034 getValidations().expire(m_journal);
1035
1036 JLOG(m_journal.debug())
1037 << "Validations Current expire. Size before: "
1038 << oldCurrentCacheSize
1039 << "; size after: " << getValidations().sizeOfCurrentCache();
1040
1041 JLOG(m_journal.debug())
1042 << "Validations SeqEnforcer expire. Size before: "
1043 << oldSizeSeqEnforcesSize << "; size after: "
1044 << getValidations().sizeOfSeqEnforcersCache();
1045
1046 JLOG(m_journal.debug())
1047 << "Validations ByLedger expire. Size before: "
1048 << oldByLedgerSize
1049 << "; size after: " << getValidations().sizeOfByLedgerCache();
1050
1051 JLOG(m_journal.debug())
1052 << "Validations BySequence expire. Size before: "
1053 << oldBySequenceSize
1054 << "; size after: " << getValidations().sizeOfBySequenceCache();
1055 }
1056 {
1057 std::size_t const oldInboundLedgersSize =
1058 getInboundLedgers().cacheSize();
1059
1060 getInboundLedgers().sweep();
1061
1062 JLOG(m_journal.debug())
1063 << "InboundLedgers sweep. Size before: "
1064 << oldInboundLedgersSize
1065 << "; size after: " << getInboundLedgers().cacheSize();
1066 }
1067 {
1068 size_t const oldTasksSize = getLedgerReplayer().tasksSize();
1069 size_t const oldDeltasSize = getLedgerReplayer().deltasSize();
1070 size_t const oldSkipListsSize = getLedgerReplayer().skipListsSize();
1071
1072 getLedgerReplayer().sweep();
1073
1074 JLOG(m_journal.debug())
1075 << "LedgerReplayer tasks sweep. Size before: " << oldTasksSize
1076 << "; size after: " << getLedgerReplayer().tasksSize();
1077
1078 JLOG(m_journal.debug())
1079 << "LedgerReplayer deltas sweep. Size before: "
1080 << oldDeltasSize
1081 << "; size after: " << getLedgerReplayer().deltasSize();
1082
1083 JLOG(m_journal.debug())
1084 << "LedgerReplayer skipLists sweep. Size before: "
1085 << oldSkipListsSize
1086 << "; size after: " << getLedgerReplayer().skipListsSize();
1087 }
1088 {
1089 std::size_t const oldAcceptedLedgerSize =
1090 m_acceptedLedgerCache.size();
1091
1092 m_acceptedLedgerCache.sweep();
1093
1094 JLOG(m_journal.debug())
1095 << "AcceptedLedgerCache sweep. Size before: "
1096 << oldAcceptedLedgerSize
1097 << "; size after: " << m_acceptedLedgerCache.size();
1098 }
1099 {
1100 std::size_t const oldCachedSLEsSize = cachedSLEs_.size();
1101
1102 cachedSLEs_.sweep();
1103
1104 JLOG(m_journal.debug())
1105 << "CachedSLEs sweep. Size before: " << oldCachedSLEsSize
1106 << "; size after: " << cachedSLEs_.size();
1107 }
1108
1109 // Set timer to do another sweep later.
1110 setSweepTimer();
1111 }
1112
1115 {
1116 return maxDisallowedLedger_;
1117 }
1118
1119 virtual std::optional<uint256> const&
1120 trapTxID() const override
1121 {
1122 return trapTxID_;
1123 }
1124
1125private:
1126 // For a newly-started validator, this is the greatest persisted ledger
1127 // and new validations must be greater than this.
1128 std::atomic<LedgerIndex> maxDisallowedLedger_{0};
1129
1130 void
1131 startGenesisLedger();
1132
1134 getLastFullLedger();
1135
1137 loadLedgerFromFile(std::string const& ledgerID);
1138
1139 bool
1140 loadOldLedger(
1141 std::string const& ledgerID,
1142 bool replay,
1143 bool isFilename,
1144 std::optional<uint256> trapTxID);
1145
1146 void
1147 setMaxDisallowedLedger();
1148};
1149
1150//------------------------------------------------------------------------------
1151
1152// TODO Break this up into smaller, more digestible initialization segments.
1153bool
1154ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
1155{
1156 // We want to intercept CTRL-C and the standard termination signal SIGTERM
1157 // and terminate the process. This handler will NEVER be invoked twice.
1158 //
1159 // Note that async_wait is "one-shot": for each call, the handler will be
1160 // invoked exactly once, either when one of the registered signals in the
1161 // signal set occurs or the signal set is cancelled. Subsequent signals are
1162 // effectively ignored (technically, they are queued up, waiting for a call
1163 // to async_wait).
1164 m_signals.add(SIGINT);
1165 m_signals.add(SIGTERM);
1166 m_signals.async_wait(
1167 [this](boost::system::error_code const& ec, int signum) {
1168 // Indicates the signal handler has been aborted; do nothing
1169 if (ec == boost::asio::error::operation_aborted)
1170 return;
1171
1172 JLOG(m_journal.info()) << "Received signal " << signum;
1173
1174 if (signum == SIGTERM || signum == SIGINT)
1175 signalStop("Signal: " + to_string(signum));
1176 });
1177
1178 auto debug_log = config_->getDebugLogFile();
1179
1180 if (!debug_log.empty())
1181 {
1182 // Let debug messages go to the file but only WARNING or higher to
1183 // regular output (unless verbose)
1184
1185 if (!logs_->open(debug_log))
1186 std::cerr << "Can't open log file " << debug_log << '\n';
1187
1188 using namespace beast::severities;
1189 if (logs_->threshold() > kDebug)
1190 logs_->threshold(kDebug);
1191 }
1192
1193 JLOG(m_journal.info()) << "Process starting: "
1194 << BuildInfo::getFullVersionString()
1195 << ", Instance Cookie: " << instanceCookie_;
1196
1197 if (numberOfThreads(*config_) < 2)
1198 {
1199 JLOG(m_journal.warn()) << "Limited to a single I/O service thread by "
1200 "system configuration.";
1201 }
1202
1203 // Optionally turn off logging to console.
1204 logs_->silent(config_->silent());
1205
1206 if (!initRelationalDatabase() || !initNodeStore())
1207 return false;
1208
1209 if (!peerReservations_->load(getWalletDB()))
1210 {
1211 JLOG(m_journal.fatal()) << "Cannot find peer reservations!";
1212 return false;
1213 }
1214
1215 if (validatorKeys_.keys)
1216 setMaxDisallowedLedger();
1217
1218 // Configure the amendments the server supports
1219 {
1220 auto const supported = []() {
1221 auto const& amendments = detail::supportedAmendments();
1223 supported.reserve(amendments.size());
1224 for (auto const& [a, vote] : amendments)
1225 {
1226 auto const f = ripple::getRegisteredFeature(a);
1227 XRPL_ASSERT(
1228 f, "ripple::ApplicationImp::setup : registered feature");
1229 if (f)
1230 supported.emplace_back(a, *f, vote);
1231 }
1232 return supported;
1233 }();
1234 Section const& downVoted = config_->section(SECTION_VETO_AMENDMENTS);
1235
1236 Section const& upVoted = config_->section(SECTION_AMENDMENTS);
1237
1238 m_amendmentTable = make_AmendmentTable(
1239 *this,
1240 config().AMENDMENT_MAJORITY_TIME,
1241 supported,
1242 upVoted,
1243 downVoted,
1244 logs_->journal("Amendments"));
1245 }
1246
1247 Pathfinder::initPathTable();
1248
1249 auto const startUp = config_->START_UP;
1250 JLOG(m_journal.debug()) << "startUp: " << startUp;
1251 if (startUp == Config::FRESH)
1252 {
1253 JLOG(m_journal.info()) << "Starting new Ledger";
1254
1255 startGenesisLedger();
1256 }
1257 else if (
1258 startUp == Config::LOAD || startUp == Config::LOAD_FILE ||
1259 startUp == Config::REPLAY)
1260 {
1261 JLOG(m_journal.info()) << "Loading specified Ledger";
1262
1263 if (!loadOldLedger(
1264 config_->START_LEDGER,
1265 startUp == Config::REPLAY,
1266 startUp == Config::LOAD_FILE,
1267 config_->TRAP_TX_HASH))
1268 {
1269 JLOG(m_journal.error())
1270 << "The specified ledger could not be loaded.";
1271 if (config_->FAST_LOAD)
1272 {
1273 // Fall back to syncing from the network, such as
1274 // when there's no existing data.
1275 startGenesisLedger();
1276 }
1277 else
1278 {
1279 return false;
1280 }
1281 }
1282 }
1283 else if (startUp == Config::NETWORK)
1284 {
1285 // This should probably become the default once we have a stable
1286 // network.
1287 if (!config_->standalone())
1288 m_networkOPs->setNeedNetworkLedger();
1289
1290 startGenesisLedger();
1291 }
1292 else
1293 {
1294 startGenesisLedger();
1295 }
1296
1297 if (auto const& forcedRange = config().FORCED_LEDGER_RANGE_PRESENT)
1298 {
1299 m_ledgerMaster->setLedgerRangePresent(
1300 forcedRange->first, forcedRange->second);
1301 }
1302
1303 m_orderBookDB.setup(getLedgerMaster().getCurrentLedger());
1304
1305 nodeIdentity_ = getNodeIdentity(*this, cmdline);
1306
1307 if (!cluster_->load(config().section(SECTION_CLUSTER_NODES)))
1308 {
1309 JLOG(m_journal.fatal()) << "Invalid entry in cluster configuration.";
1310 return false;
1311 }
1312
1313 {
1314 if (validatorKeys_.configInvalid())
1315 return false;
1316
1317 if (!validatorManifests_->load(
1318 getWalletDB(),
1319 "ValidatorManifests",
1320 validatorKeys_.manifest,
1321 config().section(SECTION_VALIDATOR_KEY_REVOCATION).values()))
1322 {
1323 JLOG(m_journal.fatal()) << "Invalid configured validator manifest.";
1324 return false;
1325 }
1326
1327 publisherManifests_->load(getWalletDB(), "PublisherManifests");
1328
1329 // It is possible to have a valid ValidatorKeys object without
1330 // setting the signingKey or masterKey. This occurs if the
1331 // configuration file does not have either
1332 // SECTION_VALIDATOR_TOKEN or SECTION_VALIDATION_SEED section.
1333
1334 // masterKey for the configuration-file specified validator keys
1335 std::optional<PublicKey> localSigningKey;
1336 if (validatorKeys_.keys)
1337 localSigningKey = validatorKeys_.keys->publicKey;
1338
1339 // Setup trusted validators
1340 if (!validators_->load(
1341 localSigningKey,
1342 config().section(SECTION_VALIDATORS).values(),
1343 config().section(SECTION_VALIDATOR_LIST_KEYS).values(),
1344 config().VALIDATOR_LIST_THRESHOLD))
1345 {
1346 JLOG(m_journal.fatal())
1347 << "Invalid entry in validator configuration.";
1348 return false;
1349 }
1350 }
1351
1352 if (!validatorSites_->load(
1353 config().section(SECTION_VALIDATOR_LIST_SITES).values()))
1354 {
1355 JLOG(m_journal.fatal())
1356 << "Invalid entry in [" << SECTION_VALIDATOR_LIST_SITES << "]";
1357 return false;
1358 }
1359
1360 // Tell the AmendmentTable who the trusted validators are.
1361 m_amendmentTable->trustChanged(validators_->getQuorumKeys().second);
1362
1363 //----------------------------------------------------------------------
1364 //
1365 // Server
1366 //
1367 //----------------------------------------------------------------------
1368
1369 // VFALCO NOTE Unfortunately, in stand-alone mode some code still
1370 // foolishly calls overlay(). When this is fixed we can
1371 // move the instantiation inside a conditional:
1372 //
1373 // if (!config_.standalone())
1374 overlay_ = make_Overlay(
1375 *this,
1376 setup_Overlay(*config_),
1377 *serverHandler_,
1378 *m_resourceManager,
1379 *m_resolver,
1380 get_io_context(),
1381 *config_,
1382 m_collectorManager->collector());
1383 add(*overlay_); // add to PropertyStream
1384
1385 // start first consensus round
1386 if (!m_networkOPs->beginConsensus(
1387 m_ledgerMaster->getClosedLedger()->info().hash, {}))
1388 {
1389 JLOG(m_journal.fatal()) << "Unable to start consensus";
1390 return false;
1391 }
1392
1393 {
1394 try
1395 {
1396 auto setup = setup_ServerHandler(
1397 *config_, beast::logstream{m_journal.error()});
1398 setup.makeContexts();
1399 serverHandler_->setup(setup, m_journal);
1400 fixConfigPorts(*config_, serverHandler_->endpoints());
1401 }
1402 catch (std::exception const& e)
1403 {
1404 if (auto stream = m_journal.fatal())
1405 {
1406 stream << "Unable to setup server handler";
1407 if (std::strlen(e.what()) > 0)
1408 stream << ": " << e.what();
1409 }
1410 return false;
1411 }
1412 }
1413
1414 // Begin connecting to network.
1415 if (!config_->standalone())
1416 {
1417 // Should this message be here, conceptually? In theory this sort
1418 // of message, if displayed, should be displayed from PeerFinder.
1419 if (config_->PEER_PRIVATE && config_->IPS_FIXED.empty())
1420 {
1421 JLOG(m_journal.warn())
1422 << "No outbound peer connections will be made";
1423 }
1424
1425 // VFALCO NOTE the state timer resets the deadlock detector.
1426 //
1427 m_networkOPs->setStateTimer();
1428 }
1429 else
1430 {
1431 JLOG(m_journal.warn()) << "Running in standalone mode";
1432
1433 m_networkOPs->setStandAlone();
1434 }
1435
1436 if (config_->canSign())
1437 {
1438 JLOG(m_journal.warn()) << "*** The server is configured to allow the "
1439 "'sign' and 'sign_for'";
1440 JLOG(m_journal.warn()) << "*** commands. These commands have security "
1441 "implications and have";
1442 JLOG(m_journal.warn()) << "*** been deprecated. They will be removed "
1443 "in a future release of";
1444 JLOG(m_journal.warn()) << "*** rippled.";
1445 JLOG(m_journal.warn()) << "*** If you do not use them to sign "
1446 "transactions please edit your";
1447 JLOG(m_journal.warn())
1448 << "*** configuration file and remove the [enable_signing] stanza.";
1449 JLOG(m_journal.warn()) << "*** If you do use them to sign transactions "
1450 "please migrate to a";
1451 JLOG(m_journal.warn())
1452 << "*** standalone signing solution as soon as possible.";
1453 }
1454
1455 //
1456 // Execute start up rpc commands.
1457 //
1458 for (auto cmd : config_->section(SECTION_RPC_STARTUP).lines())
1459 {
1460 Json::Reader jrReader;
1461 Json::Value jvCommand;
1462
1463 if (!jrReader.parse(cmd, jvCommand))
1464 {
1465 JLOG(m_journal.fatal()) << "Couldn't parse entry in ["
1466 << SECTION_RPC_STARTUP << "]: '" << cmd;
1467 }
1468
1469 if (!config_->quiet())
1470 {
1471 JLOG(m_journal.fatal())
1472 << "Startup RPC: " << jvCommand << std::endl;
1473 }
1474
1475 Resource::Charge loadType = Resource::feeReferenceRPC;
1477 RPC::JsonContext context{
1478 {journal("RPCHandler"),
1479 *this,
1480 loadType,
1481 getOPs(),
1482 getLedgerMaster(),
1483 c,
1484 Role::ADMIN,
1485 {},
1486 {},
1487 RPC::apiMaximumSupportedVersion},
1488 jvCommand};
1489
1490 Json::Value jvResult;
1491 RPC::doCommand(context, jvResult);
1492
1493 if (!config_->quiet())
1494 {
1495 JLOG(m_journal.fatal()) << "Result: " << jvResult << std::endl;
1496 }
1497 }
1498
1499 validatorSites_->start();
1500
1501 return true;
1502}
1503
1504void
1505ApplicationImp::start(bool withTimers)
1506{
1507 JLOG(m_journal.info()) << "Application starting. Version is "
1508 << BuildInfo::getVersionString();
1509
1510 if (withTimers)
1511 {
1512 setSweepTimer();
1513 setEntropyTimer();
1514 }
1515
1516 m_io_latency_sampler.start();
1517 m_resolver->start();
1518 m_loadManager->start();
1519 m_shaMapStore->start();
1520 if (overlay_)
1521 overlay_->start();
1522
1523 if (grpcServer_->start())
1525 *config_, {{SECTION_PORT_GRPC, grpcServer_->getEndpoint()}});
1526
1527 ledgerCleaner_->start();
1528 perfLog_->start();
1529}
1530
1531void
1532ApplicationImp::run()
1533{
1534 if (!config_->standalone())
1535 {
1536 // VFALCO NOTE This seems unnecessary. If we properly refactor the load
1537 // manager then the stall detector can just always be
1538 // "armed"
1539 //
1540 getLoadManager().activateStallDetector();
1541 }
1542
1543 {
1544 std::unique_lock<std::mutex> lk{stoppingMutex_};
1545 stoppingCondition_.wait(lk, [this] { return isTimeToStop.load(); });
1546 }
1547
1548 JLOG(m_journal.debug()) << "Application stopping";
1549
1550 m_io_latency_sampler.cancel_async();
1551
1552 // VFALCO Enormous hack, we have to force the probe to cancel
1553 // before we stop the io_context queue or else it never
1554 // unblocks in its destructor. The fix is to make all
1555 // io_objects gracefully handle exit so that we can
1556 // naturally return from io_context::run() instead of
1557 // forcing a call to io_context::stop()
1558 m_io_latency_sampler.cancel();
1559
1560 m_resolver->stop_async();
1561
1562 // NIKB This is a hack - we need to wait for the resolver to
1563 // stop. before we stop the io_server_queue or weird
1564 // things will happen.
1565 m_resolver->stop();
1566
1567 {
1568 try
1569 {
1570 sweepTimer_.cancel();
1571 }
1572 catch (boost::system::system_error const& e)
1573 {
1574 JLOG(m_journal.error())
1575 << "Application: sweepTimer cancel error: " << e.what();
1576 }
1577
1578 try
1579 {
1580 entropyTimer_.cancel();
1581 }
1582 catch (boost::system::system_error const& e)
1583 {
1584 JLOG(m_journal.error())
1585 << "Application: entropyTimer cancel error: " << e.what();
1586 }
1587 }
1588
1589 // Make sure that any waitHandlers pending in our timers are done
1590 // before we declare ourselves stopped.
1591 using namespace std::chrono_literals;
1592
1593 waitHandlerCounter_.join("Application", 1s, m_journal);
1594
1595 mValidations.flush();
1596
1597 validatorSites_->stop();
1598
1599 // TODO Store manifests in manifests.sqlite instead of wallet.db
1600 validatorManifests_->save(
1601 getWalletDB(), "ValidatorManifests", [this](PublicKey const& pubKey) {
1602 return validators().listed(pubKey);
1603 });
1604
1605 publisherManifests_->save(
1606 getWalletDB(), "PublisherManifests", [this](PublicKey const& pubKey) {
1607 return validators().trustedPublisher(pubKey);
1608 });
1609
1610 // The order of these stop calls is delicate.
1611 // Re-ordering them risks undefined behavior.
1612 m_loadManager->stop();
1613 m_shaMapStore->stop();
1614 m_jobQueue->stop();
1615 if (overlay_)
1616 overlay_->stop();
1617 grpcServer_->stop();
1618 m_networkOPs->stop();
1619 serverHandler_->stop();
1620 m_ledgerReplayer->stop();
1621 m_inboundTransactions->stop();
1622 m_inboundLedgers->stop();
1623 ledgerCleaner_->stop();
1624 m_nodeStore->stop();
1625 perfLog_->stop();
1626
1627 JLOG(m_journal.info()) << "Done.";
1628}
1629
1630void
1631ApplicationImp::signalStop(std::string msg)
1632{
1633 if (!isTimeToStop.exchange(true))
1634 {
1635 if (msg.empty())
1636 JLOG(m_journal.warn()) << "Server stopping";
1637 else
1638 JLOG(m_journal.warn()) << "Server stopping: " << msg;
1639
1640 stoppingCondition_.notify_all();
1641 }
1642}
1643
1644bool
1645ApplicationImp::checkSigs() const
1646{
1647 return checkSigs_;
1648}
1649
1650void
1651ApplicationImp::checkSigs(bool check)
1652{
1653 checkSigs_ = check;
1654}
1655
1656bool
1657ApplicationImp::isStopping() const
1658{
1659 return isTimeToStop.load();
1660}
1661
1662int
1663ApplicationImp::fdRequired() const
1664{
1665 // Standard handles, config file, misc I/O etc:
1666 int needed = 128;
1667
1668 // 2x the configured peer limit for peer connections:
1669 if (overlay_)
1670 needed += 2 * overlay_->limit();
1671
1672 // the number of fds needed by the backend (internally
1673 // doubled if online delete is enabled).
1674 needed += std::max(5, m_shaMapStore->fdRequired());
1675
1676 // One fd per incoming connection a port can accept, or
1677 // if no limit is set, assume it'll handle 256 clients.
1678 for (auto const& p : serverHandler_->setup().ports)
1679 needed += std::max(256, p.limit);
1680
1681 // The minimum number of file descriptors we need is 1024:
1682 return std::max(1024, needed);
1683}
1684
1685//------------------------------------------------------------------------------
1686
1687void
1688ApplicationImp::startGenesisLedger()
1689{
1690 std::vector<uint256> const initialAmendments =
1691 (config_->START_UP == Config::FRESH) ? m_amendmentTable->getDesired()
1693
1695 create_genesis, *config_, initialAmendments, nodeFamily_);
1696 m_ledgerMaster->storeLedger(genesis);
1697
1698 auto const next =
1699 std::make_shared<Ledger>(*genesis, timeKeeper().closeTime());
1700 next->updateSkipList();
1701 XRPL_ASSERT(
1702 next->info().seq < XRP_LEDGER_EARLIEST_FEES ||
1703 next->read(keylet::fees()),
1704 "ripple::ApplicationImp::startGenesisLedger : valid ledger fees");
1705 next->setImmutable();
1706 openLedger_.emplace(next, cachedSLEs_, logs_->journal("OpenLedger"));
1707 m_ledgerMaster->storeLedger(next);
1708 m_ledgerMaster->switchLCL(next);
1709}
1710
1712ApplicationImp::getLastFullLedger()
1713{
1714 auto j = journal("Ledger");
1715
1716 try
1717 {
1718 auto const [ledger, seq, hash] = getLatestLedger(*this);
1719
1720 if (!ledger)
1721 return ledger;
1722
1723 XRPL_ASSERT(
1724 ledger->info().seq < XRP_LEDGER_EARLIEST_FEES ||
1725 ledger->read(keylet::fees()),
1726 "ripple::ApplicationImp::getLastFullLedger : valid ledger fees");
1727 ledger->setImmutable();
1728
1729 if (getLedgerMaster().haveLedger(seq))
1730 ledger->setValidated();
1731
1732 if (ledger->info().hash == hash)
1733 {
1734 JLOG(j.trace()) << "Loaded ledger: " << hash;
1735 return ledger;
1736 }
1737
1738 if (auto stream = j.error())
1739 {
1740 stream << "Failed on ledger";
1741 Json::Value p;
1742 addJson(p, {*ledger, nullptr, LedgerFill::full});
1743 stream << p;
1744 }
1745
1746 return {};
1747 }
1748 catch (SHAMapMissingNode const& mn)
1749 {
1750 JLOG(j.warn()) << "Ledger in database: " << mn.what();
1751 return {};
1752 }
1753}
1754
1756ApplicationImp::loadLedgerFromFile(std::string const& name)
1757{
1758 try
1759 {
1760 std::ifstream ledgerFile(name, std::ios::in);
1761
1762 if (!ledgerFile)
1763 {
1764 JLOG(m_journal.fatal()) << "Unable to open file '" << name << "'";
1765 return nullptr;
1766 }
1767
1768 Json::Reader reader;
1769 Json::Value jLedger;
1770
1771 if (!reader.parse(ledgerFile, jLedger))
1772 {
1773 JLOG(m_journal.fatal()) << "Unable to parse ledger JSON";
1774 return nullptr;
1775 }
1776
1778
1779 // accept a wrapped ledger
1780 if (ledger.get().isMember("result"))
1781 ledger = ledger.get()["result"];
1782
1783 if (ledger.get().isMember("ledger"))
1784 ledger = ledger.get()["ledger"];
1785
1786 std::uint32_t seq = 1;
1787 auto closeTime = timeKeeper().closeTime();
1788 using namespace std::chrono_literals;
1789 auto closeTimeResolution = 30s;
1790 bool closeTimeEstimated = false;
1791 std::uint64_t totalDrops = 0;
1792
1793 if (ledger.get().isMember("accountState"))
1794 {
1795 if (ledger.get().isMember(jss::ledger_index))
1796 {
1797 seq = ledger.get()[jss::ledger_index].asUInt();
1798 }
1799
1800 if (ledger.get().isMember("close_time"))
1801 {
1802 using tp = NetClock::time_point;
1803 using d = tp::duration;
1804 closeTime = tp{d{ledger.get()["close_time"].asUInt()}};
1805 }
1806 if (ledger.get().isMember("close_time_resolution"))
1807 {
1808 using namespace std::chrono;
1809 closeTimeResolution =
1810 seconds{ledger.get()["close_time_resolution"].asUInt()};
1811 }
1812 if (ledger.get().isMember("close_time_estimated"))
1813 {
1814 closeTimeEstimated =
1815 ledger.get()["close_time_estimated"].asBool();
1816 }
1817 if (ledger.get().isMember("total_coins"))
1818 {
1819 totalDrops = beast::lexicalCastThrow<std::uint64_t>(
1820 ledger.get()["total_coins"].asString());
1821 }
1822
1823 ledger = ledger.get()["accountState"];
1824 }
1825
1826 if (!ledger.get().isArrayOrNull())
1827 {
1828 JLOG(m_journal.fatal()) << "State nodes must be an array";
1829 return nullptr;
1830 }
1831
1832 auto loadLedger =
1833 std::make_shared<Ledger>(seq, closeTime, *config_, nodeFamily_);
1834 loadLedger->setTotalDrops(totalDrops);
1835
1836 for (Json::UInt index = 0; index < ledger.get().size(); ++index)
1837 {
1838 Json::Value& entry = ledger.get()[index];
1839
1840 if (!entry.isObjectOrNull())
1841 {
1842 JLOG(m_journal.fatal()) << "Invalid entry in ledger";
1843 return nullptr;
1844 }
1845
1846 uint256 uIndex;
1847
1848 if (!uIndex.parseHex(entry[jss::index].asString()))
1849 {
1850 JLOG(m_journal.fatal()) << "Invalid entry in ledger";
1851 return nullptr;
1852 }
1853
1854 entry.removeMember(jss::index);
1855
1856 STParsedJSONObject stp("sle", ledger.get()[index]);
1857
1858 if (!stp.object || uIndex.isZero())
1859 {
1860 JLOG(m_journal.fatal()) << "Invalid entry in ledger";
1861 return nullptr;
1862 }
1863
1864 // VFALCO TODO This is the only place that
1865 // constructor is used, try to remove it
1866 STLedgerEntry sle(*stp.object, uIndex);
1867
1868 if (!loadLedger->addSLE(sle))
1869 {
1870 JLOG(m_journal.fatal())
1871 << "Couldn't add serialized ledger: " << uIndex;
1872 return nullptr;
1873 }
1874 }
1875
1876 loadLedger->stateMap().flushDirty(hotACCOUNT_NODE);
1877
1878 XRPL_ASSERT(
1879 loadLedger->info().seq < XRP_LEDGER_EARLIEST_FEES ||
1880 loadLedger->read(keylet::fees()),
1881 "ripple::ApplicationImp::loadLedgerFromFile : valid ledger fees");
1882 loadLedger->setAccepted(
1883 closeTime, closeTimeResolution, !closeTimeEstimated);
1884
1885 return loadLedger;
1886 }
1887 catch (std::exception const& x)
1888 {
1889 JLOG(m_journal.fatal()) << "Ledger contains invalid data: " << x.what();
1890 return nullptr;
1891 }
1892}
1893
1894bool
1895ApplicationImp::loadOldLedger(
1896 std::string const& ledgerID,
1897 bool replay,
1898 bool isFileName,
1899 std::optional<uint256> trapTxID)
1900{
1901 try
1902 {
1903 std::shared_ptr<Ledger const> loadLedger, replayLedger;
1904
1905 if (isFileName)
1906 {
1907 if (!ledgerID.empty())
1908 loadLedger = loadLedgerFromFile(ledgerID);
1909 }
1910 else if (ledgerID.length() == 64)
1911 {
1912 uint256 hash;
1913
1914 if (hash.parseHex(ledgerID))
1915 {
1916 loadLedger = loadByHash(hash, *this);
1917
1918 if (!loadLedger)
1919 {
1920 // Try to build the ledger from the back end
1922 *this,
1923 hash,
1924 0,
1925 InboundLedger::Reason::GENERIC,
1926 stopwatch(),
1927 make_DummyPeerSet(*this));
1928 if (il->checkLocal())
1929 loadLedger = il->getLedger();
1930 }
1931 }
1932 }
1933 else if (ledgerID.empty() || boost::iequals(ledgerID, "latest"))
1934 {
1935 loadLedger = getLastFullLedger();
1936 }
1937 else
1938 {
1939 // assume by sequence
1940 std::uint32_t index;
1941
1942 if (beast::lexicalCastChecked(index, ledgerID))
1943 loadLedger = loadByIndex(index, *this);
1944 }
1945
1946 if (!loadLedger)
1947 return false;
1948
1949 if (replay)
1950 {
1951 // Replay a ledger close with same prior ledger and transactions
1952
1953 // this ledger holds the transactions we want to replay
1954 replayLedger = loadLedger;
1955
1956 JLOG(m_journal.info()) << "Loading parent ledger";
1957
1958 loadLedger = loadByHash(replayLedger->info().parentHash, *this);
1959 if (!loadLedger)
1960 {
1961 JLOG(m_journal.info())
1962 << "Loading parent ledger from node store";
1963
1964 // Try to build the ledger from the back end
1966 *this,
1967 replayLedger->info().parentHash,
1968 0,
1969 InboundLedger::Reason::GENERIC,
1970 stopwatch(),
1971 make_DummyPeerSet(*this));
1972
1973 if (il->checkLocal())
1974 loadLedger = il->getLedger();
1975
1976 if (!loadLedger)
1977 {
1978 // LCOV_EXCL_START
1979 JLOG(m_journal.fatal()) << "Replay ledger missing/damaged";
1980 UNREACHABLE(
1981 "ripple::ApplicationImp::loadOldLedger : replay ledger "
1982 "missing/damaged");
1983 return false;
1984 // LCOV_EXCL_STOP
1985 }
1986 }
1987 }
1988 using namespace std::chrono_literals;
1989 using namespace date;
1990 static constexpr NetClock::time_point ledgerWarnTimePoint{
1991 sys_days{January / 1 / 2018} - sys_days{January / 1 / 2000}};
1992 if (loadLedger->info().closeTime < ledgerWarnTimePoint)
1993 {
1994 JLOG(m_journal.fatal())
1995 << "\n\n*** WARNING ***\n"
1996 "You are replaying a ledger from before "
1997 << to_string(ledgerWarnTimePoint)
1998 << " UTC.\n"
1999 "This replay will not handle your ledger as it was "
2000 "originally "
2001 "handled.\nConsider running an earlier version of rippled "
2002 "to "
2003 "get the older rules.\n*** CONTINUING ***\n";
2004 }
2005
2006 JLOG(m_journal.info()) << "Loading ledger " << loadLedger->info().hash
2007 << " seq:" << loadLedger->info().seq;
2008
2009 if (loadLedger->info().accountHash.isZero())
2010 {
2011 // LCOV_EXCL_START
2012 JLOG(m_journal.fatal()) << "Ledger is empty.";
2013 UNREACHABLE(
2014 "ripple::ApplicationImp::loadOldLedger : ledger is empty");
2015 return false;
2016 // LCOV_EXCL_STOP
2017 }
2018
2019 if (!loadLedger->walkLedger(journal("Ledger"), true))
2020 {
2021 // LCOV_EXCL_START
2022 JLOG(m_journal.fatal()) << "Ledger is missing nodes.";
2023 UNREACHABLE(
2024 "ripple::ApplicationImp::loadOldLedger : ledger is missing "
2025 "nodes");
2026 return false;
2027 // LCOV_EXCL_STOP
2028 }
2029
2030 if (!loadLedger->assertSensible(journal("Ledger")))
2031 {
2032 // LCOV_EXCL_START
2033 JLOG(m_journal.fatal()) << "Ledger is not sensible.";
2034 UNREACHABLE(
2035 "ripple::ApplicationImp::loadOldLedger : ledger is not "
2036 "sensible");
2037 return false;
2038 // LCOV_EXCL_STOP
2039 }
2040
2041 m_ledgerMaster->setLedgerRangePresent(
2042 loadLedger->info().seq, loadLedger->info().seq);
2043
2044 m_ledgerMaster->switchLCL(loadLedger);
2045 loadLedger->setValidated();
2046 m_ledgerMaster->setFullLedger(loadLedger, true, false);
2047 openLedger_.emplace(
2048 loadLedger, cachedSLEs_, logs_->journal("OpenLedger"));
2049
2050 if (replay)
2051 {
2052 // inject transaction(s) from the replayLedger into our open ledger
2053 // and build replay structure
2054 auto replayData =
2055 std::make_unique<LedgerReplay>(loadLedger, replayLedger);
2056
2057 for (auto const& [_, tx] : replayData->orderedTxns())
2058 {
2059 (void)_;
2060 auto txID = tx->getTransactionID();
2061 if (trapTxID == txID)
2062 {
2063 trapTxID_ = txID;
2064 JLOG(m_journal.debug()) << "Trap transaction set: " << txID;
2065 }
2066
2068 tx->add(*s);
2069
2070 forceValidity(getHashRouter(), txID, Validity::SigGoodOnly);
2071
2072 openLedger_->modify(
2073 [&txID, &s](OpenView& view, beast::Journal j) {
2074 view.rawTxInsert(txID, std::move(s), nullptr);
2075 return true;
2076 });
2077 }
2078
2079 m_ledgerMaster->takeReplay(std::move(replayData));
2080
2081 if (trapTxID && !trapTxID_)
2082 {
2083 JLOG(m_journal.fatal())
2084 << "Ledger " << replayLedger->info().seq
2085 << " does not contain the transaction hash " << *trapTxID;
2086 return false;
2087 }
2088 }
2089 }
2090 catch (SHAMapMissingNode const& mn)
2091 {
2092 JLOG(m_journal.fatal())
2093 << "While loading specified ledger: " << mn.what();
2094 return false;
2095 }
2096 catch (boost::bad_lexical_cast&)
2097 {
2098 JLOG(m_journal.fatal())
2099 << "Ledger specified '" << ledgerID << "' is not valid";
2100 return false;
2101 }
2102
2103 return true;
2104}
2105
2106bool
2107ApplicationImp::serverOkay(std::string& reason)
2108{
2109 if (!config().ELB_SUPPORT)
2110 return true;
2111
2112 if (isStopping())
2113 {
2114 reason = "Server is shutting down";
2115 return false;
2116 }
2117
2118 if (getOPs().isNeedNetworkLedger())
2119 {
2120 reason = "Not synchronized with network yet";
2121 return false;
2122 }
2123
2124 if (getOPs().isAmendmentBlocked())
2125 {
2126 reason = "Server version too old";
2127 return false;
2128 }
2129
2130 if (getOPs().isUNLBlocked())
2131 {
2132 reason = "No valid validator list available";
2133 return false;
2134 }
2135
2136 if (getOPs().getOperatingMode() < OperatingMode::SYNCING)
2137 {
2138 reason = "Not synchronized with network";
2139 return false;
2140 }
2141
2142 if (!getLedgerMaster().isCaughtUp(reason))
2143 return false;
2144
2145 if (getFeeTrack().isLoadedLocal())
2146 {
2147 reason = "Too much load";
2148 return false;
2149 }
2150
2151 return true;
2152}
2153
2155ApplicationImp::journal(std::string const& name)
2156{
2157 return logs_->journal(name);
2158}
2159
2160void
2161ApplicationImp::setMaxDisallowedLedger()
2162{
2163 auto seq = getRelationalDatabase().getMaxLedgerSeq();
2164 if (seq)
2165 maxDisallowedLedger_ = *seq;
2166
2167 JLOG(m_journal.trace())
2168 << "Max persisted ledger is " << maxDisallowedLedger_;
2169}
2170
2171//------------------------------------------------------------------------------
2172
2173Application::Application() : beast::PropertyStream::Source("app")
2174{
2175}
2176
2177//------------------------------------------------------------------------------
2178
2183 std::unique_ptr<TimeKeeper> timeKeeper)
2184{
2186 std::move(config), std::move(logs), std::move(timeKeeper));
2187}
2188
2189void
2190fixConfigPorts(Config& config, Endpoints const& endpoints)
2191{
2192 for (auto const& [name, ep] : endpoints)
2193 {
2194 if (!config.exists(name))
2195 continue;
2196
2197 auto& section = config[name];
2198 auto const optPort = section.get("port");
2199 if (optPort)
2200 {
2201 std::uint16_t const port =
2202 beast::lexicalCast<std::uint16_t>(*optPort);
2203 if (!port)
2204 section.set("port", std::to_string(ep.port()));
2205 }
2206 }
2207}
2208
2209} // namespace ripple
boost::asio::io_context & get_io_context()
Definition BasicApp.h:25
Unserialize a JSON document into a Value.
Definition json_reader.h:20
bool parse(std::string const &document, Value &root)
Read a Value from a JSON document.
Represents a JSON value.
Definition json_value.h:131
bool isObjectOrNull() const
Value removeMember(char const *key)
Remove and return the named member.
std::string asString() const
Returns the unquoted string value.
A generic endpoint for log messages.
Definition Journal.h:41
Stream fatal() const
Definition Journal.h:333
Stream warn() const
Definition Journal.h:321
std::string const & name() const
Returns the name of this source.
void add(Source &source)
Add a child source.
Abstract stream with RAII containers that produce a property tree.
A metric for reporting event timing.
Definition Event.h:22
void notify(std::chrono::duration< Rep, Period > const &value) const
Push an event notification.
Definition Event.h:45
Measures handler latency on an io_context queue.
void sample(Handler &&handler)
Initiate continuous i/o latency sampling.
void cancel()
Cancel all pending i/o.
The amendment table stores the list of enabled and potential amendments.
io_latency_sampler(beast::insight::Event ev, beast::Journal journal, std::chrono::milliseconds interval, boost::asio::io_context &ios)
std::atomic< std::chrono::milliseconds > lastSample_
beast::io_latency_probe< std::chrono::steady_clock > m_probe
std::chrono::milliseconds get() const
void operator()(Duration const &elapsed)
std::unique_ptr< TxQ > txQ_
RCLValidations & getValidations() override
virtual ServerHandler & getServerHandler() override
std::unique_ptr< Cluster > cluster_
Config & config() override
std::unique_ptr< ValidatorList > validators_
std::uint64_t const instanceCookie_
HashRouter & getHashRouter() override
OrderBookDB & getOrderBookDB() override
Logs & logs() override
std::unique_ptr< PeerReservationTable > peerReservations_
LoadFeeTrack & getFeeTrack() override
std::unique_ptr< Config > config_
Family & getNodeFamily() override
RCLValidations mValidations
std::optional< OpenLedger > openLedger_
std::unique_ptr< ResolverAsio > m_resolver
AmendmentTable & getAmendmentTable() override
io_latency_sampler m_io_latency_sampler
static std::size_t numberOfThreads(Config const &config)
bool isStopping() const override
LoadManager & getLoadManager() override
std::unique_ptr< LoadFeeTrack > mFeeTrack
boost::asio::steady_timer entropyTimer_
std::unique_ptr< LedgerCleaner > ledgerCleaner_
std::unique_ptr< NodeStore::Database > m_nodeStore
std::unique_ptr< PathRequests > m_pathRequests
std::unique_ptr< ManifestCache > validatorManifests_
LedgerIndex getMaxDisallowedLedger() override
Ensure that a newly-started validator does not sign proposals older than the last ledger it persisted...
ManifestCache & validatorManifests() override
OpenLedger const & openLedger() const override
std::unique_ptr< SHAMapStore > m_shaMapStore
std::unique_ptr< RelationalDatabase > mRelationalDatabase
std::pair< PublicKey, SecretKey > const & nodeIdentity() override
boost::asio::io_context & getIOContext() override
Overlay & overlay() override
ValidatorList & validators() override
ValidatorSite & validatorSites() override
virtual std::optional< uint256 > const & trapTxID() const override
PeerReservationTable & peerReservations() override
ManifestCache & publisherManifests() override
int fdRequired() const override
Application::MutexType & getMasterMutex() override
std::unique_ptr< LedgerMaster > m_ledgerMaster
TransactionMaster & getMasterTransaction() override
CollectorManager & getCollectorManager() override
NodeCache & getTempNodeCache() override
std::unique_ptr< InboundTransactions > m_inboundTransactions
std::unique_ptr< NetworkOPs > m_networkOPs
TransactionMaster m_txMaster
std::unique_ptr< InboundLedgers > m_inboundLedgers
std::unique_ptr< Overlay > overlay_
std::unique_ptr< HashRouter > hashRouter_
RelationalDatabase & getRelationalDatabase() override
bool serverOkay(std::string &reason) override
OpenLedger & openLedger() override
TimeKeeper & timeKeeper() override
std::optional< PublicKey const > getValidationPublicKey() const override
TxQ & getTxQ() override
std::unique_ptr< ValidatorSite > validatorSites_
beast::Journal m_journal
std::unique_ptr< CollectorManager > m_collectorManager
SHAMapStore & getSHAMapStore() override
InboundLedgers & getInboundLedgers() override
InboundTransactions & getInboundTransactions() override
ClosureCounter< void, boost::system::error_code const & > waitHandlerCounter_
void signalStop(std::string msg) override
Cluster & cluster() override
NodeStoreScheduler m_nodeStoreScheduler
LedgerReplayer & getLedgerReplayer() override
std::unique_ptr< ServerHandler > serverHandler_
LedgerMaster & getLedgerMaster() override
void gotTXSet(std::shared_ptr< SHAMap > const &set, bool fromAcquire)
void start(bool withTimers) override
std::unique_ptr< ManifestCache > publisherManifests_
boost::asio::signal_set m_signals
std::unique_ptr< LoadManager > m_loadManager
perf::PerfLog & getPerfLog() override
DatabaseCon & getWalletDB() override
Retrieve the "wallet database".
std::unique_ptr< GRPCServer > grpcServer_
Application::MutexType m_masterMutex
std::unique_ptr< perf::PerfLog > perfLog_
bool checkSigs() const override
std::unique_ptr< TimeKeeper > timeKeeper_
NodeStore::Database & getNodeStore() override
PendingSaves & pendingSaves() override
std::unique_ptr< AmendmentTable > m_amendmentTable
std::optional< uint256 > trapTxID_
ApplicationImp(std::unique_ptr< Config > config, std::unique_ptr< Logs > logs, std::unique_ptr< TimeKeeper > timeKeeper)
std::unique_ptr< DatabaseCon > mWalletDB
beast::Journal journal(std::string const &name) override
PathRequests & getPathRequests() override
std::optional< std::pair< PublicKey, SecretKey > > nodeIdentity_
boost::asio::steady_timer sweepTimer_
std::uint64_t instanceID() const override
Returns a 64-bit instance identifier, generated at startup.
std::unique_ptr< Resource::Manager > m_resourceManager
std::unique_ptr< LedgerReplayer > m_ledgerReplayer
CachedSLEs & cachedSLEs() override
std::chrono::milliseconds getIOLatency() override
LedgerCleaner & getLedgerCleaner() override
JobQueue & getJobQueue() override
ValidatorKeys const validatorKeys_
std::condition_variable stoppingCondition_
std::unique_ptr< Logs > logs_
Resource::Manager & getResourceManager() override
std::unique_ptr< JobQueue > m_jobQueue
std::atomic< bool > checkSigs_
bool setup(boost::program_options::variables_map const &cmdline) override
std::atomic< bool > isTimeToStop
TaggedCache< uint256, AcceptedLedger > & getAcceptedLedgerCache() override
NetworkOPs & getOPs() override
void onWrite(beast::PropertyStream::Map &stream) override
Subclass override.
TaggedCache< uint256, AcceptedLedger > m_acceptedLedgerCache
bool exists(std::string const &name) const
Returns true if a section with the given name exists.
The role of a ClosureCounter is to assist in shutdown by letting callers wait for the completion of c...
Provides the beast::insight::Collector service.
bool FORCE_MULTI_THREAD
Definition Config.h:220
bool standalone() const
Definition Config.h:317
std::size_t NODE_SIZE
Definition Config.h:194
Routing table for objects identified by hash.
Definition HashRouter.h:78
Manages the lifetime of inbound ledgers.
Manages the acquisition and lifetime of transaction sets.
A pool of threads to perform work.
Definition JobQueue.h:39
Check the ledger/transaction databases to make sure they have continuity.
Manages the lifetime of ledger replay tasks.
Manages the current fee schedule.
Manages load sources.
Definition LoadManager.h:27
Manages partitions for logging.
Definition Log.h:33
Remembers manifests with the highest sequence number.
Definition Manifest.h:237
Provides server functionality for clients.
Definition NetworkOPs.h:70
A NodeStore::Scheduler which uses the JobQueue.
Persistency layer for NodeObject.
Definition Database.h:32
Simple NodeStore Scheduler that just peforms the tasks synchronously.
virtual std::unique_ptr< Database > make_Database(std::size_t burstSize, Scheduler &scheduler, int readThreads, Section const &backendParameters, beast::Journal journal)=0
Construct a NodeStore database.
static Manager & instance()
Returns the instance of the manager singleton.
Represents the open ledger.
Definition OpenLedger.h:33
Writable ledger view that accumulates state and tx changes.
Definition OpenView.h:46
void rawTxInsert(key_type const &key, std::shared_ptr< Serializer const > const &txn, std::shared_ptr< Serializer const > const &metaData) override
Add a transaction to the tx map.
Definition OpenView.cpp:240
Manages the set of connected peers.
Definition Overlay.h:30
Keeps track of which ledgers haven't been fully saved.
A public key.
Definition PublicKey.h:43
static std::unique_ptr< RelationalDatabase > init(Application &app, Config const &config, JobQueue &jobQueue)
init Creates and returns an appropriate RelationalDatabase instance based on configuration.
static std::unique_ptr< ResolverAsio > New(boost::asio::io_context &, beast::Journal)
A consumption charge.
Definition Charge.h:11
An endpoint that consumes resources.
Definition Consumer.h:17
Tracks load and resource consumption.
class to create database, launch online delete thread, and related SQLite database
Definition SHAMapStore.h:19
Holds the serialized result of parsing an input JSON object.
std::optional< STObject > object
The STObject if the parse was successful.
Holds a collection of configuration values.
Definition BasicConfig.h:26
std::size_t size() const
Returns the number of items in the container.
Manages various times used by the server.
Definition TimeKeeper.h:13
Transaction Queue.
Definition TxQ.h:42
Validator keys and manifest as set in configuration file.
std::optional< Keys > keys
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
Definition base_uint.h:484
bool isZero() const
Definition base_uint.h:521
Singleton class that maintains performance counters and optionally writes Json-formatted data to a di...
Definition PerfLog.h:33
T empty(T... args)
T endl(T... args)
T hardware_concurrency(T... args)
T is_same_v
T load(T... args)
T make_unique(T... args)
T max(T... args)
T min(T... args)
unsigned int UInt
A namespace for easy access to logging severity values.
Definition Journal.h:11
bool lexicalCastChecked(Out &out, In in)
Intelligently convert from one type to another.
std::unique_ptr< Manager > make_Manager(beast::insight::Collector::ptr const &collector, beast::Journal journal)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
std::tuple< std::shared_ptr< Ledger >, std::uint32_t, uint256 > getLatestLedger(Application &app)
Definition Ledger.cpp:1089
std::unique_ptr< NetworkOPs > make_NetworkOPs(Application &app, NetworkOPs::clock_type &clock, bool standalone, std::size_t minPeerCount, bool startvalid, JobQueue &job_queue, LedgerMaster &ledgerMaster, ValidatorKeys const &validatorKeys, boost::asio::io_context &io_svc, beast::Journal journal, beast::insight::Collector::ptr const &collector)
constexpr auto megabytes(T value) noexcept
std::enable_if_t< std::is_integral< Integral >::value, Integral > rand_int()
DatabaseCon::Setup setup_DatabaseCon(Config const &c, std::optional< beast::Journal > j=std::nullopt)
std::unique_ptr< LedgerCleaner > make_LedgerCleaner(Application &app, beast::Journal journal)
TxQ::Setup setup_TxQ(Config const &config)
Build a TxQ::Setup object from application configuration.
Definition TxQ.cpp:1894
std::shared_ptr< Ledger > loadByIndex(std::uint32_t ledgerIndex, Application &app, bool acquire)
Definition Ledger.cpp:1099
std::unique_ptr< LoadManager > make_LoadManager(Application &app, beast::Journal journal)
std::unique_ptr< Application > make_Application(std::unique_ptr< Config > config, std::unique_ptr< Logs > logs, std::unique_ptr< TimeKeeper > timeKeeper)
void initAccountIdCache(std::size_t count)
Initialize the global cache used to map AccountID to base58 conversions.
Definition AccountID.cpp:88
std::unordered_map< std::string, boost::asio::ip::tcp::endpoint > Endpoints
Definition ServerImpl.h:22
@ hotACCOUNT_NODE
Definition NodeObject.h:16
std::pair< PublicKey, SecretKey > getNodeIdentity(Application &app, boost::program_options::variables_map const &cmdline)
The cryptographic credentials identifying this server instance.
std::unique_ptr< PeerSet > make_DummyPeerSet(Application &app)
Make a dummy PeerSet that does not do anything.
Definition PeerSet.cpp:168
csprng_engine & crypto_prng()
The default cryptographically secure PRNG.
std::unique_ptr< PeerSetBuilder > make_PeerSetBuilder(Application &app)
Definition PeerSet.cpp:125
std::shared_ptr< Ledger > loadByHash(uint256 const &ledgerHash, Application &app, bool acquire)
Definition Ledger.cpp:1112
void addJson(Json::Value &json, LedgerFill const &fill)
Given a Ledger and options, fill a Json::Object or Json::Value with a description of the ledger.
std::unique_ptr< CollectorManager > make_CollectorManager(Section const &params, beast::Journal journal)
std::unique_ptr< InboundTransactions > make_InboundTransactions(Application &app, beast::insight::Collector::ptr const &collector, std::function< void(std::shared_ptr< SHAMap > const &, bool)> gotSet)
std::unique_ptr< InboundLedgers > make_InboundLedgers(Application &app, InboundLedgers::clock_type &clock, beast::insight::Collector::ptr const &collector)
ServerHandler::Setup setup_ServerHandler(Config const &config, std::ostream &&log)
HashRouter::Setup setup_HashRouter(Config const &config)
Stopwatch & stopwatch()
Returns an instance of a wall clock.
Definition chrono.h:100
std::optional< uint256 > getRegisteredFeature(std::string const &name)
Definition Feature.cpp:363
std::unique_ptr< DatabaseCon > makeWalletDB(DatabaseCon::Setup const &setup, beast::Journal j)
makeWalletDB Opens the wallet database and returns it.
Definition Wallet.cpp:8
void forceValidity(HashRouter &router, uint256 const &txid, Validity validity)
Sets the validity of a given transaction in the cache.
Definition apply.cpp:99
std::unique_ptr< ServerHandler > make_ServerHandler(Application &app, boost::asio::io_context &io_context, JobQueue &jobQueue, NetworkOPs &networkOPs, Resource::Manager &resourceManager, CollectorManager &cm)
create_genesis_t const create_genesis
Definition Ledger.cpp:32
std::unique_ptr< Overlay > make_Overlay(Application &app, Overlay::Setup const &setup, ServerHandler &serverHandler, Resource::Manager &resourceManager, Resolver &resolver, boost::asio::io_context &io_context, BasicConfig const &config, beast::insight::Collector::ptr const &collector)
Creates the implementation of Overlay.
static void fixConfigPorts(Config &config, Endpoints const &endpoints)
std::unique_ptr< AmendmentTable > make_AmendmentTable(Application &app, std::chrono::seconds majorityTime, std::vector< AmendmentTable::FeatureInfo > const &supported, Section const &enabled, Section const &vetoed, beast::Journal journal)
Overlay::Setup setup_Overlay(BasicConfig const &config)
void LogicError(std::string const &how) noexcept
Called when faulty logic causes a broken invariant.
std::unique_ptr< SHAMapStore > make_SHAMapStore(Application &app, NodeStore::Scheduler &scheduler, beast::Journal journal)
STL namespace.
T ref(T... args)
T length(T... args)
T strlen(T... args)
static std::string importNodeDatabase()
T to_string(T... args)
T what(T... args)