Merge branch 'develop' into pratik/Fix_asan_lsan_flagged_issues

This commit is contained in:
Pratik Mankawde
2026-02-16 15:53:44 +00:00
committed by GitHub
60 changed files with 385 additions and 228 deletions

View File

@@ -1,4 +1,6 @@
libxrpl.basics > xrpl.basics
libxrpl.conditions > xrpl.basics
libxrpl.conditions > xrpl.conditions
libxrpl.core > xrpl.basics
libxrpl.core > xrpl.core
libxrpl.crypto > xrpl.basics
@@ -56,7 +58,7 @@ test.basics > xrpl.json
test.basics > xrpl.protocol
test.beast > xrpl.basics
test.conditions > xrpl.basics
test.conditions > xrpld.conditions
test.conditions > xrpl.conditions
test.consensus > test.csf
test.consensus > test.toplevel
test.consensus > test.unit_test
@@ -158,6 +160,8 @@ test.unit_test > xrpl.basics
tests.libxrpl > xrpl.basics
tests.libxrpl > xrpl.json
tests.libxrpl > xrpl.net
xrpl.conditions > xrpl.basics
xrpl.conditions > xrpl.protocol
xrpl.core > xrpl.basics
xrpl.core > xrpl.json
xrpl.core > xrpl.ledger
@@ -165,6 +169,7 @@ xrpl.core > xrpl.protocol
xrpl.json > xrpl.basics
xrpl.ledger > xrpl.basics
xrpl.ledger > xrpl.protocol
xrpl.ledger > xrpl.server
xrpl.net > xrpl.basics
xrpl.nodestore > xrpl.basics
xrpl.nodestore > xrpl.protocol
@@ -179,7 +184,6 @@ xrpl.resource > xrpl.protocol
xrpl.server > xrpl.basics
xrpl.server > xrpl.core
xrpl.server > xrpl.json
xrpl.server > xrpl.ledger
xrpl.server > xrpl.protocol
xrpl.server > xrpl.rdb
xrpl.server > xrpl.resource
@@ -189,8 +193,8 @@ xrpl.shamap > xrpl.nodestore
xrpl.shamap > xrpl.protocol
xrpld.app > test.unit_test
xrpld.app > xrpl.basics
xrpld.app > xrpl.conditions
xrpld.app > xrpl.core
xrpld.app > xrpld.conditions
xrpld.app > xrpld.consensus
xrpld.app > xrpld.core
xrpld.app > xrpl.json
@@ -202,8 +206,6 @@ xrpld.app > xrpl.rdb
xrpld.app > xrpl.resource
xrpld.app > xrpl.server
xrpld.app > xrpl.shamap
xrpld.conditions > xrpl.basics
xrpld.conditions > xrpl.protocol
xrpld.consensus > xrpl.basics
xrpld.consensus > xrpl.json
xrpld.consensus > xrpl.protocol

View File

