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