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/PathRequestManager.h>
39#include <xrpld/rpc/detail/Pathfinder.h>
40#include <xrpld/shamap/NodeFamily.h>
42#include <xrpl/basics/ByteUtilities.h>
43#include <xrpl/basics/Log.h>
44#include <xrpl/basics/MallocTrim.h>
45#include <xrpl/basics/ResolverAsio.h>
46#include <xrpl/basics/ToString.h>
47#include <xrpl/basics/base_uint.h>
48#include <xrpl/basics/chrono.h>
49#include <xrpl/basics/contract.h>
50#include <xrpl/basics/random.h>
51#include <xrpl/beast/asio/io_latency_probe.h>
52#include <xrpl/beast/core/LexicalCast.h>
53#include <xrpl/beast/insight/Event.h>
54#include <xrpl/beast/utility/Journal.h>
55#include <xrpl/beast/utility/PropertyStream.h>
56#include <xrpl/beast/utility/instrumentation.h>
57#include <xrpl/config/BasicConfig.h>
58#include <xrpl/config/Constants.h>
59#include <xrpl/core/ClosureCounter.h>
60#include <xrpl/core/HashRouter.h>
61#include <xrpl/core/Job.h>
62#include <xrpl/core/NetworkIDService.h>
63#include <xrpl/core/PeerReservationTable.h>
64#include <xrpl/core/PerfLog.h>
65#include <xrpl/core/StartUpType.h>
66#include <xrpl/crypto/csprng.h>
67#include <xrpl/json/json_forwards.h>
68#include <xrpl/json/json_reader.h>
69#include <xrpl/json/json_value.h>
70#include <xrpl/ledger/AmendmentTable.h>
71#include <xrpl/ledger/Ledger.h>
72#include <xrpl/ledger/OpenView.h>
73#include <xrpl/ledger/PendingSaves.h>
74#include <xrpl/nodestore/Database.h>
75#include <xrpl/nodestore/DummyScheduler.h>
76#include <xrpl/nodestore/NodeObject.h>
77#include <xrpl/protocol/AccountID.h>
78#include <xrpl/protocol/ApiVersion.h>
79#include <xrpl/protocol/BuildInfo.h>
80#include <xrpl/protocol/Feature.h>
81#include <xrpl/protocol/Indexes.h>
82#include <xrpl/protocol/Protocol.h>
83#include <xrpl/protocol/STParsedJSON.h>
84#include <xrpl/protocol/Serializer.h>
85#include <xrpl/protocol/SystemParameters.h>
86#include <xrpl/protocol/jss.h>
87#include <xrpl/rdb/DatabaseCon.h>
88#include <xrpl/resource/Charge.h>
89#include <xrpl/resource/Consumer.h>
90#include <xrpl/resource/Fees.h>
91#include <xrpl/resource/ResourceManager.h>
92#include <xrpl/server/LoadFeeTrack.h>
93#include <xrpl/server/NetworkOPs.h>
94#include <xrpl/server/Wallet.h>
95#include <xrpl/server/detail/ServerImpl.h>
96#include <xrpl/shamap/FullBelowCache.h>
97#include <xrpl/shamap/SHAMap.h>
98#include <xrpl/shamap/SHAMapMissingNode.h>
99#include <xrpl/shamap/TreeNodeCache.h>
100#include <xrpl/tx/apply.h>
102#include <boost/algorithm/string/predicate.hpp>
103#include <boost/asio/error.hpp>
104#include <boost/asio/io_context.hpp>
105#include <boost/asio/signal_set.hpp>
106#include <boost/asio/steady_timer.hpp>
107#include <boost/lexical_cast/bad_lexical_cast.hpp>
108#include <boost/program_options/variables_map.hpp>
109#include <boost/system/detail/errc.hpp>
110#include <boost/system/detail/error_code.hpp>
111#include <boost/system/system_error.hpp>
113#include <date/date.h>
157 boost::asio::io_context& ios)
168 template <
class Duration>
177 if (lastSample >= 10ms)
178 event_.notify(lastSample);
179 if (lastSample >= 500ms)
181 JLOG(
journal_.warn()) <<
"io_context latency = " << lastSample.count();
285#if XRPL_SINGLE_IO_SERVICE_THREAD
296 if ((cores == 1) || ((
config.nodeSize == 0) && (cores == 2)))
321 logs_->journal(
"PerfLog"),
326 logs_->journal(
"Collector")))
357 logs_->journal(
"JobQueue"),
365 std::chrono::seconds{90},
367 logs_->journal(
"TaggedCache"))
371 std::chrono::minutes(1),
373 logs_->journal(
"CachedSLEs"))
383 {.pathSearchMax =
config_->pathSearchMax, .standalone =
config_->standalone()}))
387 logs_->journal(
"PathRequest"),
394 logs_->journal(
"LedgerMaster")))
404 [
this](std::shared_ptr<SHAMap>
const&
set,
bool fromAcquire) {
405 gotTXSet(set, fromAcquire);
412 std::chrono::minutes{1},
414 logs_->journal(
"TaggedCache"))
425 logs_->journal(
"NetworkOPs"),
437 config_->legacy(
"database_path"),
438 logs_->journal(
"ValidatorList"),
460 logs_->journal(
"Application"),
461 std::chrono::milliseconds(100),
490 setup(boost::program_options::variables_map
const& cmdline)
override;
492 start(
bool withTimers)
override;
556 logicError(
"Accessing Application::nodeIdentity() before it is initialized.");
579 "xrpl::ApplicationImp::getServerHandler : non-null server "
584 boost::asio::io_context&
794 XRPL_ASSERT(
overlay_,
"xrpl::ApplicationImp::overlay : non-null overlay");
801 XRPL_ASSERT(
txQ_,
"xrpl::ApplicationImp::getTxQ : non-null transaction queue");
810 "xrpl::ApplicationImp::getRelationalDatabase : non-null relational database");
817 XRPL_ASSERT(
walletDB_,
"xrpl::ApplicationImp::getWalletDB : non-null wallet database");
834 "xrpl::ApplicationImp::initRelationalDatabase : null wallet "
843 setup.useGlobalPragma =
false;
849 JLOG(
journal_.fatal()) <<
"Failed to initialize SQL databases: " << e.
what();
861 auto j =
logs_->journal(
"NodeObject");
871 JLOG(j.warn()) <<
"Starting node import from '" << source->getName() <<
"' to '"
880 JLOG(j.warn()) <<
"Node import from '" << source->getName() <<
"' took "
881 << elapsed.count() <<
" seconds.";
903 if (
auto optionalCountedHandler =
905 if (e.value() == boost::system::errc::success)
907 jobQueue_->addJob(JtSweep,
"sweep", [this]() { doSweep(); });
910 if (e.value() != boost::system::errc::success &&
911 e.value() != boost::asio::error::operation_aborted)
914 JLOG(journal_.error())
915 <<
"Sweep timer got error '" << e.message() <<
"'. Restarting timer.";
924 sweepTimer_.async_wait(std::move(*optionalCountedHandler));
932 if (
auto optionalCountedHandler =
934 if (e.value() == boost::system::errc::success)
936 cryptoPrng().mixEntropy();
940 if (e.value() != boost::system::errc::success &&
941 e.value() != boost::asio::error::operation_aborted)
944 JLOG(journal_.error()) <<
"Entropy timer got error '" << e.message()
945 <<
"'. Restarting timer.";
950 using namespace std::chrono_literals;
951 entropyTimer_.expires_after(5
min);
952 entropyTimer_.async_wait(std::move(*optionalCountedHandler));
978 std::size_t const oldFullBelowSize = fullBelowCache->size();
979 std::size_t const oldTreeNodeSize = treeNodeCache->size();
984 <<
"NodeFamily::FullBelowCache sweep. Size before: " << oldFullBelowSize
985 <<
"; size after: " << fullBelowCache->size();
988 <<
"NodeFamily::TreeNodeCache sweep. Size before: " << oldTreeNodeSize
989 <<
"; size after: " << treeNodeCache->size();
999 JLOG(
journal_.debug()) <<
"MasterTransaction sweep. Size before: " << oldMasterTxSize
1000 <<
"; size after: " << masterTxCache.
size();
1012 <<
"LedgerMaster sweep. Size before: " << oldLedgerMasterCacheSize
1021 JLOG(
journal_.debug()) <<
"TempNodeCache sweep. Size before: " << oldTempNodeCacheSize
1033 <<
"Validations Current expire. Size before: " << oldCurrentCacheSize
1037 <<
"Validations SeqEnforcer expire. Size before: " << oldSizeSeqEnforcesSize
1038 <<
"; size after: " <<
getValidations().sizeOfSeqEnforcersCache();
1041 <<
"Validations ByLedger expire. Size before: " << oldByLedgerSize
1045 <<
"Validations BySequence expire. Size before: " << oldBySequenceSize
1054 <<
"InboundLedgers sweep. Size before: " << oldInboundLedgersSize
1064 JLOG(
journal_.debug()) <<
"LedgerReplayer tasks sweep. Size before: " << oldTasksSize
1067 JLOG(
journal_.debug()) <<
"LedgerReplayer deltas sweep. Size before: " << oldDeltasSize
1071 <<
"LedgerReplayer skipLists sweep. Size before: " << oldSkipListsSize
1080 <<
"AcceptedLedgerCache sweep. Size before: " << oldAcceptedLedgerSize
1088 JLOG(
journal_.debug()) <<
"CachedSLEs sweep. Size before: " << oldCachedSLEsSize
1122 startGenesisLedger();
1125 getLastFullLedger();
1138 setMaxDisallowedLedger();
1163 signals_.async_wait([
this](boost::system::error_code
const& ec,
int signum) {
1165 if (ec == boost::asio::error::operation_aborted)
1168 JLOG(
journal_.info()) <<
"Received signal " << signum;
1170 if (signum == SIGTERM || signum == SIGINT)
1185 if (
logs_->threshold() > Severity::Debug)
1186 logs_->threshold(Severity::Debug);
1194 JLOG(
journal_.warn()) <<
"Limited to a single I/O service thread by "
1195 "system configuration.";
1206 JLOG(
journal_.fatal()) <<
"Cannot find peer reservations!";
1215 auto const supported = []() {
1218 supported.
reserve(amendments.size());
1219 for (
auto const& [a, vote] : amendments)
1222 XRPL_ASSERT(f,
"xrpl::ApplicationImp::setup : registered feature");
1234 config().amendmentMajorityTime,
1238 logs_->journal(
"Amendments"));
1243 auto const startUp =
config_->startUp;
1244 JLOG(
journal_.debug()) <<
"startUp: " << startUp;
1247 JLOG(
journal_.info()) <<
"Starting new Ledger";
1255 JLOG(
journal_.info()) <<
"Loading specified Ledger";
1263 JLOG(
journal_.error()) <<
"The specified ledger could not be loaded.";
1290 if (
auto const& forcedRange =
config().forcedLedgerRangePresent)
1292 ledgerMaster_->setLedgerRangePresent(forcedRange->first, forcedRange->second);
1301 JLOG(
journal_.fatal()) <<
"Invalid entry in cluster configuration.";
1311 "ValidatorManifests",
1315 JLOG(
journal_.fatal()) <<
"Invalid configured validator manifest.";
1336 config().validatorListThreshold))
1338 JLOG(
journal_.fatal()) <<
"Invalid entry in validator configuration.";
1377 JLOG(
journal_.fatal()) <<
"Unable to start consensus";
1386 setup.makeContexts();
1392 if (
auto stream =
journal_.fatal())
1394 stream <<
"Unable to setup server handler";
1396 stream <<
": " << e.
what();
1409 JLOG(
journal_.warn()) <<
"No outbound peer connections will be made";
1418 JLOG(
journal_.warn()) <<
"Running in standalone mode";
1425 JLOG(
journal_.warn()) <<
"*** The server is configured to allow the "
1426 "'sign' and 'sign_for'";
1427 JLOG(
journal_.warn()) <<
"*** commands. These commands have security "
1428 "implications and have";
1429 JLOG(
journal_.warn()) <<
"*** been deprecated. They will be removed "
1430 "in a future release of";
1431 JLOG(
journal_.warn()) <<
"*** xrpld.";
1432 JLOG(
journal_.warn()) <<
"*** If you do not use them to sign "
1433 "transactions please edit your";
1434 JLOG(
journal_.warn()) <<
"*** configuration file and remove the [enable_signing] stanza.";
1435 JLOG(
journal_.warn()) <<
"*** If you do use them to sign transactions "
1436 "please migrate to a";
1437 JLOG(
journal_.warn()) <<
"*** standalone signing solution as soon as possible.";
1448 if (!jrReader.
parse(cmd, jvCommand))
1464 .loadType = loadType,
1527 JLOG(
journal_.debug()) <<
"Application stopping";
1551 catch (boost::system::system_error
const& e)
1553 JLOG(
journal_.error()) <<
"Application: sweepTimer cancel error: " << e.what();
1560 catch (boost::system::system_error
const& e)
1562 JLOG(
journal_.error()) <<
"Application: entropyTimer cancel error: " << e.what();
1568 using namespace std::chrono_literals;
1608 if (!
isTimeToStop.test_and_set(std::memory_order_acquire))
1612 JLOG(
journal_.warn()) <<
"Server stopping";
1616 JLOG(
journal_.warn()) <<
"Server stopping: " << msg;
1682 next->updateSkipList();
1685 "xrpl::ApplicationImp::startGenesisLedger : valid ledger fees");
1686 next->setImmutable();
1699 auto const [ledger, seq,
hash] =
1707 "xrpl::ApplicationImp::getLastFullLedger : valid ledger fees");
1708 ledger->setImmutable();
1711 ledger->setValidated();
1713 if (ledger->header().hash ==
hash)
1715 JLOG(j.trace()) <<
"Loaded ledger: " <<
hash;
1719 if (
auto stream = j.error())
1721 stream <<
"Failed on ledger";
1731 JLOG(j.warn()) <<
"Ledger in database: " << mn.
what();
1745 JLOG(
journal_.fatal()) <<
"Unable to open file '" <<
name <<
"'";
1752 if (!reader.
parse(ledgerFile, jLedger))
1754 JLOG(
journal_.fatal()) <<
"Unable to parse ledger JSON";
1761 if (ledger.
get().isMember(
"result"))
1762 ledger = ledger.
get()[
"result"];
1764 if (ledger.
get().isMember(
"ledger"))
1765 ledger = ledger.
get()[
"ledger"];
1769 using namespace std::chrono_literals;
1770 auto closeTimeResolution = 30s;
1771 bool closeTimeEstimated =
false;
1774 if (ledger.
get().isMember(
"accountState"))
1776 if (ledger.
get().isMember(jss::ledger_index))
1778 seq = ledger.
get()[jss::ledger_index].asUInt();
1781 if (ledger.
get().isMember(
"close_time"))
1784 using d = tp::duration;
1785 closeTime = tp{d{ledger.
get()[
"close_time"].asUInt()}};
1787 if (ledger.
get().isMember(
"close_time_resolution"))
1790 closeTimeResolution =
seconds{ledger.
get()[
"close_time_resolution"].asUInt()};
1792 if (ledger.
get().isMember(
"close_time_estimated"))
1794 closeTimeEstimated = ledger.
get()[
"close_time_estimated"].asBool();
1796 if (ledger.
get().isMember(
"total_coins"))
1802 ledger = ledger.
get()[
"accountState"];
1805 if (!ledger.
get().isArrayOrNull())
1807 JLOG(
journal_.fatal()) <<
"State nodes must be an array";
1813 loadLedger->setTotalDrops(totalDrops);
1821 JLOG(
journal_.fatal()) <<
"Invalid entry in ledger";
1829 JLOG(
journal_.fatal()) <<
"Invalid entry in ledger";
1839 JLOG(
journal_.fatal()) <<
"Invalid entry in ledger";
1847 if (!loadLedger->addSLE(sle))
1849 JLOG(
journal_.fatal()) <<
"Couldn't add serialized ledger: " << uIndex;
1859 "xrpl::ApplicationImp::loadLedgerFromFile : valid ledger fees");
1860 loadLedger->setAccepted(closeTime, closeTimeResolution, !closeTimeEstimated);
1866 JLOG(
journal_.fatal()) <<
"Ledger contains invalid data: " << x.
what();
1884 if (!ledgerID.
empty())
1887 else if (ledgerID.
length() == 64)
1891 if (
hash.parseHex(ledgerID))
1906 if (il->checkLocal())
1907 loadLedger = il->getLedger();
1911 else if (ledgerID.
empty() || boost::iequals(ledgerID,
"latest"))
1935 replayLedger = loadLedger;
1937 JLOG(
journal_.info()) <<
"Loading parent ledger";
1940 replayLedger->header().parentHash,
1941 Rules{config_->features},
1946 JLOG(
journal_.info()) <<
"Loading parent ledger from node store";
1951 replayLedger->header().parentHash,
1957 if (il->checkLocal())
1958 loadLedger = il->getLedger();
1963 JLOG(
journal_.fatal()) <<
"Replay ledger missing/damaged";
1965 "xrpl::ApplicationImp::loadOldLedger : replay ledger "
1972 using namespace std::chrono_literals;
1973 using namespace date;
1976 if (loadLedger->header().closeTime < kLedgerWarnTimePoint)
1978 JLOG(
journal_.fatal()) <<
"\n\n*** WARNING ***\n"
1979 "You are replaying a ledger from before "
1982 "This replay will not handle your ledger as it was "
1984 "handled.\nConsider running an earlier version of xrpld "
1986 "get the older rules.\n*** CONTINUING ***\n";
1989 JLOG(
journal_.info()) <<
"Loading ledger " << loadLedger->header().hash
1990 <<
" seq:" << loadLedger->header().seq;
1992 if (loadLedger->header().accountHash.isZero())
1995 JLOG(
journal_.fatal()) <<
"Ledger is empty.";
1996 UNREACHABLE(
"xrpl::ApplicationImp::loadOldLedger : ledger is empty");
2001 if (!loadLedger->walkLedger(
getJournal(
"Ledger"),
true))
2004 JLOG(
journal_.fatal()) <<
"Ledger is missing nodes.";
2006 "xrpl::ApplicationImp::loadOldLedger : ledger is missing "
2012 if (!loadLedger->isSensible())
2016 j[jss::accountTreeHash] =
to_string(loadLedger->header().accountHash);
2017 j[jss::transTreeHash] =
to_string(loadLedger->header().txHash);
2018 JLOG(
journal_.fatal()) <<
"Ledger is not sensible: " << j;
2020 "xrpl::ApplicationImp::loadOldLedger : ledger is not "
2026 ledgerMaster_->setLedgerRangePresent(loadLedger->header().seq, loadLedger->header().seq);
2029 loadLedger->setValidated();
2039 for (
auto const& [_, tx] : replayData->orderedTxns())
2042 auto txID = tx->getTransactionID();
2043 if (trapTxID == txID)
2046 JLOG(
journal_.debug()) <<
"Trap transaction set: " << txID;
2066 JLOG(
journal_.fatal()) <<
"Ledger " << replayLedger->header().seq
2067 <<
" does not contain the transaction hash " << *trapTxID;
2074 JLOG(
journal_.fatal()) <<
"While loading specified ledger: " << mn.
what();
2077 catch (boost::bad_lexical_cast&)
2079 JLOG(
journal_.fatal()) <<
"Ledger specified '" << ledgerID <<
"' is not valid";
2089 if (!
config().elbSupport)
2094 reason =
"Server is shutting down";
2098 if (
getOPs().isNeedNetworkLedger())
2100 reason =
"Not synchronized with network yet";
2104 if (
getOPs().isAmendmentBlocked())
2106 reason =
"Server version too old";
2110 if (
getOPs().isUNLBlocked())
2112 reason =
"No valid validator list available";
2118 reason =
"Not synchronized with network";
2127 reason =
"Too much load";
2165 std::move(config), std::move(logs), std::move(timeKeeper));
2171 for (
auto const& [name, ep] : endpoints)
2173 if (!config.
exists(name))
2176 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_
Resource::Manager & getResourceManager() override
std::unique_ptr< InboundTransactions > inboundTransactions_
ClosureCounter< void, boost::system::error_code const & > waitHandlerCounter_
NodeStoreScheduler nodeStoreScheduler_
RelationalDatabase & getRelationalDatabase() override
OpenLedger & getOpenLedger() override
TransactionMaster & getMasterTransaction() override
std::chrono::milliseconds getIOLatency() override
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
bool loadOldLedger(std::string const &ledgerID, bool replay, bool isFilename, std::optional< uint256 > trapTxID)
InboundTransactions & getInboundTransactions() override
SHAMapStore & getSHAMapStore() override
boost::asio::steady_timer sweepTimer_
boost::asio::signal_set signals_
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_
std::optional< uint256 > trapTxID_
NetworkOPs & getOPs() override
std::unique_ptr< ValidatorList > validators_
std::unique_ptr< TxQ > txQ_
std::unique_ptr< NodeStore::Database > nodeStore_
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
std::unique_ptr< Resource::Manager > resourceManager_
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".
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
TaggedCache< uint256, AcceptedLedger > acceptedLedgerCache_
bool initNodeStore() const
TransactionMaster txMaster_
std::unique_ptr< LedgerReplayer > ledgerReplayer_
void startGenesisLedger()
LedgerMaster & getLedgerMaster() override
NodeStore::Database & getNodeStore() override
std::unique_ptr< DatabaseCon > walletDB_
ValidatorSite & getValidatorSites() override
std::unique_ptr< Cluster > cluster_
std::unique_ptr< InboundLedgers > inboundLedgers_
std::optional< uint256 > const & getTrapTxID() const override
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.
TaggedCache< uint256, AcceptedLedger > & getAcceptedLedgerCache() override
perf::PerfLog & getPerfLog() override
std::unique_ptr< NetworkIDService > networkIDService_
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.
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 NodeStore::Scheduler which uses the JobQueue.
Persistency layer for NodeObject.
Simple NodeStore Scheduler that just performs the tasks synchronously.
static Manager & instance()
Returns the instance of the manager singleton.
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.
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)
An endpoint that consumes resources.
Tracks load and resource consumption.
Rules controlling protocol behavior.
class to create database, launch online delete thread, and related SQLite database
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.
Singleton class that maintains performance counters and optionally writes Json-formatted data to a di...
T duration_cast(T... args)
T emplace_back(T... args)
T hardware_concurrency(T... args)
Out lexicalCastThrow(In in)
Convert from one type to another, throw on error.
Out lexicalCast(In in, Out defaultValue=Out())
Convert from one type to another.
Severity
Severity level / threshold of a Journal message.
bool lexicalCastChecked(Out &out, In in)
Intelligently convert from one type to another.
BasicLogstream< char > logstream
std::string const & getFullVersionString()
Full server version string.
std::string const & getVersionString()
Server version.
static constexpr auto kApiMaximumSupportedVersion
Status doCommand(RPC::JsonContext &context, json::Value &result)
Execute an RPC command and store the results in a json::Value.
std::unique_ptr< Manager > makeManager(beast::insight::Collector::ptr const &collector, beast::Journal journal)
Charge const kFeeReferenceRpc
std::map< std::string, VoteBehavior > const & supportedAmendments()
Amendments that this server supports and the default voting behavior.
Keylet const & feeSettings() noexcept
The (fixed) index of the object containing the ledger fees.
Dummy class for unit tests.
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)
std::unique_ptr< InboundTransactions > makeInboundTransactions(Application &app, beast::insight::Collector::ptr const &collector, std::function< void(std::shared_ptr< SHAMap > const &, bool)> gotSet)
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::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::unordered_map< std::string, boost::asio::ip::tcp::endpoint > Endpoints
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::enable_if_t< std::is_integral_v< Integral > &&detail::is_engine< Engine >::value, Integral > randInt(Engine &engine, Integral min, Integral max)
Return a uniformly distributed random integer.
std::unique_ptr< ServerHandler > makeServerHandler(Application &app, boost::asio::io_context &ioContext, JobQueue &jobQueue, NetworkOPs &networkOPs, Resource::Manager &resourceManager, CollectorManager &cm)
std::pair< PublicKey, SecretKey > getNodeIdentity(soci::session &session)
Returns a stable public and private key for this node.
CsprngEngine & cryptoPrng()
The default cryptographically secure PRNG.
std::unique_ptr< SHAMapStore > makeSHAMapStore(Application &app, NodeStore::Scheduler &scheduler, beast::Journal journal)
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.
static constexpr std::uint32_t kXrpLedgerEarliestFees
The XRP Ledger mainnet's earliest ledger with a FeeSettings object.
std::unique_ptr< LedgerCleaner > makeLedgerCleaner(Application &app, beast::Journal journal)
constexpr auto megabytes(T value) noexcept
static void fixConfigPorts(Config &config, Endpoints const &endpoints)
std::unique_ptr< PeerSetBuilder > makePeerSetBuilder(Application &app)
std::unique_ptr< InboundLedgers > makeInboundLedgers(Application &app, InboundLedgers::clock_type &clock, beast::insight::Collector::ptr const &collector)
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.
std::unique_ptr< NetworkOPs > makeNetworkOPs(ServiceRegistry ®istry, NetworkOPs::clock_type &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)
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.
TaggedCache< uint256, SLE const > CachedSLEs
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< 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.
void forceValidity(HashRouter &router, uint256 const &txid, Validity validity)
Sets the validity of a given transaction in the cache.
@ SYNCING
fallen slightly behind
std::shared_ptr< Ledger > loadByHash(uint256 const &ledgerHash, Rules const &rules, Fees const &fees, ServiceRegistry ®istry, bool acquire)
Load a ledger by its hash.
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.
std::optional< uint256 > getRegisteredFeature(std::string const &name)
TxQ::Setup setupTxQ(Config const &config)
Build a TxQ::Setup object from application configuration.
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