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