diff --git a/include/xrpl/core/NetworkIDService.h b/include/xrpl/core/NetworkIDService.h new file mode 100644 index 0000000000..bd34046757 --- /dev/null +++ b/include/xrpl/core/NetworkIDService.h @@ -0,0 +1,36 @@ +#ifndef XRPL_CORE_NETWORKIDSERVICE_H_INCLUDED +#define XRPL_CORE_NETWORKIDSERVICE_H_INCLUDED + +#include + +namespace xrpl { + +/** Service that provides access to the network ID. + + This service provides read-only access to the network ID configured + for this server. The network ID identifies which network (mainnet, + testnet, devnet, or custom network) this server is configured to + connect to. + + Well-known network IDs: + - 0: Mainnet + - 1: Testnet + - 2: Devnet + - 1025+: Custom networks (require NetworkID field in transactions) +*/ +class NetworkIDService +{ +public: + virtual ~NetworkIDService() = default; + + /** Get the configured network ID + * + * @return The network ID this server is configured for + */ + virtual std::uint32_t + getNetworkID() const = 0; +}; + +} // namespace xrpl + +#endif diff --git a/include/xrpl/core/ServiceRegistry.h b/include/xrpl/core/ServiceRegistry.h index c6a78d6a2a..c119e60ae6 100644 --- a/include/xrpl/core/ServiceRegistry.h +++ b/include/xrpl/core/ServiceRegistry.h @@ -47,6 +47,7 @@ class LoadFeeTrack; class LoadManager; class ManifestCache; class NetworkOPs; +class NetworkIDService; class OpenLedger; class OrderBookDB; class Overlay; @@ -112,6 +113,9 @@ public: virtual LedgerConfigService& getLedgerConfigService() = 0; + virtual NetworkIDService& + getNetworkIDService() = 0; + // Protocol and validation services virtual AmendmentTable& getAmendmentTable() = 0; @@ -227,6 +231,9 @@ public: virtual Logs& logs() = 0; + virtual std::optional const& + trapTxID() const = 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& diff --git a/src/test/app/AMM_test.cpp b/src/test/app/AMM_test.cpp index 8d64dfed2a..c45b2ace18 100644 --- a/src/test/app/AMM_test.cpp +++ b/src/test/app/AMM_test.cpp @@ -3548,7 +3548,7 @@ private: auto jtx = env.jt(tx, seq(1), fee(baseFee)); env.app().config().features.erase(featureAMM); PreflightContext pfctx( - env.app(), + env.app().getServiceRegistry(), *jtx.stx, env.current()->rules(), tapNONE, @@ -3563,7 +3563,7 @@ private: jtx.jv["TxnSignature"] = "deadbeef"; jtx.stx = env.ust(jtx); PreflightContext pfctx( - env.app(), + env.app().getServiceRegistry(), *jtx.stx, env.current()->rules(), tapNONE, @@ -3578,7 +3578,7 @@ private: jtx.jv["Asset2"].removeMember("issuer"); jtx.stx = env.ust(jtx); PreflightContext pfctx( - env.app(), + env.app().getServiceRegistry(), *jtx.stx, env.current()->rules(), tapNONE, diff --git a/src/test/app/Batch_test.cpp b/src/test/app/Batch_test.cpp index d942724dab..a4af371ea0 100644 --- a/src/test/app/Batch_test.cpp +++ b/src/test/app/Batch_test.cpp @@ -1375,14 +1375,14 @@ class Batch_test : public beast::unit_test::suite batch::inner(pay(alice, bob, XRP(1)), aliceSeq), batch::inner(pay(alice, bob, XRP(1)), aliceSeq)); - env.app().openLedger().modify( - [&](OpenView& view, beast::Journal j) { - auto const result = - xrpl::apply(env.app(), view, *jt.stx, tapNONE, j); - BEAST_EXPECT( - !result.applied && result.ter == temARRAY_TOO_LARGE); - return result.applied; - }); + env.app().openLedger().modify([&](OpenView& view, + beast::Journal j) { + auto const result = xrpl::apply( + env.app().getServiceRegistry(), view, *jt.stx, tapNONE, j); + BEAST_EXPECT( + !result.applied && result.ter == temARRAY_TOO_LARGE); + return result.applied; + }); } // telENV_RPC_FAILED: Batch: signers array exceeds 8 entries. @@ -1421,14 +1421,14 @@ class Batch_test : public beast::unit_test::suite batch::inner(pay(alice, bob, XRP(5)), aliceSeq + 2), batch::sig(bob, bob, bob, bob, bob, bob, bob, bob, bob, bob)); - env.app().openLedger().modify( - [&](OpenView& view, beast::Journal j) { - auto const result = - xrpl::apply(env.app(), view, *jt.stx, tapNONE, j); - BEAST_EXPECT( - !result.applied && result.ter == temARRAY_TOO_LARGE); - return result.applied; - }); + env.app().openLedger().modify([&](OpenView& view, + beast::Journal j) { + auto const result = xrpl::apply( + env.app().getServiceRegistry(), view, *jt.stx, tapNONE, j); + BEAST_EXPECT( + !result.applied && result.ter == temARRAY_TOO_LARGE); + return result.applied; + }); } } @@ -3592,7 +3592,8 @@ class Batch_test : public beast::unit_test::suite BEAST_EXPECT(!passesLocalChecks(stx, reason)); BEAST_EXPECT(reason == "Cannot submit pseudo transactions."); env.app().openLedger().modify([&](OpenView& view, beast::Journal j) { - auto const result = xrpl::apply(env.app(), view, stx, tapNONE, j); + auto const result = xrpl::apply( + env.app().getServiceRegistry(), view, stx, tapNONE, j); BEAST_EXPECT(!result.applied && result.ter == temINVALID_FLAG); return result.applied; }); diff --git a/src/test/app/Escrow_test.cpp b/src/test/app/Escrow_test.cpp index d4a9fc5b9d..c466aaa8df 100644 --- a/src/test/app/Escrow_test.cpp +++ b/src/test/app/Escrow_test.cpp @@ -1314,7 +1314,7 @@ struct Escrow_test : public beast::unit_test::suite seq(1), fee(baseFee)); auto const pf = preflight( - env.app(), + env.app().getServiceRegistry(), env.current()->rules(), *jtx.stx, tapNONE, @@ -1329,7 +1329,7 @@ struct Escrow_test : public beast::unit_test::suite auto const jtx = env.jt(escrow::cancel("bob", "alice", 3), seq(1), fee(baseFee)); auto const pf = preflight( - env.app(), + env.app().getServiceRegistry(), env.current()->rules(), *jtx.stx, tapNONE, @@ -1344,7 +1344,7 @@ struct Escrow_test : public beast::unit_test::suite auto const jtx = env.jt(escrow::finish("bob", "alice", 3), seq(1), fee(baseFee)); auto const pf = preflight( - env.app(), + env.app().getServiceRegistry(), env.current()->rules(), *jtx.stx, tapNONE, diff --git a/src/test/app/FeeVote_test.cpp b/src/test/app/FeeVote_test.cpp index 230d9cf13e..ab6f0e206b 100644 --- a/src/test/app/FeeVote_test.cpp +++ b/src/test/app/FeeVote_test.cpp @@ -124,8 +124,12 @@ createInvalidFeeTx( bool applyFeeAndTestResult(jtx::Env& env, OpenView& view, STTx const& tx) { - auto const res = - apply(env.app(), view, tx, ApplyFlags::tapNONE, env.journal); + auto const res = apply( + env.app().getServiceRegistry(), + view, + tx, + ApplyFlags::tapNONE, + env.journal); return res.ter == tesSUCCESS; } diff --git a/src/test/app/Invariants_test.cpp b/src/test/app/Invariants_test.cpp index 8eb3047dc8..e9ed67baa0 100644 --- a/src/test/app/Invariants_test.cpp +++ b/src/test/app/Invariants_test.cpp @@ -89,7 +89,7 @@ class Invariants_test : public beast::unit_test::suite tx.setAccountID( sfAccount, setTxAccount == TxAccount::A1 ? A1.id() : A2.id()); ApplyContext ac{ - env.app(), + env.app().getServiceRegistry(), ov, tx, tesSUCCESS, diff --git a/src/test/app/LedgerHistory_test.cpp b/src/test/app/LedgerHistory_test.cpp index e7889e6bbd..539619bb8b 100644 --- a/src/test/app/LedgerHistory_test.cpp +++ b/src/test/app/LedgerHistory_test.cpp @@ -51,7 +51,12 @@ public: { OpenView accum(&*res); applyTransaction( - env.app(), accum, *stx, false, tapNONE, env.journal); + env.app().getServiceRegistry(), + accum, + *stx, + false, + tapNONE, + env.journal); accum.apply(*res); } res->updateSkipList(); diff --git a/src/test/app/LoanBroker_test.cpp b/src/test/app/LoanBroker_test.cpp index 72a732d043..ef0723d026 100644 --- a/src/test/app/LoanBroker_test.cpp +++ b/src/test/app/LoanBroker_test.cpp @@ -1291,7 +1291,7 @@ class LoanBroker_test : public beast::unit_test::suite test::StreamSink sink{beast::severities::kWarning}; beast::Journal jlog{sink}; ApplyContext ac{ - env.app(), + env.app().getServiceRegistry(), ov, tx, tesSUCCESS, @@ -1312,7 +1312,12 @@ class LoanBroker_test : public beast::unit_test::suite // Invoke preclaim against the mutated (ApplyView) view; triggers // nullptr deref PreclaimContext pctx{ - env.app(), ac.view(), tesSUCCESS, tx, tapNONE, jlog}; + env.app().getServiceRegistry(), + ac.view(), + tesSUCCESS, + tx, + tapNONE, + jlog}; (void)LoanBrokerCoverDeposit::preclaim(pctx); } diff --git a/src/test/app/NFTokenBurn_test.cpp b/src/test/app/NFTokenBurn_test.cpp index 828539f4b1..bc2dd4cba4 100644 --- a/src/test/app/NFTokenBurn_test.cpp +++ b/src/test/app/NFTokenBurn_test.cpp @@ -780,7 +780,7 @@ class NFTokenBurn_test : public beast::unit_test::suite test::StreamSink sink{beast::severities::kWarning}; beast::Journal jlog{sink}; ApplyContext ac{ - env.app(), + env.app().getServiceRegistry(), ov, tx, tesSUCCESS, @@ -824,7 +824,7 @@ class NFTokenBurn_test : public beast::unit_test::suite test::StreamSink sink{beast::severities::kWarning}; beast::Journal jlog{sink}; ApplyContext ac{ - env.app(), + env.app().getServiceRegistry(), ov, tx, tesSUCCESS, diff --git a/src/test/app/PseudoTx_test.cpp b/src/test/app/PseudoTx_test.cpp index f01ba616c8..1435c493a2 100644 --- a/src/test/app/PseudoTx_test.cpp +++ b/src/test/app/PseudoTx_test.cpp @@ -75,8 +75,8 @@ struct PseudoTx_test : public beast::unit_test::suite BEAST_EXPECT(reason == "Cannot submit pseudo transactions."); env.app().openLedger().modify( [&](OpenView& view, beast::Journal j) { - auto const result = - xrpl::apply(env.app(), view, stx, tapNONE, j); + auto const result = xrpl::apply( + env.app().getServiceRegistry(), view, stx, tapNONE, j); BEAST_EXPECT(!result.applied && result.ter == temINVALID); return result.applied; }); diff --git a/src/test/app/Regression_test.cpp b/src/test/app/Regression_test.cpp index 0ddb9fe61c..7726c266d8 100644 --- a/src/test/app/Regression_test.cpp +++ b/src/test/app/Regression_test.cpp @@ -63,8 +63,12 @@ struct Regression_test : public beast::unit_test::suite auto const jt = env.jt(pay(env.master, "alice", aliceAmount)); OpenView accum(&*next); - auto const result = - xrpl::apply(env.app(), accum, *jt.stx, tapNONE, env.journal); + auto const result = xrpl::apply( + env.app().getServiceRegistry(), + accum, + *jt.stx, + tapNONE, + env.journal); BEAST_EXPECT(result.ter == tesSUCCESS); BEAST_EXPECT(result.applied); @@ -87,8 +91,12 @@ struct Regression_test : public beast::unit_test::suite OpenView accum(&*next); - auto const result = - xrpl::apply(env.app(), accum, *jt.stx, tapNONE, env.journal); + auto const result = xrpl::apply( + env.app().getServiceRegistry(), + accum, + *jt.stx, + tapNONE, + env.journal); BEAST_EXPECT(result.ter == tecINSUFF_FEE); BEAST_EXPECT(result.applied); diff --git a/src/test/app/TxQ_test.cpp b/src/test/app/TxQ_test.cpp index f6ab13e04f..96b9974bcd 100644 --- a/src/test/app/TxQ_test.cpp +++ b/src/test/app/TxQ_test.cpp @@ -977,13 +977,17 @@ public: Env::ParsedResult parsed; - env.app().openLedger().modify([&](OpenView& view, - beast::Journal j) { - auto const result = - xrpl::apply(env.app(), view, *jt.stx, tapNONE, env.journal); - parsed.ter = result.ter; - return result.applied; - }); + env.app().openLedger().modify( + [&](OpenView& view, beast::Journal j) { + auto const result = xrpl::apply( + env.app().getServiceRegistry(), + view, + *jt.stx, + tapNONE, + env.journal); + parsed.ter = result.ter; + return result.applied; + }); env.postconditions(jt, parsed); } checkMetrics(*this, env, 1, std::nullopt, 4, 2); @@ -2428,7 +2432,7 @@ public: { auto const jtx = env.jt(offer_cancel(alice, 3), seq(5), fee(10)); auto const pf = preflight( - env.app(), + env.app().getServiceRegistry(), env.current()->rules(), *jtx.stx, tapNONE, @@ -2445,7 +2449,7 @@ public: auto const jtx = env.jt(trust("carol", USD(50000000)), seq(1), fee(10)); auto const pf = preflight( - env.app(), + env.app().getServiceRegistry(), env.current()->rules(), *jtx.stx, tapNONE, @@ -2459,7 +2463,7 @@ public: { auto const jtx = env.jt(ticket::create(alice, 1), seq(1), fee(10)); auto const pf = preflight( - env.app(), + env.app().getServiceRegistry(), env.current()->rules(), *jtx.stx, tapNONE, @@ -4190,8 +4194,8 @@ public: env.app().openLedger().modify([&](OpenView& view, beast::Journal j) { auto const tx = env.jt(noop(alice), seq(aliceSeq), fee(openLedgerCost(env))); - auto const result = - xrpl::apply(env.app(), view, *tx.stx, tapUNLIMITED, j); + auto const result = xrpl::apply( + env.app().getServiceRegistry(), view, *tx.stx, tapUNLIMITED, j); BEAST_EXPECT(result.ter == tesSUCCESS && result.applied); return result.applied; }); @@ -4262,8 +4266,8 @@ public: noop(alice), ticket::use(tktSeq0 + 1), fee(openLedgerCost(env))); - auto const result = - xrpl::apply(env.app(), view, *tx.stx, tapUNLIMITED, j); + auto const result = xrpl::apply( + env.app().getServiceRegistry(), view, *tx.stx, tapUNLIMITED, j); BEAST_EXPECT(result.ter == tesSUCCESS && result.applied); return result.applied; }); diff --git a/src/test/app/tx/apply_test.cpp b/src/test/app/tx/apply_test.cpp index 0b198dcd22..3584e588ae 100644 --- a/src/test/app/tx/apply_test.cpp +++ b/src/test/app/tx/apply_test.cpp @@ -42,8 +42,7 @@ public: Validity valid = checkValidity( fully_canonical.app().getHashRouter(), tx, - fully_canonical.current()->rules(), - fully_canonical.app().config()) + fully_canonical.current()->rules()) .first; if (valid == Validity::Valid) fail("Non-Fully canonical signature was permitted"); diff --git a/src/test/consensus/NegativeUNL_test.cpp b/src/test/consensus/NegativeUNL_test.cpp index eed2893b9e..f44ca2a083 100644 --- a/src/test/consensus/NegativeUNL_test.cpp +++ b/src/test/consensus/NegativeUNL_test.cpp @@ -1865,8 +1865,12 @@ negUnlSizeTest( bool applyAndTestResult(jtx::Env& env, OpenView& view, STTx const& tx, bool pass) { - auto const res = - apply(env.app(), view, tx, ApplyFlags::tapNONE, env.journal); + auto const res = apply( + env.app().getServiceRegistry(), + view, + tx, + ApplyFlags::tapNONE, + env.journal); if (pass) return res.ter == tesSUCCESS; else diff --git a/src/test/rpc/AccountSet_test.cpp b/src/test/rpc/AccountSet_test.cpp index 40ef4acba7..9bcf5ded7b 100644 --- a/src/test/rpc/AccountSet_test.cpp +++ b/src/test/rpc/AccountSet_test.cpp @@ -565,7 +565,8 @@ public: stx->at(sfSigningPubKey) = makeSlice(std::string("badkey")); env.app().openLedger().modify([&](OpenView& view, beast::Journal j) { - auto const result = xrpl::apply(env.app(), view, *stx, tapNONE, j); + auto const result = xrpl::apply( + env.app().getServiceRegistry(), view, *stx, tapNONE, j); BEAST_EXPECT(result.ter == temBAD_SIGNATURE); BEAST_EXPECT(!result.applied); return result.applied; diff --git a/src/xrpld/app/consensus/RCLConsensus.cpp b/src/xrpld/app/consensus/RCLConsensus.cpp index e4bd496e23..0f5beeb888 100644 --- a/src/xrpld/app/consensus/RCLConsensus.cpp +++ b/src/xrpld/app/consensus/RCLConsensus.cpp @@ -649,7 +649,7 @@ RCLConsensus::Adaptor::doAccept( "consensus", [&](OpenView& view, beast::Journal j) { // Stuff the ledger with transactions from the queue. - return app_.getTxQ().accept(app_, view); + return app_.getTxQ().accept(app_.getServiceRegistry(), view); }); // Signal a potential fee change to subscribers after the open ledger @@ -782,7 +782,8 @@ RCLConsensus::Adaptor::buildLCL( // Update fee computations based on accepted txs using namespace std::chrono_literals; - app_.getTxQ().processClosedLedger(app_, *built, roundTime > 5s); + app_.getTxQ().processClosedLedger( + app_.getServiceRegistry(), *built, roundTime > 5s); // And stash the ledger in the ledger master if (ledgerMaster_.storeLedger(built)) diff --git a/src/xrpld/app/ledger/detail/BuildLedger.cpp b/src/xrpld/app/ledger/detail/BuildLedger.cpp index 06e858dba2..e37fd84f1e 100644 --- a/src/xrpld/app/ledger/detail/BuildLedger.cpp +++ b/src/xrpld/app/ledger/detail/BuildLedger.cpp @@ -79,7 +79,7 @@ buildLedgerImpl( std::size_t applyTransactions( - Application& app, + ServiceRegistry& registry, std::shared_ptr const& built, CanonicalTXSet& txns, std::set& failed, @@ -111,7 +111,7 @@ applyTransactions( } switch (applyTransaction( - app, view, *it->second, certainRetry, tapNONE, j)) + registry, view, *it->second, certainRetry, tapNONE, j)) { case ApplyTransactionResult::Success: it = txns.erase(it); @@ -186,8 +186,8 @@ buildLedger( JLOG(j.debug()) << "Attempting to apply " << txns.size() << " transactions"; - auto const applied = applyTransactions( - registry.app(), built, txns, failedTxns, accum, j); + auto const applied = + applyTransactions(registry, built, txns, failedTxns, accum, j); if (!txns.empty() || !failedTxns.empty()) JLOG(j.debug()) @@ -226,7 +226,7 @@ buildLedger( [&](OpenView& accum, std::shared_ptr const& built) { for (auto& tx : replayData.orderedTxns()) applyTransaction( - registry.app(), accum, *tx.second, false, applyFlags, j); + registry, accum, *tx.second, false, applyFlags, j); }); } diff --git a/src/xrpld/app/ledger/detail/OpenLedger.cpp b/src/xrpld/app/ledger/detail/OpenLedger.cpp index 0d982c5ac6..8657a276e9 100644 --- a/src/xrpld/app/ledger/detail/OpenLedger.cpp +++ b/src/xrpld/app/ledger/detail/OpenLedger.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -93,7 +94,7 @@ OpenLedger::accept( f(*next, j_); // Apply local tx for (auto const& item : locals) - registry.getTxQ().apply(registry.app(), *next, item.second, flags, j_); + registry.getTxQ().apply(registry, *next, item.second, flags, j_); // If we didn't relay this transaction recently, relay it to all peers for (auto const& txpair : next->txs) diff --git a/src/xrpld/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp index 5832eb7934..353408dcfa 100644 --- a/src/xrpld/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -171,6 +172,7 @@ public: CachedSLEs cachedSLEs_; std::unique_ptr featureSetService_; std::unique_ptr ledgerConfigService_; + std::unique_ptr networkIDService_; std::optional> nodeIdentity_; ValidatorKeys const validatorKeys_; @@ -339,6 +341,8 @@ public: *config_, *featureSetService_)) + , networkIDService_(std::make_unique(*config_)) + , validatorKeys_(*config_, m_journal) , m_resourceManager(Resource::make_Manager( @@ -732,6 +736,12 @@ public: return *ledgerConfigService_; } + NetworkIDService& + getNetworkIDService() override + { + return *networkIDService_; + } + AmendmentTable& getAmendmentTable() override { diff --git a/src/xrpld/app/main/Application.h b/src/xrpld/app/main/Application.h index 03b1e7df27..70dd232fe4 100644 --- a/src/xrpld/app/main/Application.h +++ b/src/xrpld/app/main/Application.h @@ -165,6 +165,8 @@ public: getFeatureSetService() = 0; virtual LedgerConfigService& getLedgerConfigService() = 0; + virtual NetworkIDService& + getNetworkIDService() = 0; virtual AmendmentTable& getAmendmentTable() = 0; virtual HashRouter& diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index 2017123519..3982481dfd 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -1203,8 +1203,7 @@ NetworkOPsImp::submitTransaction(std::shared_ptr const& iTrans) auto const [validity, reason] = checkValidity( registry_.getHashRouter(), *trans, - m_ledgerMaster.getValidatedRules(), - registry_.app().config()); + m_ledgerMaster.getValidatedRules()); if (validity != Validity::Valid) { @@ -1264,11 +1263,8 @@ NetworkOPsImp::preProcessTransaction(std::shared_ptr& transaction) // NOTE eahennis - I think this check is redundant, // but I'm not 100% sure yet. // If so, only cost is looking up HashRouter flags. - auto const [validity, reason] = checkValidity( - registry_.getHashRouter(), - sttx, - view->rules(), - registry_.app().config()); + auto const [validity, reason] = + checkValidity(registry_.getHashRouter(), sttx, view->rules()); XRPL_ASSERT( validity == Validity::Valid, "xrpl::NetworkOPsImp::processTransaction : valid validity"); @@ -1507,7 +1503,7 @@ NetworkOPsImp::apply(std::unique_lock& batchLock) flags |= tapFAIL_HARD; auto const result = registry_.getTxQ().apply( - registry_.app(), + registry_, view, e.transaction->getSTransaction(), flags, @@ -1996,7 +1992,7 @@ NetworkOPsImp::switchLastClosedLedger( clearNeedNetworkLedger(); // Update fee computations. - registry_.getTxQ().processClosedLedger(registry_.app(), *newLCL, true); + registry_.getTxQ().processClosedLedger(registry_, *newLCL, true); // Caller must own master lock { @@ -2022,7 +2018,7 @@ NetworkOPsImp::switchLastClosedLedger( "jump", [&](OpenView& view, beast::Journal j) { // Stuff the ledger with transactions from the queue. - return registry_.getTxQ().accept(registry_.app(), view); + return registry_.getTxQ().accept(registry_, view); }); } diff --git a/src/xrpld/app/misc/TxQ.h b/src/xrpld/app/misc/TxQ.h index aff7fc89db..16d516166c 100644 --- a/src/xrpld/app/misc/TxQ.h +++ b/src/xrpld/app/misc/TxQ.h @@ -253,7 +253,7 @@ public: */ ApplyResult apply( - Application& app, + ServiceRegistry& registry, OpenView& view, std::shared_ptr const& tx, ApplyFlags flags, @@ -271,7 +271,7 @@ public: @return Whether any transactions were added to the `view`. */ bool - accept(Application& app, OpenView& view); + accept(ServiceRegistry& registry, OpenView& view); /** Update fee metrics and clean up the queue in preparation for @@ -286,7 +286,10 @@ public: that have no candidates under them are removed. */ void - processClosedLedger(Application& app, ReadView const& view, bool timeLeap); + processClosedLedger( + ServiceRegistry& registry, + ReadView const& view, + bool timeLeap); /** Return the next sequence that would go in the TxQ for an account. */ SeqProxy @@ -341,7 +344,7 @@ public: @returns a `Json objectvalue` */ Json::Value - doRPC(Application& app) const; + doRPC(ServiceRegistry& registry) const; private: // Implementation for nextQueuableSeq(). The passed lock must be held. @@ -413,7 +416,7 @@ private: */ std::size_t update( - Application& app, + ServiceRegistry& registry, ReadView const& view, bool timeLeap, TxQ::Setup const& setup); @@ -581,7 +584,7 @@ private: /// Attempt to apply the queued transaction to the open ledger. ApplyResult - apply(Application& app, OpenView& view, beast::Journal j); + apply(ServiceRegistry& registry, OpenView& view, beast::Journal j); /// Potential @ref TxConsequences of applying this transaction /// to the open ledger. @@ -716,7 +719,7 @@ private: // attempt to directly apply that transaction to the ledger. std::optional tryDirectApply( - Application& app, + ServiceRegistry& registry, OpenView& view, std::shared_ptr const& tx, ApplyFlags flags, @@ -820,7 +823,7 @@ private: */ ApplyResult tryClearAccountQueueUpThruTx( - Application& app, + ServiceRegistry& registry, OpenView& view, STTx const& tx, AccountMap::iterator const& accountIter, diff --git a/src/xrpld/app/misc/detail/TxQ.cpp b/src/xrpld/app/misc/detail/TxQ.cpp index 9f260e5f48..41495ab696 100644 --- a/src/xrpld/app/misc/detail/TxQ.cpp +++ b/src/xrpld/app/misc/detail/TxQ.cpp @@ -63,7 +63,7 @@ increase(FeeLevel64 level, std::uint32_t increasePercent) std::size_t TxQ::FeeMetrics::update( - Application& app, + ServiceRegistry& registry, ReadView const& view, bool timeLeap, TxQ::Setup const& setup) @@ -277,7 +277,7 @@ TxQ::MaybeTx::MaybeTx( } ApplyResult -TxQ::MaybeTx::apply(Application& app, OpenView& view, beast::Journal j) +TxQ::MaybeTx::apply(ServiceRegistry& registry, OpenView& view, beast::Journal j) { // If the rules or flags change, preflight again XRPL_ASSERT( @@ -290,13 +290,13 @@ TxQ::MaybeTx::apply(Application& app, OpenView& view, beast::Journal j) << " rules or flags have changed. Flags from " << pfresult->flags << " to " << flags; - pfresult.emplace( - preflight(app, view.rules(), pfresult->tx, flags, pfresult->j)); + pfresult.emplace(preflight( + registry, view.rules(), pfresult->tx, flags, pfresult->j)); } - auto pcresult = preclaim(*pfresult, app, view); + auto pcresult = preclaim(*pfresult, registry, view); - return doApply(pcresult, app, view); + return doApply(pcresult, registry, view); } TxQ::TxQAccount::TxQAccount(std::shared_ptr const& txn) @@ -497,7 +497,7 @@ TxQ::erase( ApplyResult TxQ::tryClearAccountQueueUpThruTx( - Application& app, + ServiceRegistry& registry, OpenView& view, STTx const& tx, TxQ::AccountMap::iterator const& accountIter, @@ -543,7 +543,7 @@ TxQ::tryClearAccountQueueUpThruTx( // Attempt to apply the queued transactions. for (auto it = beginTxIter; it != endTxIter; ++it) { - auto txResult = it->second.apply(app, view, j); + auto txResult = it->second.apply(registry, view, j); // Succeed or fail, use up a retry, because if the overall // process fails, we want the attempt to count. If it all // succeeds, the MaybeTx will be destructed, so it'll be @@ -578,7 +578,8 @@ TxQ::tryClearAccountQueueUpThruTx( } // Apply the current tx. Because the state of the view has been changed // by the queued txs, we also need to preclaim again. - auto const txResult = doApply(preclaim(pfresult, app, view), app, view); + auto const txResult = + doApply(preclaim(pfresult, registry, view), registry, view); if (txResult.applied) { @@ -709,7 +710,7 @@ TxQ::tryClearAccountQueueUpThruTx( // ApplyResult TxQ::apply( - Application& app, + ServiceRegistry& registry, OpenView& view, std::shared_ptr const& tx, ApplyFlags flags, @@ -720,13 +721,13 @@ TxQ::apply( // See if the transaction is valid, properly formed, // etc. before doing potentially expensive queue // replace and multi-transaction operations. - auto const pfresult = preflight(app, view.rules(), *tx, flags, j); + auto const pfresult = preflight(registry, view.rules(), *tx, flags, j); if (pfresult.ter != tesSUCCESS) return {pfresult.ter, false}; // See if the transaction paid a high enough fee that it can go straight // into the ledger. - if (auto directApplied = tryDirectApply(app, view, tx, flags, j)) + if (auto directApplied = tryDirectApply(registry, view, tx, flags, j)) return *directApplied; // If we get past tryDirectApply() without returning then we expect @@ -1144,7 +1145,7 @@ TxQ::apply( // is valid. So we use a special entry point that runs all of the // preclaim checks with the exception of the sequence check. auto const pcresult = - preclaim(pfresult, app, multiTxn ? multiTxn->openView : view); + preclaim(pfresult, registry, multiTxn ? multiTxn->openView : view); if (!pcresult.likelyToClaimFee) return {pcresult.ter, false}; @@ -1181,7 +1182,7 @@ TxQ::apply( OpenView sandbox(open_ledger, &view, view.rules()); auto result = tryClearAccountQueueUpThruTx( - app, + registry, sandbox, *tx, accountIter, @@ -1342,11 +1343,14 @@ TxQ::apply( */ void -TxQ::processClosedLedger(Application& app, ReadView const& view, bool timeLeap) +TxQ::processClosedLedger( + ServiceRegistry& registry, + ReadView const& view, + bool timeLeap) { std::lock_guard lock(mutex_); - feeMetrics_.update(app, view, timeLeap, setup_); + feeMetrics_.update(registry, view, timeLeap, setup_); auto const& snapshot = feeMetrics_.getSnapshot(); auto ledgerSeq = view.header().seq; @@ -1411,7 +1415,7 @@ TxQ::processClosedLedger(Application& app, ReadView const& view, bool timeLeap) * the next tx in the queue, simply ordered by fee. */ bool -TxQ::accept(Application& app, OpenView& view) +TxQ::accept(ServiceRegistry& registry, OpenView& view) { /* Move transactions from the queue from largest fee level to smallest. As we add more transactions, the required fee level will increase. @@ -1455,7 +1459,7 @@ TxQ::accept(Application& app, OpenView& view) << candidateIter->txID << " to open ledger."; auto const [txnResult, didApply, _metadata] = - candidateIter->apply(app, view, j_); + candidateIter->apply(registry, view, j_); if (didApply) { @@ -1655,7 +1659,7 @@ TxQ::getRequiredFeeLevel( std::optional TxQ::tryDirectApply( - Application& app, + ServiceRegistry& registry, OpenView& view, std::shared_ptr const& tx, ApplyFlags flags, @@ -1694,7 +1698,7 @@ TxQ::tryDirectApply( << " to open ledger."; auto const [txnResult, didApply, metadata] = - xrpl::apply(app, view, *tx, flags, j); + xrpl::apply(registry, view, *tx, flags, j); JLOG(j_.trace()) << "New transaction " << transactionID << (didApply ? " applied successfully with " @@ -1835,9 +1839,9 @@ TxQ::getTxs() const } Json::Value -TxQ::doRPC(Application& app) const +TxQ::doRPC(ServiceRegistry& registry) const { - auto const view = app.openLedger().current(); + auto const view = registry.app().openLedger().current(); if (!view) { BOOST_ASSERT(false); diff --git a/src/xrpld/app/tx/apply.h b/src/xrpld/app/tx/apply.h index 260bd1721b..f5342fd239 100644 --- a/src/xrpld/app/tx/apply.h +++ b/src/xrpld/app/tx/apply.h @@ -12,7 +12,6 @@ namespace xrpl { -class Application; class HashRouter; class ServiceRegistry; @@ -43,11 +42,7 @@ enum class Validity { @see Validity */ std::pair -checkValidity( - HashRouter& router, - STTx const& tx, - Rules const& rules, - Config const& config); +checkValidity(HashRouter& router, STTx const& tx, Rules const& rules); /** Sets the validity of a given transaction in the cache. @@ -103,15 +98,6 @@ forceValidity(HashRouter& router, uint256 const& txid, Validity validity); whether or not the transaction was applied. */ ApplyResult -apply( - Application& app, - OpenView& view, - STTx const& tx, - ApplyFlags flags, - beast::Journal journal); - -// Overload for ServiceRegistry -ApplyResult apply( ServiceRegistry& registry, OpenView& view, @@ -141,7 +127,7 @@ enum class ApplyTransactionResult { */ ApplyTransactionResult applyTransaction( - Application& app, + ServiceRegistry& registry, OpenView& view, STTx const& tx, bool retryAssured, diff --git a/src/xrpld/app/tx/applySteps.h b/src/xrpld/app/tx/applySteps.h index c0c530f3ac..6917e4a8c7 100644 --- a/src/xrpld/app/tx/applySteps.h +++ b/src/xrpld/app/tx/applySteps.h @@ -6,7 +6,7 @@ namespace xrpl { -class Application; +class ServiceRegistry; class STTx; class TxQ; @@ -245,7 +245,7 @@ public: /** @{ */ PreflightResult preflight( - Application& app, + ServiceRegistry& registry, Rules const& rules, STTx const& tx, ApplyFlags flags, @@ -253,7 +253,7 @@ preflight( PreflightResult preflight( - Application& app, + ServiceRegistry& registry, Rules const& rules, uint256 const& parentBatchId, STTx const& tx, @@ -292,7 +292,7 @@ preflight( PreclaimResult preclaim( PreflightResult const& preflightResult, - Application& app, + ServiceRegistry& registry, OpenView const& view); /** Compute only the expected base fee for a transaction. @@ -335,7 +335,7 @@ calculateDefaultBaseFee(ReadView const& view, STTx const& tx); @param preclaimResult The result of a previous call to `preclaim` for the transaction. - @param app The current running `Application`. + @param registry The service registry. @param view The open ledger that the transaction will attempt to be applied to. @@ -345,7 +345,10 @@ calculateDefaultBaseFee(ReadView const& view, STTx const& tx); whether or not the transaction was applied. */ ApplyResult -doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view); +doApply( + PreclaimResult const& preclaimResult, + ServiceRegistry& registry, + OpenView& view); } // namespace xrpl diff --git a/src/xrpld/app/tx/detail/AMMCreate.cpp b/src/xrpld/app/tx/detail/AMMCreate.cpp index 3a3ce4b1e1..26e66830ac 100644 --- a/src/xrpld/app/tx/detail/AMMCreate.cpp +++ b/src/xrpld/app/tx/detail/AMMCreate.cpp @@ -308,7 +308,7 @@ applyCreate( auto const dir = keylet::quality(keylet::book(book), uRate); if (auto const bookExisted = static_cast(sb.read(dir)); !bookExisted) - ctx_.app.getOrderBookDB().addOrderBook(book); + ctx_.registry.getOrderBookDB().addOrderBook(book); }; addOrderBook(amount.issue(), amount2.issue(), getRate(amount2, amount)); addOrderBook(amount2.issue(), amount.issue(), getRate(amount, amount2)); diff --git a/src/xrpld/app/tx/detail/ApplyContext.cpp b/src/xrpld/app/tx/detail/ApplyContext.cpp index d364950b44..46398c3d10 100644 --- a/src/xrpld/app/tx/detail/ApplyContext.cpp +++ b/src/xrpld/app/tx/detail/ApplyContext.cpp @@ -8,7 +8,7 @@ namespace xrpl { ApplyContext::ApplyContext( - Application& app_, + ServiceRegistry& registry_, OpenView& base, std::optional const& parentBatchId, STTx const& tx_, @@ -16,7 +16,7 @@ ApplyContext::ApplyContext( XRPAmount baseFee_, ApplyFlags flags, beast::Journal journal_) - : app(app_) + : registry(registry_) , tx(tx_) , preclaimResult(preclaimResult_) , baseFee(baseFee_) diff --git a/src/xrpld/app/tx/detail/ApplyContext.h b/src/xrpld/app/tx/detail/ApplyContext.h index 4ae2f11a85..3cb2d439a0 100644 --- a/src/xrpld/app/tx/detail/ApplyContext.h +++ b/src/xrpld/app/tx/detail/ApplyContext.h @@ -1,10 +1,8 @@ #ifndef XRPL_TX_APPLYCONTEXT_H_INCLUDED #define XRPL_TX_APPLYCONTEXT_H_INCLUDED -#include -#include - #include +#include #include #include #include @@ -18,7 +16,7 @@ class ApplyContext { public: explicit ApplyContext( - Application& app, + ServiceRegistry& registry, OpenView& base, std::optional const& parentBatchId, STTx const& tx, @@ -28,7 +26,7 @@ public: beast::Journal journal = beast::Journal{beast::Journal::getNullSink()}); explicit ApplyContext( - Application& app, + ServiceRegistry& registry, OpenView& base, STTx const& tx, TER preclaimResult, @@ -36,7 +34,7 @@ public: ApplyFlags flags, beast::Journal journal = beast::Journal{beast::Journal::getNullSink()}) : ApplyContext( - app, + registry, base, std::nullopt, tx, @@ -49,7 +47,7 @@ public: (flags & tapBATCH) == 0, "Batch apply flag should not be set"); } - Application& app; + ServiceRegistry& registry; STTx const& tx; TER const preclaimResult; XRPAmount const baseFee; diff --git a/src/xrpld/app/tx/detail/Batch.cpp b/src/xrpld/app/tx/detail/Batch.cpp index 277bd4e3b7..d69287cf1d 100644 --- a/src/xrpld/app/tx/detail/Batch.cpp +++ b/src/xrpld/app/tx/detail/Batch.cpp @@ -307,7 +307,7 @@ Batch::preflight(PreflightContext const& ctx) auto const innerAccount = stx.getAccountID(sfAccount); if (auto const preflightResult = xrpl::preflight( - ctx.app, ctx.rules, parentBatchId, stx, tapBATCH, ctx.j); + ctx.registry, ctx.rules, parentBatchId, stx, tapBATCH, ctx.j); preflightResult.ter != tesSUCCESS) { JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: " diff --git a/src/xrpld/app/tx/detail/CancelCheck.cpp b/src/xrpld/app/tx/detail/CancelCheck.cpp index b673784655..39277c7cf8 100644 --- a/src/xrpld/app/tx/detail/CancelCheck.cpp +++ b/src/xrpld/app/tx/detail/CancelCheck.cpp @@ -64,7 +64,7 @@ CancelCheck::doApply() AccountID const srcId{sleCheck->getAccountID(sfAccount)}; AccountID const dstId{sleCheck->getAccountID(sfDestination)}; - auto viewJ = ctx_.app.journal("View"); + auto viewJ = ctx_.registry.journal("View"); // If the check is not written to self (and it shouldn't be), remove the // check from the destination account root. diff --git a/src/xrpld/app/tx/detail/CancelOffer.cpp b/src/xrpld/app/tx/detail/CancelOffer.cpp index 1dc9ad0bde..3b690cb730 100644 --- a/src/xrpld/app/tx/detail/CancelOffer.cpp +++ b/src/xrpld/app/tx/detail/CancelOffer.cpp @@ -54,7 +54,7 @@ CancelOffer::doApply() if (auto sleOffer = view().peek(keylet::offer(account_, offerSequence))) { JLOG(j_.debug()) << "Trying to cancel offer #" << offerSequence; - return offerDelete(view(), sleOffer, ctx_.app.journal("View")); + return offerDelete(view(), sleOffer, ctx_.registry.journal("View")); } JLOG(j_.debug()) << "Offer #" << offerSequence << " can't be found."; diff --git a/src/xrpld/app/tx/detail/CashCheck.cpp b/src/xrpld/app/tx/detail/CashCheck.cpp index c32b7dfe4e..eb9b52f0eb 100644 --- a/src/xrpld/app/tx/detail/CashCheck.cpp +++ b/src/xrpld/app/tx/detail/CashCheck.cpp @@ -247,7 +247,7 @@ CashCheck::doApply() // // If it is not a check to self (as should be the case), then there's // work to do... - auto viewJ = ctx_.app.journal("View"); + auto viewJ = ctx_.registry.journal("View"); auto const optDeliverMin = ctx_.tx[~sfDeliverMin]; if (srcId != account_) diff --git a/src/xrpld/app/tx/detail/Change.cpp b/src/xrpld/app/tx/detail/Change.cpp index 191d91863d..dbec440d6e 100644 --- a/src/xrpld/app/tx/detail/Change.cpp +++ b/src/xrpld/app/tx/detail/Change.cpp @@ -1,5 +1,3 @@ -#include -#include #include #include #include @@ -208,7 +206,7 @@ Change::applyAmendment() entry[sfCloseTime] = view().parentCloseTime().time_since_epoch().count(); - if (!ctx_.app.getAmendmentTable().isSupported(amendment)) + if (!ctx_.registry.getAmendmentTable().isSupported(amendment)) { JLOG(j_.warn()) << "Unsupported amendment " << amendment << " received a majority."; @@ -220,13 +218,13 @@ Change::applyAmendment() amendments.push_back(amendment); amendmentObject->setFieldV256(sfAmendments, amendments); - ctx_.app.getAmendmentTable().enable(amendment); + ctx_.registry.getAmendmentTable().enable(amendment); - if (!ctx_.app.getAmendmentTable().isSupported(amendment)) + if (!ctx_.registry.getAmendmentTable().isSupported(amendment)) { JLOG(j_.error()) << "Unsupported amendment " << amendment << " activated: server blocked."; - ctx_.app.getOPs().setAmendmentBlocked(); + ctx_.registry.getOPs().setAmendmentBlocked(); } } diff --git a/src/xrpld/app/tx/detail/CreateCheck.cpp b/src/xrpld/app/tx/detail/CreateCheck.cpp index 11613a5855..a9d7cb950b 100644 --- a/src/xrpld/app/tx/detail/CreateCheck.cpp +++ b/src/xrpld/app/tx/detail/CreateCheck.cpp @@ -174,7 +174,7 @@ CreateCheck::doApply() view().insert(sleCheck); - auto viewJ = ctx_.app.journal("View"); + auto viewJ = ctx_.registry.journal("View"); // If it's not a self-send (and it shouldn't be), add Check to the // destination's owner directory. if (dstAccountId != account_) diff --git a/src/xrpld/app/tx/detail/CreateOffer.cpp b/src/xrpld/app/tx/detail/CreateOffer.cpp index f81afecd55..b4618d5f79 100644 --- a/src/xrpld/app/tx/detail/CreateOffer.cpp +++ b/src/xrpld/app/tx/detail/CreateOffer.cpp @@ -147,7 +147,7 @@ CreateOffer::preclaim(PreclaimContext const& ctx) std::uint32_t const uAccountSequence = sleCreator->getFieldU32(sfSequence); - auto viewJ = ctx.app.journal("View"); + auto viewJ = ctx.registry.journal("View"); if (isGlobalFrozen(ctx.view, uPaysIssuerID) || isGlobalFrozen(ctx.view, uGetsIssuerID)) @@ -530,7 +530,7 @@ CreateOffer::applyHybrid( bookArr.push_back(std::move(bookInfo)); if (!bookExists) - ctx_.app.getOrderBookDB().addOrderBook(book); + ctx_.registry.getOrderBookDB().addOrderBook(book); sleOffer->setFieldArray(sfAdditionalBooks, bookArr); return tesSUCCESS; @@ -564,7 +564,7 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel) // end up on the books. auto uRate = getRate(saTakerGets, saTakerPays); - auto viewJ = ctx_.app.journal("View"); + auto viewJ = ctx_.registry.journal("View"); TER result = tesSUCCESS; @@ -880,7 +880,7 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel) sb.insert(sleOffer); if (!bookExisted) - ctx_.app.getOrderBookDB().addOrderBook(book); + ctx_.registry.getOrderBookDB().addOrderBook(book); JLOG(j_.debug()) << "final result: success"; diff --git a/src/xrpld/app/tx/detail/CreateTicket.cpp b/src/xrpld/app/tx/detail/CreateTicket.cpp index 6432d1b3d5..aa01d22f7c 100644 --- a/src/xrpld/app/tx/detail/CreateTicket.cpp +++ b/src/xrpld/app/tx/detail/CreateTicket.cpp @@ -71,7 +71,7 @@ CreateTicket::doApply() return tecINSUFFICIENT_RESERVE; } - beast::Journal viewJ{ctx_.app.journal("View")}; + beast::Journal viewJ{ctx_.registry.journal("View")}; // The starting ticket sequence is the same as the current account // root sequence. Before we got here to doApply(), the transaction diff --git a/src/xrpld/app/tx/detail/DeleteAccount.cpp b/src/xrpld/app/tx/detail/DeleteAccount.cpp index 422ed37e2f..37c7785cf5 100644 --- a/src/xrpld/app/tx/detail/DeleteAccount.cpp +++ b/src/xrpld/app/tx/detail/DeleteAccount.cpp @@ -53,7 +53,7 @@ DeleteAccount::calculateBaseFee(ReadView const& view, STTx const& tx) namespace { // Define a function pointer type that can be used to delete ledger node types. using DeleterFuncPtr = TER (*)( - Application& app, + ServiceRegistry& registry, ApplyView& view, AccountID const& account, uint256 const& delIndex, @@ -63,7 +63,7 @@ using DeleterFuncPtr = TER (*)( // Local function definitions that provides signature compatibility. TER offerDelete( - Application& app, + ServiceRegistry&, ApplyView& view, AccountID const& account, uint256 const& delIndex, @@ -75,19 +75,19 @@ offerDelete( TER removeSignersFromLedger( - Application& app, + ServiceRegistry& registry, ApplyView& view, AccountID const& account, uint256 const& delIndex, std::shared_ptr const& sleDel, beast::Journal j) { - return SetSignerList::removeFromLedger(app, view, account, j); + return SetSignerList::removeFromLedger(registry, view, account, j); } TER removeTicketFromLedger( - Application&, + ServiceRegistry&, ApplyView& view, AccountID const& account, uint256 const& delIndex, @@ -99,7 +99,7 @@ removeTicketFromLedger( TER removeDepositPreauthFromLedger( - Application&, + ServiceRegistry&, ApplyView& view, AccountID const&, uint256 const& delIndex, @@ -111,7 +111,7 @@ removeDepositPreauthFromLedger( TER removeNFTokenOfferFromLedger( - Application& app, + ServiceRegistry&, ApplyView& view, AccountID const& account, uint256 const& delIndex, @@ -126,7 +126,7 @@ removeNFTokenOfferFromLedger( TER removeDIDFromLedger( - Application& app, + ServiceRegistry&, ApplyView& view, AccountID const& account, uint256 const& delIndex, @@ -138,7 +138,7 @@ removeDIDFromLedger( TER removeOracleFromLedger( - Application&, + ServiceRegistry&, ApplyView& view, AccountID const& account, uint256 const&, @@ -150,7 +150,7 @@ removeOracleFromLedger( TER removeCredentialFromLedger( - Application&, + ServiceRegistry&, ApplyView& view, AccountID const&, uint256 const&, @@ -162,7 +162,7 @@ removeCredentialFromLedger( TER removeDelegateFromLedger( - Application& app, + ServiceRegistry&, ApplyView& view, AccountID const& account, uint256 const& delIndex, @@ -364,8 +364,8 @@ DeleteAccount::doApply() std::shared_ptr& sleItem) -> std::pair { if (auto deleter = nonObligationDeleter(nodeType)) { - TER const result{ - deleter(ctx_.app, view(), account_, dirEntry, sleItem, j_)}; + TER const result{deleter( + ctx_.registry, view(), account_, dirEntry, sleItem, j_)}; return {result, SkipEntry::No}; } diff --git a/src/xrpld/app/tx/detail/Escrow.cpp b/src/xrpld/app/tx/detail/Escrow.cpp index 4e5f41a427..2370930ea5 100644 --- a/src/xrpld/app/tx/detail/Escrow.cpp +++ b/src/xrpld/app/tx/detail/Escrow.cpp @@ -590,7 +590,7 @@ EscrowFinish::preflightSigValidated(PreflightContext const& ctx) if (cb && fb) { - auto& router = ctx.app.getHashRouter(); + auto& router = ctx.registry.getHashRouter(); auto const id = ctx.tx.getTransactionID(); auto const flags = router.getFlags(id); @@ -977,7 +977,7 @@ EscrowFinish::doApply() // Check cryptocondition fulfillment { auto const id = ctx_.tx.getTransactionID(); - auto flags = ctx_.app.getHashRouter().getFlags(id); + auto flags = ctx_.registry.getHashRouter().getFlags(id); auto const cb = ctx_.tx[~sfCondition]; @@ -997,7 +997,7 @@ EscrowFinish::doApply() else flags = SF_CF_INVALID; - ctx_.app.getHashRouter().setFlags(id, flags); + ctx_.registry.getHashRouter().setFlags(id, flags); // LCOV_EXCL_STOP } diff --git a/src/xrpld/app/tx/detail/PayChan.cpp b/src/xrpld/app/tx/detail/PayChan.cpp index 163ea802a8..3356f5d4f2 100644 --- a/src/xrpld/app/tx/detail/PayChan.cpp +++ b/src/xrpld/app/tx/detail/PayChan.cpp @@ -328,7 +328,7 @@ PayChanFund::doApply() if ((cancelAfter && closeTime >= *cancelAfter) || (expiration && closeTime >= *expiration)) return closeChannel( - slep, ctx_.view(), k.key, ctx_.app.journal("View")); + slep, ctx_.view(), k.key, ctx_.registry.journal("View")); } if (src != txAccount) @@ -485,7 +485,7 @@ PayChanClaim::doApply() if ((cancelAfter && closeTime >= *cancelAfter) || (curExpiration && closeTime >= *curExpiration)) return closeChannel( - slep, ctx_.view(), k.key, ctx_.app.journal("View")); + slep, ctx_.view(), k.key, ctx_.registry.journal("View")); } if (txAccount != src && txAccount != dst) @@ -546,7 +546,7 @@ PayChanClaim::doApply() // Channel will close immediately if dry or the receiver closes if (dst == txAccount || (*slep)[sfBalance] == (*slep)[sfAmount]) return closeChannel( - slep, ctx_.view(), k.key, ctx_.app.journal("View")); + slep, ctx_.view(), k.key, ctx_.registry.journal("View")); auto const settleExpiration = ctx_.view().header().parentCloseTime.time_since_epoch().count() + diff --git a/src/xrpld/app/tx/detail/Payment.cpp b/src/xrpld/app/tx/detail/Payment.cpp index 7a14cecc2d..33cc66a26a 100644 --- a/src/xrpld/app/tx/detail/Payment.cpp +++ b/src/xrpld/app/tx/detail/Payment.cpp @@ -455,7 +455,7 @@ Payment::doApply() account_, ctx_.tx.getFieldPathSet(sfPaths), ctx_.tx[~sfDomainID], - ctx_.app.logs(), + ctx_.registry.logs(), &rcInput); // VFALCO NOTE We might not need to apply, depending // on the TER. But always applying *should* diff --git a/src/xrpld/app/tx/detail/SetRegularKey.cpp b/src/xrpld/app/tx/detail/SetRegularKey.cpp index ff1dbdf769..c349ee8ec3 100644 --- a/src/xrpld/app/tx/detail/SetRegularKey.cpp +++ b/src/xrpld/app/tx/detail/SetRegularKey.cpp @@ -48,7 +48,7 @@ SetRegularKey::doApply() if (!sle) return tefINTERNAL; // LCOV_EXCL_LINE - if (!minimumFee(ctx_.app, ctx_.baseFee, view().fees(), view().flags())) + if (!minimumFee(ctx_.registry, ctx_.baseFee, view().fees(), view().flags())) sle->setFlag(lsfPasswordSpent); if (ctx_.tx.isFieldPresent(sfRegularKey)) diff --git a/src/xrpld/app/tx/detail/SetSignerList.cpp b/src/xrpld/app/tx/detail/SetSignerList.cpp index f65c17e303..17d81baf43 100644 --- a/src/xrpld/app/tx/detail/SetSignerList.cpp +++ b/src/xrpld/app/tx/detail/SetSignerList.cpp @@ -1,8 +1,8 @@ -#include #include #include #include +#include #include #include #include @@ -171,7 +171,7 @@ signerCountBasedOwnerCountDelta(std::size_t entryCount, Rules const& rules) static TER removeSignersFromLedger( - Application& app, + ServiceRegistry& registry, ApplyView& view, Keylet const& accountKeylet, Keylet const& ownerDirKeylet, @@ -213,7 +213,7 @@ removeSignersFromLedger( view, view.peek(accountKeylet), removeFromOwnerCount, - app.journal("View")); + registry.journal("View")); view.erase(signers); @@ -222,7 +222,7 @@ removeSignersFromLedger( TER SetSignerList::removeFromLedger( - Application& app, + ServiceRegistry& registry, ApplyView& view, AccountID const& account, beast::Journal j) @@ -232,7 +232,7 @@ SetSignerList::removeFromLedger( auto const signerListKeylet = keylet::signers(account); return removeSignersFromLedger( - app, view, accountKeylet, ownerDirKeylet, signerListKeylet, j); + registry, view, accountKeylet, ownerDirKeylet, signerListKeylet, j); } NotTEC @@ -306,7 +306,7 @@ SetSignerList::replaceSignerList() // old signer list. May reduce the reserve, so this is done before // checking the reserve. if (TER const ter = removeSignersFromLedger( - ctx_.app, + ctx_.registry, view(), accountKeylet, ownerDirKeylet, @@ -338,7 +338,7 @@ SetSignerList::replaceSignerList() view().insert(signerList); writeSignersToSLE(signerList, flags); - auto viewJ = ctx_.app.journal("View"); + auto viewJ = ctx_.registry.journal("View"); // Add the signer list to the account's directory. auto const page = ctx_.view().dirInsert( ownerDirKeylet, signerListKeylet, describeOwnerDir(account_)); @@ -374,7 +374,12 @@ SetSignerList::destroySignerList() auto const ownerDirKeylet = keylet::ownerDir(account_); auto const signerListKeylet = keylet::signers(account_); return removeSignersFromLedger( - ctx_.app, view(), accountKeylet, ownerDirKeylet, signerListKeylet, j_); + ctx_.registry, + view(), + accountKeylet, + ownerDirKeylet, + signerListKeylet, + j_); } void diff --git a/src/xrpld/app/tx/detail/SetSignerList.h b/src/xrpld/app/tx/detail/SetSignerList.h index f6f63d2b7d..971565e987 100644 --- a/src/xrpld/app/tx/detail/SetSignerList.h +++ b/src/xrpld/app/tx/detail/SetSignerList.h @@ -46,7 +46,7 @@ public: // Interface used by DeleteAccount static TER removeFromLedger( - Application& app, + ServiceRegistry& registry, ApplyView& view, AccountID const& account, beast::Journal j); diff --git a/src/xrpld/app/tx/detail/SetTrust.cpp b/src/xrpld/app/tx/detail/SetTrust.cpp index 77d7e6d9b5..be0c5cc3d0 100644 --- a/src/xrpld/app/tx/detail/SetTrust.cpp +++ b/src/xrpld/app/tx/detail/SetTrust.cpp @@ -376,7 +376,7 @@ SetTrust::doApply() bool const bSetDeepFreeze = (uTxFlags & tfSetDeepFreeze); bool const bClearDeepFreeze = (uTxFlags & tfClearDeepFreeze); - auto viewJ = ctx_.app.journal("View"); + auto viewJ = ctx_.registry.journal("View"); SLE::pointer sleDst = view().peek(keylet::account(uDstAccountID)); diff --git a/src/xrpld/app/tx/detail/Transactor.cpp b/src/xrpld/app/tx/detail/Transactor.cpp index 7b0cbbbdd4..78c804031a 100644 --- a/src/xrpld/app/tx/detail/Transactor.cpp +++ b/src/xrpld/app/tx/detail/Transactor.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -33,7 +34,7 @@ preflight0(PreflightContext const& ctx, std::uint32_t flagMask) if (!isPseudoTx(ctx.tx) || ctx.tx.isFieldPresent(sfNetworkID)) { - uint32_t nodeNID = ctx.app.config().NETWORK_ID; + uint32_t nodeNID = ctx.registry.getNetworkIDService().getNetworkID(); std::optional txNID = ctx.tx[~sfNetworkID]; if (nodeNID <= 1024) @@ -210,8 +211,8 @@ Transactor::preflight2(PreflightContext const& ctx) // Do not add any checks after this point that are relevant for // batch inner transactions. They will be skipped. - auto const sigValid = checkValidity( - ctx.app.getHashRouter(), ctx.tx, ctx.rules, ctx.app.config()); + auto const sigValid = + checkValidity(ctx.registry.getHashRouter(), ctx.tx, ctx.rules); if (sigValid.first == Validity::SigBad) { // LCOV_EXCL_START JLOG(ctx.j.debug()) << "preflight2: bad signature. " << sigValid.second; @@ -314,12 +315,13 @@ Transactor::calculateOwnerReserveFee(ReadView const& view, STTx const& tx) XRPAmount Transactor::minimumFee( - Application& app, + ServiceRegistry& registry, XRPAmount baseFee, Fees const& fees, ApplyFlags flags) { - return scaleFeeLoad(baseFee, app.getFeeTrack(), fees, flags & tapUNLIMITED); + return scaleFeeLoad( + baseFee, registry.getFeeTrack(), fees, flags & tapUNLIMITED); } TER @@ -346,7 +348,7 @@ Transactor::checkFee(PreclaimContext const& ctx, XRPAmount baseFee) if (ctx.view.open()) { auto const feeDue = - minimumFee(ctx.app, baseFee, ctx.view.fees(), ctx.flags); + minimumFee(ctx.registry, baseFee, ctx.view.fees(), ctx.flags); if (feePaid < feeDue) { @@ -1155,7 +1157,7 @@ Transactor::operator()() } #endif - if (auto const& trap = ctx_.app.trapTxID(); + if (auto const& trap = ctx_.registry.trapTxID(); trap && *trap == ctx_.tx.getTransactionID()) { trapTransaction(*trap); @@ -1267,19 +1269,19 @@ Transactor::operator()() // If necessary, remove any offers found unfunded during processing if ((result == tecOVERSIZE) || (result == tecKILLED)) removeUnfundedOffers( - view(), removedOffers, ctx_.app.journal("View")); + view(), removedOffers, ctx_.registry.journal("View")); if (result == tecEXPIRED) removeExpiredNFTokenOffers( - view(), expiredNFTokenOffers, ctx_.app.journal("View")); + view(), expiredNFTokenOffers, ctx_.registry.journal("View")); if (result == tecINCOMPLETE) removeDeletedTrustLines( - view(), removedTrustLines, ctx_.app.journal("View")); + view(), removedTrustLines, ctx_.registry.journal("View")); if (result == tecEXPIRED) removeExpiredCredentials( - view(), expiredCredentials, ctx_.app.journal("View")); + view(), expiredCredentials, ctx_.registry.journal("View")); applied = isTecClaim(result); } diff --git a/src/xrpld/app/tx/detail/Transactor.h b/src/xrpld/app/tx/detail/Transactor.h index 7d24df0a3b..5a82f62c0e 100644 --- a/src/xrpld/app/tx/detail/Transactor.h +++ b/src/xrpld/app/tx/detail/Transactor.h @@ -15,7 +15,7 @@ namespace xrpl { struct PreflightContext { public: - Application& app; + ServiceRegistry& registry; STTx const& tx; Rules const rules; ApplyFlags flags; @@ -23,13 +23,13 @@ public: beast::Journal const j; PreflightContext( - Application& app_, + ServiceRegistry& registry_, STTx const& tx_, uint256 parentBatchId_, Rules const& rules_, ApplyFlags flags_, beast::Journal j_ = beast::Journal{beast::Journal::getNullSink()}) - : app(app_) + : registry(registry_) , tx(tx_) , rules(rules_) , flags(flags_) @@ -41,12 +41,12 @@ public: } PreflightContext( - Application& app_, + ServiceRegistry& registry_, STTx const& tx_, Rules const& rules_, ApplyFlags flags_, beast::Journal j_ = beast::Journal{beast::Journal::getNullSink()}) - : app(app_), tx(tx_), rules(rules_), flags(flags_), j(j_) + : registry(registry_), tx(tx_), rules(rules_), flags(flags_), j(j_) { XRPL_ASSERT( (flags_ & tapBATCH) == 0, "Batch apply flag should not be set"); @@ -60,7 +60,7 @@ public: struct PreclaimContext { public: - Application& app; + ServiceRegistry& registry; ReadView const& view; TER preflightResult; ApplyFlags flags; @@ -69,14 +69,14 @@ public: beast::Journal const j; PreclaimContext( - Application& app_, + ServiceRegistry& registry_, ReadView const& view_, TER preflightResult_, STTx const& tx_, ApplyFlags flags_, std::optional parentBatchId_, beast::Journal j_ = beast::Journal{beast::Journal::getNullSink()}) - : app(app_) + : registry(registry_) , view(view_) , preflightResult(preflightResult_) , flags(flags_) @@ -90,14 +90,14 @@ public: } PreclaimContext( - Application& app_, + ServiceRegistry& registry_, ReadView const& view_, TER preflightResult_, STTx const& tx_, ApplyFlags flags_, beast::Journal j_ = beast::Journal{beast::Journal::getNullSink()}) : PreclaimContext( - app_, + registry_, view_, preflightResult_, tx_, @@ -245,7 +245,7 @@ protected: /** Compute the minimum fee required to process a transaction with a given baseFee based on the current server load. - @param app The application hosting the server + @param registry The service registry. @param baseFee The base fee of a candidate transaction @see xrpl::calculateBaseFee @param fees Fee settings from the current ledger @@ -253,7 +253,7 @@ protected: */ static XRPAmount minimumFee( - Application& app, + ServiceRegistry& registry, XRPAmount baseFee, Fees const& fees, ApplyFlags flags); diff --git a/src/xrpld/app/tx/detail/apply.cpp b/src/xrpld/app/tx/detail/apply.cpp index bf844f01ad..3be9f4a98d 100644 --- a/src/xrpld/app/tx/detail/apply.cpp +++ b/src/xrpld/app/tx/detail/apply.cpp @@ -23,11 +23,7 @@ constexpr HashRouterFlags SF_LOCALGOOD = //------------------------------------------------------------------------------ std::pair -checkValidity( - HashRouter& router, - STTx const& tx, - Rules const& rules, - Config const& config) +checkValidity(HashRouter& router, STTx const& tx, Rules const& rules) { auto const id = tx.getTransactionID(); auto const flags = router.getFlags(id); @@ -112,26 +108,15 @@ forceValidity(HashRouter& router, uint256 const& txid, Validity validity) template ApplyResult -apply(Application& app, OpenView& view, PreflightChecks&& preflightChecks) +apply( + ServiceRegistry& registry, + OpenView& view, + PreflightChecks&& preflightChecks) { NumberSO stNumberSO{view.rules().enabled(fixUniversalNumber)}; - return doApply(preclaim(preflightChecks(), app, view), app, view); + return doApply(preclaim(preflightChecks(), registry, view), registry, view); } -ApplyResult -apply( - Application& app, - OpenView& view, - STTx const& tx, - ApplyFlags flags, - beast::Journal j) -{ - return apply(app, view, [&]() mutable { - return preflight(app, view.rules(), tx, flags, j); - }); -} - -// ServiceRegistry overload - delegates to Application version ApplyResult apply( ServiceRegistry& registry, @@ -140,26 +125,28 @@ apply( ApplyFlags flags, beast::Journal j) { - return apply(registry.app(), view, tx, flags, j); + return apply(registry, view, [&]() mutable { + return preflight(registry, view.rules(), tx, flags, j); + }); } ApplyResult apply( - Application& app, + ServiceRegistry& registry, OpenView& view, uint256 const& parentBatchId, STTx const& tx, ApplyFlags flags, beast::Journal j) { - return apply(app, view, [&]() mutable { - return preflight(app, view.rules(), parentBatchId, tx, flags, j); + return apply(registry, view, [&]() mutable { + return preflight(registry, view.rules(), parentBatchId, tx, flags, j); }); } static bool applyBatchTransactions( - Application& app, + ServiceRegistry& registry, OpenView& batchView, STTx const& batchTxn, beast::Journal j) @@ -173,11 +160,11 @@ applyBatchTransactions( auto const mode = batchTxn.getFlags(); auto applyOneTransaction = - [&app, &j, &parentBatchId, &batchView](STTx&& tx) { + [®istry, &j, &parentBatchId, &batchView](STTx&& tx) { OpenView perTxBatchView(batch_view, batchView); auto const ret = - apply(app, perTxBatchView, parentBatchId, tx, tapBATCH, j); + apply(registry, perTxBatchView, parentBatchId, tx, tapBATCH, j); XRPL_ASSERT( ret.applied == (isTesSuccess(ret.ter) || isTecClaim(ret.ter)), "Inner transaction should not be applied"); @@ -225,7 +212,7 @@ applyBatchTransactions( ApplyTransactionResult applyTransaction( - Application& app, + ServiceRegistry& registry, OpenView& view, STTx const& txn, bool retryAssured, @@ -241,7 +228,7 @@ applyTransaction( try { - auto const result = apply(app, view, txn, flags, j); + auto const result = apply(registry, view, txn, flags, j); if (result.applied) { @@ -254,7 +241,7 @@ applyTransaction( { OpenView wholeBatchView(batch_view, view); - if (applyBatchTransactions(app, wholeBatchView, txn, j)) + if (applyBatchTransactions(registry, wholeBatchView, txn, j)) wholeBatchView.apply(view); } diff --git a/src/xrpld/app/tx/detail/applySteps.cpp b/src/xrpld/app/tx/detail/applySteps.cpp index 7f0d971fdc..e9c38abb76 100644 --- a/src/xrpld/app/tx/detail/applySteps.cpp +++ b/src/xrpld/app/tx/detail/applySteps.cpp @@ -14,6 +14,7 @@ // DO NOT INCLUDE TRANSACTOR HEADER FILES HERE. // See the instructions at the top of transactions.macro instead. +#include #include #include @@ -282,13 +283,13 @@ invoke_apply(ApplyContext& ctx) PreflightResult preflight( - Application& app, + ServiceRegistry& registry, Rules const& rules, STTx const& tx, ApplyFlags flags, beast::Journal j) { - PreflightContext const pfctx(app, tx, rules, flags, j); + PreflightContext const pfctx(registry, tx, rules, flags, j); try { return {pfctx, invoke_preflight(pfctx)}; @@ -302,14 +303,14 @@ preflight( PreflightResult preflight( - Application& app, + ServiceRegistry& registry, Rules const& rules, uint256 const& parentBatchId, STTx const& tx, ApplyFlags flags, beast::Journal j) { - PreflightContext const pfctx(app, tx, parentBatchId, rules, flags, j); + PreflightContext const pfctx(registry, tx, parentBatchId, rules, flags, j); try { return {pfctx, invoke_preflight(pfctx)}; @@ -324,7 +325,7 @@ preflight( PreclaimResult preclaim( PreflightResult const& preflightResult, - Application& app, + ServiceRegistry& registry, OpenView const& view) { std::optional ctx; @@ -333,7 +334,7 @@ preclaim( auto secondFlight = [&]() { if (preflightResult.parentBatchId) return preflight( - app, + registry, view.rules(), preflightResult.parentBatchId.value(), preflightResult.tx, @@ -341,7 +342,7 @@ preclaim( preflightResult.j); return preflight( - app, + registry, view.rules(), preflightResult.tx, preflightResult.flags, @@ -349,7 +350,7 @@ preclaim( }(); ctx.emplace( - app, + registry, view, secondFlight.ter, secondFlight.tx, @@ -360,7 +361,7 @@ preclaim( else { ctx.emplace( - app, + registry, view, preflightResult.ter, preflightResult.tx, @@ -395,7 +396,10 @@ calculateDefaultBaseFee(ReadView const& view, STTx const& tx) } ApplyResult -doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view) +doApply( + PreclaimResult const& preclaimResult, + ServiceRegistry& registry, + OpenView& view) { if (preclaimResult.view.seq() != view.seq()) { @@ -408,7 +412,7 @@ doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view) if (!preclaimResult.likelyToClaimFee) return {preclaimResult.ter, false}; ApplyContext ctx( - app, + registry, view, preclaimResult.parentBatchId, preclaimResult.tx, diff --git a/src/xrpld/core/NetworkIDServiceImpl.h b/src/xrpld/core/NetworkIDServiceImpl.h new file mode 100644 index 0000000000..f97b51e4fd --- /dev/null +++ b/src/xrpld/core/NetworkIDServiceImpl.h @@ -0,0 +1,35 @@ +#ifndef XRPLD_CORE_NETWORKIDSERVICEIMPL_H_INCLUDED +#define XRPLD_CORE_NETWORKIDSERVICEIMPL_H_INCLUDED + +#include + +#include + +namespace xrpl { + +// Forward declaration +class Config; + +/** Implementation of NetworkIDService that reads from Config. + + This class provides a NetworkIDService interface that wraps + the network ID from the application Config. It caches the + network ID at construction time. +*/ +class NetworkIDServiceImpl : public NetworkIDService +{ +public: + explicit NetworkIDServiceImpl(Config const& config); + + ~NetworkIDServiceImpl() override = default; + + std::uint32_t + getNetworkID() const override; + +private: + std::uint32_t networkID_; +}; + +} // namespace xrpl + +#endif diff --git a/src/xrpld/core/ServiceRegistryImpl.h b/src/xrpld/core/ServiceRegistryImpl.h index 2b3a91e1fa..395a867ebb 100644 --- a/src/xrpld/core/ServiceRegistryImpl.h +++ b/src/xrpld/core/ServiceRegistryImpl.h @@ -52,6 +52,9 @@ public: LedgerConfigService& getLedgerConfigService() override; + NetworkIDService& + getNetworkIDService() override; + // Protocol and validation services AmendmentTable& getAmendmentTable() override; @@ -167,6 +170,9 @@ public: Logs& logs() override; + std::optional const& + trapTxID() const override; + // Temporary: Get the underlying Application Application& app() override; diff --git a/src/xrpld/core/detail/NetworkIDServiceImpl.cpp b/src/xrpld/core/detail/NetworkIDServiceImpl.cpp new file mode 100644 index 0000000000..a9eb48d766 --- /dev/null +++ b/src/xrpld/core/detail/NetworkIDServiceImpl.cpp @@ -0,0 +1,17 @@ +#include +#include + +namespace xrpl { + +NetworkIDServiceImpl::NetworkIDServiceImpl(Config const& config) + : networkID_(config.NETWORK_ID) +{ +} + +std::uint32_t +NetworkIDServiceImpl::getNetworkID() const +{ + return networkID_; +} + +} // namespace xrpl diff --git a/src/xrpld/core/detail/ServiceRegistryImpl.cpp b/src/xrpld/core/detail/ServiceRegistryImpl.cpp index 7b3cdc1bba..fc55fa32de 100644 --- a/src/xrpld/core/detail/ServiceRegistryImpl.cpp +++ b/src/xrpld/core/detail/ServiceRegistryImpl.cpp @@ -57,6 +57,12 @@ ServiceRegistryImpl::getLedgerConfigService() return app_.getLedgerConfigService(); } +NetworkIDService& +ServiceRegistryImpl::getNetworkIDService() +{ + return app_.getNetworkIDService(); +} + // Protocol and validation services AmendmentTable& ServiceRegistryImpl::getAmendmentTable() @@ -280,6 +286,12 @@ ServiceRegistryImpl::logs() return app_.logs(); } +std::optional const& +ServiceRegistryImpl::trapTxID() const +{ + return app_.trapTxID(); +} + Application& ServiceRegistryImpl::app() { diff --git a/src/xrpld/overlay/detail/PeerImp.cpp b/src/xrpld/overlay/detail/PeerImp.cpp index 7e621c97b6..0df7170961 100644 --- a/src/xrpld/overlay/detail/PeerImp.cpp +++ b/src/xrpld/overlay/detail/PeerImp.cpp @@ -3023,8 +3023,7 @@ PeerImp::checkTransaction( if (auto [valid, validReason] = checkValidity( app_.getHashRouter(), *stx, - app_.getLedgerMaster().getValidatedRules(), - app_.config()); + app_.getLedgerMaster().getValidatedRules()); valid != Validity::Valid) { if (!validReason.empty()) diff --git a/src/xrpld/rpc/detail/TransactionSign.cpp b/src/xrpld/rpc/detail/TransactionSign.cpp index 28f9d32e6d..370551d3f2 100644 --- a/src/xrpld/rpc/detail/TransactionSign.cpp +++ b/src/xrpld/rpc/detail/TransactionSign.cpp @@ -706,9 +706,8 @@ transactionConstructImpl( app.getHashRouter(), sttxNew->getTransactionID(), Validity::SigGoodOnly); - if (checkValidity( - app.getHashRouter(), *sttxNew, rules, app.config()) - .first != Validity::Valid) + if (checkValidity(app.getHashRouter(), *sttxNew, rules).first != + Validity::Valid) { ret.first = RPC::make_error(rpcINTERNAL, "Invalid signature."); return ret; diff --git a/src/xrpld/rpc/handlers/Fee1.cpp b/src/xrpld/rpc/handlers/Fee1.cpp index 49a36261f4..abc67293da 100644 --- a/src/xrpld/rpc/handlers/Fee1.cpp +++ b/src/xrpld/rpc/handlers/Fee1.cpp @@ -10,7 +10,7 @@ namespace xrpl { Json::Value doFee(RPC::JsonContext& context) { - auto result = context.app.getTxQ().doRPC(context.app); + auto result = context.app.getTxQ().doRPC(context.app.getServiceRegistry()); if (result.type() == Json::objectValue) return result; diff --git a/src/xrpld/rpc/handlers/Simulate.cpp b/src/xrpld/rpc/handlers/Simulate.cpp index 8dc90b799b..dff347cc14 100644 --- a/src/xrpld/rpc/handlers/Simulate.cpp +++ b/src/xrpld/rpc/handlers/Simulate.cpp @@ -217,7 +217,7 @@ simulateTxn(RPC::JsonContext& context, std::shared_ptr transaction) // Process the transaction OpenView view = *context.app.openLedger().current(); auto const result = context.app.getTxQ().apply( - context.app, + context.app.getServiceRegistry(), view, transaction->getSTransaction(), tapDRY_RUN, diff --git a/src/xrpld/rpc/handlers/Submit.cpp b/src/xrpld/rpc/handlers/Submit.cpp index bd2f4368a6..3281dc423a 100644 --- a/src/xrpld/rpc/handlers/Submit.cpp +++ b/src/xrpld/rpc/handlers/Submit.cpp @@ -85,8 +85,7 @@ doSubmit(RPC::JsonContext& context) auto [validity, reason] = checkValidity( context.app.getHashRouter(), *stTx, - context.ledgerMaster.getCurrentLedger()->rules(), - context.app.config()); + context.ledgerMaster.getCurrentLedger()->rules()); if (validity != Validity::Valid) { jvResult[jss::error] = "invalidTransaction";