1#include <xrpld/app/main/Application.h>
3#include <xrpld/app/consensus/RCLValidations.h>
4#include <xrpld/app/ledger/InboundLedger.h>
5#include <xrpld/app/ledger/InboundLedgers.h>
6#include <xrpld/app/ledger/InboundTransactions.h>
7#include <xrpld/app/ledger/LedgerCleaner.h>
8#include <xrpld/app/ledger/LedgerMaster.h>
9#include <xrpld/app/ledger/LedgerPersistence.h>
10#include <xrpld/app/ledger/LedgerReplay.h>
11#include <xrpld/app/ledger/LedgerReplayer.h>
12#include <xrpld/app/ledger/LedgerToJson.h>
13#include <xrpld/app/ledger/OpenLedger.h>
14#include <xrpld/app/ledger/OrderBookDBImpl.h>
15#include <xrpld/app/ledger/TransactionMaster.h>
16#include <xrpld/app/main/BasicApp.h>
17#include <xrpld/app/main/CollectorManager.h>
18#include <xrpld/app/main/GRPCServer.h>
19#include <xrpld/app/main/LoadManager.h>
20#include <xrpld/app/main/NodeIdentity.h>
21#include <xrpld/app/main/NodeStoreScheduler.h>
22#include <xrpld/app/misc/SHAMapStore.h>
23#include <xrpld/app/misc/TxQ.h>
24#include <xrpld/app/misc/ValidatorKeys.h>
25#include <xrpld/app/misc/ValidatorSite.h>
26#include <xrpld/app/misc/make_NetworkOPs.h>
27#include <xrpld/app/misc/setup_HashRouter.h>
28#include <xrpld/app/rdb/backend/SQLiteDatabase.h>
29#include <xrpld/core/Config.h>
30#include <xrpld/core/NetworkIDServiceImpl.h>
31#include <xrpld/overlay/Cluster.h>
32#include <xrpld/overlay/PeerSet.h>
33#include <xrpld/overlay/make_Overlay.h>
34#include <xrpld/rpc/Context.h>
35#include <xrpld/rpc/RPCHandler.h>
36#include <xrpld/rpc/Role.h>
37#include <xrpld/rpc/ServerHandler.h>
38#include <xrpld/rpc/detail/Handler.h>
39#include <xrpld/rpc/detail/PathRequestManager.h>
40#include <xrpld/rpc/detail/Pathfinder.h>
41#include <xrpld/shamap/NodeFamily.h>
43#include <xrpl/basics/ByteUtilities.h>
44#include <xrpl/basics/Log.h>
45#include <xrpl/basics/MallocTrim.h>
46#include <xrpl/basics/ResolverAsio.h>
47#include <xrpl/basics/ToString.h>
48#include <xrpl/basics/base_uint.h>
49#include <xrpl/basics/chrono.h>
50#include <xrpl/basics/contract.h>
51#include <xrpl/basics/random.h>
52#include <xrpl/beast/asio/io_latency_probe.h>
53#include <xrpl/beast/core/LexicalCast.h>
54#include <xrpl/beast/insight/Event.h>
55#include <xrpl/beast/utility/Journal.h>
56#include <xrpl/beast/utility/PropertyStream.h>
57#include <xrpl/beast/utility/instrumentation.h>
58#include <xrpl/config/BasicConfig.h>
59#include <xrpl/config/Constants.h>
60#include <xrpl/core/ClosureCounter.h>
61#include <xrpl/core/HashRouter.h>
62#include <xrpl/core/Job.h>
63#include <xrpl/core/NetworkIDService.h>
64#include <xrpl/core/PeerReservationTable.h>
65#include <xrpl/core/PerfLog.h>
66#include <xrpl/core/StartUpType.h>
67#include <xrpl/crypto/csprng.h>
68#include <xrpl/json/json_forwards.h>
69#include <xrpl/json/json_reader.h>
70#include <xrpl/json/json_value.h>
71#include <xrpl/ledger/AmendmentTable.h>
72#include <xrpl/ledger/Ledger.h>
73#include <xrpl/ledger/OpenView.h>
74#include <xrpl/ledger/PendingSaves.h>
75#include <xrpl/ledger/entries/FeeSettingsEntry.h>
76#include <xrpl/nodestore/Database.h>
77#include <xrpl/nodestore/DummyScheduler.h>
78#include <xrpl/nodestore/Manager.h>
79#include <xrpl/nodestore/NodeObject.h>
80#include <xrpl/protocol/AccountID.h>
81#include <xrpl/protocol/ApiVersion.h>
82#include <xrpl/protocol/BuildInfo.h>
83#include <xrpl/protocol/Feature.h>
84#include <xrpl/protocol/Indexes.h>
85#include <xrpl/protocol/Protocol.h>
86#include <xrpl/protocol/STParsedJSON.h>
87#include <xrpl/protocol/Serializer.h>
88#include <xrpl/protocol/SystemParameters.h>
89#include <xrpl/protocol/jss.h>
90#include <xrpl/rdb/DatabaseCon.h>
91#include <xrpl/resource/Charge.h>
92#include <xrpl/resource/Consumer.h>
93#include <xrpl/resource/Fees.h>
94#include <xrpl/resource/ResourceManager.h>
95#include <xrpl/server/LoadFeeTrack.h>
96#include <xrpl/server/Manifest.h>
97#include <xrpl/server/NetworkOPs.h>
98#include <xrpl/server/Wallet.h>
99#include <xrpl/server/detail/ServerImpl.h>
100#include <xrpl/shamap/FullBelowCache.h>
101#include <xrpl/shamap/SHAMap.h>
102#include <xrpl/shamap/SHAMapMissingNode.h>
103#include <xrpl/shamap/TreeNodeCache.h>
104#include <xrpl/tx/apply.h>
106#include <boost/algorithm/string/predicate.hpp>
107#include <boost/asio/error.hpp>
108#include <boost/asio/io_context.hpp>
109#include <boost/asio/signal_set.hpp>
110#include <boost/asio/steady_timer.hpp>
111#include <boost/lexical_cast/bad_lexical_cast.hpp>
112#include <boost/program_options/variables_map.hpp>
113#include <boost/system/detail/errc.hpp>
114#include <boost/system/detail/error_code.hpp>
115#include <boost/system/system_error.hpp>
117#include <date/date.h>
161 boost::asio::io_context& ios)
172 template <
class Duration>
181 if (lastSample >= 10ms)
182 event_.notify(lastSample);
183 if (lastSample >= 500ms)
185 JLOG(
journal_.warn()) <<
"io_context latency = " << lastSample.count();
289#if XRPL_SINGLE_IO_SERVICE_THREAD
300 if ((cores == 1) || ((
config.nodeSize == 0) && (cores == 2)))
325 rpc::getHandlerNames(),
326 logs_->journal(
"PerfLog"),
331 logs_->journal(
"Collector")))
362 logs_->journal(
"JobQueue"),
370 std::chrono::seconds{90},
372 logs_->journal(
"TaggedCache"))
376 std::chrono::minutes(1),
378 logs_->journal(
"CachedSLEs"))
388 {.pathSearchMax =
config_->pathSearchMax, .standalone =
config_->standalone()}))
392 logs_->journal(
"PathRequest"),
399 logs_->journal(
"LedgerMaster")))
409 [
this](std::shared_ptr<SHAMap>
const&
set,
bool fromAcquire) {
410 gotTXSet(set, fromAcquire);
417 std::chrono::minutes{1},
419 logs_->journal(
"TaggedCache"))
430 logs_->journal(
"NetworkOPs"),
437 logs_->journal(
"ManifestCache"),
441 logs_->journal(
"ManifestCache"),
448 config_->legacy(
"database_path"),
449 logs_->journal(
"ValidatorList"),
471 logs_->journal(
"Application"),
472 std::chrono::milliseconds(100),
501 setup(boost::program_options::variables_map
const& cmdline)
override;
503 start(
bool withTimers)
override;
567 logicError(
"Accessing Application::nodeIdentity() before it is initialized.");
590 "xrpl::ApplicationImp::getServerHandler : non-null server "
595 boost::asio::io_context&
805 XRPL_ASSERT(
overlay_,
"xrpl::ApplicationImp::overlay : non-null overlay");
812 XRPL_ASSERT(
txQ_,
"xrpl::ApplicationImp::getTxQ : non-null transaction queue");
821 "xrpl::ApplicationImp::getRelationalDatabase : non-null relational database");
828 XRPL_ASSERT(
walletDB_,
"xrpl::ApplicationImp::getWalletDB : non-null wallet database");
845 "xrpl::ApplicationImp::initRelationalDatabase : null wallet "
854 setup.useGlobalPragma =
false;
860 JLOG(
journal_.fatal()) <<
"Failed to initialize SQL databases: " << e.
what();
872 auto j =
logs_->journal(
"NodeObject");
882 JLOG(j.warn()) <<
"Starting node import from '" << source->getName() <<
"' to '"
891 JLOG(j.warn()) <<
"Node import from '" << source->getName() <<
"' took "
892 << elapsed.count() <<
" seconds.";
914 if (
auto optionalCountedHandler =
916 if (e.value() == boost::system::errc::success)
918 jobQueue_->addJob(JtSweep,
"sweep", [this]() { doSweep(); });
921 if (e.value() != boost::system::errc::success &&
922 e.value() != boost::asio::error::operation_aborted)
925 JLOG(journal_.error())
926 <<
"Sweep timer got error '" << e.message() <<
"'. Restarting timer.";
935 sweepTimer_.async_wait(std::move(*optionalCountedHandler));
943 if (
auto optionalCountedHandler =
945 if (e.value() == boost::system::errc::success)
947 cryptoPrng().mixEntropy();
951 if (e.value() != boost::system::errc::success &&
952 e.value() != boost::asio::error::operation_aborted)
955 JLOG(journal_.error()) <<
"Entropy timer got error '" << e.message()
956 <<
"'. Restarting timer.";
961 using namespace std::chrono_literals;
962 entropyTimer_.expires_after(5
min);
963 entropyTimer_.async_wait(std::move(*optionalCountedHandler));
989 std::size_t const oldFullBelowSize = fullBelowCache->size();
990 std::size_t const oldTreeNodeSize = treeNodeCache->size();
995 <<
"NodeFamily::FullBelowCache sweep. Size before: " << oldFullBelowSize
996 <<
"; size after: " << fullBelowCache->size();
999 <<
"NodeFamily::TreeNodeCache sweep. Size before: " << oldTreeNodeSize
1000 <<
"; size after: " << treeNodeCache->size();
1010 JLOG(
journal_.debug()) <<
"MasterTransaction sweep. Size before: " << oldMasterTxSize
1011 <<
"; size after: " << masterTxCache.
size();
1023 <<
"LedgerMaster sweep. Size before: " << oldLedgerMasterCacheSize
1032 JLOG(
journal_.debug()) <<
"TempNodeCache sweep. Size before: " << oldTempNodeCacheSize
1044 <<
"Validations Current expire. Size before: " << oldCurrentCacheSize
1048 <<
"Validations SeqEnforcer expire. Size before: " << oldSizeSeqEnforcesSize
1049 <<
"; size after: " <<
getValidations().sizeOfSeqEnforcersCache();
1052 <<
"Validations ByLedger expire. Size before: " << oldByLedgerSize
1056 <<
"Validations BySequence expire. Size before: " << oldBySequenceSize
1065 <<
"InboundLedgers sweep. Size before: " << oldInboundLedgersSize
1075 JLOG(
journal_.debug()) <<
"LedgerReplayer tasks sweep. Size before: " << oldTasksSize
1078 JLOG(
journal_.debug()) <<
"LedgerReplayer deltas sweep. Size before: " << oldDeltasSize
1082 <<
"LedgerReplayer skipLists sweep. Size before: " << oldSkipListsSize
1091 <<
"AcceptedLedgerCache sweep. Size before: " << oldAcceptedLedgerSize
1099 JLOG(
journal_.debug()) <<
"CachedSLEs sweep. Size before: " << oldCachedSLEsSize
1133 startGenesisLedger();
1136 getLastFullLedger();
1149 setMaxDisallowedLedger();
1174 signals_.async_wait([
this](boost::system::error_code
const& ec,
int signum) {
1176 if (ec == boost::asio::error::operation_aborted)
1179 JLOG(
journal_.info()) <<
"Received signal " << signum;
1181 if (signum == SIGTERM || signum == SIGINT)
1196 if (
logs_->threshold() > Severity::Debug)
1197 logs_->threshold(Severity::Debug);
1205 JLOG(
journal_.warn()) <<
"Manifest counts: max_untrusted_count "
1207 << (
config_->maxUntrustedCount ?
" (configured)" :
" (default)")
1208 <<
", max_trusted_count "
1210 << (
config_->maxTrustedCount ?
" (configured)" :
" (default)");
1214 JLOG(
journal_.warn()) <<
"Limited to a single I/O service thread by "
1215 "system configuration.";
1226 JLOG(
journal_.fatal()) <<
"Cannot find peer reservations!";
1235 auto const supported = []() {
1238 supported.
reserve(amendments.size());
1239 for (
auto const& [a, vote] : amendments)
1242 XRPL_ASSERT(f,
"xrpl::ApplicationImp::setup : registered feature");
1254 config().amendmentMajorityTime,
1258 logs_->journal(
"Amendments"));
1263 auto const startUp =
config_->startUp;
1264 JLOG(
journal_.debug()) <<
"startUp: " << startUp;
1267 JLOG(
journal_.info()) <<
"Starting new Ledger";
1275 JLOG(
journal_.info()) <<
"Loading specified Ledger";
1283 JLOG(
journal_.error()) <<
"The specified ledger could not be loaded.";
1310 if (
auto const& forcedRange =
config().forcedLedgerRangePresent)
1312 ledgerMaster_->setLedgerRangePresent(forcedRange->first, forcedRange->second);
1321 JLOG(
journal_.fatal()) <<
"Invalid entry in cluster configuration.";
1331 "ValidatorManifests",
1335 JLOG(
journal_.fatal()) <<
"Invalid configured validator manifest.";
1356 config().validatorListThreshold))
1358 JLOG(
journal_.fatal()) <<
"Invalid entry in validator configuration.";
1397 JLOG(
journal_.fatal()) <<
"Unable to start consensus";
1406 setup.makeContexts();
1412 if (
auto stream =
journal_.fatal())
1414 stream <<
"Unable to setup server handler";
1416 stream <<
": " << e.
what();
1429 JLOG(
journal_.warn()) <<
"No outbound peer connections will be made";
1438 JLOG(
journal_.warn()) <<
"Running in standalone mode";
1445 JLOG(
journal_.warn()) <<
"*** The server is configured to allow the "
1446 "'sign' and 'sign_for'";
1447 JLOG(
journal_.warn()) <<
"*** commands. These commands have security "
1448 "implications and have";
1449 JLOG(
journal_.warn()) <<
"*** been deprecated. They will be removed "
1450 "in a future release of";
1451 JLOG(
journal_.warn()) <<
"*** xrpld.";
1452 JLOG(
journal_.warn()) <<
"*** If you do not use them to sign "
1453 "transactions please edit your";
1454 JLOG(
journal_.warn()) <<
"*** configuration file and remove the [enable_signing] stanza.";
1455 JLOG(
journal_.warn()) <<
"*** If you do use them to sign transactions "
1456 "please migrate to a";
1457 JLOG(
journal_.warn()) <<
"*** standalone signing solution as soon as possible.";
1468 if (!jrReader.
parse(cmd, jvCommand))
1484 .loadType = loadType,
1547 JLOG(
journal_.debug()) <<
"Application stopping";
1571 catch (boost::system::system_error
const& e)
1573 JLOG(
journal_.error()) <<
"Application: sweepTimer cancel error: " << e.what();
1580 catch (boost::system::system_error
const& e)
1582 JLOG(
journal_.error()) <<
"Application: entropyTimer cancel error: " << e.what();
1588 using namespace std::chrono_literals;
1628 if (!
isTimeToStop.test_and_set(std::memory_order_acquire))
1632 JLOG(
journal_.warn()) <<
"Server stopping";
1636 JLOG(
journal_.warn()) <<
"Server stopping: " << msg;
1702 next->updateSkipList();
1705 "xrpl::ApplicationImp::startGenesisLedger : valid ledger fees");
1706 next->setImmutable();
1719 auto const [ledger, seq,
hash] =
1727 "xrpl::ApplicationImp::getLastFullLedger : valid ledger fees");
1728 ledger->setImmutable();
1731 ledger->setValidated();
1733 if (ledger->header().hash ==
hash)
1735 JLOG(j.trace()) <<
"Loaded ledger: " <<
hash;
1739 if (
auto stream = j.error())
1741 stream <<
"Failed on ledger";
1751 JLOG(j.warn()) <<
"Ledger in database: " << mn.
what();
1765 JLOG(
journal_.fatal()) <<
"Unable to open file '" <<
name <<
"'";
1772 if (!reader.
parse(ledgerFile, jLedger))
1774 JLOG(
journal_.fatal()) <<
"Unable to parse ledger JSON";
1781 if (ledger.
get().isMember(
"result"))
1782 ledger = ledger.
get()[
"result"];
1784 if (ledger.
get().isMember(
"ledger"))
1785 ledger = ledger.
get()[
"ledger"];
1789 using namespace std::chrono_literals;
1790 auto closeTimeResolution = 30s;
1791 bool closeTimeEstimated =
false;
1794 if (ledger.
get().isMember(
"accountState"))
1796 if (ledger.
get().isMember(jss::ledger_index))
1798 seq = ledger.
get()[jss::ledger_index].asUInt();
1801 if (ledger.
get().isMember(
"close_time"))
1804 using D = Tp::duration;
1805 closeTime = Tp{D{ledger.
get()[
"close_time"].asUInt()}};
1807 if (ledger.
get().isMember(
"close_time_resolution"))
1810 closeTimeResolution =
seconds{ledger.
get()[
"close_time_resolution"].asUInt()};
1812 if (ledger.
get().isMember(
"close_time_estimated"))
1814 closeTimeEstimated = ledger.
get()[
"close_time_estimated"].asBool();
1816 if (ledger.
get().isMember(
"total_coins"))
1822 ledger = ledger.
get()[
"accountState"];
1825 if (!ledger.
get().isArrayOrNull())
1827 JLOG(
journal_.fatal()) <<
"State nodes must be an array";
1833 loadLedger->setTotalDrops(totalDrops);
1841 JLOG(
journal_.fatal()) <<
"Invalid entry in ledger";
1849 JLOG(
journal_.fatal()) <<
"Invalid entry in ledger";
1859 JLOG(
journal_.fatal()) <<
"Invalid entry in ledger";
1867 if (!loadLedger->addSLE(sle))
1869 JLOG(
journal_.fatal()) <<
"Couldn't add serialized ledger: " << uIndex;
1878 "xrpl::ApplicationImp::loadLedgerFromFile : valid ledger fees");
1879 loadLedger->setAccepted(closeTime, closeTimeResolution, !closeTimeEstimated);
1885 JLOG(
journal_.fatal()) <<
"Ledger contains invalid data: " << x.
what();
1903 if (!ledgerID.
empty())
1906 else if (ledgerID.
length() == 64)
1910 if (
hash.parseHex(ledgerID))
1925 if (il->checkLocal())
1926 loadLedger = il->getLedger();
1930 else if (ledgerID.
empty() || boost::iequals(ledgerID,
"latest"))
1954 replayLedger = loadLedger;
1956 JLOG(
journal_.info()) <<
"Loading parent ledger";
1959 replayLedger->header().parentHash,
1960 Rules{config_->features},
1965 JLOG(
journal_.info()) <<
"Loading parent ledger from node store";
1970 replayLedger->header().parentHash,
1976 if (il->checkLocal())
1977 loadLedger = il->getLedger();
1982 JLOG(
journal_.fatal()) <<
"Replay ledger missing/damaged";
1984 "xrpl::ApplicationImp::loadOldLedger : replay ledger "
1991 using namespace std::chrono_literals;
1992 using namespace date;
1995 if (loadLedger->header().closeTime < kLedgerWarnTimePoint)
1997 JLOG(
journal_.fatal()) <<
"\n\n*** WARNING ***\n"
1998 "You are replaying a ledger from before "
2001 "This replay will not handle your ledger as it was "
2003 "handled.\nConsider running an earlier version of xrpld "
2005 "get the older rules.\n*** CONTINUING ***\n";
2008 JLOG(
journal_.info()) <<
"Loading ledger " << loadLedger->header().hash
2009 <<
" seq:" << loadLedger->header().seq;
2011 if (loadLedger->header().accountHash.isZero())
2014 JLOG(
journal_.fatal()) <<
"Ledger is empty.";
2015 UNREACHABLE(
"xrpl::ApplicationImp::loadOldLedger : ledger is empty");
2020 if (!loadLedger->walkLedger(
getJournal(
"Ledger"),
true))
2023 JLOG(
journal_.fatal()) <<
"Ledger is missing nodes.";
2025 "xrpl::ApplicationImp::loadOldLedger : ledger is missing "
2031 if (!loadLedger->isSensible())
2035 j[jss::accountTreeHash] =
to_string(loadLedger->header().accountHash);
2036 j[jss::transTreeHash] =
to_string(loadLedger->header().txHash);
2037 JLOG(
journal_.fatal()) <<
"Ledger is not sensible: " << j;
2039 "xrpl::ApplicationImp::loadOldLedger : ledger is not "
2045 ledgerMaster_->setLedgerRangePresent(loadLedger->header().seq, loadLedger->header().seq);
2048 loadLedger->setValidated();
2058 for (
auto const& [_, tx] : replayData->orderedTxns())
2061 auto txID = tx->getTransactionID();
2062 if (trapTxID == txID)
2065 JLOG(
journal_.debug()) <<
"Trap transaction set: " << txID;
2085 JLOG(
journal_.fatal()) <<
"Ledger " << replayLedger->header().seq
2086 <<
" does not contain the transaction hash " << *trapTxID;
2093 JLOG(
journal_.fatal()) <<
"While loading specified ledger: " << mn.
what();
2096 catch (boost::bad_lexical_cast&)
2098 JLOG(
journal_.fatal()) <<
"Ledger specified '" << ledgerID <<
"' is not valid";
2108 if (!
config().elbSupport)
2113 reason =
"Server is shutting down";
2117 if (
getOPs().isNeedNetworkLedger())
2119 reason =
"Not synchronized with network yet";
2123 if (
getOPs().isAmendmentBlocked())
2125 reason =
"Server version too old";
2129 if (
getOPs().isUNLBlocked())
2131 reason =
"No valid validator list available";
2137 reason =
"Not synchronized with network";
2146 reason =
"Too much load";
2184 std::move(config), std::move(logs), std::move(timeKeeper));
2190 for (
auto const& [name, ep] : endpoints)
2192 if (!config.
exists(name))
2195 auto& section = config[name];
size_t getNumberOfThreads() const
BasicApp(std::size_t numberOfThreads)
boost::asio::io_context & getIoContext()
Measures handler latency on an io_context queue.
A generic endpoint for log messages.
std::string const & name() const
Returns the name of this source.
void add(Source &source)
Add a child source.
A metric for reporting event timing.
Unserialize a JSON document into a Value.
bool parse(std::string const &document, Value &root)
Read a Value from a JSON document.
Value removeMember(char const *key)
Remove and return the named member.
std::string asString() const
Returns the unquoted string value.
bool isObjectOrNull() const
The amendment table stores the list of enabled and potential amendments.
beast::insight::Event event_
beast::IOLatencyProbe< std::chrono::steady_clock > probe_
std::chrono::milliseconds get() const
void operator()(Duration const &elapsed)
std::atomic< std::chrono::milliseconds > lastSample_
IOLatencySampler(beast::insight::Event ev, beast::Journal journal, std::chrono::milliseconds interval, boost::asio::io_context &ios)
LedgerReplayer & getLedgerReplayer() override
Application::MutexType & getMasterMutex() override
std::optional< std::pair< PublicKey, SecretKey > > nodeIdentity_
InboundLedgers & getInboundLedgers() override
ValidatorList & getValidators() override
std::unique_ptr< SHAMapStore > shaMapStore_
TimeKeeper & getTimeKeeper() override
std::unique_ptr< LedgerCleaner > ledgerCleaner_
void start(bool withTimers) override
LoadFeeTrack & getFeeTrack() override
std::unique_ptr< perf::PerfLog > perfLog_
std::unique_ptr< HashRouter > hashRouter_
std::optional< OpenLedger > openLedger_
RCLValidations & getValidations() override
std::unique_ptr< ResolverAsio > resolver_
Application::MutexType masterMutex_
std::unique_ptr< InboundTransactions > inboundTransactions_
node_store::Database & getNodeStore() override
ClosureCounter< void, boost::system::error_code const & > waitHandlerCounter_
NodeStoreScheduler nodeStoreScheduler_
RelationalDatabase & getRelationalDatabase() override
OpenLedger & getOpenLedger() override
TransactionMaster & getMasterTransaction() override
std::chrono::milliseconds getIOLatency() override
std::unique_ptr< resource::Manager > resourceManager_
boost::asio::io_context & getIOContext() override
std::unique_ptr< PathRequestManager > pathRequestManager_
std::optional< PublicKey const > getValidationPublicKey() const override
HashRouter & getHashRouter() override
LoadManager & getLoadManager() override
size_t getNumberOfThreads() const override
Returns the number of io_context (I/O worker) threads used by the application.
PendingSaves pendingSaves_
ManifestCache & getValidatorManifests() override
std::atomic< bool > checkSigs_
bool checkSigs() const override
ManifestCache & getPublisherManifests() override
void signalStop(std::string const &msg) override
bool serverOkay(std::string &reason) override
resource::Manager & getResourceManager() override
InboundTransactions & getInboundTransactions() override
SHAMapStore & getSHAMapStore() override
boost::asio::steady_timer sweepTimer_
boost::asio::signal_set signals_
TaggedCache< UInt256, AcceptedLedger > acceptedLedgerCache_
bool loadOldLedger(std::string const &ledgerID, bool replay, bool isFilename, std::optional< UInt256 > trapTxID)
boost::asio::steady_timer entropyTimer_
std::unique_ptr< Overlay > overlay_
bool setup(boost::program_options::variables_map const &cmdline) override
bool initRelationalDatabase()
std::unique_ptr< OrderBookDB > orderBookDB_
std::unique_ptr< Config > config_
std::unique_ptr< ManifestCache > validatorManifests_
std::unique_ptr< LoadFeeTrack > feeTrack_
CollectorManager & getCollectorManager() override
std::unique_ptr< NetworkOPs > networkOPs_
NetworkOPs & getOPs() override
std::unique_ptr< ValidatorList > validators_
std::unique_ptr< TxQ > txQ_
static std::size_t numberOfThreads(Config const &config)
std::unique_ptr< ManifestCache > publisherManifests_
CachedSLEs & getCachedSLEs() override
LedgerIndex getMaxDisallowedLedger() override
Ensure that a newly-started validator does not sign proposals older than the last ledger it persisted...
NodeCache & getTempNodeCache() override
void setMaxDisallowedLedger()
ApplicationImp(std::unique_ptr< Config > config, std::unique_ptr< Logs > logs, std::unique_ptr< TimeKeeper > timeKeeper)
std::unique_ptr< PeerReservationTable > peerReservations_
Cluster & getCluster() override
std::pair< PublicKey, SecretKey > const & nodeIdentity() override
std::unique_ptr< Logs > logs_
NetworkIDService & getNetworkIDService() override
std::atomic_flag isTimeToStop
std::optional< SQLiteDatabase > relationalDatabase_
OpenLedger const & getOpenLedger() const override
std::shared_ptr< Ledger > getLastFullLedger()
std::unique_ptr< GRPCServer > grpcServer_
std::unique_ptr< ServerHandler > serverHandler_
Application & getApp() override
TaggedCache< UInt256, AcceptedLedger > & getAcceptedLedgerCache() override
ValidatorKeys const validatorKeys_
std::uint64_t instanceID() const override
Returns a 64-bit instance identifier, generated at startup.
OrderBookDB & getOrderBookDB() override
Family & getNodeFamily() override
RCLValidations validations_
PeerReservationTable & getPeerReservations() override
Config & config() override
DatabaseCon & getWalletDB() override
Retrieve the "wallet database".
std::optional< UInt256 > trapTxID_
bool isStopping() const override
std::unique_ptr< TimeKeeper > timeKeeper_
std::unique_ptr< LedgerMaster > ledgerMaster_
void gotTXSet(std::shared_ptr< SHAMap > const &set, bool fromAcquire) const
std::unique_ptr< ValidatorSite > validatorSites_
Logs & getLogs() override
std::unique_ptr< CollectorManager > collectorManager_
std::shared_ptr< Ledger > loadLedgerFromFile(std::string const &ledgerID)
PathRequestManager & getPathRequestManager() override
std::uint64_t const instanceCookie_
IOLatencySampler io_latency_sampler_
LedgerCleaner & getLedgerCleaner() override
std::unique_ptr< AmendmentTable > amendmentTable_
std::atomic< LedgerIndex > maxDisallowedLedger_
AmendmentTable & getAmendmentTable() override
std::unique_ptr< JobQueue > jobQueue_
int fdRequired() const override
beast::Journal getJournal(std::string const &name) override
bool initNodeStore() const
TransactionMaster txMaster_
std::unique_ptr< LedgerReplayer > ledgerReplayer_
void startGenesisLedger()
LedgerMaster & getLedgerMaster() override
std::unique_ptr< DatabaseCon > walletDB_
std::optional< UInt256 > const & getTrapTxID() const override
ValidatorSite & getValidatorSites() override
std::unique_ptr< Cluster > cluster_
std::unique_ptr< InboundLedgers > inboundLedgers_
PendingSaves & getPendingSaves() override
std::unique_ptr< LoadManager > loadManager_
Overlay & getOverlay() override
JobQueue & getJobQueue() override
ServerHandler & getServerHandler() override
void onWrite(beast::PropertyStream::Map &stream) override
Subclass override.
perf::PerfLog & getPerfLog() override
std::unique_ptr< NetworkIDService > networkIDService_
std::unique_ptr< node_store::Database > nodeStore_
std::recursive_mutex MutexType
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
bool exists(std::string const &name) const
Returns true if a section with the given name exists.
The role of a ClosureCounter is to assist in shutdown by letting callers wait for the completion of c...
Provides the beast::insight::Collector service.
Routing table for objects identified by hash.
Manages the lifetime of inbound ledgers.
Manages the acquisition and lifetime of transaction sets.
A pool of threads to perform work.
Check the ledger/transaction databases to make sure they have continuity.
Tracks the current ledger and any ledgers in the process of closing.
Manages the lifetime of ledger replay tasks.
Manages the current fee schedule.
Manages partitions for logging.
Remembers manifests with the highest sequence number.
std::chrono::time_point< NetClock > time_point
Service that provides access to the network ID.
Provides server functionality for clients.
A node_store::Scheduler which uses the JobQueue.
Represents the open ledger.
Writable ledger view that accumulates state and tx changes.
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.
Tracks order books in the ledger.
Manages the set of connected peers.
static void initPathTable()
Keeps track of which ledgers haven't been fully saved.
static std::unique_ptr< ResolverAsio > make(boost::asio::io_context &, beast::Journal)
Rules controlling protocol behavior.
class to create database, launch online delete thread, and related SQLite database
A serialized ledger entry, commonly abbreviated "SLE".
Holds the serialized result of parsing an input JSON object.
std::optional< STObject > object
The STObject if the parse was successful.
Holds a collection of configuration values.
std::size_t size() const
Returns the number of items in the container.
Manages various times used by the server.
Validator keys and manifest as set in configuration file.
Persistency layer for NodeObject.
Simple NodeStore Scheduler that just performs the tasks synchronously.
virtual std::unique_ptr< Database > makeDatabase(std::size_t burstSize, Scheduler &scheduler, int readThreads, Section const &backendParameters, beast::Journal journal)=0
Construct a NodeStore database.
static Manager & instance()
Returns the instance of the manager singleton.
Singleton class that maintains performance counters and optionally writes Json-formatted data to a di...
An endpoint that consumes resources.
Tracks load and resource consumption.
T duration_cast(T... args)
T emplace_back(T... args)
T hardware_concurrency(T... args)
constexpr Out lexicalCastThrow(In in)
Convert from one type to another, throw on error.
Severity
Severity level / threshold of a Journal message.
constexpr bool lexicalCastChecked(Out &out, In in)
Intelligently convert from one type to another.
constexpr Out lexicalCast(In in, Out defaultValue=Out())
Convert from one type to another.
BasicLogstream< char > LogStream
std::string const & getFullVersionString()
Full server version string.
std::string const & getVersionString()
Server version.
std::map< std::string, VoteBehavior > const & supportedAmendments()
Amendments that this server supports and the default voting behavior.
Dummy class for unit tests.
std::unique_ptr< Manager > makeManager(beast::insight::Collector::Ptr const &collector, beast::Journal journal)
Charge const kFeeReferenceRpc
API version numbers used in later API versions.
static constexpr auto kApiMaximumSupportedVersion
Status doCommand(rpc::JsonContext &context, json::Value &result)
Execute an RPC command and store the results in a json::Value.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::unique_ptr< CollectorManager > makeCollectorManager(Section const ¶ms, beast::Journal journal)
bool set(T &target, std::string const &name, Section const §ion)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
std::unordered_map< std::string, boost::asio::ip::tcp::endpoint > Endpoints
std::tuple< std::shared_ptr< Ledger >, std::uint32_t, UInt256 > getLatestLedger(Rules const &rules, Fees const &fees, ServiceRegistry ®istry)
Fetch the ledger with the highest sequence contained in the database.
std::unique_ptr< AmendmentTable > makeAmendmentTable(ServiceRegistry ®istry, std::chrono::seconds majorityTime, std::vector< AmendmentTable::FeatureInfo > const &supported, Section const &enabled, Section const &vetoed, beast::Journal journal)
ServerHandler::Setup setupServerHandler(Config const &config, std::ostream &log)
@ SigGoodOnly
Signature is good, but local checks fail.
beast::Journal debugLog()
Returns a debug journal.
std::uint32_t LedgerIndex
A ledger index.
CreateGenesisT const kCreateGenesis
Stopwatch & stopwatch()
Returns an instance of a wall clock.
void addJson(json::Value &json, LedgerFill const &fill)
Given a Ledger and options, fill a json::Value with a description of the ledger.
std::optional< UInt256 > getRegisteredFeature(std::string const &name)
std::unique_ptr< SHAMapStore > makeSHAMapStore(Application &app, node_store::Scheduler &scheduler, beast::Journal journal)
std::unique_ptr< InboundLedgers > makeInboundLedgers(Application &app, InboundLedgers::ClockType &clock, beast::insight::Collector::Ptr const &collector)
std::pair< PublicKey, SecretKey > getNodeIdentity(soci::session &session)
Returns a stable public and private key for this node.
std::unique_ptr< NetworkOPs > makeNetworkOPs(ServiceRegistry ®istry, NetworkOPs::ClockType &clock, bool standalone, std::size_t minPeerCount, bool startValid, JobQueue &jobQueue, LedgerMaster &ledgerMaster, ValidatorKeys const &validatorKeys, boost::asio::io_context &ioSvc, beast::Journal journal, beast::insight::Collector::Ptr const &collector)
CsprngEngine & cryptoPrng()
The default cryptographically secure PRNG.
std::shared_ptr< Ledger > loadByIndex(std::uint32_t ledgerIndex, Rules const &rules, Fees const &fees, ServiceRegistry ®istry, bool acquire)
Load a ledger by its sequence number.
std::string to_string(BaseUInt< Bits, Tag > const &a)
void logicError(std::string const &how) noexcept
Called when faulty logic causes a broken invariant.
TaggedCache< UInt256, SLE const > CachedSLEs
static constexpr std::uint32_t kXrpLedgerEarliestFees
The XRP Ledger mainnet's earliest ledger with a FeeSettings object.
void forceValidity(HashRouter &router, UInt256 const &txid, Validity validity)
Sets the validity of a given transaction in the cache.
std::unique_ptr< LedgerCleaner > makeLedgerCleaner(Application &app, beast::Journal journal)
constexpr auto megabytes(T value) noexcept
std::shared_ptr< Ledger > loadByHash(UInt256 const &ledgerHash, Rules const &rules, Fees const &fees, ServiceRegistry ®istry, bool acquire)
Load a ledger by its hash.
static void fixConfigPorts(Config &config, Endpoints const &endpoints)
std::unique_ptr< ServerHandler > makeServerHandler(Application &app, boost::asio::io_context &ioContext, JobQueue &jobQueue, NetworkOPs &networkOPs, resource::Manager &resourceManager, CollectorManager &cm)
std::unique_ptr< PeerSetBuilder > makePeerSetBuilder(Application &app)
json::Value getJson(LedgerFill const &fill)
Return a new json::Value representing the ledger with given options.
Validations< RCLValidationsAdaptor > RCLValidations
Alias for RCL-specific instantiation of generic Validations.
Integral randInt(Engine &engine, Integral min, Integral max)
Return a uniformly distributed random integer.
std::unique_ptr< DatabaseCon > makeWalletDB(DatabaseCon::Setup const &setup, beast::Journal j)
makeWalletDB Opens the wallet database and returns it.
void initAccountIdCache(std::size_t count)
Initialize the global cache used to map AccountID to base58 conversions.
std::unique_ptr< Overlay > makeOverlay(Application &app, Overlay::Setup const &setup, ServerHandler &serverHandler, resource::Manager &resourceManager, Resolver &resolver, boost::asio::io_context &ioContext, BasicConfig const &config, beast::insight::Collector::Ptr const &collector)
Creates the implementation of Overlay.
constexpr std::size_t trustedManifestCount(std::optional< std::size_t > const &configured)
Number of trusted manifests allowed in a Manifest message.
std::unique_ptr< Application > makeApplication(std::unique_ptr< Config > config, std::unique_ptr< Logs > logs, std::unique_ptr< TimeKeeper > timeKeeper)
MallocTrimReport mallocTrim(std::string_view tag, beast::Journal journal)
Attempt to return freed memory to the operating system.
std::unique_ptr< PeerSet > makeDummyPeerSet(Application &app)
Make a dummy PeerSet that does not do anything.
std::unique_ptr< LoadManager > makeLoadManager(Application &app, beast::Journal journal)
DatabaseCon::Setup setupDatabaseCon(Config const &c, std::optional< beast::Journal > j=std::nullopt)
TaggedCache< SHAMapHash, Blob > NodeCache
HashRouter::Setup setupHashRouter(Config const &config)
Create HashRouter setup from configuration.
constexpr std::size_t untrustedManifestCount(std::optional< std::size_t > const &configured)
Number of untrusted manifests to store in cache and allowed in one Manifest message.
@ SYNCING
fallen slightly behind
FeeSettingsEntry< ReadView > FeeSettingsEntryR
Overlay::Setup setupOverlay(BasicConfig const &config, beast::Journal j)
SQLiteDatabase setupRelationalDatabase(ServiceRegistry ®istry, Config const &config, JobQueue &jobQueue)
setupRelationalDatabase Creates and returns a SQLiteDatabase instance based on configuration.
TxQ::Setup setupTxQ(Config const &config)
Build a TxQ::Setup object from application configuration.
std::unique_ptr< InboundTransactions > makeInboundTransactions(Application &app, beast::insight::Collector::Ptr const &collector, std::function< void(std::shared_ptr< SHAMap > const &, bool)> gotSet)
std::unique_ptr< OrderBookDB > makeOrderBookDb(ServiceRegistry ®istry, OrderBookDBConfig const &config)
Create an OrderBookDB instance.
static constexpr auto kPort
static constexpr auto kValidators
static constexpr auto kValidatorListKeys
static constexpr auto kImportNodeDatabase
static constexpr auto kAmendments
static constexpr auto kRpcStartup
static constexpr auto kValidatorKeyRevocation
static constexpr auto kPortGrpc
static constexpr auto kVetoAmendments
static constexpr auto kClusterNodes
static constexpr auto kInsight
static constexpr auto kValidatorListSites