20 #include <ripple/app/consensus/RCLConsensus.h>
21 #include <ripple/app/consensus/RCLValidations.h>
22 #include <ripple/app/ledger/AcceptedLedger.h>
23 #include <ripple/app/ledger/InboundLedgers.h>
24 #include <ripple/app/ledger/LedgerMaster.h>
25 #include <ripple/app/ledger/LedgerToJson.h>
26 #include <ripple/app/ledger/LocalTxs.h>
27 #include <ripple/app/ledger/OpenLedger.h>
28 #include <ripple/app/ledger/OrderBookDB.h>
29 #include <ripple/app/ledger/TransactionMaster.h>
30 #include <ripple/app/main/LoadManager.h>
31 #include <ripple/app/misc/AmendmentTable.h>
32 #include <ripple/app/misc/HashRouter.h>
33 #include <ripple/app/misc/LoadFeeTrack.h>
34 #include <ripple/app/misc/NetworkOPs.h>
35 #include <ripple/app/misc/Transaction.h>
36 #include <ripple/app/misc/TxQ.h>
37 #include <ripple/app/misc/ValidatorKeys.h>
38 #include <ripple/app/misc/ValidatorList.h>
39 #include <ripple/app/misc/impl/AccountTxPaging.h>
40 #include <ripple/app/rdb/RelationalDBInterface.h>
41 #include <ripple/app/reporting/ReportingETL.h>
42 #include <ripple/app/tx/apply.h>
43 #include <ripple/basics/PerfLog.h>
44 #include <ripple/basics/UptimeClock.h>
45 #include <ripple/basics/mulDiv.h>
46 #include <ripple/basics/safe_cast.h>
47 #include <ripple/beast/rfc2616.h>
48 #include <ripple/beast/utility/rngfill.h>
49 #include <ripple/consensus/Consensus.h>
50 #include <ripple/consensus/ConsensusParms.h>
51 #include <ripple/crypto/RFC1751.h>
52 #include <ripple/crypto/csprng.h>
53 #include <ripple/json/to_string.h>
54 #include <ripple/nodestore/DatabaseShard.h>
55 #include <ripple/overlay/Cluster.h>
56 #include <ripple/overlay/Overlay.h>
57 #include <ripple/overlay/predicates.h>
58 #include <ripple/protocol/BuildInfo.h>
59 #include <ripple/protocol/Feature.h>
60 #include <ripple/protocol/STParsedJSON.h>
61 #include <ripple/resource/ResourceManager.h>
62 #include <ripple/rpc/DeliveredAmount.h>
63 #include <ripple/rpc/impl/RPCHelpers.h>
64 #include <boost/asio/ip/host_name.hpp>
65 #include <boost/asio/steady_timer.hpp>
139 std::chrono::system_clock::time_point
start_ =
204 return !(*
this != b);
223 boost::asio::io_service& io_svc,
236 app_.logs().journal(
"FeeVote")),
239 app.getInboundTransactions(),
240 beast::get_abstract_clock<
std::chrono::steady_clock>(),
242 app_.logs().journal(
"LedgerConsensus"))
421 getServerInfo(
bool human,
bool admin,
bool counters)
override;
448 TER terResult)
override;
541 boost::system::error_code ec;
546 <<
"NetworkOPs: heartbeatTimer cancel error: "
555 <<
"NetworkOPs: clusterTimer cancel error: "
560 using namespace std::chrono_literals;
669 template <
class Handler>
671 Handler
const& handler,
673 :
hook(collector->make_hook(handler))
676 "Disconnected_duration"))
679 "Connected_duration"))
681 collector->make_gauge(
"State_Accounting",
"Syncing_duration"))
684 "Tracking_duration"))
686 collector->make_gauge(
"State_Accounting",
"Full_duration"))
689 "Disconnected_transitions"))
692 "Connected_transitions"))
695 "Syncing_transitions"))
698 "Tracking_transitions"))
700 collector->make_gauge(
"State_Accounting",
"Full_transitions"))
729 {
"disconnected",
"connected",
"syncing",
"tracking",
"full"}};
787 static std::string const hostname = boost::asio::ip::host_name();
794 static std::string const shroudedHostId = [
this]() {
800 return shroudedHostId;
815 [
this](boost::system::error_code
const& e) {
816 if ((e.value() == boost::system::errc::success) &&
817 (!m_job_queue.isStopped()))
820 jtNETOP_TIMER,
"NetOPs.heartbeat", [this](Job&) {
821 processHeartbeatTimer();
825 if (e.value() != boost::system::errc::success &&
826 e.value() != boost::asio::error::operation_aborted)
829 JLOG(m_journal.error())
830 <<
"Heartbeat timer got error '" << e.message()
831 <<
"'. Restarting timer.";
846 [
this](boost::system::error_code
const& e) {
847 if ((e.value() == boost::system::errc::success) &&
848 (!m_job_queue.isStopped()))
851 jtNETOP_CLUSTER,
"NetOPs.cluster", [this](Job&) {
852 processClusterTimer();
856 if (e.value() != boost::system::errc::success &&
857 e.value() != boost::asio::error::operation_aborted)
860 JLOG(m_journal.error())
861 <<
"Cluster timer got error '" << e.message()
862 <<
"'. Restarting timer.";
867 using namespace std::chrono_literals;
868 clusterTimer_.expires_from_now(10s);
869 clusterTimer_.async_wait(std::move(*optionalCountedHandler));
892 <<
"Node count (" << numPeers <<
") has fallen "
908 <<
"Node count (" << numPeers <<
") is sufficient.";
934 using namespace std::chrono_literals;
950 protocol::TMCluster cluster;
952 protocol::TMClusterNode& n = *cluster.add_clusternodes();
957 n.set_nodename(node.
name());
961 for (
auto& item : gossip.
items)
963 protocol::TMLoadSource& node = *cluster.add_loadsources();
965 node.set_cost(item.balance);
968 std::make_shared<Message>(cluster, protocol::mtCLUSTER),
1007 auto const txid = trans->getTransactionID();
1010 if ((flags & SF_BAD) != 0)
1012 JLOG(
m_journal.
warn()) <<
"Submitted transaction cached bad";
1027 <<
"Submitted transaction invalid: " << reason;
1033 JLOG(
m_journal.
warn()) <<
"Exception checking transaction" << txid;
1040 auto tx = std::make_shared<Transaction>(trans, reason,
app_);
1058 if ((newFlags & SF_BAD) != 0)
1061 transaction->setStatus(
INVALID);
1072 *transaction->getSTransaction(),
1080 JLOG(
m_journal.
info()) <<
"Transaction has bad signature: " << reason;
1081 transaction->setStatus(
INVALID);
1104 if (transaction->getApplying())
1109 transaction->setApplying();
1130 if (!transaction->getApplying())
1134 transaction->setApplying();
1160 }
while (transaction->getApplying());
1183 assert(!transactions.
empty());
1192 bool changed =
false;
1210 app_, view, e.transaction->getSTransaction(), flags, j);
1211 e.result = result.first;
1212 e.applied = result.second;
1213 changed = changed || result.second;
1223 validatedLedgerIndex = l->info().seq;
1228 e.transaction->clearSubmitResult();
1233 newOL, e.transaction->getSTransaction(), e.result);
1234 e.transaction->setApplied();
1237 e.transaction->setResult(e.result);
1250 <<
"TransactionResult: " << token <<
": " << human;
1255 bool addLocal = e.local;
1260 <<
"Transaction is now included in open ledger";
1261 e.transaction->setStatus(
INCLUDED);
1263 auto const& txCur = e.transaction->getSTransaction();
1269 auto t = std::make_shared<Transaction>(trans, reason,
app_);
1278 e.transaction->setStatus(
OBSOLETE);
1283 <<
"Transaction is likely to claim a"
1284 <<
" fee, but is queued until fee drops";
1286 e.transaction->setStatus(
HELD);
1291 e.transaction->setQueued();
1292 e.transaction->setKept();
1300 <<
"Transaction should be held: " << e.result;
1301 e.transaction->setStatus(
HELD);
1303 e.transaction->setKept();
1309 <<
"Status other than success " << e.result;
1310 e.transaction->setStatus(
INVALID);
1313 auto const enforceFailHard =
1316 if (addLocal && !enforceFailHard)
1320 e.transaction->getSTransaction());
1321 e.transaction->setKept();
1335 protocol::TMTransaction tx;
1338 e.transaction->getSTransaction()->add(s);
1339 tx.set_rawtransaction(s.
data(), s.
size());
1340 tx.set_status(protocol::tsCURRENT);
1341 tx.set_receivetimestamp(
1346 std::make_shared<Message>(tx, protocol::mtTRANSACTION),
1348 e.transaction->setBroadcast();
1352 if (validatedLedgerIndex)
1354 auto [fee, accountSeq, availableSeq] =
1356 *newOL, e.transaction->getSTransaction());
1357 e.transaction->setCurrentLedgerState(
1358 *validatedLedgerIndex, fee, accountSeq, availableSeq);
1366 e.transaction->clearApplying();
1368 if (!submit_held.
empty())
1373 for (
auto& e : submit_held)
1400 for (
auto const& uDirEntry : sleNode->getFieldV256(
sfIndexes))
1405 switch (sleCur->getType())
1408 if (!jvObjects.
isMember(jss::offers))
1409 jvObjects[jss::offers] =
1412 jvObjects[jss::offers].
append(
1417 if (!jvObjects.
isMember(jss::ripple_lines))
1419 jvObjects[jss::ripple_lines] =
1423 jvObjects[jss::ripple_lines].
append(
1439 sleNode = lpLedger->read(
keylet::page(root, uNodeDir));
1518 JLOG(
m_journal.
trace()) <<
"NetworkOPsImp::checkLastClosedLedger";
1525 uint256 closedLedger = ourClosed->info().hash;
1526 uint256 prevClosedLedger = ourClosed->info().parentHash;
1535 <<
"ValidationTrie " <<
Json::Compact(validations.getJsonTrie());
1539 peerCounts[closedLedger] = 0;
1541 peerCounts[closedLedger]++;
1543 for (
auto& peer : peerList)
1545 uint256 peerLedger = peer->getClosedLedgerHash();
1548 ++peerCounts[peerLedger];
1551 for (
auto const& it : peerCounts)
1552 JLOG(
m_journal.
debug()) <<
"L: " << it.first <<
" n=" << it.second;
1554 uint256 preferredLCL = validations.getPreferredLCL(
1559 bool switchLedgers = preferredLCL != closedLedger;
1561 closedLedger = preferredLCL;
1563 if (switchLedgers && (closedLedger == prevClosedLedger))
1566 JLOG(
m_journal.
info()) <<
"We won't switch to our own previous ledger";
1567 networkClosed = ourClosed->info().hash;
1568 switchLedgers =
false;
1571 networkClosed = closedLedger;
1589 networkClosed = ourClosed->info().hash;
1593 JLOG(
m_journal.
warn()) <<
"We are not running on the consensus ledger";
1619 <<
"JUMP last closed ledger to " << newLCL->info().hash;
1655 protocol::TMStatusChange s;
1656 s.set_newevent(protocol::neSWITCHED_LEDGER);
1657 s.set_ledgerseq(newLCL->info().seq);
1659 s.set_ledgerhashprevious(
1660 newLCL->info().parentHash.begin(), newLCL->info().parentHash.size());
1661 s.set_ledgerhash(newLCL->info().hash.begin(), newLCL->info().hash.size());
1664 send_always(std::make_shared<Message>(s, protocol::mtSTATUS_CHANGE)));
1674 JLOG(
m_journal.
info()) <<
"Consensus time for #" << closingInfo.seq
1675 <<
" with LCL " << closingInfo.parentHash;
1684 JLOG(
m_journal.
warn()) <<
"Don't have LCL, going to tracking";
1691 assert(prevLedger->info().hash == closingInfo.parentHash);
1693 closingInfo.parentHash ==
1700 closingInfo.parentCloseTime,
1705 if (!changes.
added.empty() || !changes.
removed.empty())
1740 protocol::TMHaveTransactionSet msg;
1741 msg.set_hash(map->getHash().as_uint256().begin(), 256 / 8);
1742 msg.set_status(protocol::tsHAVE);
1744 send_always(std::make_shared<Message>(msg, protocol::mtHAVE_SET)));
1758 if (it && (it->getClosedLedgerHash() == deadLedger))
1769 if (networkClosed.
isZero())
1798 2 *
current->info().closeTimeResolution))
1826 jvObj[jss::type] =
"manifestReceived";
1829 jvObj[jss::signing_key] =
1833 jvObj[jss::signature] =
strHex(*sig);
1836 jvObj[jss::domain] = mo.
domain;
1842 if (
auto p = i->second.lock())
1844 p->send(jvObj,
true);
1860 , loadBaseServer{loadFeeTrack.getLoadBase()}
1862 , em{std::move(escalationMetrics)}
1872 em.has_value() != b.
em.has_value())
1878 em->minProcessingFeeLevel != b.
em->minProcessingFeeLevel ||
1879 em->openLedgerFeeLevel != b.
em->openLedgerFeeLevel ||
1880 em->referenceFeeLevel != b.
em->referenceFeeLevel);
1913 jvObj[jss::type] =
"serverStatus";
1915 jvObj[jss::load_base] = f.loadBaseServer;
1916 jvObj[jss::load_factor_server] = f.loadFactorServer;
1917 jvObj[jss::base_fee] = f.baseFee.jsonClipped();
1922 safe_cast<std::uint64_t>(f.loadFactorServer),
1924 f.em->openLedgerFeeLevel,
1926 f.em->referenceFeeLevel)
1929 jvObj[jss::load_factor] =
trunc32(loadFactor);
1930 jvObj[jss::load_factor_fee_escalation] =
1931 f.em->openLedgerFeeLevel.jsonClipped();
1932 jvObj[jss::load_factor_fee_queue] =
1933 f.em->minProcessingFeeLevel.jsonClipped();
1934 jvObj[jss::load_factor_fee_reference] =
1935 f.em->referenceFeeLevel.jsonClipped();
1938 jvObj[jss::load_factor] = f.loadFactorServer;
1952 p->send(jvObj,
true);
1969 if (!streamMap.empty())
1972 jvObj[jss::type] =
"consensusPhase";
1973 jvObj[jss::consensus] =
to_string(phase);
1975 for (
auto i = streamMap.begin(); i != streamMap.end();)
1977 if (
auto p = i->second.lock())
1979 p->send(jvObj,
true);
1984 i = streamMap.erase(i);
2000 auto const signerPublic = val->getSignerPublic();
2002 jvObj[jss::type] =
"validationReceived";
2003 jvObj[jss::validation_public_key] =
2005 jvObj[jss::ledger_hash] =
to_string(val->getLedgerHash());
2006 jvObj[jss::signature] =
strHex(val->getSignature());
2007 jvObj[jss::full] = val->isFull();
2008 jvObj[jss::flags] = val->getFlags();
2010 jvObj[jss::data] =
strHex(val->getSerializer().slice());
2015 if (
auto cookie = (*val)[~
sfCookie])
2019 jvObj[jss::validated_hash] =
strHex(*hash);
2021 auto const masterKey =
2024 if (masterKey != signerPublic)
2028 jvObj[jss::ledger_index] =
to_string(*seq);
2033 for (
auto const& amendment : val->getFieldV256(
sfAmendments))
2038 jvObj[jss::close_time] = *closeTime;
2040 if (
auto const loadFee = (*val)[~
sfLoadFee])
2041 jvObj[jss::load_fee] = *loadFee;
2043 if (
auto const baseFee = (*val)[~
sfBaseFee])
2044 jvObj[jss::base_fee] =
static_cast<double>(*baseFee);
2047 jvObj[jss::reserve_base] = *reserveBase;
2050 jvObj[jss::reserve_inc] = *reserveInc;
2055 if (
auto p = i->second.lock())
2057 p->send(jvObj,
true);
2077 jvObj[jss::type] =
"peerStatusChange";
2086 p->send(jvObj,
true);
2100 using namespace std::chrono_literals;
2132 <<
"recvValidation " << val->getLedgerHash() <<
" from " << source;
2162 "This server is amendment blocked, and must be updated to be "
2163 "able to stay in sync with the network.";
2170 "This server has an expired validator list. validators.txt "
2171 "may be incorrectly configured or some [validator_list_sites] "
2172 "may be unreachable.";
2179 "One or more unsupported amendments have reached majority. "
2180 "Upgrade to the latest version before they are activated "
2181 "to avoid being amendment blocked.";
2182 if (
auto const expected =
2186 d[jss::expected_date] = expected->time_since_epoch().count();
2187 d[jss::expected_date_UTC] =
to_string(*expected);
2191 if (warnings.size())
2192 info[jss::warnings] = std::move(warnings);
2205 info[jss::network_id] =
static_cast<Json::UInt>(*netid);
2211 info[jss::time] =
to_string(std::chrono::floor<std::chrono::microseconds>(
2215 info[jss::network_ledger] =
"waiting";
2217 info[jss::validation_quorum] =
2225 info[jss::node_size] =
"tiny";
2228 info[jss::node_size] =
"small";
2231 info[jss::node_size] =
"medium";
2234 info[jss::node_size] =
"large";
2237 info[jss::node_size] =
"huge";
2246 info[jss::validator_list_expires] =
2247 safe_cast<Json::UInt>(when->time_since_epoch().count());
2249 info[jss::validator_list_expires] = 0;
2259 if (*when == TimeKeeper::time_point::max())
2261 x[jss::expiration] =
"never";
2262 x[jss::status] =
"active";
2269 x[jss::status] =
"active";
2271 x[jss::status] =
"expired";
2276 x[jss::status] =
"unknown";
2277 x[jss::expiration] =
"unknown";
2281 info[jss::io_latency_ms] =
2288 info[jss::pubkey_validator] =
toBase58(
2293 info[jss::pubkey_validator] =
"none";
2306 info[jss::counters][jss::nodestore] = nodestore;
2310 info[jss::pubkey_node] =
2316 info[jss::amendment_blocked] =
true;
2331 lastClose[jss::converge_time_s] =
2336 lastClose[jss::converge_time] =
2340 info[jss::last_close] = lastClose;
2349 auto const escalationMetrics =
2357 auto const loadFactorFeeEscalation =
2359 escalationMetrics.openLedgerFeeLevel,
2361 escalationMetrics.referenceFeeLevel)
2365 safe_cast<std::uint64_t>(loadFactorServer),
2366 loadFactorFeeEscalation);
2370 info[jss::load_base] = loadBaseServer;
2371 info[jss::load_factor] =
trunc32(loadFactor);
2372 info[jss::load_factor_server] = loadFactorServer;
2379 info[jss::load_factor_fee_escalation] =
2380 escalationMetrics.openLedgerFeeLevel.jsonClipped();
2381 info[jss::load_factor_fee_queue] =
2382 escalationMetrics.minProcessingFeeLevel.jsonClipped();
2383 info[jss::load_factor_fee_reference] =
2384 escalationMetrics.referenceFeeLevel.jsonClipped();
2388 info[jss::load_factor] =
2389 static_cast<double>(loadFactor) / loadBaseServer;
2391 if (loadFactorServer != loadFactor)
2392 info[jss::load_factor_server] =
2393 static_cast<double>(loadFactorServer) / loadBaseServer;
2398 if (fee != loadBaseServer)
2399 info[jss::load_factor_local] =
2400 static_cast<double>(fee) / loadBaseServer;
2402 if (fee != loadBaseServer)
2403 info[jss::load_factor_net] =
2404 static_cast<double>(fee) / loadBaseServer;
2406 if (fee != loadBaseServer)
2407 info[jss::load_factor_cluster] =
2408 static_cast<double>(fee) / loadBaseServer;
2410 if (escalationMetrics.openLedgerFeeLevel !=
2411 escalationMetrics.referenceFeeLevel &&
2412 (admin || loadFactorFeeEscalation != loadFactor))
2413 info[jss::load_factor_fee_escalation] =
2414 escalationMetrics.openLedgerFeeLevel.decimalFromReference(
2415 escalationMetrics.referenceFeeLevel);
2416 if (escalationMetrics.minProcessingFeeLevel !=
2417 escalationMetrics.referenceFeeLevel)
2418 info[jss::load_factor_fee_queue] =
2419 escalationMetrics.minProcessingFeeLevel
2420 .decimalFromReference(
2421 escalationMetrics.referenceFeeLevel);
2435 XRPAmount const baseFee = lpClosed->fees().base;
2437 l[jss::seq] =
Json::UInt(lpClosed->info().seq);
2438 l[jss::hash] =
to_string(lpClosed->info().hash);
2443 l[jss::reserve_base] =
2444 lpClosed->fees().accountReserve(0).jsonClipped();
2445 l[jss::reserve_inc] = lpClosed->fees().increment.jsonClipped();
2447 lpClosed->info().closeTime.time_since_epoch().count());
2452 l[jss::reserve_base_xrp] =
2453 lpClosed->fees().accountReserve(0).decimalXRP();
2454 l[jss::reserve_inc_xrp] = lpClosed->fees().increment.decimalXRP();
2457 if (std::abs(nowOffset.count()) >= 60)
2458 l[jss::system_time_offset] = nowOffset.count();
2461 if (std::abs(closeOffset.count()) >= 60)
2462 l[jss::close_time_offset] = closeOffset.count();
2469 Json::UInt(age < highAgeThreshold ? age.count() : 0);
2473 auto lCloseTime = lpClosed->info().closeTime;
2475 if (lCloseTime <= closeTime)
2477 using namespace std::chrono_literals;
2478 auto age = closeTime - lCloseTime;
2480 Json::UInt(age < highAgeThreshold ? age.count() : 0);
2486 info[jss::validated_ledger] = l;
2488 info[jss::closed_ledger] = l;
2492 info[jss::published_ledger] =
"none";
2493 else if (lpPublished->info().seq != lpClosed->info().seq)
2494 info[jss::published_ledger] = lpPublished->info().seq;
2497 std::tie(info[jss::state_accounting], info[jss::server_state_duration_us]) =
2502 info[jss::jq_trans_overflow] =
2504 info[jss::peer_disconnects] =
2506 info[jss::peer_disconnects_resources] =
2547 p->send(jvObj,
true);
2568 if (jvObj[jss::validated].asBool())
2580 p->send(jvObj,
true);
2596 for (
auto& jv : jvObj)
2602 else if (jv.isString())
2626 if (jvObj.
isMember(jss::transaction))
2635 << __func__ <<
" : "
2636 <<
"error parsing json for accounts affected";
2645 for (
auto const& affectedAccount : accounts)
2650 auto it = simiIt->second.begin();
2652 while (it != simiIt->second.end())
2663 it = simiIt->second.erase(it);
2670 <<
" iProposed=" << iProposed;
2672 if (!notify.
empty())
2675 isrListener->send(jvObj,
true);
2689 alpAccepted = std::make_shared<AcceptedLedger>(lpAccepted,
app_);
2691 lpAccepted->info().hash, alpAccepted);
2696 <<
"Publishing ledger = " << lpAccepted->info().seq;
2703 jvObj[jss::type] =
"ledgerClosed";
2704 jvObj[jss::ledger_index] = lpAccepted->info().seq;
2705 jvObj[jss::ledger_hash] =
to_string(lpAccepted->info().hash);
2707 lpAccepted->info().closeTime.time_since_epoch().count());
2709 jvObj[jss::fee_ref] = lpAccepted->fees().units.jsonClipped();
2710 jvObj[jss::fee_base] = lpAccepted->fees().base.jsonClipped();
2711 jvObj[jss::reserve_base] =
2712 lpAccepted->fees().accountReserve(0).jsonClipped();
2713 jvObj[jss::reserve_inc] =
2714 lpAccepted->fees().increment.jsonClipped();
2716 jvObj[jss::txn_count] =
Json::UInt(alpAccepted->getTxnCount());
2720 jvObj[jss::validated_ledgers] =
2731 <<
"Publishing ledger = " << lpAccepted->info().seq
2732 <<
" : consumer = " << p->getConsumer()
2733 <<
" : obj = " << jvObj;
2734 p->send(jvObj,
true);
2744 for (
auto const& [_, accTx] : alpAccepted->getMap())
2766 jtCLIENT,
"reportFeeChange->pubServer", [
this](
Job&) {
2777 "reportConsensusStateChange->pubConsensus",
2807 jvObj[jss::type] =
"transaction";
2812 jvObj[jss::ledger_index] = lpCurrent->info().seq;
2813 jvObj[jss::ledger_hash] =
to_string(lpCurrent->info().hash);
2814 jvObj[jss::transaction][jss::date] =
2815 lpCurrent->info().closeTime.time_since_epoch().count();
2816 jvObj[jss::validated] =
true;
2822 jvObj[jss::validated] =
false;
2823 jvObj[jss::ledger_current_index] = lpCurrent->info().seq;
2826 jvObj[jss::status] = bValidated ?
"closed" :
"proposed";
2827 jvObj[jss::engine_result] = sToken;
2828 jvObj[jss::engine_result_code] = terResult;
2829 jvObj[jss::engine_result_message] = sHuman;
2837 if (account != amount.issue().account)
2845 jvObj[jss::transaction][jss::owner_funds] = ownerFunds.getText();
2860 if (
auto const txMeta = alTx.
getMeta())
2864 jvObj[jss::meta], *alAccepted, stTxn, *txMeta);
2877 p->send(jvObj,
true);
2892 p->send(jvObj,
true);
2921 for (
auto const& affectedAccount : alTx.
getAffected())
2926 auto it = simiIt->second.begin();
2928 while (it != simiIt->second.end())
2939 it = simiIt->second.erase(it);
2949 auto it = simiIt->second.begin();
2950 while (it != simiIt->second.end())
2961 it = simiIt->second.erase(it);
2969 <<
"pubAccountTransaction:"
2970 <<
" iProposed=" << iProposed <<
" iAccepted=" << iAccepted;
2972 if (!notify.
empty())
2980 if (
auto const txMeta = alTx.
getMeta())
2984 jvObj[jss::meta], *lpCurrent, stTxn, *txMeta);
2989 isrListener->send(jvObj,
true);
3005 for (
auto const& naAccountID : vnaAccountIDs)
3008 <<
"subAccount: account: " <<
toBase58(naAccountID);
3010 isrListener->insertSubAccountInfo(naAccountID, rt);
3015 for (
auto const& naAccountID : vnaAccountIDs)
3017 auto simIterator = subMap.
find(naAccountID);
3018 if (simIterator == subMap.
end())
3022 usisElement[isrListener->getSeq()] = isrListener;
3024 subMap.
insert(simIterator, make_pair(naAccountID, usisElement));
3029 simIterator->second[isrListener->getSeq()] = isrListener;
3040 for (
auto const& naAccountID : vnaAccountIDs)
3043 isrListener->deleteSubAccountInfo(naAccountID, rt);
3060 for (
auto const& naAccountID : vnaAccountIDs)
3062 auto simIterator = subMap.
find(naAccountID);
3064 if (simIterator != subMap.
end())
3067 simIterator->second.erase(uSeq);
3069 if (simIterator->second.empty())
3072 subMap.
erase(simIterator);
3082 listeners->addSubscriber(isrListener);
3092 listeners->removeSubscriber(uSeq);
3106 Throw<std::runtime_error>(
3107 "Operation only possible in STANDALONE mode.");
3122 jvResult[jss::ledger_index] = lpClosed->info().seq;
3123 jvResult[jss::ledger_hash] =
to_string(lpClosed->info().hash);
3125 lpClosed->info().closeTime.time_since_epoch().count());
3126 jvResult[jss::fee_ref] = lpClosed->fees().units.jsonClipped();
3127 jvResult[jss::fee_base] = lpClosed->fees().base.jsonClipped();
3128 jvResult[jss::reserve_base] =
3129 lpClosed->fees().accountReserve(0).jsonClipped();
3130 jvResult[jss::reserve_inc] = lpClosed->fees().increment.jsonClipped();
3135 jvResult[jss::validated_ledgers] =
3141 .emplace(isrListener->getSeq(), isrListener)
3159 .emplace(isrListener->getSeq(), isrListener)
3187 jvResult[jss::random] =
to_string(uRandom);
3189 jvResult[jss::load_base] = feeTrack.getLoadBase();
3190 jvResult[jss::load_factor] = feeTrack.getLoadFactor();
3191 jvResult[jss::hostid] =
getHostId(admin);
3192 jvResult[jss::pubkey_node] =
3197 .emplace(isrListener->getSeq(), isrListener)
3215 .emplace(isrListener->getSeq(), isrListener)
3233 .emplace(isrListener->getSeq(), isrListener)
3251 .emplace(isrListener->getSeq(), isrListener)
3269 .emplace(isrListener->getSeq(), isrListener)
3287 .emplace(isrListener->getSeq(), isrListener)
3335 if (map.find(pInfo->getSeq()) != map.end())
3342 #ifndef USE_NEW_BOOK_PAGE
3353 unsigned int iLimit,
3363 uint256 uTipIndex = uBookBase;
3367 stream <<
"getBookPage:" << book;
3368 stream <<
"getBookPage: uBookBase=" << uBookBase;
3369 stream <<
"getBookPage: uBookEnd=" << uBookEnd;
3370 stream <<
"getBookPage: uTipIndex=" << uTipIndex;
3379 bool bDirectAdvance =
true;
3383 unsigned int uBookEntry;
3389 while (!bDone && iLimit-- > 0)
3393 bDirectAdvance =
false;
3397 auto const ledgerIndex = view.
succ(uTipIndex, uBookEnd);
3401 sleOfferDir.
reset();
3410 uTipIndex = sleOfferDir->key();
3422 <<
"getBookPage: uTipIndex=" << uTipIndex;
3424 <<
"getBookPage: offerIndex=" << offerIndex;
3434 auto const uOfferOwnerID = sleOffer->getAccountID(
sfAccount);
3435 auto const& saTakerGets = sleOffer->getFieldAmount(
sfTakerGets);
3436 auto const& saTakerPays = sleOffer->getFieldAmount(
sfTakerPays);
3438 bool firstOwnerOffer(
true);
3444 saOwnerFunds = saTakerGets;
3446 else if (bGlobalFreeze)
3454 auto umBalanceEntry = umBalance.
find(uOfferOwnerID);
3455 if (umBalanceEntry != umBalance.
end())
3459 saOwnerFunds = umBalanceEntry->second;
3460 firstOwnerOffer =
false;
3474 if (saOwnerFunds < beast::zero)
3478 saOwnerFunds.
clear();
3486 STAmount saOwnerFundsLimit = saOwnerFunds;
3498 saOwnerFundsLimit =
divide(saOwnerFunds, offerRate);
3501 if (saOwnerFundsLimit >= saTakerGets)
3504 saTakerGetsFunded = saTakerGets;
3510 saTakerGetsFunded = saOwnerFundsLimit;
3512 saTakerGetsFunded.
setJson(jvOffer[jss::taker_gets_funded]);
3516 saTakerGetsFunded, saDirRate, saTakerPays.
issue()))
3517 .setJson(jvOffer[jss::taker_pays_funded]);
3523 saOwnerFunds,
multiply(saTakerGetsFunded, offerRate));
3525 umBalance[uOfferOwnerID] = saOwnerFunds - saOwnerPays;
3529 jvOf[jss::quality] = saDirRate.
getText();
3531 if (firstOwnerOffer)
3532 jvOf[jss::owner_funds] = saOwnerFunds.
getText();
3547 bDirectAdvance =
true;
3552 <<
"getBookPage: offerIndex=" << offerIndex;
3572 unsigned int iLimit,
3580 MetaView lesActive(lpLedger,
tapNONE,
true);
3581 OrderBookIterator obIterator(lesActive, book);
3585 const bool bGlobalFreeze = lesActive.isGlobalFrozen(book.
out.
account) ||
3586 lesActive.isGlobalFrozen(book.
in.
account);
3588 while (iLimit-- > 0 && obIterator.nextOffer())
3593 auto const uOfferOwnerID = sleOffer->getAccountID(
sfAccount);
3594 auto const& saTakerGets = sleOffer->getFieldAmount(
sfTakerGets);
3595 auto const& saTakerPays = sleOffer->getFieldAmount(
sfTakerPays);
3596 STAmount saDirRate = obIterator.getCurrentRate();
3602 saOwnerFunds = saTakerGets;
3604 else if (bGlobalFreeze)
3612 auto umBalanceEntry = umBalance.
find(uOfferOwnerID);
3614 if (umBalanceEntry != umBalance.
end())
3618 saOwnerFunds = umBalanceEntry->second;
3624 saOwnerFunds = lesActive.accountHolds(
3630 if (saOwnerFunds.isNegative())
3634 saOwnerFunds.zero();
3641 STAmount saTakerGetsFunded;
3642 STAmount saOwnerFundsLimit = saOwnerFunds;
3654 saOwnerFundsLimit =
divide(saOwnerFunds, offerRate);
3657 if (saOwnerFundsLimit >= saTakerGets)
3660 saTakerGetsFunded = saTakerGets;
3665 saTakerGetsFunded = saOwnerFundsLimit;
3667 saTakerGetsFunded.setJson(jvOffer[jss::taker_gets_funded]);
3673 multiply(saTakerGetsFunded, saDirRate, saTakerPays.issue()))
3674 .setJson(jvOffer[jss::taker_pays_funded]);
3677 STAmount saOwnerPays = (
parityRate == offerRate)
3680 saOwnerFunds,
multiply(saTakerGetsFunded, offerRate));
3682 umBalance[uOfferOwnerID] = saOwnerFunds - saOwnerPays;
3684 if (!saOwnerFunds.isZero() || uOfferOwnerID == uTakerID)
3688 jvOf[jss::quality] = saDirRate.
getText();
3703 auto const current = std::chrono::duration_cast<std::chrono::microseconds>(
3743 ++counters_[
static_cast<std::size_t>(om)].transitions;
3745 std::chrono::duration_cast<std::chrono::microseconds>(now - start_);
3754 auto [counters, mode, start] = getCounterData();
3755 auto const current = std::chrono::duration_cast<std::chrono::microseconds>(
3766 auto& state = ret[
states_[i]];
3767 state[jss::transitions] = counters[i].transitions;
3768 state[jss::duration_us] =
std::to_string(counters[i].dur.count());
3786 boost::asio::io_service& io_svc,
3790 return std::make_unique<NetworkOPsImp>(
bool unsubValidations(std::uint64_t uListener) override
beast::insight::Hook hook
TxType getTxnType() const
FeeVote::Setup setup_FeeVote(Section const §ion)
Build FeeVote::Setup from a config section.
bool subValidations(InfoSub::ref ispListener) override
void processHeartbeatTimer()
Provides server functionality for clients.
const SF_UINT64 sfIndexNext
ConsensusPhase phase() const
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
void mapComplete(std::shared_ptr< SHAMap > const &map, bool fromAcquire) override
Rate transferRate(ReadView const &view, AccountID const &issuer)
virtual std::chrono::duration< std::int32_t > nowOffset() const =0
bool unsubConsensus(std::uint64_t uListener) override
std::string domain
The domain, if one was specified in the manifest; empty otherwise.
virtual OrderBookDB & getOrderBookDB()=0
A peer's signed, proposed position for use in RCLConsensus.
@ ledgerMaster
ledger master data for signing
bool processTrustedProposal(RCLCxPeerPos proposal) override
virtual Json::Value getInfo()=0
const SF_UINT32 sfReserveBase
virtual Cluster & cluster()=0
std::shared_ptr< ReadView const > getPublishedLedger()
void pubProposedTransaction(std::shared_ptr< ReadView const > const &lpCurrent, std::shared_ptr< STTx const > const &stTxn, TER terResult) override
virtual TaggedCache< uint256, AcceptedLedger > & getAcceptedLedgerCache()=0
std::shared_ptr< OpenView const > current() const
Returns a view to the current open ledger.
ServerFeeSummary mLastFeeSummary
PublicKey localPublicKey() const
Returns local validator public key.
@ proposing
We are normal participant in consensus and propose our position.
boost::asio::steady_timer heartbeatTimer_
PublicKey getMasterKey(PublicKey const &pk) const
Returns ephemeral signing key's master public key.
Json::Value getJson(bool full) const
const std::size_t minPeerCount_
Represents a transfer rate.
void setStateTimer() override
Called to initially start our timers.
void startRound(NetClock::time_point const &now, RCLCxLedger::ID const &prevLgrId, RCLCxLedger const &prevLgr, hash_set< NodeID > const &nowUntrusted, hash_set< NodeID > const &nowTrusted)
Adjust the set of trusted validators and kick-off the next round of consensus.
Stream trace() const
Severity stream access functions.
const SF_UINT32 sfLedgerSequence
std::shared_ptr< STTx const > const & getTxn() const
int getFlags(uint256 const &key)
std::unique_ptr< FeeVote > make_FeeVote(FeeVote::Setup const &setup, beast::Journal journal)
Create an instance of the FeeVote logic.
Changes in trusted nodes after updating validator list.
Data format for exchanging consumption information across peers.
void setAmendmentWarned() override
void pubManifest(Manifest const &) override
bool subPeerStatus(InfoSub::ref ispListener) override
DispatchState mDispatchState
@ arrayValue
array value (ordered list)
std::pair< TER, bool > apply(Application &app, OpenView &view, std::shared_ptr< STTx const > const &tx, ApplyFlags flags, beast::Journal j)
Add a new transaction to the open ledger, hold it in the queue, or reject it.
virtual std::uint64_t getJqTransOverflow() const =0
SubInfoMapType mSubRTAccount
std::atomic< bool > amendmentWarned_
static const std::array< char const *, 5 > states_
@ wrongLedger
We have the wrong ledger and are attempting to acquire it.
LedgerIndex getValidLedgerIndex()
virtual AmendmentTable & getAmendmentTable()=0
void setMode(OperatingMode om) override
std::string const & name() const
Writable ledger view that accumulates state and tx changes.
bool cdirNext(ReadView const &view, uint256 const &uRootIndex, std::shared_ptr< SLE const > &sleNode, unsigned int &uDirEntry, uint256 &uEntryIndex, beast::Journal j)
Decorator for streaming out compact json.
uint256 getBookBase(Book const &book)
std::chrono::microseconds dur
PublicKey signingKey
The ephemeral key associated with this manifest.
bool isUNLBlocked() override
std::string serialized
The manifest in serialized form.
void trustChanged(hash_set< NodeID > const &added, hash_set< NodeID > const &removed)
Update trust status of validations.
void setNeedNetworkLedger() override
bool tryRemoveRpcSub(std::string const &strUrl) override
PublicKey masterKey
The master key associated with this manifest.
STAmount accountHolds(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j)
bool empty() const noexcept
std::string getText() const override
bool recvValidation(std::shared_ptr< STValidation > const &val, std::string const &source) override
void setNegativeUNL(hash_set< PublicKey > const &negUnl)
set the Negative UNL with validators' master public keys
std::string getHostId(bool forAdmin)
void gotTxSet(NetClock::time_point const &now, RCLTxSet const &txSet)
void forwardProposedTransaction(Json::Value const &jvObj) override
csprng_engine & crypto_prng()
The default cryptographically secure PRNG.
Keylet offer(AccountID const &id, std::uint32_t seq) noexcept
An offer from an account.
Rules getValidatedRules()
Json::Value getJson(int c=0)
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
beast::insight::Gauge disconnected_duration
void switchLCL(std::shared_ptr< Ledger const > const &lastClosed)
Keylet child(uint256 const &key) noexcept
Any item that can be in an owner dir.
void consensusViewChange() override
StateAccounting accounting_
std::chrono::milliseconds ledgerGRANULARITY
How often we check state or change positions.
virtual NodeStore::DatabaseShard * getShardStore()=0
const SF_UINT32 sfCloseTime
std::shared_ptr< Ledger const > getLedgerByHash(uint256 const &hash)
void timerEntry(NetClock::time_point const &now)
virtual std::size_t size() const =0
Returns the number of active peers.
void apply(std::unique_lock< std::mutex > &batchLock)
Attempt to apply transactions and post-process based on the results.
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
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)
beast::insight::Gauge syncing_transitions
std::uint32_t getLoadBase() const
std::atomic< bool > unlBlocked_
uint256 getQualityNext(uint256 const &uBase)
virtual TimeKeeper & timeKeeper()=0
virtual MutexType & getMasterMutex()=0
void forwardProposedAccountTransaction(Json::Value const &jvObj) override
virtual OpenLedger & openLedger()=0
void pubLedger(std::shared_ptr< ReadView const > const &lpAccepted) override
bool update(PublicKey const &identity, std::string name, std::uint32_t loadFee=0, NetClock::time_point reportTime=NetClock::time_point{})
Store information about the state of a cluster node.
void switchLastClosedLedger(std::shared_ptr< Ledger const > const &newLCL)
void setUNLBlocked() override
void doTransactionAsync(std::shared_ptr< Transaction > transaction, bool bUnlimited, FailHard failtype)
For transactions not submitted by a locally connected client, fire and forget.
Structure returned by TxQ::getMetrics, expressed in reference fee level units.
Select all peers that are in the specified set.
Wraps a ledger instance for use in generic Validations LedgerTrie.
void accept(Application &app, Rules const &rules, std::shared_ptr< Ledger const > const &ledger, OrderedTxs const &locals, bool retriesFirst, OrderedTxs &retries, ApplyFlags flags, std::string const &suffix="", modify_type const &f={})
Accept a new ledger.
const Rate parityRate(QUALITY_ONE)
A transfer rate signifying a 1:1 exchange.
Validator keys and manifest as set in configuration file.
virtual AccountIDCache const & accountIDCache() const =0
virtual InboundLedgers & getInboundLedgers()=0
virtual LoadFeeTrack & getFeeTrack()=0
constexpr static std::size_t size()
std::string getCompleteLedgers()
Sends a message to all peers.
const SF_HASH256 sfValidatedHash
@ SYNCING
fallen slightly behind
void processClusterTimer()
bool unsubTransactions(std::uint64_t uListener) override
void const * data() const noexcept
const SF_VECTOR256 sfIndexes
void simulate(NetClock::time_point const &now, std::optional< std::chrono::milliseconds > consensusDelay)
virtual Gossip exportConsumers()=0
Extract packaged consumer information for export.
std::recursive_mutex & peekMutex()
std::uint32_t loadFactorServer
STAmount divide(STAmount const &amount, Rate const &rate)
~NetworkOPsImp() override
std::uint32_t getRemoteFee() const
const SF_AMOUNT sfTakerPays
static void getAccounts(Json::Value const &jvObj, std::vector< AccountID > &accounts)
Manages the generic consensus algorithm for use by the RCL.
@ warnRPC_AMENDMENT_BLOCKED
T time_since_epoch(T... args)
bool isGlobalFrozen(ReadView const &view, AccountID const &issuer)
beast::insight::Gauge syncing_duration
bool isAmendmentBlocked() override
InfoSub::pointer addRpcSub(std::string const &strUrl, InfoSub::ref) override
Value & append(const Value &value)
Append value to array at the end.
StateCountersJson json() const
Output state counters in JSON format.
virtual ReportingETL & getReportingETL()=0
@ DISCONNECTED
not ready to process requests
void clearAmendmentWarned() override
void setJson(Json::Value &) const
void processTxn(std::shared_ptr< ReadView const > const &ledger, const AcceptedLedgerTx &alTx, Json::Value const &jvObj)
std::shared_ptr< TxMeta > const & getMeta() const
virtual std::chrono::milliseconds getIOLatency()=0
Json::Value getOwnerInfo(std::shared_ptr< ReadView const > lpLedger, AccountID const &account) override
const SF_UINT64 sfServerVersion
std::pair< Validity, std::string > checkValidity(HashRouter &router, STTx const &tx, Rules const &rules, Config const &config)
Checks transaction signature and local checks.
void reportFeeChange() override
std::uint32_t getLocalFee() const
@ CONNECTED
convinced we are talking to the network
virtual LoadManager & getLoadManager()=0
std::shared_ptr< InfoSub > pointer
@ objectValue
object value (collection of name/value pairs).
constexpr double decimalXRP() const
const SF_UINT32 sfLoadFee
virtual LedgerMaster & getLedgerMaster()=0
bool isBlocked() override
virtual std::shared_ptr< Ledger const > acquire(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason)=0
bool peerProposal(NetClock::time_point const &now, RCLCxPeerPos const &newProposal)
@ TRACKING
convinced we agree with the network
void pubValidatedTransaction(std::shared_ptr< ReadView const > const &alAccepted, const AcceptedLedgerTx &alTransaction)
AccountID getAccountID(SField const &field) const
const SF_UINT32 sfReserveIncrement
DispatchState
Synchronization states for transaction batches.
virtual Config & config()=0
Select all peers (except optional excluded) that are in our cluster.
hash_set< NodeID > removed
Represents a set of transactions in RCLConsensus.
Keylet page(uint256 const &key, std::uint64_t index) noexcept
A page in a directory.
void endConsensus() override
TrustChanges updateTrusted(hash_set< NodeID > const &seenValidators, NetClock::time_point closeTime, NetworkOPs &ops, Overlay &overlay, HashRouter &hashRouter)
Update trusted nodes.
void unsubAccount(InfoSub::ref ispListener, hash_set< AccountID > const &vnaAccountIDs, bool rt) override
virtual std::pair< PublicKey, SecretKey > const & nodeIdentity()=0
bool canBeCurrent(std::shared_ptr< Ledger const > const &ledger)
Check the sequence number and parent close time of a ledger against our clock and last validated ledg...
bool unsubRTTransactions(std::uint64_t uListener) override
Manages the current fee schedule.
std::optional< Blob > getSignature() const
Returns manifest signature.
bool subManifests(InfoSub::ref ispListener) override
A transaction that is in a closed ledger.
virtual std::optional< NetClock::time_point > firstUnsupportedExpected() const =0
std::vector< Item > items
const std::shared_ptr< Transaction > transaction
void clearUNLBlocked() override
FeeAndSeq getTxRequiredFeeAndSeq(OpenView const &view, std::shared_ptr< STTx const > const &tx) const
Returns minimum required fee for tx and two sequences: first vaild sequence for this account in curre...
Server fees published on server subscription.
Json::Value transJson(const STTx &stTxn, TER terResult, bool bValidated, std::shared_ptr< ReadView const > const &lpCurrent)
std::unique_ptr< LocalTxs > m_localTX
NetworkOPsImp(Application &app, NetworkOPs::clock_type &clock, bool standalone, std::size_t minPeerCount, bool start_valid, JobQueue &job_queue, LedgerMaster &ledgerMaster, ValidatorKeys const &validatorKeys, boost::asio::io_service &io_svc, beast::Journal journal, beast::insight::Collector::ptr const &collector)
ConsensusPhase
Phases of consensus for a single ledger round.
@ warnRPC_EXPIRED_VALIDATOR_LIST
bool isCompatible(ReadView const &, beast::Journal::Stream, char const *reason)
std::string const & getVersionString()
Server version.
const SF_AMOUNT sfTakerGets
void pubAccountTransaction(std::shared_ptr< ReadView const > const &lpCurrent, const AcceptedLedgerTx &alTransaction, bool isAccepted)
ConsensusMode mode() const
boost::container::flat_set< AccountID > const & getAffected() const
virtual PeerSequence getActivePeers() const =0
Returns a sequence representing the current list of peers.
decltype(counters_) counters
beast::insight::Gauge tracking_duration
@ warnRPC_UNSUPPORTED_MAJORITY
bool subTransactions(InfoSub::ref ispListener) override
virtual time_point closeTime() const =0
Returns the close time, in network time.
@ current
This was a new validation and was added.
The role of a ClosureCounter is to assist in shutdown by letting callers wait for the completion of c...
std::array< Counters, 5 > counters_
bool isMember(const char *key) const
Return true if the object has a member named key.
bool unsubLedger(std::uint64_t uListener) override
A generic endpoint for log messages.
bool isAmendmentWarned() override
virtual RCLValidations & getValidations()=0
std::atomic< bool > needNetworkLedger_
virtual std::optional< key_type > succ(key_type const &key, std::optional< key_type > const &last=std::nullopt) const =0
Return the key of the next state item.
std::optional< std::set< PeerShortID > > shouldRelay(uint256 const &key)
Determines whether the hashed item should be relayed.
void addHeldTransaction(std::shared_ptr< Transaction > const &trans)
Blob getMasterSignature() const
Returns manifest master key signature.
void foreach(Function f) const
Visit every active peer.
ServerFeeSummary()=default
std::uint32_t getClusterFee() const
virtual PublicKey const & getValidationPublicKey() const =0
void pubValidation(std::shared_ptr< STValidation > const &val) override
STAmount amountFromQuality(std::uint64_t rate)
BookListeners::pointer makeBookListeners(Book const &)
void processClosedLedger(Application &app, ReadView const &view, bool timeLeap)
Update fee metrics and clean up the queue in preparation for the next ledger.
void subAccount(InfoSub::ref ispListener, hash_set< AccountID > const &vnaAccountIDs, bool rt) override
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
std::shared_ptr< ReadView const > getCurrentLedger()
ConsensusParms const & parms() const
Json::Value getJson(JsonOptions options) const override
STAmount accountFunds(ReadView const &view, AccountID const &id, STAmount const &saDefault, FreezeHandling freezeHandling, beast::Journal j)
Transaction with input flags and results to be applied in batches.
virtual ValidatorList & validators()=0
A metric for measuring an integral value.
void transactionBatch()
Apply transactions in batches.
bool isNeedNetworkLedger() override
void resetDeadlockDetector()
Reset the deadlock detection timer.
bool operator!=(ServerFeeSummary const &b) const
TransactionStatus(std::shared_ptr< Transaction > t, bool a, bool l, FailHard f)
void setStandAlone() override
A pool of threads to perform work.
std::recursive_mutex mSubLock
std::optional< TimeKeeper::time_point > expires() const
Return the time when the validator list will expire.
bool operator==(ServerFeeSummary const &b) const
std::chrono::system_clock::time_point start_
STAmount multiply(STAmount const &amount, Rate const &rate)
BookListeners::pointer getBookListeners(Book const &)
std::uint32_t sequence
The sequence number of this manifest.
virtual Resource::Manager & getResourceManager()=0
std::size_t getFetchPackCacheSize() const
Json::Value getJson(LedgerFill const &fill)
Return a new Json::Value representing the ledger with given options.
const SF_UINT64 sfBaseFee
beast::insight::Gauge tracking_transitions
bool haveValidated()
Whether we have ever fully validated a ledger.
std::chrono::seconds getValidatedLedgerAge()
std::shared_ptr< Ledger const > getClosedLedger()
beast::insight::Gauge connected_transitions
boost::asio::steady_timer clusterTimer_
virtual Json::Value countersJson() const =0
Render performance counters in Json.
std::vector< TransactionStatus > mTransactions
void reportConsensusStateChange(ConsensusPhase phase)
T emplace_back(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool transResultInfo(TER code, std::string &token, std::string &text)
bool unsubServer(std::uint64_t uListener) override
std::chrono::milliseconds prevRoundTime() const
Get duration of the previous round.
std::shared_ptr< STTx const > sterilize(STTx const &stx)
Sterilize a transaction.
std::unordered_set< uint256, beast::uhash<> > features
Stats(Handler const &handler, beast::insight::Collector::ptr const &collector)
virtual NodeStore::Database & getNodeStore()=0
virtual beast::Journal journal(std::string const &name)=0
virtual ManifestCache & validatorManifests()=0
std::size_t getLocalTxCount() override
std::array< SubMapType, SubTypes::sLastEntry+1 > mStreamMaps
std::size_t size() const noexcept
std::uint32_t getLoadFactor() const
Json::Value getLedgerFetchInfo() override
send_if_not_pred< Predicate > send_if_not(std::shared_ptr< Message > const &m, Predicate const &f)
Helper function to aid in type deduction.
@ Valid
Signature and local checks are good / passed.
bool unsubBook(std::uint64_t uListener, Book const &) override
void canonicalize(std::shared_ptr< Transaction > *pTransaction)
std::uint32_t acceptLedger(std::optional< std::chrono::milliseconds > consensusDelay) override
Accepts the current transaction tree, return the new ledger's sequence.
SubInfoMapType mSubAccount
std::string SERVER_DOMAIN
void clearNeedNetworkLedger() override
void rngfill(void *buffer, std::size_t bytes, Generator &g)
Issue const & issue() const
Lightweight wrapper to tag static string.
const uint256 featureNegativeUNL
bool checkLastClosedLedger(const Overlay::PeerSequence &, uint256 &networkClosed)
std::string strOperatingMode(OperatingMode const mode, bool const admin) const override
void getBookPage(std::shared_ptr< ReadView const > &lpLedger, Book const &, AccountID const &uTakerID, const bool bProof, unsigned int iLimit, Json::Value const &jvMarker, Json::Value &jvResult) override
void insertDeliveredAmount(Json::Value &meta, ReadView const &, std::shared_ptr< STTx const > const &serializedTx, TxMeta const &)
Add a delivered_amount field to the meta input/output parameter.
void pubPeerStatus(std::function< Json::Value(void)> const &) override
std::condition_variable mCond
void getCountsJson(Json::Value &obj)
LedgerIndex getCurrentLedgerIndex()
bool subLedger(InfoSub::ref ispListener, Json::Value &jvResult) override
beast::insight::Gauge full_transitions
static const std::array< char const *, 5 > stateNames
virtual time_point now() const override=0
Returns the estimate of wall time, in network time.
std::size_t prevProposers() const
Get the number of proposing peers that participated in the previous round.
virtual Overlay & overlay()=0
std::atomic< OperatingMode > mMode
std::shared_ptr< Ledger const > getValidatedLedger()
bool unsubManifests(std::uint64_t uListener) override
std::atomic< bool > amendmentBlocked_
void submitTransaction(std::shared_ptr< STTx const > const &) override
OperatingMode
Specifies the mode under which the server believes it's operating.
virtual std::optional< std::uint32_t > networkID() const =0
Returns the ID of the network this server is configured for, if any.
bool RELAY_UNTRUSTED_VALIDATIONS
virtual void clearFailures()=0
void join(char const *name, std::chrono::milliseconds wait, beast::Journal j)
Returns once all counted in-flight closures are destroyed.
ConsensusPhase mLastConsensusPhase
void updateLocalTx(ReadView const &view) override
Json::Value getJson() const
void pubConsensus(ConsensusPhase phase)
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
void for_each(std::function< void(ClusterNode const &)> func) const
Invokes the callback once for every cluster node.
bool subRTTransactions(InfoSub::ref ispListener) override
NetClock::time_point getReportTime() const
beast::insight::Gauge disconnected_transitions
const SF_ACCOUNT sfAccount
std::string strHex(FwdIt begin, FwdIt end)
std::pair< bool, Dest > mulDiv(Source1 value, Dest mul, Source2 div)
Json::Value getServerInfo(bool human, bool admin, bool counters) override
virtual Json::Value currentJson() const =0
Render currently executing jobs and RPC calls and durations in Json.
LedgerMaster & m_ledgerMaster
bool subServer(InfoSub::ref ispListener, Json::Value &jvResult, bool admin) override
auto getCurrentNodeIDs() -> hash_set< NodeID >
Get the set of node ids associated with current validations.
@ ltDIR_NODE
Directory node.
@ SigBad
Signature is bad. Didn't do local checks.
bool validating() const
Whether we are validating consensus ledgers.
std::unique_ptr< LocalTxs > make_LocalTxs()
Metrics getMetrics(OpenView const &view) const
Returns fee metrics in reference fee level units.
void doTransactionSync(std::shared_ptr< Transaction > transaction, bool bUnlimited, FailHard failType)
For transactions submitted directly by a client, apply batch of transactions and wait for this transa...
CounterData getCounterData() const
std::unique_ptr< LoadEvent > makeLoadEvent(JobType t, std::string const &name)
Return a scoped LoadEvent.
beast::insight::Gauge full_duration
virtual perf::PerfLog & getPerfLog()=0
send_if_pred< Predicate > send_if(std::shared_ptr< Message > const &m, Predicate const &f)
Helper function to aid in type deduction.
virtual std::uint64_t getPeerDisconnect() const =0
CanonicalTXSet OrderedTxs
bool subBook(InfoSub::ref ispListener, Book const &) override
bool subConsensus(InfoSub::ref ispListener) override
Json::Value getConsensusInfo() override
beast::insight::Gauge connected_duration
std::size_t count() const
Return the number of configured validator list sites.
ClosureCounter< void, boost::system::error_code const & > waitHandlerCounter_
void mode(OperatingMode om)
Record state transition.
std::optional< AccountID > accountFromStringStrict(std::string const &account)
Get an AccountID from an account ID or public key.
static const std::array< Json::StaticString const, 5 > states_
static std::string getWordFromBlob(void const *blob, size_t bytes)
Chooses a single dictionary word from the data.
void unsubAccountInternal(std::uint64_t seq, hash_set< AccountID > const &vnaAccountIDs, bool rt) override
const SF_UINT32 sfSigningTime
std::shared_ptr< STTx const > popAcctTransaction(std::shared_ptr< STTx const > const &tx)
Get the next transaction held for a particular account if any.
State accounting records two attributes for each possible server state: 1) Amount of time spent in ea...
A reference to a handler for performing polled collection.
std::uint64_t getQuality(uint256 const &uBase)
virtual std::uint64_t getPeerDisconnectCharges() const =0
virtual HashRouter & getHashRouter()=0
bool modify(modify_type const &f)
Modify the open ledger.
std::uint32_t transitions
STAmount const & getFieldAmount(SField const &field) const
bool unsubPeerStatus(std::uint64_t uListener) override
bool setFlags(uint256 const &key, int flags)
Set the flags on a hash.
void handleNewValidation(Application &app, std::shared_ptr< STValidation > const &val, std::string const &source)
Handle a new validation.
bool isTemMalformed(TER x)
static std::uint32_t trunc32(std::uint64_t v)
Json::Value jsonClipped() const
OperatingMode getOperatingMode() const override
PublicKey const & identity() const
std::optional< TxQ::Metrics > em
std::size_t quorum() const
Get quorum value for current trusted key set.
const SF_VECTOR256 sfAmendments
virtual std::chrono::duration< std::int32_t > closeOffset() const =0
InfoSub::pointer findRpcSub(std::string const &strUrl) override
void set(value_type value) const
Set the value on the gauge.
std::uint32_t loadBaseServer
void clearLedgerFetch() override
std::uint32_t getLoadFee() const
std::optional< Substitute< Closure > > wrap(Closure &&closure)
Wrap the passed closure with a reference counter.
Json::Value rate(Account const &account, double multiplier)
Set a transfer rate.
bool cdirFirst(ReadView const &view, uint256 const &uRootIndex, std::shared_ptr< SLE const > &sleNode, unsigned int &uDirEntry, uint256 &uEntryIndex, beast::Journal j)
virtual TransactionMaster & getMasterTransaction()=0
bool beginConsensus(uint256 const &networkClosed) override
void setAmendmentBlocked() override
void processTransaction(std::shared_ptr< Transaction > &transaction, bool bUnlimited, bool bLocal, FailHard failType) override
Process transactions as they arrive from the network or which are submitted by clients.
@ FULL
we have the ledger and can even validate