@@ -98,9 +98,18 @@ add_module(xrpl server)
target_link_libraries(xrpl.libxrpl.server PUBLIC xrpl.libxrpl.protocol xrpl.libxrpl.core xrpl.libxrpl.rdb
xrpl.libxrpl.resource)
add_module(xrpl conditions)
target_link_libraries(xrpl.libxrpl.conditions PUBLIC xrpl.libxrpl.server)
add_module(xrpl ledger)
target_link_libraries(xrpl.libxrpl.ledger PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json xrpl.libxrpl.protocol
xrpl.libxrpl.rdb)
target_link_libraries(
xrpl.libxrpl.ledger
PUBLIC xrpl.libxrpl.basics
xrpl.libxrpl.json
xrpl.libxrpl.protocol
xrpl.libxrpl.rdb
xrpl.libxrpl.server
xrpl.libxrpl.conditions)
add_library(xrpl.libxrpl)
set_target_properties(xrpl.libxrpl PROPERTIES OUTPUT_NAME xrpl)
@@ -115,6 +124,7 @@ target_link_modules(
PUBLIC
basics
beast
conditions
core
crypto
json

View File

@@ -20,6 +20,7 @@ install(TARGETS common
xrpl.libxrpl
xrpl.libxrpl.basics
xrpl.libxrpl.beast
xrpl.libxrpl.conditions
xrpl.libxrpl.core
xrpl.libxrpl.crypto
xrpl.libxrpl.json

View File

@@ -1,9 +1,8 @@
#pragma once
#include <xrpld/conditions/detail/utils.h>
#include <xrpl/basics/Buffer.h>
#include <xrpl/basics/Slice.h>
#include <xrpl/conditions/detail/utils.h>
#include <cstdint>
#include <set>

View File

@@ -1,9 +1,8 @@
#pragma once
#include <xrpld/conditions/Condition.h>
#include <xrpl/basics/Buffer.h>
#include <xrpl/basics/Slice.h>
#include <xrpl/conditions/Condition.h>
namespace xrpl {
namespace cryptoconditions {

View File

@@ -1,11 +1,10 @@
#pragma once
#include <xrpld/conditions/Condition.h>
#include <xrpld/conditions/Fulfillment.h>
#include <xrpld/conditions/detail/error.h>
#include <xrpl/basics/Buffer.h>
#include <xrpl/basics/Slice.h>
#include <xrpl/conditions/Condition.h>
#include <xrpl/conditions/Fulfillment.h>
#include <xrpl/conditions/detail/error.h>
#include <xrpl/protocol/digest.h>
#include <memory>

View File

@@ -1,9 +1,8 @@
#pragma once
#include <xrpld/conditions/detail/error.h>
#include <xrpl/basics/Buffer.h>
#include <xrpl/basics/Slice.h>
#include <xrpl/conditions/detail/error.h>
#include <boost/dynamic_bitset.hpp>

View File

@@ -251,7 +251,4 @@ private:
beast::aged_unordered_map<uint256, Entry, Stopwatch::clock_type, hardened_hash<strong_hash>> suppressionMap_;
};
HashRouter::Setup
setup_HashRouter(Config const&);
} // namespace xrpl

View File

@@ -214,6 +214,13 @@ public:
virtual Logs&
logs() = 0;
virtual std::optional<uint256> const&
trapTxID() const = 0;
/** Retrieve the "wallet database" */
virtual DatabaseCon&
getWalletDB() = 0;
// Temporary: Get the underlying Application for functions that haven't
// been migrated yet. This should be removed once all code is migrated.
virtual Application&

View File

@@ -1,15 +1,15 @@
#pragma once
#include <xrpld/app/ledger/Ledger.h>
#include <xrpl/basics/CountedObject.h>
#include <xrpl/ledger/ReadView.h>
#include <xrpl/protocol/AccountID.h>
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/TxMeta.h>
#include <boost/container/flat_set.hpp>
namespace xrpl {
class Logs;
/**
A transaction that is in a closed ledger.

View File

@@ -0,0 +1,93 @@
#pragma once
#include <xrpl/ledger/AcceptedLedgerTx.h>
#include <xrpl/ledger/BookListeners.h>
#include <xrpl/ledger/ReadView.h>
#include <xrpl/protocol/Book.h>
#include <xrpl/protocol/Issue.h>
#include <xrpl/protocol/MultiApiJson.h>
#include <xrpl/protocol/UintTypes.h>
#include <memory>
#include <optional>
#include <vector>
namespace xrpl {
/** Tracks order books in the ledger.
This interface provides access to order book information, including:
- Which order books exist in the ledger
- Querying order books by issue
- Managing order book subscriptions
The order book database is updated as ledgers are accepted and provides
efficient lookup of order book information for pathfinding and client
subscriptions.
*/
class OrderBookDB
{
public:
virtual ~OrderBookDB() = default;
/** Initialize or update the order book database with a new ledger.
This method should be called when a new ledger is accepted to update
the order book database with the current state of all order books.
@param ledger The ledger to scan for order books
*/
virtual void
setup(std::shared_ptr<ReadView const> const& ledger) = 0;
/** Add an order book to track.
@param book The order book to add
*/
virtual void
addOrderBook(Book const& book) = 0;
/** Get all order books that want a specific issue.
Returns a list of all order books where the taker pays the specified
issue. This is useful for pathfinding to find all possible next hops
from a given currency.
@param issue The issue to search for
@param domain Optional domain restriction for the order book
@return Vector of books that want this issue
*/
virtual std::vector<Book>
getBooksByTakerPays(Issue const& issue, std::optional<Domain> const& domain = std::nullopt) = 0;
/** Get the count of order books that want a specific issue.
@param issue The issue to search for
@param domain Optional domain restriction for the order book
@return Number of books that want this issue
*/
virtual int
getBookSize(Issue const& issue, std::optional<Domain> const& domain = std::nullopt) = 0;
/** Check if an order book to XRP exists for the given issue.
@param issue The issue to check
@param domain Optional domain restriction for the order book
@return true if a book from this issue to XRP exists
*/
virtual bool
isBookToXRP(Issue const& issue, std::optional<Domain> domain = std::nullopt) = 0;
virtual void
processTxn(
std::shared_ptr<ReadView const> const& ledger,
AcceptedLedgerTx const& alTx,
MultiApiJson const& jvObj) = 0;
virtual BookListeners::pointer
getBookListeners(Book const&) = 0;
virtual BookListeners::pointer
makeBookListeners(Book const&) = 0;
};
} // namespace xrpl

View File

@@ -2,7 +2,6 @@
#include <xrpl/core/JobQueue.h>
#include <xrpl/core/ServiceRegistry.h>
#include <xrpl/ledger/ReadView.h>
#include <xrpl/protocol/STValidation.h>
#include <xrpl/protocol/TER.h>
#include <xrpl/protocol/messages.h>
@@ -19,6 +18,8 @@ namespace xrpl {
// Master operational handler, server sequencer, network tracker
class Peer;
class STTx;
class ReadView;
class LedgerMaster;
class Transaction;
class ValidatorKeys;

View File

@@ -1,6 +1,6 @@
#include <xrpld/conditions/Condition.h>
#include <xrpld/conditions/detail/PreimageSha256.h>
#include <xrpld/conditions/detail/utils.h>
#include <xrpl/conditions/Condition.h>
#include <xrpl/conditions/detail/PreimageSha256.h>
#include <xrpl/conditions/detail/utils.h>
namespace xrpl {
namespace cryptoconditions {

View File

@@ -1,9 +1,8 @@
#include <xrpld/conditions/Condition.h>
#include <xrpld/conditions/Fulfillment.h>
#include <xrpld/conditions/detail/PreimageSha256.h>
#include <xrpld/conditions/detail/utils.h>
#include <xrpl/basics/safe_cast.h>
#include <xrpl/conditions/Condition.h>
#include <xrpl/conditions/Fulfillment.h>
#include <xrpl/conditions/detail/PreimageSha256.h>
#include <xrpl/conditions/detail/utils.h>
namespace xrpl {
namespace cryptoconditions {

View File

@@ -1,6 +1,5 @@
#include <xrpld/conditions/detail/error.h>
#include <xrpl/basics/safe_cast.h>
#include <xrpl/conditions/detail/error.h>
#include <string>

View File

@@ -1,5 +1,4 @@
#include <xrpld/app/misc/HashRouter.h>
#include <xrpld/core/Config.h>
#include <xrpl/core/HashRouter.h>
namespace xrpl {
@@ -108,38 +107,4 @@ HashRouter::shouldRelay(uint256 const& key) -> std::optional<std::set<PeerShortI
return s.releasePeerSet();
}
HashRouter::Setup
setup_HashRouter(Config const& config)
{
using namespace std::chrono;
HashRouter::Setup setup;
auto const& section = config.section("hashrouter");
std::int32_t tmp;
if (set(tmp, "hold_time", section))
{
if (tmp < 12)
Throw<std::runtime_error>(
"HashRouter hold time must be at least 12 seconds (the "
"approximate validation time for three ledgers).");
setup.holdTime = seconds(tmp);
}
if (set(tmp, "relay_time", section))
{
if (tmp < 8)
Throw<std::runtime_error>(
"HashRouter relay time must be at least 8 seconds (the "
"approximate validation time for two ledgers).");
setup.relayTime = seconds(tmp);
}
if (setup.relayTime > setup.holdTime)
{
Throw<std::runtime_error>("HashRouter relay time must be less than or equal to hold time");
}
return setup;
}
} // namespace xrpl

View File

@@ -1,7 +1,7 @@
#include <xrpld/app/ledger/AcceptedLedgerTx.h>
#include <xrpl/basics/Log.h>
#include <xrpl/basics/StringUtilities.h>
#include <xrpl/ledger/AcceptedLedgerTx.h>
#include <xrpl/ledger/View.h>
#include <xrpl/protocol/UintTypes.h>
#include <xrpl/protocol/jss.h>

View File

@@ -1,4 +1,4 @@
#include <xrpld/app/ledger/OrderBookDB.h>
#include <xrpl/ledger/BookListeners.h>
namespace xrpl {

View File

@@ -2,11 +2,11 @@
#include <test/jtx/TestHelpers.h>
#include <test/jtx/utility.h>
#include <xrpld/app/misc/HashRouter.h>
#include <xrpld/app/misc/Transaction.h>
#include <xrpld/app/tx/apply.h>
#include <xrpld/app/tx/detail/Batch.h>
#include <xrpl/core/HashRouter.h>
#include <xrpl/protocol/Batch.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/STParsedJSON.h>

View File

@@ -1,8 +1,9 @@
#include <xrpld/app/misc/HashRouter.h>
#include <xrpld/app/misc/setup_HashRouter.h>
#include <xrpld/core/Config.h>
#include <xrpl/basics/chrono.h>
#include <xrpl/beast/unit_test.h>
#include <xrpl/core/HashRouter.h>
namespace xrpl {
namespace test {

View File

@@ -2,7 +2,7 @@
#include <test/jtx/CaptureLogs.h>
#include <test/jtx/Env.h>
#include <xrpld/app/misc/HashRouter.h>
#include <xrpl/core/HashRouter.h>
namespace xrpl {
namespace test {

View File

@@ -1,12 +1,11 @@
#include <xrpld/conditions/Condition.h>
#include <xrpld/conditions/Fulfillment.h>
#include <xrpld/conditions/detail/PreimageSha256.h>
#include <xrpl/basics/Buffer.h>
#include <xrpl/basics/Slice.h>
#include <xrpl/basics/StringUtilities.h>
#include <xrpl/basics/strHex.h>
#include <xrpl/beast/unit_test.h>
#include <xrpl/conditions/Condition.h>
#include <xrpl/conditions/Fulfillment.h>
#include <xrpl/conditions/detail/PreimageSha256.h>
#include <algorithm>
#include <string>

View File

@@ -8,7 +8,6 @@
#include <xrpld/app/ledger/LocalTxs.h>
#include <xrpld/app/ledger/OpenLedger.h>
#include <xrpld/app/misc/AmendmentTable.h>
#include <xrpld/app/misc/HashRouter.h>
#include <xrpld/app/misc/LoadFeeTrack.h>
#include <xrpld/app/misc/NegativeUNLVote.h>
#include <xrpld/app/misc/TxQ.h>
@@ -21,6 +20,7 @@
#include <xrpl/basics/random.h>
#include <xrpl/beast/core/LexicalCast.h>
#include <xrpl/beast/utility/instrumentation.h>
#include <xrpl/core/HashRouter.h>
#include <xrpl/protocol/BuildInfo.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/digest.h>

View File

@@ -4,7 +4,7 @@
namespace xrpl {
AcceptedLedger::AcceptedLedger(std::shared_ptr<ReadView const> const& ledger, Application& app) : mLedger(ledger)
AcceptedLedger::AcceptedLedger(std::shared_ptr<ReadView const> const& ledger) : mLedger(ledger)
{
transactions_.reserve(256);

View File

@@ -1,6 +1,8 @@
#pragma once
#include <xrpld/app/ledger/AcceptedLedgerTx.h>
#include <xrpl/basics/CountedObject.h>
#include <xrpl/core/ServiceRegistry.h>
#include <xrpl/ledger/AcceptedLedgerTx.h>
namespace xrpl {
@@ -23,7 +25,7 @@ namespace xrpl {
class AcceptedLedger : public CountedObject<AcceptedLedger>
{
public:
AcceptedLedger(std::shared_ptr<ReadView const> const& ledger, Application& app);
AcceptedLedger(std::shared_ptr<ReadView const> const& ledger);
std::shared_ptr<ReadView const> const&
getLedger() const

View File

@@ -3,13 +3,13 @@
#include <xrpld/app/ledger/LedgerToJson.h>
#include <xrpld/app/ledger/PendingSaves.h>
#include <xrpld/app/main/Application.h>
#include <xrpld/app/misc/HashRouter.h>
#include <xrpld/consensus/LedgerTiming.h>
#include <xrpld/core/Config.h>
#include <xrpl/basics/Log.h>
#include <xrpl/basics/contract.h>
#include <xrpl/beast/utility/instrumentation.h>
#include <xrpl/core/HashRouter.h>
#include <xrpl/core/JobQueue.h>
#include <xrpl/json/to_string.h>
#include <xrpl/nodestore/Database.h>

View File

@@ -1,75 +0,0 @@
#pragma once
#include <xrpld/app/ledger/AcceptedLedgerTx.h>
#include <xrpld/app/ledger/BookListeners.h>
#include <xrpld/app/main/Application.h>
#include <xrpl/protocol/MultiApiJson.h>
#include <xrpl/protocol/UintTypes.h>
#include <mutex>
#include <optional>
namespace xrpl {
class OrderBookDB
{
public:
explicit OrderBookDB(Application& app);
void
setup(std::shared_ptr<ReadView const> const& ledger);
void
update(std::shared_ptr<ReadView const> const& ledger);
void
addOrderBook(Book const&);
/** @return a list of all orderbooks that want this issuerID and currencyID.
*/
std::vector<Book>
getBooksByTakerPays(Issue const&, std::optional<Domain> const& domain = std::nullopt);
/** @return a count of all orderbooks that want this issuerID and
currencyID. */
int
getBookSize(Issue const&, std::optional<Domain> const& domain = std::nullopt);
bool
isBookToXRP(Issue const&, std::optional<Domain> domain = std::nullopt);
BookListeners::pointer
getBookListeners(Book const&);
BookListeners::pointer
makeBookListeners(Book const&);
// see if this txn effects any orderbook
void
processTxn(std::shared_ptr<ReadView const> const& ledger, AcceptedLedgerTx const& alTx, MultiApiJson const& jvObj);
private:
Application& app_;
// Maps order books by "issue in" to "issue out":
hardened_hash_map<Issue, hardened_hash_set<Issue>> allBooks_;
hardened_hash_map<std::pair<Issue, Domain>, hardened_hash_set<Issue>> domainBooks_;
// does an order book to XRP exist
hash_set<Issue> xrpBooks_;
// does an order book to XRP exist
hash_set<std::pair<Issue, Domain>> xrpDomainBooks_;
std::recursive_mutex mLock;
using BookToListenersMap = hash_map<Book, BookListeners::pointer>;
BookToListenersMap mListeners;
std::atomic<std::uint32_t> seq_;
beast::Journal const j_;
};
} // namespace xrpl

View File

@@ -1,6 +1,5 @@
#include <xrpld/app/ledger/LedgerMaster.h>
#include <xrpld/app/ledger/OrderBookDB.h>
#include <xrpld/app/main/Application.h>
#include <xrpld/app/ledger/OrderBookDBImpl.h>
#include <xrpld/app/misc/AMMUtils.h>
#include <xrpld/core/Config.h>
@@ -11,14 +10,25 @@
namespace xrpl {
OrderBookDB::OrderBookDB(Application& app) : app_(app), seq_(0), j_(app.journal("OrderBookDB"))
OrderBookDBImpl::OrderBookDBImpl(ServiceRegistry& registry, OrderBookDBConfig const& config)
: registry_(registry)
, pathSearchMax_(config.pathSearchMax)
, standalone_(config.standalone)
, seq_(0)
, j_(registry.journal("OrderBookDB"))
{
}
void
OrderBookDB::setup(std::shared_ptr<ReadView const> const& ledger)
std::unique_ptr<OrderBookDB>
make_OrderBookDB(ServiceRegistry& registry, OrderBookDBConfig const& config)
{
if (!app_.config().standalone() && app_.getOPs().isNeedNetworkLedger())
return std::make_unique<OrderBookDBImpl>(registry, config);
}
void
OrderBookDBImpl::setup(std::shared_ptr<ReadView const> const& ledger)
{
if (!standalone_ && registry_.getOPs().isNeedNetworkLedger())
{
JLOG(j_.warn()) << "Eliding full order book update: no ledger";
return;
@@ -40,19 +50,20 @@ OrderBookDB::setup(std::shared_ptr<ReadView const> const& ledger)
JLOG(j_.debug()) << "Full order book update: " << seq << " to " << ledger->seq();
if (app_.config().PATH_SEARCH_MAX != 0)
if (pathSearchMax_ != 0)
{
if (app_.config().standalone())
if (standalone_)
update(ledger);
else
app_.getJobQueue().addJob(jtUPDATE_PF, "OrderBookUpd", [this, ledger]() { update(ledger); });
registry_.getJobQueue().addJob(
jtUPDATE_PF, "OrderBookUpd" + std::to_string(ledger->seq()), [this, ledger]() { update(ledger); });
}
}
void
OrderBookDB::update(std::shared_ptr<ReadView const> const& ledger)
OrderBookDBImpl::update(std::shared_ptr<ReadView const> const& ledger)
{
if (app_.config().PATH_SEARCH_MAX == 0)
if (pathSearchMax_ == 0)
return; // pathfinding has been disabled
// A newer full update job is pending
@@ -79,7 +90,7 @@ OrderBookDB::update(std::shared_ptr<ReadView const> const& ledger)
{
for (auto& sle : ledger->sles)
{
if (app_.isStopping())
if (registry_.isStopping())
{
JLOG(j_.info()) << "Update halted because the process is stopping";
seq_.store(0);
@@ -143,11 +154,11 @@ OrderBookDB::update(std::shared_ptr<ReadView const> const& ledger)
xrpDomainBooks_.swap(xrpDomainBooks);
}
app_.getLedgerMaster().newOrderBookDB();
registry_.getLedgerMaster().newOrderBookDB();
}
void
OrderBookDB::addOrderBook(Book const& book)
OrderBookDBImpl::addOrderBook(Book const& book)
{
bool toXRP = isXRP(book.out);
@@ -166,7 +177,7 @@ OrderBookDB::addOrderBook(Book const& book)
// return list of all orderbooks that want this issuerID and currencyID
std::vector<Book>
OrderBookDB::getBooksByTakerPays(Issue const& issue, std::optional<uint256> const& domain)
OrderBookDBImpl::getBooksByTakerPays(Issue const& issue, std::optional<uint256> const& domain)
{
std::vector<Book> ret;
@@ -194,7 +205,7 @@ OrderBookDB::getBooksByTakerPays(Issue const& issue, std::optional<uint256> cons
}
int
OrderBookDB::getBookSize(Issue const& issue, std::optional<uint256> const& domain)
OrderBookDBImpl::getBookSize(Issue const& issue, std::optional<uint256> const& domain)
{
std::lock_guard sl(mLock);
@@ -213,7 +224,7 @@ OrderBookDB::getBookSize(Issue const& issue, std::optional<uint256> const& domai
}
bool
OrderBookDB::isBookToXRP(Issue const& issue, std::optional<Domain> domain)
OrderBookDBImpl::isBookToXRP(Issue const& issue, std::optional<Domain> domain)
{
std::lock_guard sl(mLock);
if (domain)
@@ -222,7 +233,7 @@ OrderBookDB::isBookToXRP(Issue const& issue, std::optional<Domain> domain)
}
BookListeners::pointer
OrderBookDB::makeBookListeners(Book const& book)
OrderBookDBImpl::makeBookListeners(Book const& book)
{
std::lock_guard sl(mLock);
auto ret = getBookListeners(book);
@@ -242,7 +253,7 @@ OrderBookDB::makeBookListeners(Book const& book)
}
BookListeners::pointer
OrderBookDB::getBookListeners(Book const& book)
OrderBookDBImpl::getBookListeners(Book const& book)
{
BookListeners::pointer ret;
std::lock_guard sl(mLock);
@@ -257,7 +268,7 @@ OrderBookDB::getBookListeners(Book const& book)
// Based on the meta, send the meta to the streams that are listening.
// We need to determine which streams a given meta effects.
void
OrderBookDB::processTxn(
OrderBookDBImpl::processTxn(
std::shared_ptr<ReadView const> const& ledger,
AcceptedLedgerTx const& alTx,
MultiApiJson const& jvObj)

View File

@@ -0,0 +1,93 @@
#pragma once
#include <xrpl/core/ServiceRegistry.h>
#include <xrpl/ledger/AcceptedLedgerTx.h>
#include <xrpl/ledger/BookListeners.h>
#include <xrpl/ledger/OrderBookDB.h>
#include <xrpl/protocol/MultiApiJson.h>
#include <xrpl/protocol/UintTypes.h>
#include <mutex>
#include <optional>
namespace xrpl {
/** Configuration for OrderBookDB */
struct OrderBookDBConfig
{
int pathSearchMax;
bool standalone;
};
/** Create an OrderBookDB instance.
@param registry Service registry for accessing other services
@param config Configuration parameters
@return A new OrderBookDB instance
*/
std::unique_ptr<OrderBookDB>
make_OrderBookDB(ServiceRegistry& registry, OrderBookDBConfig const& config);
class OrderBookDBImpl final : public OrderBookDB
{
public:
OrderBookDBImpl(ServiceRegistry& registry, OrderBookDBConfig const& config);
// OrderBookDB interface implementation
void
setup(std::shared_ptr<ReadView const> const& ledger) override;
void
addOrderBook(Book const& book) override;
std::vector<Book>
getBooksByTakerPays(Issue const& issue, std::optional<Domain> const& domain = std::nullopt) override;
int
getBookSize(Issue const& issue, std::optional<Domain> const& domain = std::nullopt) override;
bool
isBookToXRP(Issue const& issue, std::optional<Domain> domain = std::nullopt) override;
// OrderBookDBImpl-specific methods
void
update(std::shared_ptr<ReadView const> const& ledger);
// see if this txn effects any orderbook
void
processTxn(std::shared_ptr<ReadView const> const& ledger, AcceptedLedgerTx const& alTx, MultiApiJson const& jvObj)
override;
BookListeners::pointer
getBookListeners(Book const&) override;
BookListeners::pointer
makeBookListeners(Book const&) override;
private:
ServiceRegistry& registry_;
int const pathSearchMax_;
bool const standalone_;
// Maps order books by "issue in" to "issue out":
hardened_hash_map<Issue, hardened_hash_set<Issue>> allBooks_;
hardened_hash_map<std::pair<Issue, Domain>, hardened_hash_set<Issue>> domainBooks_;
// does an order book to XRP exist
hash_set<Issue> xrpBooks_;
// does an order book to XRP exist
hash_set<std::pair<Issue, Domain>> xrpDomainBooks_;
std::recursive_mutex mLock;
using BookToListenersMap = hash_map<Book, BookListeners::pointer>;
BookToListenersMap mListeners;
std::atomic<std::uint32_t> seq_;
beast::Journal const j_;
};
} // namespace xrpl

View File

@@ -3,7 +3,6 @@
#include <xrpld/app/ledger/LedgerMaster.h>
#include <xrpld/app/ledger/LedgerReplayer.h>
#include <xrpld/app/ledger/OpenLedger.h>
#include <xrpld/app/ledger/OrderBookDB.h>
#include <xrpld/app/ledger/PendingSaves.h>
#include <xrpld/app/main/Application.h>
#include <xrpld/app/misc/AmendmentTable.h>
@@ -24,6 +23,7 @@
#include <xrpl/basics/safe_cast.h>
#include <xrpl/basics/scope.h>
#include <xrpl/beast/utility/instrumentation.h>
#include <xrpl/ledger/OrderBookDB.h>
#include <xrpl/protocol/BuildInfo.h>
#include <xrpl/protocol/HashPrefix.h>
#include <xrpl/protocol/digest.h>

View File

@@ -1,11 +1,11 @@
#include <xrpld/app/ledger/OpenLedger.h>
#include <xrpld/app/main/Application.h>
#include <xrpld/app/misc/HashRouter.h>
#include <xrpld/app/misc/TxQ.h>
#include <xrpld/app/tx/apply.h>
#include <xrpld/overlay/Message.h>
#include <xrpld/overlay/Overlay.h>
#include <xrpl/core/HashRouter.h>
#include <xrpl/ledger/CachedView.h>
#include <xrpl/protocol/TxFlags.h>

View File

@@ -6,7 +6,7 @@
#include <xrpld/app/ledger/LedgerReplayer.h>
#include <xrpld/app/ledger/LedgerToJson.h>
#include <xrpld/app/ledger/OpenLedger.h>
#include <xrpld/app/ledger/OrderBookDB.h>
#include <xrpld/app/ledger/OrderBookDBImpl.h>
#include <xrpld/app/ledger/PendingSaves.h>
#include <xrpld/app/ledger/TransactionMaster.h>
#include <xrpld/app/main/Application.h>
@@ -16,13 +16,13 @@
#include <xrpld/app/main/NodeIdentity.h>
#include <xrpld/app/main/NodeStoreScheduler.h>
#include <xrpld/app/misc/AmendmentTable.h>
#include <xrpld/app/misc/HashRouter.h>
#include <xrpld/app/misc/LoadFeeTrack.h>
#include <xrpld/app/misc/SHAMapStore.h>
#include <xrpld/app/misc/TxQ.h>
#include <xrpld/app/misc/ValidatorKeys.h>
#include <xrpld/app/misc/ValidatorSite.h>
#include <xrpld/app/misc/make_NetworkOPs.h>
#include <xrpld/app/misc/setup_HashRouter.h>
#include <xrpld/app/paths/PathRequests.h>
#include <xrpld/app/rdb/backend/SQLiteDatabase.h>
#include <xrpld/app/tx/apply.h>
@@ -36,6 +36,7 @@
#include <xrpl/basics/random.h>
#include <xrpl/beast/asio/io_latency_probe.h>
#include <xrpl/beast/core/LexicalCast.h>
#include <xrpl/core/HashRouter.h>
#include <xrpl/core/PeerReservationTable.h>
#include <xrpl/core/PerfLog.h>
#include <xrpl/crypto/csprng.h>
@@ -164,8 +165,7 @@ public:
std::unique_ptr<NodeStore::Database> m_nodeStore;
NodeFamily nodeFamily_;
// VFALCO TODO Make OrderBookDB abstract
OrderBookDB m_orderBookDB;
std::unique_ptr<OrderBookDB> m_orderBookDB;
std::unique_ptr<PathRequests> m_pathRequests;
std::unique_ptr<LedgerMaster> m_ledgerMaster;
std::unique_ptr<LedgerCleaner> ledgerCleaner_;
@@ -296,7 +296,7 @@ public:
, nodeFamily_(*this, *m_collectorManager)
, m_orderBookDB(*this)
, m_orderBookDB(make_OrderBookDB(*this, {config_->PATH_SEARCH_MAX, config_->standalone()}))
, m_pathRequests(
std::make_unique<PathRequests>(*this, logs_->journal("PathRequest"), m_collectorManager->collector()))
@@ -613,7 +613,7 @@ public:
OrderBookDB&
getOrderBookDB() override
{
return m_orderBookDB;
return *m_orderBookDB;
}
PathRequests&
@@ -1170,7 +1170,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
m_ledgerMaster->setLedgerRangePresent(forcedRange->first, forcedRange->second);
}
m_orderBookDB.setup(getLedgerMaster().getCurrentLedger());
m_orderBookDB->setup(getLedgerMaster().getCurrentLedger());
nodeIdentity_ = getNodeIdentity(*this, cmdline);

View File

@@ -153,17 +153,10 @@ public:
virtual int
fdRequired() const = 0;
/** Retrieve the "wallet database" */
virtual DatabaseCon&
getWalletDB() = 0;
/** Ensure that a newly-started validator does not sign proposals older
* than the last ledger it persisted. */
virtual LedgerIndex
getMaxDisallowedLedger() = 0;
virtual std::optional<uint256> const&
trapTxID() const = 0;
};
std::unique_ptr<Application>

View File

@@ -3,6 +3,7 @@
#include <xrpld/app/ledger/Ledger.h>
#include <xrpld/core/ConfigSections.h>
#include <xrpl/core/ServiceRegistry.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/Protocol.h>
#include <xrpl/protocol/STValidation.h>
@@ -163,7 +164,7 @@ public:
std::unique_ptr<AmendmentTable>
make_AmendmentTable(
Application& app,
ServiceRegistry& registry,
std::chrono::seconds majorityTime,
std::vector<AmendmentTable::FeatureInfo> const& supported,
Section const& enabled,

View File

@@ -7,13 +7,11 @@
#include <xrpld/app/ledger/LedgerToJson.h>
#include <xrpld/app/ledger/LocalTxs.h>
#include <xrpld/app/ledger/OpenLedger.h>
#include <xrpld/app/ledger/OrderBookDB.h>
#include <xrpld/app/ledger/TransactionMaster.h>
#include <xrpld/app/main/LoadManager.h>
#include <xrpld/app/main/Tuning.h>
#include <xrpld/app/misc/AmendmentTable.h>
#include <xrpld/app/misc/DeliverMax.h>
#include <xrpld/app/misc/HashRouter.h>
#include <xrpld/app/misc/LoadFeeTrack.h>
#include <xrpld/app/misc/Transaction.h>
#include <xrpld/app/misc/TxQ.h>
@@ -39,9 +37,11 @@
#include <xrpl/basics/safe_cast.h>
#include <xrpl/basics/scope.h>
#include <xrpl/beast/utility/rngfill.h>
#include <xrpl/core/HashRouter.h>
#include <xrpl/core/PerfLog.h>
#include <xrpl/crypto/RFC1751.h>
#include <xrpl/crypto/csprng.h>
#include <xrpl/ledger/OrderBookDB.h>
#include <xrpl/protocol/BuildInfo.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/MultiApiJson.h>
@@ -2824,7 +2824,7 @@ NetworkOPsImp::pubLedger(std::shared_ptr<ReadView const> const& lpAccepted)
std::shared_ptr<AcceptedLedger> alpAccepted = registry_.getAcceptedLedgerCache().fetch(lpAccepted->header().hash);
if (!alpAccepted)
{
alpAccepted = std::make_shared<AcceptedLedger>(lpAccepted, registry_.app());
alpAccepted = std::make_shared<AcceptedLedger>(lpAccepted);
registry_.getAcceptedLedgerCache().canonicalize_replace_client(lpAccepted->header().hash, alpAccepted);
}

View File

@@ -1,7 +1,7 @@
#include <xrpld/app/main/Application.h>
#include <xrpld/app/misc/AmendmentTable.h>
#include <xrpld/core/ConfigSections.h>
#include <xrpl/core/ServiceRegistry.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/STValidation.h>
#include <xrpl/protocol/TxFlags.h>
@@ -400,7 +400,7 @@ private:
public:
AmendmentTableImpl(
Application& app,
ServiceRegistry& registry,
std::chrono::seconds majorityTime,
std::vector<FeatureInfo> const& supported,
Section const& enabled,
@@ -461,13 +461,17 @@ public:
//------------------------------------------------------------------------------
AmendmentTableImpl::AmendmentTableImpl(
Application& app,
ServiceRegistry& registry,
std::chrono::seconds majorityTime,
std::vector<FeatureInfo> const& supported,
Section const& enabled,
Section const& vetoed,
beast::Journal journal)
: lastUpdateSeq_(0), majorityTime_(majorityTime), unsupportedEnabled_(false), j_(journal), db_(app.getWalletDB())
: lastUpdateSeq_(0)
, majorityTime_(majorityTime)
, unsupportedEnabled_(false)
, j_(journal)
, db_(registry.getWalletDB())
{
std::lock_guard lock(mutex_);
@@ -957,14 +961,14 @@ AmendmentTableImpl::getJson(uint256 const& amendmentID, bool isAdmin) const
std::unique_ptr<AmendmentTable>
make_AmendmentTable(
Application& app,
ServiceRegistry& registry,
std::chrono::seconds majorityTime,
std::vector<AmendmentTable::FeatureInfo> const& supported,
Section const& enabled,
Section const& vetoed,
beast::Journal journal)
{
return std::make_unique<AmendmentTableImpl>(app, majorityTime, supported, enabled, vetoed, journal);
return std::make_unique<AmendmentTableImpl>(registry, majorityTime, supported, enabled, vetoed, journal);
}
} // namespace xrpl

View File

@@ -1,11 +1,11 @@
#include <xrpld/app/ledger/LedgerMaster.h>
#include <xrpld/app/main/Application.h>
#include <xrpld/app/misc/HashRouter.h>
#include <xrpld/app/misc/Transaction.h>
#include <xrpld/app/tx/apply.h>
#include <xrpld/rpc/CTID.h>
#include <xrpl/basics/safe_cast.h>
#include <xrpl/core/HashRouter.h>
#include <xrpl/protocol/ErrorCodes.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/rdb/RelationalDatabase.h>

View File

@@ -1,4 +1,3 @@
#include <xrpld/app/misc/HashRouter.h>
#include <xrpld/app/misc/ValidatorList.h>
#include <xrpld/overlay/Overlay.h>
@@ -6,6 +5,7 @@
#include <xrpl/basics/Slice.h>
#include <xrpl/basics/StringUtilities.h>
#include <xrpl/basics/base64.h>
#include <xrpl/core/HashRouter.h>
#include <xrpl/json/json_reader.h>
#include <xrpl/protocol/PublicKey.h>
#include <xrpl/protocol/STValidation.h>

View File

@@ -0,0 +1,42 @@
#include <xrpld/app/misc/setup_HashRouter.h>
#include <xrpld/core/Config.h>
#include <xrpl/basics/BasicConfig.h>
namespace xrpl {
HashRouter::Setup
setup_HashRouter(Config const& config)
{
using namespace std::chrono;
HashRouter::Setup setup;
auto const& section = config.section("hashrouter");
std::int32_t tmp{};
if (set(tmp, "hold_time", section))
{
if (tmp < 12)
Throw<std::runtime_error>(
"HashRouter hold time must be at least 12 seconds (the "
"approximate validation time for three ledgers).");
setup.holdTime = seconds(tmp);
}
if (set(tmp, "relay_time", section))
{
if (tmp < 8)
Throw<std::runtime_error>(
"HashRouter relay time must be at least 8 seconds (the "
"approximate validation time for two ledgers).");
setup.relayTime = seconds(tmp);
}
if (setup.relayTime > setup.holdTime)
{
Throw<std::runtime_error>("HashRouter relay time must be less than or equal to hold time");
}
return setup;
}
} // namespace xrpl

View File

@@ -0,0 +1,17 @@
#ifndef XRPLD_APP_MISC_SETUP_HASHROUTER_H_INCLUDED
#define XRPLD_APP_MISC_SETUP_HASHROUTER_H_INCLUDED
#include <xrpl/core/HashRouter.h>
namespace xrpl {
// Forward declaration
class Config;
/** Create HashRouter setup from configuration */
HashRouter::Setup
setup_HashRouter(Config const& config);
} // namespace xrpl
#endif

View File

@@ -1,4 +1,3 @@
#include <xrpld/app/ledger/OrderBookDB.h>
#include <xrpld/app/main/Application.h>
#include <xrpld/app/paths/Pathfinder.h>
#include <xrpld/app/paths/RippleCalc.h>
@@ -9,6 +8,7 @@
#include <xrpl/basics/join.h>
#include <xrpl/core/JobQueue.h>
#include <xrpl/json/to_string.h>
#include <xrpl/ledger/OrderBookDB.h>
#include <xrpl/ledger/PaymentSandbox.h>
#include <tuple>

View File

@@ -203,7 +203,7 @@ saveValidatedLedger(
aLedger = app.getAcceptedLedgerCache().fetch(ledger->header().hash);
if (!aLedger)
{
aLedger = std::make_shared<AcceptedLedger>(ledger, app);
aLedger = std::make_shared<AcceptedLedger>(ledger);
app.getAcceptedLedgerCache().canonicalize_replace_client(ledger->header().hash, aLedger);
}
}

View File

@@ -1,8 +1,8 @@
#include <xrpld/app/ledger/OrderBookDB.h>
#include <xrpld/app/misc/AMMHelpers.h>
#include <xrpld/app/misc/AMMUtils.h>
#include <xrpld/app/tx/detail/AMMCreate.h>
#include <xrpl/ledger/OrderBookDB.h>
#include <xrpl/ledger/Sandbox.h>
#include <xrpl/ledger/View.h>
#include <xrpl/protocol/AMMCore.h>

View File

@@ -6,6 +6,7 @@
#include <xrpl/ledger/View.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/SystemParameters.h>
#include <xrpl/protocol/TER.h>
#include <xrpl/protocol/TxFlags.h>

View File

@@ -1,7 +1,6 @@
#pragma once
#include <xrpld/app/tx/detail/Transactor.h>
#include <xrpld/core/Config.h>
#include <xrpl/basics/Log.h>
#include <xrpl/protocol/Indexes.h>

View File

@@ -1,8 +1,8 @@
#include <xrpld/app/ledger/Ledger.h>
#include <xrpld/app/tx/detail/CancelCheck.h>
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/ApplyView.h>
#include <xrpl/ledger/View.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/TER.h>

View File

@@ -1,9 +1,9 @@
#include <xrpld/app/ledger/Ledger.h>
#include <xrpld/app/paths/Flow.h>
#include <xrpld/app/tx/detail/CashCheck.h>
#include <xrpl/basics/Log.h>
#include <xrpl/basics/scope.h>
#include <xrpl/ledger/View.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/TER.h>

View File

@@ -1,10 +1,10 @@
#include <xrpld/app/ledger/OrderBookDB.h>
#include <xrpld/app/misc/PermissionedDEXHelpers.h>
#include <xrpld/app/paths/Flow.h>
#include <xrpld/app/tx/detail/CreateOffer.h>
#include <xrpl/basics/base_uint.h>
#include <xrpl/beast/utility/WrappedSink.h>
#include <xrpl/ledger/OrderBookDB.h>
#include <xrpl/ledger/PaymentSandbox.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/STAmount.h>

View File

@@ -1,6 +1,7 @@
#include <xrpld/app/tx/detail/CreateTicket.h>
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/View.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/TxFlags.h>

View File

@@ -1,6 +1,5 @@
#pragma once
#include <xrpld/app/ledger/Ledger.h>
#include <xrpld/app/tx/detail/Transactor.h>
namespace xrpl {

View File

@@ -1,11 +1,11 @@
#include <xrpld/app/misc/HashRouter.h>
#include <xrpld/app/tx/detail/Escrow.h>
#include <xrpld/app/tx/detail/MPTokenAuthorize.h>
#include <xrpld/conditions/Condition.h>
#include <xrpld/conditions/Fulfillment.h>
#include <xrpl/basics/Log.h>
#include <xrpl/basics/chrono.h>
#include <xrpl/conditions/Condition.h>
#include <xrpl/conditions/Fulfillment.h>
#include <xrpl/core/HashRouter.h>
#include <xrpl/ledger/ApplyView.h>
#include <xrpl/ledger/CredentialHelpers.h>
#include <xrpl/ledger/View.h>

View File

@@ -1,6 +1,5 @@
#include <xrpld/app/misc/DelegateUtils.h>
#include <xrpld/app/tx/detail/SetAccount.h>
#include <xrpld/core/Config.h>
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/View.h>

View File

@@ -1,11 +1,9 @@
#include <xrpld/app/main/Application.h>
#include <xrpld/app/misc/DelegateUtils.h>
#include <xrpld/app/misc/LoadFeeTrack.h>
#include <xrpld/app/tx/apply.h>
#include <xrpld/app/tx/detail/NFTokenUtils.h>
#include <xrpld/app/tx/detail/SignerEntries.h>
#include <xrpld/app/tx/detail/Transactor.h>
#include <xrpld/core/Config.h>
#include <xrpl/basics/Log.h>
#include <xrpl/basics/contract.h>
@@ -15,6 +13,7 @@
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/Protocol.h>
#include <xrpl/protocol/SystemParameters.h>
#include <xrpl/protocol/TxFlags.h>
#include <xrpl/protocol/UintTypes.h>

View File

@@ -1,8 +1,9 @@
#include <xrpld/app/misc/HashRouter.h>
#include <xrpld/app/tx/apply.h>
#include <xrpld/app/tx/applySteps.h>
#include <xrpl/basics/Log.h>
#include <xrpl/core/HashRouter.h>
#include <xrpl/core/ServiceRegistry.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/TxFlags.h>

View File

@@ -1,4 +1,3 @@
#include <xrpld/app/misc/HashRouter.h>
#include <xrpld/app/misc/ValidatorList.h>
#include <xrpld/app/misc/ValidatorSite.h>
#include <xrpld/overlay/Cluster.h>
@@ -15,6 +14,7 @@
#include <xrpl/basics/make_SSLContext.h>
#include <xrpl/basics/random.h>
#include <xrpl/beast/core/LexicalCast.h>
#include <xrpl/core/HashRouter.h>
#include <xrpl/protocol/STTx.h>
#include <xrpl/rdb/RelationalDatabase.h>
#include <xrpl/server/NetworkOPs.h>

View File

@@ -3,7 +3,6 @@
#include <xrpld/app/ledger/InboundTransactions.h>
#include <xrpld/app/ledger/LedgerMaster.h>
#include <xrpld/app/ledger/TransactionMaster.h>
#include <xrpld/app/misc/HashRouter.h>
#include <xrpld/app/misc/LoadFeeTrack.h>
#include <xrpld/app/misc/Transaction.h>
#include <xrpld/app/misc/ValidatorList.h>
@@ -16,6 +15,7 @@
#include <xrpl/basics/base64.h>
#include <xrpl/basics/random.h>
#include <xrpl/basics/safe_cast.h>
#include <xrpl/core/HashRouter.h>
#include <xrpl/core/PerfLog.h>
#include <xrpl/protocol/TxFlags.h>
#include <xrpl/protocol/digest.h>

View File

@@ -2,7 +2,6 @@
#include <xrpld/app/consensus/RCLCxPeerPos.h>
#include <xrpld/app/ledger/detail/LedgerReplayMsgHandler.h>
#include <xrpld/app/misc/HashRouter.h>
#include <xrpld/overlay/Squelch.h>
#include <xrpld/overlay/detail/OverlayImpl.h>
#include <xrpld/overlay/detail/ProtocolVersion.h>
@@ -11,6 +10,7 @@
#include <xrpl/basics/Log.h>
#include <xrpl/basics/UnorderedContainers.h>
#include <xrpl/beast/utility/WrappedSink.h>
#include <xrpl/core/HashRouter.h>
#include <xrpl/protocol/Protocol.h>
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STValidation.h>

View File

@@ -1,6 +1,5 @@
#include <xrpld/app/ledger/LedgerMaster.h>
#include <xrpld/app/ledger/OpenLedger.h>
#include <xrpld/app/misc/HashRouter.h>
#include <xrpld/app/misc/Transaction.h>
#include <xrpld/app/misc/TxQ.h>
#include <xrpld/app/tx/apply.h>
@@ -10,6 +9,7 @@
#include <xrpld/rpc/MPTokenIssuanceID.h>
#include <xrpld/rpc/detail/TransactionSign.h>
#include <xrpl/core/HashRouter.h>
#include <xrpl/protocol/ErrorCodes.h>
#include <xrpl/protocol/NFTSyntheticSerializer.h>
#include <xrpl/protocol/RPCErr.h>