From d4a3dbeb4f6211313a740670a8b5b113b9804e09 Mon Sep 17 00:00:00 2001 From: marta-lokhova Date: Wed, 18 Sep 2024 13:42:14 -0700 Subject: [PATCH 1/4] Re-purpose OverlayAppConnector to just AppConnector the rest of the app can use, add new functions --- src/main/AppConnector.cpp | 132 ++++++++++++++++++ .../AppConnector.h} | 15 +- src/main/Application.h | 3 + src/main/ApplicationImpl.cpp | 8 ++ src/main/ApplicationImpl.h | 3 + src/overlay/FlowControl.cpp | 3 +- src/overlay/FlowControl.h | 6 +- src/overlay/OverlayAppConnector.cpp | 93 ------------ src/overlay/Peer.cpp | 2 +- src/overlay/Peer.h | 4 +- 10 files changed, 166 insertions(+), 103 deletions(-) create mode 100644 src/main/AppConnector.cpp rename src/{overlay/OverlayAppConnector.h => main/AppConnector.h} (67%) delete mode 100644 src/overlay/OverlayAppConnector.cpp diff --git a/src/main/AppConnector.cpp b/src/main/AppConnector.cpp new file mode 100644 index 0000000000..a5953fc6ea --- /dev/null +++ b/src/main/AppConnector.cpp @@ -0,0 +1,132 @@ +#include "main/AppConnector.h" +#include "herder/Herder.h" +#include "invariant/InvariantManager.h" +#include "ledger/LedgerManager.h" +#include "ledger/LedgerTxn.h" +#include "main/Application.h" +#include "overlay/BanManager.h" +#include "overlay/OverlayManager.h" +#include "overlay/OverlayMetrics.h" +#include "util/Timer.h" + +namespace stellar +{ + +AppConnector::AppConnector(Application& app) + : mApp(app), mConfig(app.getConfig()) +{ +} + +Herder& +AppConnector::getHerder() +{ + releaseAssert(threadIsMain()); + return mApp.getHerder(); +} + +LedgerManager& +AppConnector::getLedgerManager() +{ + releaseAssert(threadIsMain()); + return mApp.getLedgerManager(); +} + +OverlayManager& +AppConnector::getOverlayManager() +{ + releaseAssert(threadIsMain()); + return mApp.getOverlayManager(); +} + +BanManager& +AppConnector::getBanManager() +{ + releaseAssert(threadIsMain()); + return mApp.getBanManager(); +} + +SorobanNetworkConfig const& +AppConnector::getSorobanNetworkConfig() const +{ + releaseAssert(threadIsMain()); + return mApp.getLedgerManager().getSorobanNetworkConfig(); +} + +medida::MetricsRegistry& +AppConnector::getMetrics() const +{ + releaseAssert(threadIsMain()); + return mApp.getMetrics(); +} + +SorobanMetrics& +AppConnector::getSorobanMetrics() const +{ + releaseAssert(threadIsMain()); + return mApp.getLedgerManager().getSorobanMetrics(); +} + +void +AppConnector::checkOnOperationApply(Operation const& operation, + OperationResult const& opres, + LedgerTxnDelta const& ltxDelta) +{ + releaseAssert(threadIsMain()); + mApp.getInvariantManager().checkOnOperationApply(operation, opres, + ltxDelta); +} + +Hash const& +AppConnector::getNetworkID() const +{ + releaseAssert(threadIsMain()); + return mApp.getNetworkID(); +} + +void +AppConnector::postOnMainThread(std::function&& f, std::string&& message, + Scheduler::ActionType type) +{ + mApp.postOnMainThread(std::move(f), std::move(message), type); +} + +void +AppConnector::postOnOverlayThread(std::function&& f, + std::string const& message) +{ + mApp.postOnOverlayThread(std::move(f), message); +} + +Config const& +AppConnector::getConfig() const +{ + return mConfig; +} + +bool +AppConnector::overlayShuttingDown() const +{ + return mApp.getOverlayManager().isShuttingDown(); +} + +VirtualClock::time_point +AppConnector::now() const +{ + return mApp.getClock().now(); +} + +bool +AppConnector::shouldYield() const +{ + releaseAssert(threadIsMain()); + return mApp.getClock().shouldYield(); +} + +OverlayMetrics& +AppConnector::getOverlayMetrics() +{ + // OverlayMetrics class is thread-safe + return mApp.getOverlayManager().getOverlayMetrics(); +} + +} \ No newline at end of file diff --git a/src/overlay/OverlayAppConnector.h b/src/main/AppConnector.h similarity index 67% rename from src/overlay/OverlayAppConnector.h rename to src/main/AppConnector.h index d915d51aef..6e6d19ce52 100644 --- a/src/overlay/OverlayAppConnector.h +++ b/src/main/AppConnector.h @@ -1,6 +1,7 @@ #pragma once #include "main/Config.h" +#include "medida/metrics_registry.h" namespace stellar { @@ -10,10 +11,13 @@ class LedgerManager; class Herder; class BanManager; struct OverlayMetrics; +class SorobanNetworkConfig; +class SorobanMetrics; +struct LedgerTxnDelta; // Helper class to isolate access to Application; all function helpers must // either be called from main or be thread-sade -class OverlayAppConnector +class AppConnector { Application& mApp; // Copy config for threads to use, and avoid warnings from thread sanitizer @@ -21,7 +25,7 @@ class OverlayAppConnector Config const mConfig; public: - OverlayAppConnector(Application& app); + AppConnector(Application& app); // Methods that can only be called from main thread Herder& getHerder(); @@ -29,6 +33,13 @@ class OverlayAppConnector OverlayManager& getOverlayManager(); BanManager& getBanManager(); bool shouldYield() const; + SorobanNetworkConfig const& getSorobanNetworkConfig() const; + medida::MetricsRegistry& getMetrics() const; + SorobanMetrics& getSorobanMetrics() const; + void checkOnOperationApply(Operation const& operation, + OperationResult const& opres, + LedgerTxnDelta const& ltxDelta); + Hash const& getNetworkID() const; // Thread-safe methods void postOnMainThread( diff --git a/src/main/Application.h b/src/main/Application.h index fcdd55c417..944691ec8b 100644 --- a/src/main/Application.h +++ b/src/main/Application.h @@ -46,6 +46,7 @@ class AbstractLedgerTxnParent; class BasicWork; enum class LoadGenMode; struct GeneratedLoadConfig; +class AppConnector; #ifdef BUILD_TESTS class LoadGenerator; @@ -326,6 +327,8 @@ class Application // (while preserving the overlay data). virtual void resetDBForInMemoryMode() = 0; + virtual AppConnector& getAppConnector() = 0; + protected: Application() { diff --git a/src/main/ApplicationImpl.cpp b/src/main/ApplicationImpl.cpp index ef2ced2f04..2a42a6485a 100644 --- a/src/main/ApplicationImpl.cpp +++ b/src/main/ApplicationImpl.cpp @@ -40,6 +40,7 @@ #include "ledger/LedgerHeaderUtils.h" #include "ledger/LedgerManager.h" #include "ledger/LedgerTxn.h" +#include "main/AppConnector.h" #include "main/ApplicationUtils.h" #include "main/CommandHandler.h" #include "main/ExternalQueue.h" @@ -330,6 +331,7 @@ ApplicationImpl::initialize(bool createNewDB, bool forceRebuild) mWorkScheduler = WorkScheduler::create(*this); mBanManager = BanManager::create(*this); mStatusManager = std::make_unique(); + mAppConnector = std::make_unique(*this); if (getConfig().MODE_USES_IN_MEMORY_LEDGER) { @@ -1635,4 +1637,10 @@ ApplicationImpl::getLedgerTxnRoot() return mConfig.MODE_USES_IN_MEMORY_LEDGER ? *mNeverCommittingLedgerTxn : *mLedgerTxnRoot; } + +AppConnector& +ApplicationImpl::getAppConnector() +{ + return *mAppConnector; +} } diff --git a/src/main/ApplicationImpl.h b/src/main/ApplicationImpl.h index d195e04774..91292e20a7 100644 --- a/src/main/ApplicationImpl.h +++ b/src/main/ApplicationImpl.h @@ -35,6 +35,7 @@ class LedgerTxnRoot; class InMemoryLedgerTxn; class InMemoryLedgerTxnRoot; class LoadGenerator; +class AppConnector; class ApplicationImpl : public Application { @@ -76,6 +77,7 @@ class ApplicationImpl : public Application virtual WorkScheduler& getWorkScheduler() override; virtual BanManager& getBanManager() override; virtual StatusManager& getStatusManager() override; + virtual AppConnector& getAppConnector() override; virtual asio::io_context& getWorkerIOContext() override; virtual asio::io_context& getEvictionIOContext() override; @@ -177,6 +179,7 @@ class ApplicationImpl : public Application std::unique_ptr mBanManager; std::unique_ptr mStatusManager; std::unique_ptr mLedgerTxnRoot; + std::unique_ptr mAppConnector; // These two exist for use in MODE_USES_IN_MEMORY_LEDGER only: the // mInMemoryLedgerTxnRoot is a _stub_ AbstractLedgerTxnParent that refuses diff --git a/src/overlay/FlowControl.cpp b/src/overlay/FlowControl.cpp index 84df135ff6..e5f8e7c4fd 100644 --- a/src/overlay/FlowControl.cpp +++ b/src/overlay/FlowControl.cpp @@ -31,8 +31,7 @@ FlowControl::getOutboundQueueByteLimit( return mAppConnector.getConfig().OUTBOUND_TX_QUEUE_BYTE_LIMIT; } -FlowControl::FlowControl(OverlayAppConnector& connector, - bool useBackgroundThread) +FlowControl::FlowControl(AppConnector& connector, bool useBackgroundThread) : mFlowControlCapacity(connector.getConfig(), mNodeID) , mFlowControlBytesCapacity( connector.getConfig(), mNodeID, diff --git a/src/overlay/FlowControl.h b/src/overlay/FlowControl.h index d35f15e74b..2f17cbaf61 100644 --- a/src/overlay/FlowControl.h +++ b/src/overlay/FlowControl.h @@ -13,7 +13,7 @@ namespace stellar { -class OverlayAppConnector; +class AppConnector; struct OverlayMetrics; // num messages, bytes @@ -66,7 +66,7 @@ class FlowControl FlowControlByteCapacity mFlowControlBytesCapacity; OverlayMetrics& mOverlayMetrics; - OverlayAppConnector& mAppConnector; + AppConnector& mAppConnector; bool const mUseBackgroundThread; // Outbound queues indexes by priority @@ -92,7 +92,7 @@ class FlowControl bool canRead(std::lock_guard const& lockGuard) const; public: - FlowControl(OverlayAppConnector& connector, bool useBackgoundThread); + FlowControl(AppConnector& connector, bool useBackgoundThread); virtual ~FlowControl() = default; void maybeReleaseCapacity(StellarMessage const& msg); diff --git a/src/overlay/OverlayAppConnector.cpp b/src/overlay/OverlayAppConnector.cpp deleted file mode 100644 index 68a7a8bfe8..0000000000 --- a/src/overlay/OverlayAppConnector.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "overlay/OverlayAppConnector.h" -#include "herder/Herder.h" -#include "ledger/LedgerManager.h" -#include "main/Application.h" -#include "overlay/BanManager.h" -#include "overlay/OverlayManager.h" -#include "overlay/OverlayMetrics.h" -#include "util/Timer.h" - -namespace stellar -{ - -OverlayAppConnector::OverlayAppConnector(Application& app) - : mApp(app), mConfig(app.getConfig()) -{ -} - -Herder& -OverlayAppConnector::getHerder() -{ - releaseAssert(threadIsMain()); - return mApp.getHerder(); -} - -LedgerManager& -OverlayAppConnector::getLedgerManager() -{ - releaseAssert(threadIsMain()); - return mApp.getLedgerManager(); -} - -OverlayManager& -OverlayAppConnector::getOverlayManager() -{ - releaseAssert(threadIsMain()); - return mApp.getOverlayManager(); -} - -BanManager& -OverlayAppConnector::getBanManager() -{ - releaseAssert(threadIsMain()); - return mApp.getBanManager(); -} - -void -OverlayAppConnector::postOnMainThread(std::function&& f, - std::string&& message, - Scheduler::ActionType type) -{ - mApp.postOnMainThread(std::move(f), std::move(message), type); -} - -void -OverlayAppConnector::postOnOverlayThread(std::function&& f, - std::string const& message) -{ - mApp.postOnOverlayThread(std::move(f), message); -} - -Config const& -OverlayAppConnector::getConfig() const -{ - return mConfig; -} - -bool -OverlayAppConnector::overlayShuttingDown() const -{ - return mApp.getOverlayManager().isShuttingDown(); -} - -VirtualClock::time_point -OverlayAppConnector::now() const -{ - return mApp.getClock().now(); -} - -bool -OverlayAppConnector::shouldYield() const -{ - releaseAssert(threadIsMain()); - return mApp.getClock().shouldYield(); -} - -OverlayMetrics& -OverlayAppConnector::getOverlayMetrics() -{ - // OverlayMetrics class is thread-safe - return mApp.getOverlayManager().getOverlayMetrics(); -} - -} \ No newline at end of file diff --git a/src/overlay/Peer.cpp b/src/overlay/Peer.cpp index ef6fa955cf..cb54af4ddd 100644 --- a/src/overlay/Peer.cpp +++ b/src/overlay/Peer.cpp @@ -52,7 +52,7 @@ static constexpr VirtualClock::time_point PING_NOT_SENT = VirtualClock::time_point::min(); Peer::Peer(Application& app, PeerRole role) - : mAppConnector(app) + : mAppConnector(app.getAppConnector()) , mNetworkID(app.getNetworkID()) , mFlowControl( std::make_shared(mAppConnector, useBackgroundThread())) diff --git a/src/overlay/Peer.h b/src/overlay/Peer.h index 2be07ead8b..a59cdbb72b 100644 --- a/src/overlay/Peer.h +++ b/src/overlay/Peer.h @@ -7,9 +7,9 @@ #include "util/asio.h" // IWYU pragma: keep #include "database/Database.h" #include "lib/json/json.h" +#include "main/AppConnector.h" #include "medida/timer.h" #include "overlay/Hmac.h" -#include "overlay/OverlayAppConnector.h" #include "overlay/PeerBareAddress.h" #include "util/NonCopyable.h" #include "util/Timer.h" @@ -179,7 +179,7 @@ class Peer : public std::enable_shared_from_this, ~MsgCapacityTracker(); }; - OverlayAppConnector mAppConnector; + AppConnector& mAppConnector; Hash const mNetworkID; std::shared_ptr mFlowControl; From ec6c961a6a03742cefeac6b70c0dec2710560cf6 Mon Sep 17 00:00:00 2001 From: marta-lokhova Date: Wed, 18 Sep 2024 13:42:47 -0700 Subject: [PATCH 2/4] Stop passing Application in apply and validation paths --- src/herder/HerderSCPDriver.cpp | 4 - src/herder/TransactionQueue.cpp | 7 +- src/herder/TxSetFrame.cpp | 3 +- src/herder/TxSetUtils.cpp | 3 +- src/herder/test/TxSetTests.cpp | 3 +- src/herder/test/UpgradesTests.cpp | 5 +- src/ledger/LedgerManagerImpl.cpp | 4 +- src/main/CommandLine.cpp | 1 - src/main/test/CommandHandlerTests.cpp | 4 +- src/simulation/ApplyLoad.cpp | 3 +- src/simulation/LoadGenerator.cpp | 8 +- src/test/FuzzerImpl.cpp | 8 +- src/test/TxTests.cpp | 12 +- .../BeginSponsoringFutureReservesOpFrame.cpp | 2 +- .../BeginSponsoringFutureReservesOpFrame.h | 2 +- src/transactions/BumpSequenceOpFrame.cpp | 2 +- src/transactions/BumpSequenceOpFrame.h | 2 +- src/transactions/ChangeTrustOpFrame.cpp | 2 +- src/transactions/ChangeTrustOpFrame.h | 2 +- .../ClaimClaimableBalanceOpFrame.cpp | 2 +- .../ClaimClaimableBalanceOpFrame.h | 2 +- .../ClawbackClaimableBalanceOpFrame.cpp | 2 +- .../ClawbackClaimableBalanceOpFrame.h | 2 +- src/transactions/ClawbackOpFrame.cpp | 2 +- src/transactions/ClawbackOpFrame.h | 2 +- src/transactions/CreateAccountOpFrame.cpp | 2 +- src/transactions/CreateAccountOpFrame.h | 2 +- .../CreateClaimableBalanceOpFrame.cpp | 2 +- .../CreateClaimableBalanceOpFrame.h | 2 +- .../EndSponsoringFutureReservesOpFrame.cpp | 2 +- .../EndSponsoringFutureReservesOpFrame.h | 2 +- .../ExtendFootprintTTLOpFrame.cpp | 2 +- src/transactions/ExtendFootprintTTLOpFrame.h | 2 +- src/transactions/FeeBumpTransactionFrame.cpp | 12 +- src/transactions/FeeBumpTransactionFrame.h | 8 +- src/transactions/InflationOpFrame.cpp | 2 +- src/transactions/InflationOpFrame.h | 2 +- .../InvokeHostFunctionOpFrame.cpp | 4 +- src/transactions/InvokeHostFunctionOpFrame.h | 2 +- .../LiquidityPoolDepositOpFrame.cpp | 2 +- .../LiquidityPoolDepositOpFrame.h | 2 +- .../LiquidityPoolWithdrawOpFrame.cpp | 2 +- .../LiquidityPoolWithdrawOpFrame.h | 2 +- src/transactions/ManageDataOpFrame.cpp | 2 +- src/transactions/ManageDataOpFrame.h | 2 +- src/transactions/ManageOfferOpFrameBase.cpp | 2 +- src/transactions/ManageOfferOpFrameBase.h | 2 +- src/transactions/MergeOpFrame.cpp | 2 +- src/transactions/MergeOpFrame.h | 2 +- src/transactions/OperationFrame.cpp | 5 +- src/transactions/OperationFrame.h | 7 +- .../PathPaymentStrictReceiveOpFrame.cpp | 2 +- .../PathPaymentStrictReceiveOpFrame.h | 2 +- .../PathPaymentStrictSendOpFrame.cpp | 2 +- .../PathPaymentStrictSendOpFrame.h | 2 +- src/transactions/PaymentOpFrame.cpp | 2 +- src/transactions/PaymentOpFrame.h | 2 +- src/transactions/RestoreFootprintOpFrame.cpp | 2 +- src/transactions/RestoreFootprintOpFrame.h | 2 +- src/transactions/RevokeSponsorshipOpFrame.cpp | 2 +- src/transactions/RevokeSponsorshipOpFrame.h | 2 +- src/transactions/SetOptionsOpFrame.cpp | 2 +- src/transactions/SetOptionsOpFrame.h | 2 +- src/transactions/TransactionFrame.cpp | 32 ++- src/transactions/TransactionFrame.h | 25 +- src/transactions/TransactionFrameBase.h | 9 +- src/transactions/TransactionUtils.cpp | 2 +- src/transactions/TransactionUtils.h | 3 +- src/transactions/TrustFlagsOpFrameBase.cpp | 2 +- src/transactions/TrustFlagsOpFrameBase.h | 2 +- .../BeginSponsoringFutureReservesTests.cpp | 47 +-- src/transactions/test/ChangeTrustTests.cpp | 40 +-- .../test/ClaimableBalanceTests.cpp | 32 ++- .../test/ClawbackClaimableBalanceTests.cpp | 5 +- src/transactions/test/CreateAccountTests.cpp | 20 +- .../test/EndSponsoringFutureReservesTests.cpp | 8 +- .../test/FeeBumpTransactionTests.cpp | 73 +++-- .../test/InvokeHostFunctionTests.cpp | 29 +- src/transactions/test/ManageBuyOfferTests.cpp | 2 +- src/transactions/test/MergeTests.cpp | 20 +- src/transactions/test/OfferTests.cpp | 25 +- src/transactions/test/PathPaymentTests.cpp | 10 +- .../test/RevokeSponsorshipTests.cpp | 269 +++++++++++------- src/transactions/test/SetOptionsTests.cpp | 15 +- .../test/SetTrustLineFlagsTests.cpp | 165 +++++------ src/transactions/test/SorobanTxTestUtils.cpp | 7 +- .../test/SponsorshipTestUtils.cpp | 41 +-- .../test/TransactionTestFrame.cpp | 19 +- src/transactions/test/TransactionTestFrame.h | 17 +- src/transactions/test/TxEnvelopeTests.cpp | 131 +++++---- 90 files changed, 712 insertions(+), 529 deletions(-) diff --git a/src/herder/HerderSCPDriver.cpp b/src/herder/HerderSCPDriver.cpp index a46a6a8b21..47f1453d11 100644 --- a/src/herder/HerderSCPDriver.cpp +++ b/src/herder/HerderSCPDriver.cpp @@ -360,8 +360,6 @@ HerderSCPDriver::validateValue(uint64_t slotIndex, Value const& value, validateValueHelper(slotIndex, b, nomination); if (res != SCPDriver::kInvalidValue) { - auto const& lcl = mLedgerManager.getLastClosedLedgerHeader(); - LedgerUpgradeType lastUpgradeType = LEDGER_UPGRADE_VERSION; // check upgrades @@ -419,8 +417,6 @@ HerderSCPDriver::extractValidValue(uint64_t slotIndex, Value const& value) if (validateValueHelper(slotIndex, b, true) == SCPDriver::kFullyValidatedValue) { - auto const& lcl = mLedgerManager.getLastClosedLedgerHeader(); - // remove the upgrade steps we don't like LedgerUpgradeType thisUpgradeType; for (auto it = b.upgrades.begin(); it != b.upgrades.end();) diff --git a/src/herder/TransactionQueue.cpp b/src/herder/TransactionQueue.cpp index d763262e3a..8950a01e56 100644 --- a/src/herder/TransactionQueue.cpp +++ b/src/herder/TransactionQueue.cpp @@ -380,7 +380,7 @@ TransactionQueue::canAdd( { auto txResult = tx->createSuccessResult(); if (!tx->checkSorobanResourceAndSetError( - mApp, + mApp.getAppConnector(), mApp.getLedgerManager() .getLastClosedLedgerHeader() .header.ledgerVersion, @@ -457,8 +457,9 @@ TransactionQueue::canAdd( mApp.getLedgerManager().getLastClosedLedgerNum() + 1; } - auto txResult = tx->checkValid( - mApp, ls, 0, 0, getUpperBoundCloseTimeOffset(mApp, closeTime)); + auto txResult = + tx->checkValid(mApp.getAppConnector(), ls, 0, 0, + getUpperBoundCloseTimeOffset(mApp, closeTime)); if (!txResult->isSuccess()) { return AddResult(TransactionQueue::AddResultCode::ADD_STATUS_ERROR, diff --git a/src/herder/TxSetFrame.cpp b/src/herder/TxSetFrame.cpp index 73e705ff93..e4f951f458 100644 --- a/src/herder/TxSetFrame.cpp +++ b/src/herder/TxSetFrame.cpp @@ -243,7 +243,8 @@ phaseTxsAreValid(TxSetTransactions const& phase, Application& app, app.getLedgerManager().getLastClosedLedgerNum() + 1; for (auto const& tx : phase) { - auto txResult = tx->checkValid(app, ls, 0, lowerBoundCloseTimeOffset, + auto txResult = tx->checkValid(app.getAppConnector(), ls, 0, + lowerBoundCloseTimeOffset, upperBoundCloseTimeOffset); if (!txResult->isSuccess()) { diff --git a/src/herder/TxSetUtils.cpp b/src/herder/TxSetUtils.cpp index 4157cf936c..7b10651bfc 100644 --- a/src/herder/TxSetUtils.cpp +++ b/src/herder/TxSetUtils.cpp @@ -153,7 +153,8 @@ TxSetUtils::getInvalidTxList(TxSetTransactions const& txs, Application& app, for (auto const& tx : txs) { - auto txResult = tx->checkValid(app, ls, 0, lowerBoundCloseTimeOffset, + auto txResult = tx->checkValid(app.getAppConnector(), ls, 0, + lowerBoundCloseTimeOffset, upperBoundCloseTimeOffset); if (!txResult->isSuccess()) { diff --git a/src/herder/test/TxSetTests.cpp b/src/herder/test/TxSetTests.cpp index 79a8488880..f79fc76f10 100644 --- a/src/herder/test/TxSetTests.cpp +++ b/src/herder/test/TxSetTests.cpp @@ -846,7 +846,8 @@ TEST_CASE("generalized tx set fees", "[txset][soroban]") LedgerTxn ltx(app->getLedgerTxnRoot()); if (validateTx) { - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), ltx, 0, + 0, 0)); } return tx; } diff --git a/src/herder/test/UpgradesTests.cpp b/src/herder/test/UpgradesTests.cpp index 3a1b3adf56..c1f86fb7ce 100644 --- a/src/herder/test/UpgradesTests.cpp +++ b/src/herder/test/UpgradesTests.cpp @@ -2433,8 +2433,9 @@ TEST_CASE_VERSIONS("upgrade base reserve", "[upgrades]") auto submitTx = [&](TransactionTestFramePtr tx) { LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE( + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); ltx.commit(); REQUIRE(tx->getResultCode() == txSUCCESS); diff --git a/src/ledger/LedgerManagerImpl.cpp b/src/ledger/LedgerManagerImpl.cpp index 2b7f328671..adf556e958 100644 --- a/src/ledger/LedgerManagerImpl.cpp +++ b/src/ledger/LedgerManagerImpl.cpp @@ -1567,8 +1567,8 @@ LedgerManagerImpl::applyTransactions( } ++txNum; - tx->apply(mApp, ltx, tm, mutableTxResult, subSeed); - tx->processPostApply(mApp, ltx, tm, mutableTxResult); + tx->apply(mApp.getAppConnector(), ltx, tm, mutableTxResult, subSeed); + tx->processPostApply(mApp.getAppConnector(), ltx, tm, mutableTxResult); TransactionResultPair results; results.transactionHash = tx->getContentsHash(); results.result = mutableTxResult->getResult(); diff --git a/src/main/CommandLine.cpp b/src/main/CommandLine.cpp index 5210bb8fb1..70b5b9d6fb 100644 --- a/src/main/CommandLine.cpp +++ b/src/main/CommandLine.cpp @@ -1896,7 +1896,6 @@ runApplyLoad(CommandLineArgs const& args) auto& app = *appPtr; { - auto& lm = app.getLedgerManager(); app.start(); ApplyLoad al(app, ledgerMaxInstructions, diff --git a/src/main/test/CommandHandlerTests.cpp b/src/main/test/CommandHandlerTests.cpp index b6394311e3..3e4f5df9d9 100644 --- a/src/main/test/CommandHandlerTests.cpp +++ b/src/main/test/CommandHandlerTests.cpp @@ -509,8 +509,8 @@ TEST_CASE("manualclose", "[commandhandler]") { LedgerTxn checkLtx(app->getLedgerTxnRoot()); - auto valid = - txFrame->checkValidForTesting(*app, checkLtx, 0, 0, 0); + auto valid = txFrame->checkValidForTesting( + app->getAppConnector(), checkLtx, 0, 0, 0); REQUIRE(valid); } diff --git a/src/simulation/ApplyLoad.cpp b/src/simulation/ApplyLoad.cpp index b4d40fd2b6..7b4ff29e05 100644 --- a/src/simulation/ApplyLoad.cpp +++ b/src/simulation/ApplyLoad.cpp @@ -251,7 +251,8 @@ ApplyLoad::benchmark() { LedgerTxn ltx(mApp.getLedgerTxnRoot()); - auto res = tx.second->checkValid(mApp, ltx, 0, 0, UINT64_MAX); + auto res = tx.second->checkValid(mApp.getAppConnector(), ltx, 0, 0, + UINT64_MAX); releaseAssert((res && res->isSuccess())); } diff --git a/src/simulation/LoadGenerator.cpp b/src/simulation/LoadGenerator.cpp index 9a8a4991d2..fd124f321d 100644 --- a/src/simulation/LoadGenerator.cpp +++ b/src/simulation/LoadGenerator.cpp @@ -88,10 +88,6 @@ LoadGenerator::LoadGenerator(Application& app) , mApp(app) , mLastSecond(0) , mTotalSubmitted(0) - , mLoadgenComplete( - mApp.getMetrics().NewMeter({"loadgen", "run", "complete"}, "run")) - , mLoadgenFail( - mApp.getMetrics().NewMeter({"loadgen", "run", "failed"}, "run")) , mStepTimer(mApp.getMetrics().NewTimer({"loadgen", "step", "submit"})) , mStepMeter( mApp.getMetrics().NewMeter({"loadgen", "step", "count"}, "step")) @@ -100,6 +96,10 @@ LoadGenerator::LoadGenerator(Application& app) mApp.getMetrics().NewTimer({"ledger", "transaction", "apply"})) , mApplyOpTimer( mApp.getMetrics().NewTimer({"ledger", "operation", "apply"})) + , mLoadgenComplete( + mApp.getMetrics().NewMeter({"loadgen", "run", "complete"}, "run")) + , mLoadgenFail( + mApp.getMetrics().NewMeter({"loadgen", "run", "failed"}, "run")) { } diff --git a/src/test/FuzzerImpl.cpp b/src/test/FuzzerImpl.cpp index ea19953621..23e4c400df 100644 --- a/src/test/FuzzerImpl.cpp +++ b/src/test/FuzzerImpl.cpp @@ -927,8 +927,9 @@ class FuzzTransactionFrame : public TransactionFrame LedgerSnapshot ltxStmt(ltx); // if any ill-formed Operations, do not attempt transaction application auto isInvalidOperation = [&](auto const& op, auto& opResult) { - return !op->checkValid(app, signatureChecker, ltxStmt, false, - opResult, mTxResult->getSorobanData()); + return !op->checkValid(app.getAppConnector(), signatureChecker, + ltxStmt, false, opResult, + mTxResult->getSorobanData()); }; auto const& ops = getOperations(); @@ -949,7 +950,8 @@ class FuzzTransactionFrame : public TransactionFrame loadSourceAccount(ltx, ltx.loadHeader()); processSeqNum(ltx); TransactionMetaFrame tm(2); - applyOperations(signatureChecker, app, ltx, tm, *mTxResult, Hash{}); + applyOperations(signatureChecker, app.getAppConnector(), ltx, tm, + *mTxResult, Hash{}); if (mTxResult->getResultCode() == txINTERNAL_ERROR) { throw std::runtime_error("Internal error while fuzzing"); diff --git a/src/test/TxTests.cpp b/src/test/TxTests.cpp index b306e737c1..732a6fd376 100644 --- a/src/test/TxTests.cpp +++ b/src/test/TxTests.cpp @@ -141,7 +141,8 @@ applyCheck(TransactionTestFramePtr tx, Application& app, bool checkSeqNum) { LedgerTxn ltxFeeProc(ltx); // use checkedTx here for validity check as to keep tx untouched - check = checkedTx->checkValidForTesting(app, ltxFeeProc, 0, 0, 0); + check = checkedTx->checkValidForTesting(app.getAppConnector(), + ltxFeeProc, 0, 0, 0); checkResult = checkedTx->getResult(); REQUIRE((!check || checkResult.result.code() == txSUCCESS)); @@ -166,7 +167,8 @@ applyCheck(TransactionTestFramePtr tx, Application& app, bool checkSeqNum) { TransactionMetaFrame cleanTm( ltxCleanTx.loadHeader().current().ledgerVersion); - checkedTxApplyRes = checkedTx->apply(app, ltxCleanTx, cleanTm); + checkedTxApplyRes = checkedTx->apply(app.getAppConnector(), + ltxCleanTx, cleanTm); } catch (...) { @@ -233,7 +235,7 @@ applyCheck(TransactionTestFramePtr tx, Application& app, bool checkSeqNum) TransactionMetaFrame tm(ltxTx.loadHeader().current().ledgerVersion); try { - res = tx->apply(app, ltxTx, tm); + res = tx->apply(app.getAppConnector(), ltxTx, tm); } catch (...) { @@ -437,8 +439,8 @@ validateTxResults(TransactionTestFramePtr const& tx, Application& app, tx->getEnvelope())); { LedgerTxn ltx(app.getLedgerTxnRoot()); - REQUIRE(checkedTx->checkValidForTesting(app, ltx, 0, 0, 0) == - shouldValidateOk); + REQUIRE(checkedTx->checkValidForTesting(app.getAppConnector(), ltx, 0, + 0, 0) == shouldValidateOk); } REQUIRE(checkedTx->getResult().result.code() == validationResult.code); REQUIRE(checkedTx->getResult().feeCharged == validationResult.fee); diff --git a/src/transactions/BeginSponsoringFutureReservesOpFrame.cpp b/src/transactions/BeginSponsoringFutureReservesOpFrame.cpp index 53dc18ad1f..5943728c7e 100644 --- a/src/transactions/BeginSponsoringFutureReservesOpFrame.cpp +++ b/src/transactions/BeginSponsoringFutureReservesOpFrame.cpp @@ -63,7 +63,7 @@ BeginSponsoringFutureReservesOpFrame::createSponsorshipCounter( bool BeginSponsoringFutureReservesOpFrame::doApply( - Application& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, + AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { ZoneNamedN(applyZone, "BeginSponsoringFutureReservesOpFrame apply", true); diff --git a/src/transactions/BeginSponsoringFutureReservesOpFrame.h b/src/transactions/BeginSponsoringFutureReservesOpFrame.h index da60867f99..0e83409022 100644 --- a/src/transactions/BeginSponsoringFutureReservesOpFrame.h +++ b/src/transactions/BeginSponsoringFutureReservesOpFrame.h @@ -27,7 +27,7 @@ class BeginSponsoringFutureReservesOpFrame : public OperationFrame BeginSponsoringFutureReservesOpFrame(Operation const& op, TransactionFrame const& parentTx); - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/BumpSequenceOpFrame.cpp b/src/transactions/BumpSequenceOpFrame.cpp index 2657cc8a32..d0583613f8 100644 --- a/src/transactions/BumpSequenceOpFrame.cpp +++ b/src/transactions/BumpSequenceOpFrame.cpp @@ -36,7 +36,7 @@ BumpSequenceOpFrame::isOpSupported(LedgerHeader const& header) const } bool -BumpSequenceOpFrame::doApply(Application& app, AbstractLedgerTxn& ltx, +BumpSequenceOpFrame::doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const diff --git a/src/transactions/BumpSequenceOpFrame.h b/src/transactions/BumpSequenceOpFrame.h index 956adcad3a..98a6380014 100644 --- a/src/transactions/BumpSequenceOpFrame.h +++ b/src/transactions/BumpSequenceOpFrame.h @@ -26,7 +26,7 @@ class BumpSequenceOpFrame : public OperationFrame public: BumpSequenceOpFrame(Operation const& op, TransactionFrame const& parentTx); - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/ChangeTrustOpFrame.cpp b/src/transactions/ChangeTrustOpFrame.cpp index afb7fb7e9b..aed6f670be 100644 --- a/src/transactions/ChangeTrustOpFrame.cpp +++ b/src/transactions/ChangeTrustOpFrame.cpp @@ -141,7 +141,7 @@ ChangeTrustOpFrame::ChangeTrustOpFrame(Operation const& op, } bool -ChangeTrustOpFrame::doApply(Application& app, AbstractLedgerTxn& ltx, +ChangeTrustOpFrame::doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const diff --git a/src/transactions/ChangeTrustOpFrame.h b/src/transactions/ChangeTrustOpFrame.h index 60443e7000..d643c89de1 100644 --- a/src/transactions/ChangeTrustOpFrame.h +++ b/src/transactions/ChangeTrustOpFrame.h @@ -30,7 +30,7 @@ class ChangeTrustOpFrame : public OperationFrame public: ChangeTrustOpFrame(Operation const& op, TransactionFrame const& parentTx); - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/ClaimClaimableBalanceOpFrame.cpp b/src/transactions/ClaimClaimableBalanceOpFrame.cpp index 807fab7dc1..13ad295b7f 100644 --- a/src/transactions/ClaimClaimableBalanceOpFrame.cpp +++ b/src/transactions/ClaimClaimableBalanceOpFrame.cpp @@ -71,7 +71,7 @@ validatePredicate(ClaimPredicate const& pred, TimePoint closeTime) bool ClaimClaimableBalanceOpFrame::doApply( - Application& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, + AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { ZoneNamedN(applyZone, "ClaimClaimableBalanceOpFrame apply", true); diff --git a/src/transactions/ClaimClaimableBalanceOpFrame.h b/src/transactions/ClaimClaimableBalanceOpFrame.h index 56ac7ac669..0917d560db 100644 --- a/src/transactions/ClaimClaimableBalanceOpFrame.h +++ b/src/transactions/ClaimClaimableBalanceOpFrame.h @@ -28,7 +28,7 @@ class ClaimClaimableBalanceOpFrame : public OperationFrame bool isOpSupported(LedgerHeader const& header) const override; - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/ClawbackClaimableBalanceOpFrame.cpp b/src/transactions/ClawbackClaimableBalanceOpFrame.cpp index cb2ef4851e..7d97e0b98e 100644 --- a/src/transactions/ClawbackClaimableBalanceOpFrame.cpp +++ b/src/transactions/ClawbackClaimableBalanceOpFrame.cpp @@ -28,7 +28,7 @@ ClawbackClaimableBalanceOpFrame::isOpSupported(LedgerHeader const& header) const bool ClawbackClaimableBalanceOpFrame::doApply( - Application& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, + AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { ZoneNamedN(applyZone, "ClawbackClaimableBalanceOp apply", true); diff --git a/src/transactions/ClawbackClaimableBalanceOpFrame.h b/src/transactions/ClawbackClaimableBalanceOpFrame.h index 9a6e511422..65ddac42ed 100644 --- a/src/transactions/ClawbackClaimableBalanceOpFrame.h +++ b/src/transactions/ClawbackClaimableBalanceOpFrame.h @@ -27,7 +27,7 @@ class ClawbackClaimableBalanceOpFrame : public OperationFrame bool isOpSupported(LedgerHeader const& header) const override; - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/ClawbackOpFrame.cpp b/src/transactions/ClawbackOpFrame.cpp index 25effb4909..9958c11fe4 100644 --- a/src/transactions/ClawbackOpFrame.cpp +++ b/src/transactions/ClawbackOpFrame.cpp @@ -25,7 +25,7 @@ ClawbackOpFrame::isOpSupported(LedgerHeader const& header) const } bool -ClawbackOpFrame::doApply(Application& app, AbstractLedgerTxn& ltx, +ClawbackOpFrame::doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { diff --git a/src/transactions/ClawbackOpFrame.h b/src/transactions/ClawbackOpFrame.h index 6a8ea3b3af..cba22d2f3a 100644 --- a/src/transactions/ClawbackOpFrame.h +++ b/src/transactions/ClawbackOpFrame.h @@ -26,7 +26,7 @@ class ClawbackOpFrame : public OperationFrame bool isOpSupported(LedgerHeader const& header) const override; - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/CreateAccountOpFrame.cpp b/src/transactions/CreateAccountOpFrame.cpp index 1de2b34178..4ed5be618f 100644 --- a/src/transactions/CreateAccountOpFrame.cpp +++ b/src/transactions/CreateAccountOpFrame.cpp @@ -137,7 +137,7 @@ CreateAccountOpFrame::doApplyFromV14(AbstractLedgerTxn& ltxOuter, } bool -CreateAccountOpFrame::doApply(Application& app, AbstractLedgerTxn& ltx, +CreateAccountOpFrame::doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const diff --git a/src/transactions/CreateAccountOpFrame.h b/src/transactions/CreateAccountOpFrame.h index efb41c70ce..e4096b5258 100644 --- a/src/transactions/CreateAccountOpFrame.h +++ b/src/transactions/CreateAccountOpFrame.h @@ -27,7 +27,7 @@ class CreateAccountOpFrame : public OperationFrame public: CreateAccountOpFrame(Operation const& op, TransactionFrame const& parentTx); - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/CreateClaimableBalanceOpFrame.cpp b/src/transactions/CreateClaimableBalanceOpFrame.cpp index 8da6aebee6..08e88041ef 100644 --- a/src/transactions/CreateClaimableBalanceOpFrame.cpp +++ b/src/transactions/CreateClaimableBalanceOpFrame.cpp @@ -141,7 +141,7 @@ CreateClaimableBalanceOpFrame::isOpSupported(LedgerHeader const& header) const bool CreateClaimableBalanceOpFrame::doApply( - Application& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, + AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { ZoneNamedN(applyZone, "CreateClaimableBalanceOpFrame apply", true); diff --git a/src/transactions/CreateClaimableBalanceOpFrame.h b/src/transactions/CreateClaimableBalanceOpFrame.h index f0d5ba2c20..0a709c57d7 100644 --- a/src/transactions/CreateClaimableBalanceOpFrame.h +++ b/src/transactions/CreateClaimableBalanceOpFrame.h @@ -31,7 +31,7 @@ class CreateClaimableBalanceOpFrame : public OperationFrame bool isOpSupported(LedgerHeader const& header) const override; - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/EndSponsoringFutureReservesOpFrame.cpp b/src/transactions/EndSponsoringFutureReservesOpFrame.cpp index 998fc580fd..926e58b271 100644 --- a/src/transactions/EndSponsoringFutureReservesOpFrame.cpp +++ b/src/transactions/EndSponsoringFutureReservesOpFrame.cpp @@ -28,7 +28,7 @@ EndSponsoringFutureReservesOpFrame::isOpSupported( bool EndSponsoringFutureReservesOpFrame::doApply( - Application& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, + AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { ZoneNamedN(applyZone, "EndSponsoringFutureReservesOpFrame apply", true); diff --git a/src/transactions/EndSponsoringFutureReservesOpFrame.h b/src/transactions/EndSponsoringFutureReservesOpFrame.h index ee77631a7f..c98669ffd1 100644 --- a/src/transactions/EndSponsoringFutureReservesOpFrame.h +++ b/src/transactions/EndSponsoringFutureReservesOpFrame.h @@ -23,7 +23,7 @@ class EndSponsoringFutureReservesOpFrame : public OperationFrame EndSponsoringFutureReservesOpFrame(Operation const& op, TransactionFrame const& parentTx); - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/ExtendFootprintTTLOpFrame.cpp b/src/transactions/ExtendFootprintTTLOpFrame.cpp index e29e00eee9..fcf23d1c8a 100644 --- a/src/transactions/ExtendFootprintTTLOpFrame.cpp +++ b/src/transactions/ExtendFootprintTTLOpFrame.cpp @@ -51,7 +51,7 @@ ExtendFootprintTTLOpFrame::isOpSupported(LedgerHeader const& header) const bool ExtendFootprintTTLOpFrame::doApply( - Application& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, + AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { releaseAssertOrThrow(sorobanData); diff --git a/src/transactions/ExtendFootprintTTLOpFrame.h b/src/transactions/ExtendFootprintTTLOpFrame.h index 8977603ef6..a3212f2c4e 100644 --- a/src/transactions/ExtendFootprintTTLOpFrame.h +++ b/src/transactions/ExtendFootprintTTLOpFrame.h @@ -28,7 +28,7 @@ class ExtendFootprintTTLOpFrame : public OperationFrame bool isOpSupported(LedgerHeader const& header) const override; - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValidForSoroban(SorobanNetworkConfig const& networkConfig, diff --git a/src/transactions/FeeBumpTransactionFrame.cpp b/src/transactions/FeeBumpTransactionFrame.cpp index 7e5e74e91f..ebddd16896 100644 --- a/src/transactions/FeeBumpTransactionFrame.cpp +++ b/src/transactions/FeeBumpTransactionFrame.cpp @@ -73,7 +73,7 @@ FeeBumpTransactionFrame::FeeBumpTransactionFrame( #endif bool -FeeBumpTransactionFrame::apply(Application& app, AbstractLedgerTxn& ltx, +FeeBumpTransactionFrame::apply(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, MutableTxResultPtr txResult, Hash const& sorobanBasePrngSeed) const @@ -122,7 +122,7 @@ FeeBumpTransactionFrame::apply(Application& app, AbstractLedgerTxn& ltx, } void -FeeBumpTransactionFrame::processPostApply(Application& app, +FeeBumpTransactionFrame::processPostApply(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, MutableTxResultPtr txResult) const @@ -132,8 +132,7 @@ FeeBumpTransactionFrame::processPostApply(Application& app, // Note that we are not calling TransactionFrame::processPostApply, so if // any logic is added there, we would have to reason through if that logic // should also be reflected here. - int64_t refund = - mInnerTx->processRefund(app, ltx, meta, getFeeSourceID(), *txResult); + mInnerTx->processRefund(app, ltx, meta, getFeeSourceID(), *txResult); } bool @@ -154,7 +153,7 @@ FeeBumpTransactionFrame::checkSignature(SignatureChecker& signatureChecker, } MutableTxResultPtr -FeeBumpTransactionFrame::checkValid(Application& app, LedgerSnapshot const& ls, +FeeBumpTransactionFrame::checkValid(AppConnector& app, LedgerSnapshot const& ls, SequenceNumber current, uint64_t lowerBoundCloseTimeOffset, uint64_t upperBoundCloseTimeOffset) const @@ -197,7 +196,8 @@ FeeBumpTransactionFrame::checkValid(Application& app, LedgerSnapshot const& ls, bool FeeBumpTransactionFrame::checkSorobanResourceAndSetError( - Application& app, uint32_t ledgerVersion, MutableTxResultPtr txResult) const + AppConnector& app, uint32_t ledgerVersion, + MutableTxResultPtr txResult) const { return mInnerTx->checkSorobanResourceAndSetError(app, ledgerVersion, txResult); diff --git a/src/transactions/FeeBumpTransactionFrame.h b/src/transactions/FeeBumpTransactionFrame.h index 3190e31cfd..6435c84eab 100644 --- a/src/transactions/FeeBumpTransactionFrame.h +++ b/src/transactions/FeeBumpTransactionFrame.h @@ -68,20 +68,20 @@ class FeeBumpTransactionFrame : public TransactionFrameBase virtual ~FeeBumpTransactionFrame(){}; - bool apply(Application& app, AbstractLedgerTxn& ltx, + bool apply(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, MutableTxResultPtr txResult, Hash const& sorobanBasePrngSeed) const override; - void processPostApply(Application& app, AbstractLedgerTxn& ltx, + void processPostApply(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, MutableTxResultPtr txResult) const override; MutableTxResultPtr - checkValid(Application& app, LedgerSnapshot const& ls, + checkValid(AppConnector& app, LedgerSnapshot const& ls, SequenceNumber current, uint64_t lowerBoundCloseTimeOffset, uint64_t upperBoundCloseTimeOffset) const override; bool - checkSorobanResourceAndSetError(Application& app, uint32_t ledgerVersion, + checkSorobanResourceAndSetError(AppConnector& app, uint32_t ledgerVersion, MutableTxResultPtr txResult) const override; MutableTxResultPtr createSuccessResult() const override; diff --git a/src/transactions/InflationOpFrame.cpp b/src/transactions/InflationOpFrame.cpp index f15399be28..a1801f5c65 100644 --- a/src/transactions/InflationOpFrame.cpp +++ b/src/transactions/InflationOpFrame.cpp @@ -29,7 +29,7 @@ InflationOpFrame::InflationOpFrame(Operation const& op, } bool -InflationOpFrame::doApply(Application& app, AbstractLedgerTxn& ltx, +InflationOpFrame::doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { diff --git a/src/transactions/InflationOpFrame.h b/src/transactions/InflationOpFrame.h index bc9d44e6e7..1038df799b 100644 --- a/src/transactions/InflationOpFrame.h +++ b/src/transactions/InflationOpFrame.h @@ -23,7 +23,7 @@ class InflationOpFrame : public OperationFrame public: InflationOpFrame(Operation const& op, TransactionFrame const& parentTx); - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/InvokeHostFunctionOpFrame.cpp b/src/transactions/InvokeHostFunctionOpFrame.cpp index 2f50f1db1e..20f39c7f27 100644 --- a/src/transactions/InvokeHostFunctionOpFrame.cpp +++ b/src/transactions/InvokeHostFunctionOpFrame.cpp @@ -56,7 +56,7 @@ toCxxBuf(T const& t) } CxxLedgerInfo -getLedgerInfo(AbstractLedgerTxn& ltx, Application& app, +getLedgerInfo(AbstractLedgerTxn& ltx, AppConnector& app, SorobanNetworkConfig const& sorobanConfig) { CxxLedgerInfo info{}; @@ -317,7 +317,7 @@ InvokeHostFunctionOpFrame::maybePopulateDiagnosticEvents( bool InvokeHostFunctionOpFrame::doApply( - Application& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, + AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { releaseAssertOrThrow(sorobanData); diff --git a/src/transactions/InvokeHostFunctionOpFrame.h b/src/transactions/InvokeHostFunctionOpFrame.h index c283098a70..6ba21e7509 100644 --- a/src/transactions/InvokeHostFunctionOpFrame.h +++ b/src/transactions/InvokeHostFunctionOpFrame.h @@ -38,7 +38,7 @@ class InvokeHostFunctionOpFrame : public OperationFrame bool isOpSupported(LedgerHeader const& header) const override; - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; diff --git a/src/transactions/LiquidityPoolDepositOpFrame.cpp b/src/transactions/LiquidityPoolDepositOpFrame.cpp index 23e8638c62..f51876fe13 100644 --- a/src/transactions/LiquidityPoolDepositOpFrame.cpp +++ b/src/transactions/LiquidityPoolDepositOpFrame.cpp @@ -190,7 +190,7 @@ updateBalance(LedgerTxnHeader& header, TrustLineWrapper& tl, bool LiquidityPoolDepositOpFrame::doApply( - Application& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, + AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { ZoneNamedN(applyZone, "LiquidityPoolDepositOpFrame apply", true); diff --git a/src/transactions/LiquidityPoolDepositOpFrame.h b/src/transactions/LiquidityPoolDepositOpFrame.h index 8fbc4be5e3..26b8e30ef9 100644 --- a/src/transactions/LiquidityPoolDepositOpFrame.h +++ b/src/transactions/LiquidityPoolDepositOpFrame.h @@ -43,7 +43,7 @@ class LiquidityPoolDepositOpFrame : public OperationFrame bool isOpSupported(LedgerHeader const& header) const override; - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/LiquidityPoolWithdrawOpFrame.cpp b/src/transactions/LiquidityPoolWithdrawOpFrame.cpp index b34d136756..51cdac6d10 100644 --- a/src/transactions/LiquidityPoolWithdrawOpFrame.cpp +++ b/src/transactions/LiquidityPoolWithdrawOpFrame.cpp @@ -30,7 +30,7 @@ LiquidityPoolWithdrawOpFrame::isOpSupported(LedgerHeader const& header) const bool LiquidityPoolWithdrawOpFrame::doApply( - Application& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, + AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { ZoneNamedN(applyZone, "LiquidityPoolWithdrawOpFrame apply", true); diff --git a/src/transactions/LiquidityPoolWithdrawOpFrame.h b/src/transactions/LiquidityPoolWithdrawOpFrame.h index 8b716b56af..9203f400b3 100644 --- a/src/transactions/LiquidityPoolWithdrawOpFrame.h +++ b/src/transactions/LiquidityPoolWithdrawOpFrame.h @@ -30,7 +30,7 @@ class LiquidityPoolWithdrawOpFrame : public OperationFrame bool isOpSupported(LedgerHeader const& header) const override; - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/ManageDataOpFrame.cpp b/src/transactions/ManageDataOpFrame.cpp index de56131237..8ad8e16c13 100644 --- a/src/transactions/ManageDataOpFrame.cpp +++ b/src/transactions/ManageDataOpFrame.cpp @@ -29,7 +29,7 @@ ManageDataOpFrame::ManageDataOpFrame(Operation const& op, } bool -ManageDataOpFrame::doApply(Application& app, AbstractLedgerTxn& ltx, +ManageDataOpFrame::doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const diff --git a/src/transactions/ManageDataOpFrame.h b/src/transactions/ManageDataOpFrame.h index 4c4e6f4323..4fcfb25290 100644 --- a/src/transactions/ManageDataOpFrame.h +++ b/src/transactions/ManageDataOpFrame.h @@ -24,7 +24,7 @@ class ManageDataOpFrame : public OperationFrame public: ManageDataOpFrame(Operation const& op, TransactionFrame const& parentTx); - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/ManageOfferOpFrameBase.cpp b/src/transactions/ManageOfferOpFrameBase.cpp index d4c57682c2..38905dbde3 100644 --- a/src/transactions/ManageOfferOpFrameBase.cpp +++ b/src/transactions/ManageOfferOpFrameBase.cpp @@ -213,7 +213,7 @@ ManageOfferOpFrameBase::computeOfferExchangeParameters( bool ManageOfferOpFrameBase::doApply( - Application& app, AbstractLedgerTxn& ltxOuter, + AppConnector& app, AbstractLedgerTxn& ltxOuter, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { diff --git a/src/transactions/ManageOfferOpFrameBase.h b/src/transactions/ManageOfferOpFrameBase.h index 13f65b0a63..49fbe4a229 100644 --- a/src/transactions/ManageOfferOpFrameBase.h +++ b/src/transactions/ManageOfferOpFrameBase.h @@ -43,7 +43,7 @@ class ManageOfferOpFrameBase : public OperationFrame bool doCheckValid(uint32_t ledgerVersion, OperationResult& res) const override; - bool doApply(Application& app, AbstractLedgerTxn& ltxOuter, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltxOuter, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; diff --git a/src/transactions/MergeOpFrame.cpp b/src/transactions/MergeOpFrame.cpp index c0f63a93cb..5b186ea95d 100644 --- a/src/transactions/MergeOpFrame.cpp +++ b/src/transactions/MergeOpFrame.cpp @@ -61,7 +61,7 @@ MergeOpFrame::isSeqnumTooFar(AbstractLedgerTxn& ltx, // make sure the we delete all the trustlines // move the XLM to the new account bool -MergeOpFrame::doApply(Application& app, AbstractLedgerTxn& ltx, +MergeOpFrame::doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { diff --git a/src/transactions/MergeOpFrame.h b/src/transactions/MergeOpFrame.h index 5c75de0e2c..35d7ff2828 100644 --- a/src/transactions/MergeOpFrame.h +++ b/src/transactions/MergeOpFrame.h @@ -31,7 +31,7 @@ class MergeOpFrame : public OperationFrame public: MergeOpFrame(Operation const& op, TransactionFrame const& parentTx); - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/OperationFrame.cpp b/src/transactions/OperationFrame.cpp index ce74aacf2d..69c2660c60 100644 --- a/src/transactions/OperationFrame.cpp +++ b/src/transactions/OperationFrame.cpp @@ -135,7 +135,7 @@ OperationFrame::OperationFrame(Operation const& op, } bool -OperationFrame::apply(Application& app, SignatureChecker& signatureChecker, +OperationFrame::apply(AppConnector& app, SignatureChecker& signatureChecker, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const @@ -217,7 +217,8 @@ OperationFrame::getSourceID() const // make sure sig is correct // verifies that the operation is well formed (operation specific) bool -OperationFrame::checkValid(Application& app, SignatureChecker& signatureChecker, +OperationFrame::checkValid(AppConnector& app, + SignatureChecker& signatureChecker, LedgerSnapshot const& ls, bool forApply, OperationResult& res, std::shared_ptr sorobanData) const diff --git a/src/transactions/OperationFrame.h b/src/transactions/OperationFrame.h index 48d9950c63..5cc8aa6641 100644 --- a/src/transactions/OperationFrame.h +++ b/src/transactions/OperationFrame.h @@ -7,6 +7,7 @@ #include "ledger/LedgerHashUtils.h" #include "ledger/LedgerManager.h" #include "ledger/NetworkConfig.h" +#include "main/AppConnector.h" #include "overlay/StellarXDR.h" #include "transactions/MutableTransactionResult.h" #include "util/types.h" @@ -43,7 +44,7 @@ class OperationFrame SorobanTxData& sorobanData) const; virtual bool doCheckValid(uint32_t ledgerVersion, OperationResult& res) const = 0; - virtual bool doApply(Application& app, AbstractLedgerTxn& ltx, + virtual bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const = 0; @@ -72,12 +73,12 @@ class OperationFrame AccountID getSourceID() const; - bool checkValid(Application& app, SignatureChecker& signatureChecker, + bool checkValid(AppConnector& app, SignatureChecker& signatureChecker, LedgerSnapshot const& ls, bool forApply, OperationResult& res, std::shared_ptr sorobanData) const; - bool apply(Application& app, SignatureChecker& signatureChecker, + bool apply(AppConnector& app, SignatureChecker& signatureChecker, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const; diff --git a/src/transactions/PathPaymentStrictReceiveOpFrame.cpp b/src/transactions/PathPaymentStrictReceiveOpFrame.cpp index 572a39284a..4507d68690 100644 --- a/src/transactions/PathPaymentStrictReceiveOpFrame.cpp +++ b/src/transactions/PathPaymentStrictReceiveOpFrame.cpp @@ -24,7 +24,7 @@ PathPaymentStrictReceiveOpFrame::PathPaymentStrictReceiveOpFrame( bool PathPaymentStrictReceiveOpFrame::doApply( - Application& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, + AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { ZoneNamedN(applyZone, "PathPaymentStrictReceiveOp apply", true); diff --git a/src/transactions/PathPaymentStrictReceiveOpFrame.h b/src/transactions/PathPaymentStrictReceiveOpFrame.h index 5ccf0f06c9..ca0ba48155 100644 --- a/src/transactions/PathPaymentStrictReceiveOpFrame.h +++ b/src/transactions/PathPaymentStrictReceiveOpFrame.h @@ -23,7 +23,7 @@ class PathPaymentStrictReceiveOpFrame : public PathPaymentOpFrameBase PathPaymentStrictReceiveOpFrame(Operation const& op, TransactionFrame const& parentTx); - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/PathPaymentStrictSendOpFrame.cpp b/src/transactions/PathPaymentStrictSendOpFrame.cpp index befc6d4f6e..2820453453 100644 --- a/src/transactions/PathPaymentStrictSendOpFrame.cpp +++ b/src/transactions/PathPaymentStrictSendOpFrame.cpp @@ -31,7 +31,7 @@ PathPaymentStrictSendOpFrame::isOpSupported(LedgerHeader const& header) const bool PathPaymentStrictSendOpFrame::doApply( - Application& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, + AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { ZoneNamedN(applyZone, "PathPaymentStrictSendOp apply", true); diff --git a/src/transactions/PathPaymentStrictSendOpFrame.h b/src/transactions/PathPaymentStrictSendOpFrame.h index 1311655446..15336a8c60 100644 --- a/src/transactions/PathPaymentStrictSendOpFrame.h +++ b/src/transactions/PathPaymentStrictSendOpFrame.h @@ -25,7 +25,7 @@ class PathPaymentStrictSendOpFrame : public PathPaymentOpFrameBase bool isOpSupported(LedgerHeader const& header) const override; - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/PaymentOpFrame.cpp b/src/transactions/PaymentOpFrame.cpp index 6d6bb0b38e..316859e4ee 100644 --- a/src/transactions/PaymentOpFrame.cpp +++ b/src/transactions/PaymentOpFrame.cpp @@ -25,7 +25,7 @@ PaymentOpFrame::PaymentOpFrame(Operation const& op, } bool -PaymentOpFrame::doApply(Application& app, AbstractLedgerTxn& ltx, +PaymentOpFrame::doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { diff --git a/src/transactions/PaymentOpFrame.h b/src/transactions/PaymentOpFrame.h index 34a2c8cea3..7575cf792e 100644 --- a/src/transactions/PaymentOpFrame.h +++ b/src/transactions/PaymentOpFrame.h @@ -22,7 +22,7 @@ class PaymentOpFrame : public OperationFrame public: PaymentOpFrame(Operation const& op, TransactionFrame const& parentTx); - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/RestoreFootprintOpFrame.cpp b/src/transactions/RestoreFootprintOpFrame.cpp index 1d697c59a7..36d5a20953 100644 --- a/src/transactions/RestoreFootprintOpFrame.cpp +++ b/src/transactions/RestoreFootprintOpFrame.cpp @@ -52,7 +52,7 @@ RestoreFootprintOpFrame::isOpSupported(LedgerHeader const& header) const bool RestoreFootprintOpFrame::doApply( - Application& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, + AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { ZoneNamedN(applyZone, "RestoreFootprintOpFrame apply", true); diff --git a/src/transactions/RestoreFootprintOpFrame.h b/src/transactions/RestoreFootprintOpFrame.h index f2b43ab272..47e3206080 100644 --- a/src/transactions/RestoreFootprintOpFrame.h +++ b/src/transactions/RestoreFootprintOpFrame.h @@ -28,7 +28,7 @@ class RestoreFootprintOpFrame : public OperationFrame bool isOpSupported(LedgerHeader const& header) const override; - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValidForSoroban(SorobanNetworkConfig const& networkConfig, diff --git a/src/transactions/RevokeSponsorshipOpFrame.cpp b/src/transactions/RevokeSponsorshipOpFrame.cpp index ee664f077b..91243d3290 100644 --- a/src/transactions/RevokeSponsorshipOpFrame.cpp +++ b/src/transactions/RevokeSponsorshipOpFrame.cpp @@ -383,7 +383,7 @@ RevokeSponsorshipOpFrame::updateSignerSponsorship(AbstractLedgerTxn& ltx, bool RevokeSponsorshipOpFrame::doApply( - Application& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, + AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const { ZoneNamedN(applyZone, "RevokeSponsorshipOpFrame apply", true); diff --git a/src/transactions/RevokeSponsorshipOpFrame.h b/src/transactions/RevokeSponsorshipOpFrame.h index 8cf51b4ac7..372c4071f6 100644 --- a/src/transactions/RevokeSponsorshipOpFrame.h +++ b/src/transactions/RevokeSponsorshipOpFrame.h @@ -45,7 +45,7 @@ class RevokeSponsorshipOpFrame : public OperationFrame RevokeSponsorshipOpFrame(Operation const& op, TransactionFrame const& parentTx); - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/SetOptionsOpFrame.cpp b/src/transactions/SetOptionsOpFrame.cpp index 2e1e4d355a..2241a233dd 100644 --- a/src/transactions/SetOptionsOpFrame.cpp +++ b/src/transactions/SetOptionsOpFrame.cpp @@ -121,7 +121,7 @@ SetOptionsOpFrame::deleteSigner(AbstractLedgerTxn& ltx, } bool -SetOptionsOpFrame::doApply(Application& app, AbstractLedgerTxn& ltx, +SetOptionsOpFrame::doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const diff --git a/src/transactions/SetOptionsOpFrame.h b/src/transactions/SetOptionsOpFrame.h index c9101fcdea..f81e0a190c 100644 --- a/src/transactions/SetOptionsOpFrame.h +++ b/src/transactions/SetOptionsOpFrame.h @@ -27,7 +27,7 @@ class SetOptionsOpFrame : public OperationFrame public: SetOptionsOpFrame(Operation const& op, TransactionFrame const& parentTx); - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; bool doCheckValid(uint32_t ledgerVersion, diff --git a/src/transactions/TransactionFrame.cpp b/src/transactions/TransactionFrame.cpp index 4e488625a9..1eb017d768 100644 --- a/src/transactions/TransactionFrame.cpp +++ b/src/transactions/TransactionFrame.cpp @@ -20,6 +20,7 @@ #include "ledger/LedgerTxnHeader.h" #include "ledger/LedgerTypeUtils.h" #include "ledger/SorobanMetrics.h" +#include "main/AppConnector.h" #include "main/Application.h" #include "transactions/MutableTransactionResult.h" #include "transactions/SignatureChecker.h" @@ -701,10 +702,10 @@ TransactionFrame::refundSorobanFee(AbstractLedgerTxn& ltxOuter, } void -TransactionFrame::updateSorobanMetrics(Application& app) const +TransactionFrame::updateSorobanMetrics(AppConnector& app) const { releaseAssertOrThrow(isSoroban()); - SorobanMetrics& metrics = app.getLedgerManager().getSorobanMetrics(); + SorobanMetrics& metrics = app.getSorobanMetrics(); auto txSize = static_cast(this->getSize()); auto r = sorobanResources(); // update the tx metrics @@ -874,7 +875,7 @@ TransactionFrame::isTooEarlyForAccount(LedgerHeaderWrapper const& header, bool TransactionFrame::commonValidPreSeqNum( - Application& app, LedgerSnapshot const& ls, bool chargeFee, + AppConnector& app, LedgerSnapshot const& ls, bool chargeFee, uint64_t lowerBoundCloseTimeOffset, uint64_t upperBoundCloseTimeOffset, std::optional sorobanResourceFee, MutableTxResultPtr txResult) const @@ -1179,7 +1180,7 @@ TransactionFrame::isBadSeq(LedgerHeaderWrapper const& header, } TransactionFrame::ValidationType -TransactionFrame::commonValid(Application& app, +TransactionFrame::commonValid(AppConnector& app, SignatureChecker& signatureChecker, LedgerSnapshot const& ls, SequenceNumber current, bool applying, bool chargeFee, @@ -1410,7 +1411,7 @@ TransactionFrame::removeAccountSigner(AbstractLedgerTxn& ltxOuter, MutableTxResultPtr TransactionFrame::checkValidWithOptionallyChargedFee( - Application& app, LedgerSnapshot const& ls, SequenceNumber current, + AppConnector& app, LedgerSnapshot const& ls, SequenceNumber current, bool chargeFee, uint64_t lowerBoundCloseTimeOffset, uint64_t upperBoundCloseTimeOffset) const { @@ -1478,7 +1479,7 @@ TransactionFrame::checkValidWithOptionallyChargedFee( } MutableTxResultPtr -TransactionFrame::checkValid(Application& app, LedgerSnapshot const& ls, +TransactionFrame::checkValid(AppConnector& app, LedgerSnapshot const& ls, SequenceNumber current, uint64_t lowerBoundCloseTimeOffset, uint64_t upperBoundCloseTimeOffset) const @@ -1500,7 +1501,8 @@ TransactionFrame::checkValid(Application& app, LedgerSnapshot const& ls, bool TransactionFrame::checkSorobanResourceAndSetError( - Application& app, uint32_t ledgerVersion, MutableTxResultPtr txResult) const + AppConnector& app, uint32_t ledgerVersion, + MutableTxResultPtr txResult) const { auto const& sorobanConfig = app.getLedgerManager().getSorobanNetworkConfig(); @@ -1556,7 +1558,7 @@ TransactionFrame::insertKeysForTxApply(UnorderedSet& keys, } bool -TransactionFrame::apply(Application& app, AbstractLedgerTxn& ltx, +TransactionFrame::apply(AppConnector& app, AbstractLedgerTxn& ltx, MutableTxResultPtr txResult, Hash const& sorobanBasePrngSeed) const { @@ -1566,7 +1568,7 @@ TransactionFrame::apply(Application& app, AbstractLedgerTxn& ltx, bool TransactionFrame::applyOperations(SignatureChecker& signatureChecker, - Application& app, AbstractLedgerTxn& ltx, + AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& outerMeta, MutableTransactionResultBase& txResult, Hash const& sorobanBasePrngSeed) const @@ -1623,8 +1625,8 @@ TransactionFrame::applyOperations(SignatureChecker& signatureChecker, } if (success) { - app.getInvariantManager().checkOnOperationApply( - op->getOperation(), opResult, ltxOp.getDelta()); + app.checkOnOperationApply(op->getOperation(), opResult, + ltxOp.getDelta()); // The operation meta will be empty if the transaction // doesn't succeed so we may as well not do any work in that @@ -1774,7 +1776,7 @@ TransactionFrame::applyOperations(SignatureChecker& signatureChecker, } bool -TransactionFrame::apply(Application& app, AbstractLedgerTxn& ltx, +TransactionFrame::apply(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, MutableTxResultPtr txResult, bool chargeFee, Hash const& sorobanBasePrngSeed) const { @@ -1862,7 +1864,7 @@ TransactionFrame::apply(Application& app, AbstractLedgerTxn& ltx, } bool -TransactionFrame::apply(Application& app, AbstractLedgerTxn& ltx, +TransactionFrame::apply(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, MutableTxResultPtr txResult, Hash const& sorobanBasePrngSeed) const { @@ -1870,7 +1872,7 @@ TransactionFrame::apply(Application& app, AbstractLedgerTxn& ltx, } void -TransactionFrame::processPostApply(Application& app, +TransactionFrame::processPostApply(AppConnector& app, AbstractLedgerTxn& ltxOuter, TransactionMetaFrame& meta, MutableTxResultPtr txResult) const @@ -1882,7 +1884,7 @@ TransactionFrame::processPostApply(Application& app, // This is a TransactionFrame specific function that should only be used by // FeeBumpTransactionFrame to forward a different account for the refund. int64_t -TransactionFrame::processRefund(Application& app, AbstractLedgerTxn& ltxOuter, +TransactionFrame::processRefund(AppConnector& app, AbstractLedgerTxn& ltxOuter, TransactionMetaFrame& meta, AccountID const& feeSource, MutableTransactionResultBase& txResult) const diff --git a/src/transactions/TransactionFrame.h b/src/transactions/TransactionFrame.h index 4cb02a0e7c..ad46e3b650 100644 --- a/src/transactions/TransactionFrame.h +++ b/src/transactions/TransactionFrame.h @@ -43,6 +43,7 @@ class MutableTransactionResultBase; class SorobanTxData; class XDROutputFileStream; class SHA256; +class AppConnector; class TransactionFrame; using TransactionFramePtr = std::shared_ptr; @@ -93,7 +94,7 @@ class TransactionFrame : public TransactionFrameBase LedgerEntryWrapper const& sourceAccount, uint64_t lowerBoundCloseTimeOffset) const; - bool commonValidPreSeqNum(Application& app, LedgerSnapshot const& ls, + bool commonValidPreSeqNum(AppConnector& app, LedgerSnapshot const& ls, bool chargeFee, uint64_t lowerBoundCloseTimeOffset, uint64_t upperBoundCloseTimeOffset, @@ -103,7 +104,7 @@ class TransactionFrame : public TransactionFrameBase virtual bool isBadSeq(LedgerHeaderWrapper const& header, int64_t seqNum) const; - ValidationType commonValid(Application& app, + ValidationType commonValid(AppConnector& app, SignatureChecker& signatureChecker, LedgerSnapshot const& ls, SequenceNumber current, bool applying, bool chargeFee, @@ -118,7 +119,7 @@ class TransactionFrame : public TransactionFrameBase AccountID const& accountID, SignerKey const& signerKey) const; - bool applyOperations(SignatureChecker& checker, Application& app, + bool applyOperations(SignatureChecker& checker, AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, MutableTransactionResultBase& txResult, Hash const& sorobanBasePrngSeed) const; @@ -141,7 +142,7 @@ class TransactionFrame : public TransactionFrameBase SorobanTxData& sorobanData) const; int64_t refundSorobanFee(AbstractLedgerTxn& ltx, AccountID const& feeSource, MutableTransactionResultBase& txResult) const; - void updateSorobanMetrics(Application& app) const; + void updateSorobanMetrics(AppConnector& app) const; #ifdef BUILD_TESTS public: #endif @@ -207,15 +208,15 @@ class TransactionFrame : public TransactionFrameBase bool checkExtraSigners(SignatureChecker& signatureChecker) const; MutableTxResultPtr checkValidWithOptionallyChargedFee( - Application& app, LedgerSnapshot const& ls, SequenceNumber current, + AppConnector& app, LedgerSnapshot const& ls, SequenceNumber current, bool chargeFee, uint64_t lowerBoundCloseTimeOffset, uint64_t upperBoundCloseTimeOffset) const; MutableTxResultPtr - checkValid(Application& app, LedgerSnapshot const& ls, + checkValid(AppConnector& app, LedgerSnapshot const& ls, SequenceNumber current, uint64_t lowerBoundCloseTimeOffset, uint64_t upperBoundCloseTimeOffset) const override; bool - checkSorobanResourceAndSetError(Application& app, uint32_t ledgerVersion, + checkSorobanResourceAndSetError(AppConnector& app, uint32_t ledgerVersion, MutableTxResultPtr txResult) const override; MutableTxResultPtr createSuccessResult() const override; @@ -237,10 +238,10 @@ class TransactionFrame : public TransactionFrameBase // apply this transaction to the current ledger // returns true if successfully applied - bool apply(Application& app, AbstractLedgerTxn& ltx, + bool apply(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, MutableTxResultPtr txResult, bool chargeFee, Hash const& sorobanBasePrngSeed) const; - bool apply(Application& app, AbstractLedgerTxn& ltx, + bool apply(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, MutableTxResultPtr txResult, Hash const& sorobanBasePrngSeed = Hash{}) const override; @@ -248,20 +249,20 @@ class TransactionFrame : public TransactionFrameBase // This has to be called after both `processFeeSeqNum` and // `apply` have been called. // Currently this only takes care of Soroban fee refunds. - void processPostApply(Application& app, AbstractLedgerTxn& ltx, + void processPostApply(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, MutableTxResultPtr txResult) const override; // TransactionFrame specific function that allows fee bumps to forward a // different account for the refund. It also returns the refund so // FeeBumpTransactionFrame can adjust feeCharged. - int64_t processRefund(Application& app, AbstractLedgerTxn& ltx, + int64_t processRefund(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, AccountID const& feeSource, MutableTransactionResultBase& txResult) const; // version without meta - bool apply(Application& app, AbstractLedgerTxn& ltx, + bool apply(AppConnector& app, AbstractLedgerTxn& ltx, MutableTxResultPtr txResult, Hash const& sorobanBasePrngSeed) const; diff --git a/src/transactions/TransactionFrameBase.h b/src/transactions/TransactionFrameBase.h index a3db674fce..707fd10cf9 100644 --- a/src/transactions/TransactionFrameBase.h +++ b/src/transactions/TransactionFrameBase.h @@ -25,6 +25,7 @@ class Database; class OperationFrame; class TransactionFrame; class FeeBumpTransactionFrame; +class AppConnector; class MutableTransactionResultBase; using MutableTxResultPtr = std::shared_ptr; @@ -41,15 +42,15 @@ class TransactionFrameBase makeTransactionFromWire(Hash const& networkID, TransactionEnvelope const& env); - virtual bool apply(Application& app, AbstractLedgerTxn& ltx, + virtual bool apply(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, MutableTxResultPtr txResult, Hash const& sorobanBasePrngSeed = Hash{}) const = 0; virtual MutableTxResultPtr - checkValid(Application& app, LedgerSnapshot const& ls, + checkValid(AppConnector& app, LedgerSnapshot const& ls, SequenceNumber current, uint64_t lowerBoundCloseTimeOffset, uint64_t upperBoundCloseTimeOffset) const = 0; virtual bool - checkSorobanResourceAndSetError(Application& app, uint32_t ledgerVersion, + checkSorobanResourceAndSetError(AppConnector& app, uint32_t ledgerVersion, MutableTxResultPtr txResult) const = 0; virtual MutableTxResultPtr createSuccessResult() const = 0; @@ -101,7 +102,7 @@ class TransactionFrameBase processFeeSeqNum(AbstractLedgerTxn& ltx, std::optional baseFee) const = 0; - virtual void processPostApply(Application& app, AbstractLedgerTxn& ltx, + virtual void processPostApply(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, MutableTxResultPtr txResult) const = 0; diff --git a/src/transactions/TransactionUtils.cpp b/src/transactions/TransactionUtils.cpp index 09fb1cd495..bcdb02c257 100644 --- a/src/transactions/TransactionUtils.cpp +++ b/src/transactions/TransactionUtils.cpp @@ -1983,7 +1983,7 @@ hasMuxedAccount(TransactionEnvelope const& e) } bool -isTransactionXDRValidForCurrentProtocol(Application& app, +isTransactionXDRValidForCurrentProtocol(AppConnector& app, TransactionEnvelope const& envelope) { uint32_t maxProtocol = app.getConfig().CURRENT_LEDGER_PROTOCOL_VERSION; diff --git a/src/transactions/TransactionUtils.h b/src/transactions/TransactionUtils.h index c9320ee9c3..e4c5789d10 100644 --- a/src/transactions/TransactionUtils.h +++ b/src/transactions/TransactionUtils.h @@ -4,6 +4,7 @@ // under the Apache License, Version 2.0. See the COPYING file at the root // of this distribution or at http://www.apache.org/licenses/LICENSE-2.0 +#include "main/AppConnector.h" #include "util/NonCopyable.h" #include "util/ProtocolVersion.h" #include "xdr/Stellar-ledger-entries.h" @@ -261,7 +262,7 @@ bool accountFlagMaskCheckIsValid(uint32_t flag, uint32_t ledgerVersion); bool hasMuxedAccount(TransactionEnvelope const& e); bool -isTransactionXDRValidForCurrentProtocol(Application& app, +isTransactionXDRValidForCurrentProtocol(AppConnector& app, TransactionEnvelope const& envelope); uint64_t getUpperBoundCloseTimeOffset(Application& app, uint64_t lastCloseTime); diff --git a/src/transactions/TrustFlagsOpFrameBase.cpp b/src/transactions/TrustFlagsOpFrameBase.cpp index 187a9a4287..b58ab13d58 100644 --- a/src/transactions/TrustFlagsOpFrameBase.cpp +++ b/src/transactions/TrustFlagsOpFrameBase.cpp @@ -51,7 +51,7 @@ TrustFlagsOpFrameBase::removeOffers(AbstractLedgerTxn& ltx, } bool -TrustFlagsOpFrameBase::doApply(Application& app, AbstractLedgerTxn& ltx, +TrustFlagsOpFrameBase::doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const diff --git a/src/transactions/TrustFlagsOpFrameBase.h b/src/transactions/TrustFlagsOpFrameBase.h index d37c26f155..1eca7975b8 100644 --- a/src/transactions/TrustFlagsOpFrameBase.h +++ b/src/transactions/TrustFlagsOpFrameBase.h @@ -39,7 +39,7 @@ class TrustFlagsOpFrameBase : public OperationFrame TrustFlagsOpFrameBase(Operation const& op, TransactionFrame const& parentTx); - bool doApply(Application& app, AbstractLedgerTxn& ltx, + bool doApply(AppConnector& app, AbstractLedgerTxn& ltx, Hash const& sorobanBasePrngSeed, OperationResult& res, std::shared_ptr sorobanData) const override; }; diff --git a/src/transactions/test/BeginSponsoringFutureReservesTests.cpp b/src/transactions/test/BeginSponsoringFutureReservesTests.cpp index df618e38d4..d500da592e 100644 --- a/src/transactions/test/BeginSponsoringFutureReservesTests.cpp +++ b/src/transactions/test/BeginSponsoringFutureReservesTests.cpp @@ -49,7 +49,8 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") {root.op(beginSponsoringFutureReserves(a1))}, {}); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); ltx.commit(); REQUIRE(getOperationResultCode(*tx, 0) == opNOT_SUPPORTED); @@ -64,7 +65,8 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") {root.op(beginSponsoringFutureReserves(root))}, {}); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); ltx.commit(); REQUIRE(getBeginSponsoringFutureReservesResultCode(*tx, 0) == @@ -84,8 +86,9 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx->apply(*app, ltx, txm)); + REQUIRE( + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(!tx->apply(app->getAppConnector(), ltx, txm)); ltx.commit(); REQUIRE(tx->getResult().result.code() == txFAILED); @@ -106,8 +109,9 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx->apply(*app, ltx, txm)); + REQUIRE( + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(!tx->apply(app->getAppConnector(), ltx, txm)); ltx.commit(); REQUIRE(tx->getResultCode() == txBAD_SPONSORSHIP); @@ -129,8 +133,9 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx->apply(*app, ltx, txm)); + REQUIRE( + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(!tx->apply(app->getAppConnector(), ltx, txm)); ltx.commit(); REQUIRE(tx->getResult().result.code() == txFAILED); @@ -156,8 +161,9 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx->apply(*app, ltx, txm)); + REQUIRE( + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(!tx->apply(app->getAppConnector(), ltx, txm)); ltx.commit(); REQUIRE(tx->getResult().result.code() == txFAILED); @@ -180,8 +186,9 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE( + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); ltx.commit(); REQUIRE(tx->getResultCode() == txSUCCESS); @@ -208,8 +215,9 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); checkSponsorship(ltx, trustlineKey(a1, cur1), 1, &root.getPublicKey()); @@ -222,8 +230,9 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") {a1}); TransactionMetaFrame txm2(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); + REQUIRE(tx2->apply(app->getAppConnector(), ltx, txm2)); checkSponsorship(ltx, a1.getPublicKey(), signer.key, 2, &root.getPublicKey()); @@ -264,7 +273,8 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); REQUIRE(tx->getResultCode() == txBAD_MIN_SEQ_AGE_OR_GAP); } @@ -272,7 +282,8 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") // this increments ledgerSeq closeLedger(*app); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); REQUIRE(tx->getResultCode() == txSUCCESS); } } diff --git a/src/transactions/test/ChangeTrustTests.cpp b/src/transactions/test/ChangeTrustTests.cpp index fcb09d4af6..72edb46160 100644 --- a/src/transactions/test/ChangeTrustTests.cpp +++ b/src/transactions/test/ChangeTrustTests.cpp @@ -294,8 +294,9 @@ TEST_CASE_VERSIONS("change trust", "[tx][changetrust]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE( + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); }); } } @@ -701,8 +702,9 @@ TEST_CASE_VERSIONS("change trust pool share trustline", LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(tx->getResultCode() == txSUCCESS); ltx.commit(); } @@ -731,8 +733,9 @@ TEST_CASE_VERSIONS("change trust pool share trustline", LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(!tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(tx->getResultCode() == txFAILED); auto const& opRes = tx->getResult().result.results()[0]; @@ -756,8 +759,9 @@ TEST_CASE_VERSIONS("change trust pool share trustline", LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(!tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(tx->getResultCode() == txFAILED); auto const& opRes = tx->getResult().result.results()[1]; @@ -780,8 +784,9 @@ TEST_CASE_VERSIONS("change trust pool share trustline", LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(tx->getResultCode() == txSUCCESS); } @@ -802,8 +807,9 @@ TEST_CASE_VERSIONS("change trust pool share trustline", LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(tx->getResultCode() == txSUCCESS); } } @@ -830,8 +836,9 @@ TEST_CASE_VERSIONS("change trust pool share trustline", LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); ltx.commit(); }; @@ -879,8 +886,9 @@ TEST_CASE_VERSIONS("change trust pool share trustline", LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); ltx.commit(); } diff --git a/src/transactions/test/ClaimableBalanceTests.cpp b/src/transactions/test/ClaimableBalanceTests.cpp index f90e37633b..b3d8980bb2 100644 --- a/src/transactions/test/ClaimableBalanceTests.cpp +++ b/src/transactions/test/ClaimableBalanceTests.cpp @@ -177,8 +177,8 @@ validateBalancesOnCreateAndClaim(TestAccount& createAcc, TestAccount& claimAcc, LedgerTxn ltx(app.getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app.getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx->apply(app.getAppConnector(), ltx, txm)); REQUIRE(tx->getResultCode() == txSUCCESS); // the create is the second op in the tx @@ -236,8 +236,8 @@ validateBalancesOnCreateAndClaim(TestAccount& createAcc, TestAccount& claimAcc, LedgerTxn ltx(app.getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app.getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx->apply(app.getAppConnector(), ltx, txm)); ltx.commit(); REQUIRE(tx->getResultCode() == txSUCCESS); @@ -257,8 +257,8 @@ validateBalancesOnCreateAndClaim(TestAccount& createAcc, TestAccount& claimAcc, LedgerTxn ltx(app.getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app.getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx->apply(app.getAppConnector(), ltx, txm)); ltx.commit(); REQUIRE(tx->getResultCode() == txSUCCESS); @@ -1164,8 +1164,9 @@ TEST_CASE_VERSIONS("claimableBalance", "[tx][claimablebalance]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE( + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(tx->getResultCode() == txSUCCESS); auto balanceID = root.getBalanceID(1); @@ -1177,8 +1178,9 @@ TEST_CASE_VERSIONS("claimableBalance", "[tx][claimablebalance]") {}); TransactionMetaFrame txm2(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); + REQUIRE(!tx2->apply(app->getAppConnector(), ltx, txm2)); REQUIRE(tx2->getResultCode() == txFAILED); REQUIRE(tx2->getResult() @@ -1242,8 +1244,9 @@ TEST_CASE_VERSIONS("claimableBalance", "[tx][claimablebalance]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(tx->getResultCode() == txSUCCESS); ltx.commit(); } @@ -1272,8 +1275,9 @@ TEST_CASE_VERSIONS("claimableBalance", "[tx][claimablebalance]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx2->apply(app->getAppConnector(), ltx, txm2)); REQUIRE(tx2->getResultCode() == txSUCCESS); // increment ledgerSeq diff --git a/src/transactions/test/ClawbackClaimableBalanceTests.cpp b/src/transactions/test/ClawbackClaimableBalanceTests.cpp index 195dd9aee0..c9f9e1dcc8 100644 --- a/src/transactions/test/ClawbackClaimableBalanceTests.cpp +++ b/src/transactions/test/ClawbackClaimableBalanceTests.cpp @@ -113,8 +113,9 @@ TEST_CASE_VERSIONS("clawbackClaimableBalance", LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(tx->getResultCode() == txSUCCESS); // the create is the second op in the tx diff --git a/src/transactions/test/CreateAccountTests.cpp b/src/transactions/test/CreateAccountTests.cpp index fb8ed2e424..ece78844dd 100644 --- a/src/transactions/test/CreateAccountTests.cpp +++ b/src/transactions/test/CreateAccountTests.cpp @@ -53,11 +53,13 @@ TEST_CASE_VERSIONS("create account", "[tx][createaccount]") {root.op(createAccount(key.getPublicKey(), 1))}, {}); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx1->checkValidForTesting(app->getAppConnector(), ltx, 0, + 0, 0)); REQUIRE(getCreateAccountResultCode(tx1, 0) == CREATE_ACCOUNT_MALFORMED); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); }); for_versions_from(14, *app, [&] { @@ -71,11 +73,13 @@ TEST_CASE_VERSIONS("create account", "[tx][createaccount]") {root.op(createAccount(key.getPublicKey(), 0))}, {}); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx1->checkValidForTesting(app->getAppConnector(), ltx, 0, + 0, 0)); REQUIRE(getCreateAccountResultCode(tx1, 0) == CREATE_ACCOUNT_MALFORMED); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); }); } @@ -87,7 +91,8 @@ TEST_CASE_VERSIONS("create account", "[tx][createaccount]") {root.op(createAccount(root, -1))}, {}); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); REQUIRE(getCreateAccountResultCode(tx, 0) == CREATE_ACCOUNT_MALFORMED); }); @@ -185,8 +190,9 @@ TEST_CASE_VERSIONS("create account", "[tx][createaccount]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), ltx, 0, + 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); ltx.commit(); } diff --git a/src/transactions/test/EndSponsoringFutureReservesTests.cpp b/src/transactions/test/EndSponsoringFutureReservesTests.cpp index a92b6e2281..f321b37b93 100644 --- a/src/transactions/test/EndSponsoringFutureReservesTests.cpp +++ b/src/transactions/test/EndSponsoringFutureReservesTests.cpp @@ -48,7 +48,8 @@ TEST_CASE_VERSIONS("confirm and clear sponsor", "[tx][sponsorship]") {root.op(endSponsoringFutureReserves())}, {}); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); REQUIRE(getOperationResultCode(tx, 0) == opNOT_SUPPORTED); }); @@ -64,8 +65,9 @@ TEST_CASE_VERSIONS("confirm and clear sponsor", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx->apply(*app, ltx, txm)); + REQUIRE( + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(!tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(tx->getResult().result.code() == txFAILED); REQUIRE(getEndSponsoringFutureReservesResultCode(tx, 0) == diff --git a/src/transactions/test/FeeBumpTransactionTests.cpp b/src/transactions/test/FeeBumpTransactionTests.cpp index c645829d61..573666e942 100644 --- a/src/transactions/test/FeeBumpTransactionTests.cpp +++ b/src/transactions/test/FeeBumpTransactionTests.cpp @@ -82,7 +82,8 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") auto fb = feeBump(app->getNetworkID(), root, root, root, 2 * fee, fee, 1); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!fb->checkValidForTesting(app->getAppConnector(), ltx, + 0, 0, 0)); REQUIRE(fb->getResultCode() == txNOT_SUPPORTED); }); } @@ -93,7 +94,8 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") auto fb = feeBump(app->getNetworkID(), root, root, root, 2 * fee - 1, 1, 1); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!fb->checkValidForTesting(app->getAppConnector(), ltx, + 0, 0, 0)); REQUIRE(fb->getResultCode() == txINSUFFICIENT_FEE); REQUIRE(fb->getResult().feeCharged == 2 * fee); }); @@ -105,7 +107,8 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") auto fb = feeBump(app->getNetworkID(), root, root, root, 2 * fee + 1, 101, 1); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!fb->checkValidForTesting(app->getAppConnector(), ltx, + 0, 0, 0)); REQUIRE(fb->getResultCode() == txINSUFFICIENT_FEE); REQUIRE(fb->getResult().feeCharged == 2 * 101); }); @@ -118,7 +121,8 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") auto fb = feeBump(app->getNetworkID(), acc, root, root, 2 * fee, fee, 1); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!fb->checkValidForTesting(app->getAppConnector(), ltx, + 0, 0, 0)); REQUIRE(fb->getResultCode() == txNO_ACCOUNT); }); } @@ -134,7 +138,8 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") TransactionFrameBase::makeTransactionFromWire( app->getNetworkID(), fbXDR)); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!fb->checkValidForTesting(app->getAppConnector(), ltx, + 0, 0, 0)); REQUIRE(fb->getResultCode() == txBAD_AUTH); }); } @@ -153,7 +158,8 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") TransactionFrameBase::makeTransactionFromWire( app->getNetworkID(), fbXDR)); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!fb->checkValidForTesting(app->getAppConnector(), ltx, + 0, 0, 0)); REQUIRE(fb->getResultCode() == txBAD_AUTH); }); } @@ -165,7 +171,8 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") auto fb = feeBump(app->getNetworkID(), acc, root, root, 2 * fee, fee, 1); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!fb->checkValidForTesting(app->getAppConnector(), ltx, + 0, 0, 0)); REQUIRE(fb->getResultCode() == txINSUFFICIENT_BALANCE); }); } @@ -183,7 +190,8 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") TransactionFrameBase::makeTransactionFromWire( app->getNetworkID(), fbXDR)); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!fb->checkValidForTesting(app->getAppConnector(), ltx, + 0, 0, 0)); REQUIRE(fb->getResultCode() == txBAD_AUTH_EXTRA); }); } @@ -198,7 +206,8 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") TransactionFrameBase::makeTransactionFromWire( app->getNetworkID(), fbXDR)); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!fb->checkValidForTesting(app->getAppConnector(), ltx, + 0, 0, 0)); REQUIRE(fb->getResultCode() == txFEE_BUMP_INNER_FAILED); auto const& fbRes = fb->getResult(); REQUIRE(fbRes.feeCharged == 2 * fee); @@ -215,7 +224,8 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") auto fb = feeBump(app->getNetworkID(), acc, root, root, 2 * fee, fee, -1); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!fb->checkValidForTesting(app->getAppConnector(), ltx, + 0, 0, 0)); REQUIRE(fb->getResultCode() == txFEE_BUMP_INNER_FAILED); auto const& fbRes = fb->getResult(); REQUIRE(fbRes.feeCharged == 2 * fee); @@ -235,7 +245,8 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") auto fb = feeBump(app->getNetworkID(), acc, root, root, 2 * fee, fee, 1); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(fb->checkValidForTesting(app->getAppConnector(), ltx, 0, + 0, 0)); REQUIRE(fb->getResultCode() == txFEE_BUMP_INNER_SUCCESS); auto const& fbRes = fb->getResult(); REQUIRE(fbRes.feeCharged == 2 * fee); @@ -279,14 +290,15 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") fee, 1); { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(fb->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); } acc.merge(root); { LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame meta( ltx.loadHeader().current().ledgerVersion); - REQUIRE(fb->apply(*app, ltx, meta)); + REQUIRE(fb->apply(app->getAppConnector(), ltx, meta)); REQUIRE(fb->getResultCode() == txFEE_BUMP_INNER_SUCCESS); } }); @@ -300,14 +312,15 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") fee, 1); { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(fb->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); } acc.setOptions(setMasterWeight(0)); { LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame meta( ltx.loadHeader().current().ledgerVersion); - REQUIRE(fb->apply(*app, ltx, meta)); + REQUIRE(fb->apply(app->getAppConnector(), ltx, meta)); REQUIRE(fb->getResultCode() == txFEE_BUMP_INNER_SUCCESS); } }); @@ -321,14 +334,15 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") fee, 1); { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(fb->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); } acc.pay(root, 2 * fee); { LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame meta( ltx.loadHeader().current().ledgerVersion); - REQUIRE(fb->apply(*app, ltx, meta)); + REQUIRE(fb->apply(app->getAppConnector(), ltx, meta)); REQUIRE(fb->getResultCode() == txFEE_BUMP_INNER_SUCCESS); } }); @@ -349,7 +363,8 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") auto fb = TransactionTestFrame::fromTxFrame(rawTx); { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(fb->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); } auto setOptionsTx = acc.tx({setOptions(setLowThreshold(1))}); @@ -360,7 +375,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame meta( ltx.loadHeader().current().ledgerVersion); - REQUIRE(fb->apply(*app, ltx, meta)); + REQUIRE(fb->apply(app->getAppConnector(), ltx, meta)); REQUIRE(fb->getResultCode() == txFEE_BUMP_INNER_SUCCESS); } }); @@ -374,7 +389,8 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") fee, 1); { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(fb->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); } auto setOptionsOp = setOptions(setMasterWeight(0)); @@ -387,7 +403,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame meta( ltx.loadHeader().current().ledgerVersion); - REQUIRE(!fb->apply(*app, ltx, meta)); + REQUIRE(!fb->apply(app->getAppConnector(), ltx, meta)); REQUIRE(fb->getResultCode() == txFEE_BUMP_INNER_FAILED); auto const& innerRes = fb->getResult().result.innerResultPair().result; @@ -405,13 +421,14 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") fee, INT64_MAX); { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(fb->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); } { LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame meta( ltx.loadHeader().current().ledgerVersion); - REQUIRE(!fb->apply(*app, ltx, meta)); + REQUIRE(!fb->apply(app->getAppConnector(), ltx, meta)); REQUIRE(fb->getResultCode() == txFEE_BUMP_INNER_FAILED); auto const& innerRes = fb->getResult().result.innerResultPair().result; @@ -462,8 +479,9 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(tx->getResultCode() == txSUCCESS); checkSponsorship(ltx, acc, fbSigner, 2, @@ -477,14 +495,15 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(fb->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(fb->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); REQUIRE(fb->getResultCode() == txFEE_BUMP_INNER_SUCCESS); } { LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame meta( ltx.loadHeader().current().ledgerVersion); - REQUIRE(fb->apply(*app, ltx, meta)); + REQUIRE(fb->apply(app->getAppConnector(), ltx, meta)); REQUIRE(fb->getResultCode() == txFEE_BUMP_INNER_SUCCESS); REQUIRE(meta.getNumChangesBefore() == (isFbSignerSponsored ? 6 : 4)); diff --git a/src/transactions/test/InvokeHostFunctionTests.cpp b/src/transactions/test/InvokeHostFunctionTests.cpp index d0bc20ee93..0340898ae4 100644 --- a/src/transactions/test/InvokeHostFunctionTests.cpp +++ b/src/transactions/test/InvokeHostFunctionTests.cpp @@ -418,7 +418,8 @@ TEST_CASE("basic contract invocation", "[tx][soroban]") addContractKeys); auto tx = invocation.createTx(&rootAccount); - auto result = tx->checkValid(test.getApp(), rootLtx, 0, 0, 0); + auto result = + tx->checkValid(test.getApp().getAppConnector(), rootLtx, 0, 0, 0); REQUIRE(tx->getFullFee() == spec.getInclusionFee() + spec.getResourceFee()); @@ -445,12 +446,14 @@ TEST_CASE("basic contract invocation", "[tx][soroban]") TransactionMetaFrame txm(test.getLedgerVersion()); auto timerBefore = hostFnExecTimer.count(); - bool success = tx->apply(test.getApp(), rootLtx, txm, result); + bool success = + tx->apply(test.getApp().getAppConnector(), rootLtx, txm, result); REQUIRE(hostFnExecTimer.count() - timerBefore > 0); { LedgerTxn ltx(rootLtx); - tx->processPostApply(test.getApp(), ltx, txm, result); + tx->processPostApply(test.getApp().getAppConnector(), ltx, txm, + result); ltx.commit(); } @@ -754,7 +757,8 @@ TEST_CASE("Soroban footprint validation", "[tx][soroban]") MutableTxResultPtr result; { LedgerTxn ltx(test.getApp().getLedgerTxnRoot()); - result = tx->checkValid(test.getApp(), ltx, 0, 0, 0); + result = + tx->checkValid(test.getApp().getAppConnector(), ltx, 0, 0, 0); } REQUIRE(result->isSuccess() == shouldBeValid); @@ -770,7 +774,8 @@ TEST_CASE("Soroban footprint validation", "[tx][soroban]") MutableTxResultPtr result; { LedgerTxn ltx(test.getApp().getLedgerTxnRoot()); - result = tx->checkValid(test.getApp(), ltx, 0, 0, 0); + result = + tx->checkValid(test.getApp().getAppConnector(), ltx, 0, 0, 0); } REQUIRE(result->isSuccess() == shouldBeValid); if (!shouldBeValid) @@ -798,7 +803,8 @@ TEST_CASE("Soroban footprint validation", "[tx][soroban]") MutableTxResultPtr result; { LedgerTxn ltx(test.getApp().getLedgerTxnRoot()); - result = tx->checkValid(test.getApp(), ltx, 0, 0, 0); + result = + tx->checkValid(test.getApp().getAppConnector(), ltx, 0, 0, 0); } REQUIRE(result->isSuccess() == shouldBeValid); if (!shouldBeValid) @@ -1448,7 +1454,7 @@ TEST_CASE("transaction validation diagnostics", "[tx][soroban]") MutableTxResultPtr result; { LedgerTxn ltx(test.getApp().getLedgerTxnRoot()); - result = tx->checkValid(test.getApp(), ltx, 0, 0, 0); + result = tx->checkValid(test.getApp().getAppConnector(), ltx, 0, 0, 0); } REQUIRE(!test.isTxValid(tx)); @@ -3148,8 +3154,8 @@ TEST_CASE("settings upgrade command line utils", "[tx][soroban][upgrades]") auto tx = TransactionTestFrame::fromTxFrame(rawTx); LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); ltx.commit(); } @@ -3215,8 +3221,9 @@ TEST_CASE("settings upgrade command line utils", "[tx][soroban][upgrades]") auto txRevertSettings = TransactionTestFrame::fromTxFrame(txRaw); LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(txRevertSettings->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(txRevertSettings->apply(*app, ltx, txm)); + REQUIRE(txRevertSettings->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(txRevertSettings->apply(app->getAppConnector(), ltx, txm)); ltx.commit(); std::string command2 = "mode=set&configupgradesetkey="; diff --git a/src/transactions/test/ManageBuyOfferTests.cpp b/src/transactions/test/ManageBuyOfferTests.cpp index 377794b5b0..49e836fc8a 100644 --- a/src/transactions/test/ManageBuyOfferTests.cpp +++ b/src/transactions/test/ManageBuyOfferTests.cpp @@ -374,7 +374,7 @@ TEST_CASE_VERSIONS("manage buy offer liabilities", "[tx][offers]") { LedgerTxn ltx(app->getLedgerTxnRoot()); - tx->checkValidForTesting(*app, ltx, 0, 0, 0); + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0); } auto buyOp = std::static_pointer_cast( diff --git a/src/transactions/test/MergeTests.cpp b/src/transactions/test/MergeTests.cpp index d462768ac0..c183024d59 100644 --- a/src/transactions/test/MergeTests.cpp +++ b/src/transactions/test/MergeTests.cpp @@ -759,8 +759,9 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); checkSponsorship(ltx, dest, signer.key, 2, &sponsoringAcc.getPublicKey()); @@ -822,8 +823,9 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); checkSponsorship(ltx, key.getPublicKey(), 1, &sponsoringAcc.getPublicKey(), 0, 2, 0, 2); @@ -894,8 +896,9 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(!tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(tx->getResult() .result.results()[1] .tr() @@ -917,8 +920,9 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); checkSponsorship(ltx, sponsoringAcc, 0, nullptr, 0, 2, 1, 0); diff --git a/src/transactions/test/OfferTests.cpp b/src/transactions/test/OfferTests.cpp index 184766e7b8..65b1257716 100644 --- a/src/transactions/test/OfferTests.cpp +++ b/src/transactions/test/OfferTests.cpp @@ -3007,8 +3007,9 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE( + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); ltx.commit(); }; @@ -3034,8 +3035,9 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") auto expOfferID = ltx.loadHeader().current().idPool + 1; TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE( + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); auto const& results = tx->getResult().result.results(); auto const& msoResult = results[1].tr().manageSellOfferResult(); @@ -3745,8 +3747,9 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(!loadOffer(ltx, a2.getPublicKey(), expOfferID)); ltx.commit(); @@ -3788,8 +3791,9 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), ltx, 0, + 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); ltx.commit(); } @@ -3850,8 +3854,9 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), ltx, 0, + 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(loadOffer(ltx, acc1.getPublicKey(), offerIdUsdXlm)); REQUIRE(loadOffer(ltx, acc1.getPublicKey(), offerIdXlmUsd)); diff --git a/src/transactions/test/PathPaymentTests.cpp b/src/transactions/test/PathPaymentTests.cpp index 2b74d11974..a36a8b460e 100644 --- a/src/transactions/test/PathPaymentTests.cpp +++ b/src/transactions/test/PathPaymentTests.cpp @@ -4435,8 +4435,9 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE( + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); ltx.commit(); }; @@ -4828,8 +4829,9 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), ltx, 0, + 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); ltx.commit(); } diff --git a/src/transactions/test/RevokeSponsorshipTests.cpp b/src/transactions/test/RevokeSponsorshipTests.cpp index aa7c4db2fe..e88154e458 100644 --- a/src/transactions/test/RevokeSponsorshipTests.cpp +++ b/src/transactions/test/RevokeSponsorshipTests.cpp @@ -66,8 +66,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); checkSponsorship(ltx, accountKey(a1), 0, nullptr); checkSponsorship(ltx, a1, 0, nullptr, 0, 0, 0, 0); @@ -86,8 +87,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); checkSponsorship(ltx, trustlineKey(a1, cur1), 0, nullptr); checkSponsorship(ltx, a1, 0, nullptr, 1, 0, 0, 0); @@ -107,8 +109,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); checkSponsorship(ltx, a1, signer.key, 0, nullptr); checkSponsorship(ltx, a1, 0, nullptr, 1, 0, 0, 0); @@ -131,8 +134,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(!tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(getRevokeSponsorshipResultCode(tx, 0) == REVOKE_SPONSORSHIP_ONLY_TRANSFERABLE); @@ -161,8 +165,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); checkSponsorship(ltx, accountKey(a1), 1, &root.getPublicKey()); @@ -185,8 +190,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); checkSponsorship(ltx, trustlineKey(a1, cur1), 1, &root.getPublicKey()); @@ -217,9 +223,10 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); + REQUIRE(tx->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); REQUIRE( - tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + tx->apply(app->getAppConnector(), ltx, txm)); ltx.commit(); } @@ -233,8 +240,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); checkSponsorship(ltx, a1, signer.key, 2, &root.getPublicKey()); @@ -279,8 +287,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); checkSponsorship(ltx, claimableBalanceKey(balanceID), 1, &root.getPublicKey()); @@ -309,8 +318,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); auto tx2 = transactionFrameFromOps( app->getNetworkID(), root, @@ -320,8 +330,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx2->apply(app->getAppConnector(), ltx, txm2)); checkSponsorship(ltx, accountKey(a1.getPublicKey()), 1, nullptr); @@ -345,8 +356,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); auto tx2 = transactionFrameFromOps( app->getNetworkID(), root, @@ -355,8 +367,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx2->apply(app->getAppConnector(), ltx, txm2)); checkSponsorship(ltx, trustlineKey(a1, cur1), 1, nullptr); checkSponsorship(ltx, a1, 0, nullptr, 1, 2, 0, 0); @@ -379,8 +392,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); auto tx2 = transactionFrameFromOps( app->getNetworkID(), root, @@ -388,8 +402,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx2->apply(app->getAppConnector(), ltx, txm2)); checkSponsorship(ltx, a1, signer.key, 2, nullptr); checkSponsorship(ltx, a1, 0, nullptr, 1, 2, 0, 0); @@ -412,8 +427,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); auto balanceID = tx1->getResult() .result.results()[1] @@ -429,8 +445,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(!tx2->apply(app->getAppConnector(), ltx, txm2)); REQUIRE(getRevokeSponsorshipResultCode(tx2, 0) == REVOKE_SPONSORSHIP_ONLY_TRANSFERABLE); @@ -461,8 +478,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); auto tx2 = transactionFrameFromOps( app->getNetworkID(), root, @@ -474,8 +492,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx2->apply(app->getAppConnector(), ltx, txm2)); checkSponsorship(ltx, a1, 1, &a2.getPublicKey(), 0, 2, 0, 2); @@ -499,8 +518,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); auto tx2 = transactionFrameFromOps( app->getNetworkID(), root, @@ -511,8 +531,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx2->apply(app->getAppConnector(), ltx, txm2)); checkSponsorship(ltx, trustlineKey(a1, cur1), 1, &a2.getPublicKey()); @@ -538,8 +559,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); auto tx2 = transactionFrameFromOps( app->getNetworkID(), root, {a2.op(beginSponsoringFutureReserves(root)), @@ -549,8 +571,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx2->apply(app->getAppConnector(), ltx, txm2)); checkSponsorship(ltx, a1, signer.key, 2, &a2.getPublicKey()); @@ -576,8 +599,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); auto balanceID = tx1->getResult() .result.results()[1] @@ -595,8 +619,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx2->apply(app->getAppConnector(), ltx, txm2)); checkSponsorship(ltx, claimableBalanceKey(balanceID), 1, &a2.getPublicKey()); @@ -622,8 +647,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); auto tx2 = transactionFrameFromOps( app->getNetworkID(), root, @@ -634,8 +660,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx2->apply(app->getAppConnector(), ltx, txm2)); checkSponsorship(ltx, dataKey(a1, dataName), 1, &a2.getPublicKey()); @@ -663,8 +690,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); auto offerID = ltx.loadHeader().current().idPool; auto tx2 = transactionFrameFromOps( @@ -676,8 +704,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx2->apply(app->getAppConnector(), ltx, txm2)); checkSponsorship(ltx, offerKey(a1, offerID), 1, &a2.getPublicKey()); @@ -704,8 +733,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); auto tx2 = transactionFrameFromOps( app->getNetworkID(), root, @@ -717,8 +747,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx2->apply(app->getAppConnector(), ltx, txm2)); checkSponsorship(ltx, accountKey(a1.getPublicKey()), 1, nullptr); @@ -742,8 +773,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); auto tx2 = transactionFrameFromOps( app->getNetworkID(), root, @@ -754,8 +786,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx2->apply(app->getAppConnector(), ltx, txm2)); checkSponsorship(ltx, trustlineKey(a1, cur1), 1, nullptr); checkSponsorship(ltx, a1, 0, nullptr, 1, 2, 0, 0); @@ -778,8 +811,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); auto tx2 = transactionFrameFromOps( app->getNetworkID(), root, @@ -790,8 +824,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx2->apply(app->getAppConnector(), ltx, txm2)); checkSponsorship(ltx, a1, signer.key, 2, nullptr); checkSponsorship(ltx, a1, 0, nullptr, 1, 2, 0, 0); @@ -815,8 +850,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); auto tx2 = transactionFrameFromOps( app->getNetworkID(), root, @@ -827,8 +863,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx2->apply(app->getAppConnector(), ltx, txm2)); checkSponsorship(ltx, dataKey(a1, dataName), 1, nullptr); checkSponsorship(ltx, a1, 0, nullptr, 1, 2, 0, 0); @@ -853,8 +890,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); auto offerID = ltx.loadHeader().current().idPool; auto tx2 = transactionFrameFromOps( @@ -866,8 +904,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx2->apply(app->getAppConnector(), ltx, txm2)); checkSponsorship(ltx, offerKey(a1, offerID), 1, nullptr); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 0, 0); @@ -893,8 +932,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(!tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(getRevokeSponsorshipResultCode(tx, 0) == REVOKE_SPONSORSHIP_DOES_NOT_EXIST); @@ -921,8 +961,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(!tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(getRevokeSponsorshipResultCode(tx, 0) == REVOKE_SPONSORSHIP_DOES_NOT_EXIST); @@ -947,8 +988,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(!tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(getRevokeSponsorshipResultCode(tx, 0) == REVOKE_SPONSORSHIP_DOES_NOT_EXIST); @@ -960,8 +1002,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(!tx2->apply(app->getAppConnector(), ltx, txm2)); REQUIRE(getRevokeSponsorshipResultCode(tx2, 0) == REVOKE_SPONSORSHIP_DOES_NOT_EXIST); @@ -995,8 +1038,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm1)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm1)); checkSponsorship(ltx, a1, 0, &root.getPublicKey(), 1, 2, 0, 1); ltx.commit(); @@ -1024,8 +1068,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx->apply(*app, ltx, txm1)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(!tx->apply(app->getAppConnector(), ltx, txm1)); REQUIRE(getRevokeSponsorshipResultCode(tx, 0) == REVOKE_SPONSORSHIP_NOT_SPONSOR); @@ -1046,16 +1091,18 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx2->apply(app->getAppConnector(), ltx, txm2)); checkSponsorship(ltx, a1, 0, nullptr, 1, 2, 0, 0); auto tx3 = transactionFrameFromOps(app->getNetworkID(), a2, {op}, {}); TransactionMetaFrame txm3(2); - REQUIRE(tx3->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx3->apply(*app, ltx, txm3)); + REQUIRE(tx3->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(!tx3->apply(app->getAppConnector(), ltx, txm3)); REQUIRE(getRevokeSponsorshipResultCode(tx3, 0) == REVOKE_SPONSORSHIP_NOT_SPONSOR); @@ -1107,8 +1154,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); Operation middleOpTx2 = entryTest @@ -1125,8 +1173,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(!tx2->apply(app->getAppConnector(), ltx, txm2)); REQUIRE(getRevokeSponsorshipResultCode(tx2, 1) == REVOKE_SPONSORSHIP_LOW_RESERVE); @@ -1149,8 +1198,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(*app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app->getAppConnector(), ltx, txm1)); Operation opTx2 = entryTest @@ -1163,8 +1213,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx2->apply(*app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(!tx2->apply(app->getAppConnector(), ltx, txm2)); REQUIRE(getRevokeSponsorshipResultCode(tx2, 0) == REVOKE_SPONSORSHIP_LOW_RESERVE); @@ -1199,8 +1250,9 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(!tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(!tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(getRevokeSponsorshipResultCode(tx, 1) == REVOKE_SPONSORSHIP_LOW_RESERVE); @@ -1309,7 +1361,8 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") {root.op(revokeSponsorship(trustlineKey(root, Asset{})))}, {}); LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); REQUIRE(getRevokeSponsorshipResultCode(tx, 0) == REVOKE_SPONSORSHIP_MALFORMED); }); @@ -1324,7 +1377,8 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") {root.op(revokeSponsorship(trustlineKey(root, cur1)))}, {}); LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); REQUIRE(getRevokeSponsorshipResultCode(tx, 0) == REVOKE_SPONSORSHIP_MALFORMED); }); @@ -1340,7 +1394,8 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); REQUIRE(getRevokeSponsorshipResultCode(tx, 0) == REVOKE_SPONSORSHIP_MALFORMED); diff --git a/src/transactions/test/SetOptionsTests.cpp b/src/transactions/test/SetOptionsTests.cpp index 482b55a0e9..d5a5d522ec 100644 --- a/src/transactions/test/SetOptionsTests.cpp +++ b/src/transactions/test/SetOptionsTests.cpp @@ -358,8 +358,9 @@ TEST_CASE_VERSIONS("set options", "[tx][setoptions]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); checkSponsorship(ltx, acc1.getPublicKey(), 0, nullptr, 2, 2, 0, 1); @@ -398,8 +399,9 @@ TEST_CASE_VERSIONS("set options", "[tx][setoptions]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); checkSponsorship(ltx, acc1.getPublicKey(), 0, nullptr, 2, 2, 0, 1); @@ -497,8 +499,9 @@ TEST_CASE_VERSIONS("set options", "[tx][setoptions]") LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), ltx, 0, + 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); ltx.commit(); checkSigners(); diff --git a/src/transactions/test/SetTrustLineFlagsTests.cpp b/src/transactions/test/SetTrustLineFlagsTests.cpp index c7de65867c..d030c62f7e 100644 --- a/src/transactions/test/SetTrustLineFlagsTests.cpp +++ b/src/transactions/test/SetTrustLineFlagsTests.cpp @@ -1151,9 +1151,10 @@ TEST_CASE_VERSIONS("revoke from pool", LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, - 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, + txm)); REQUIRE(tx->getResultCode() == txSUCCESS); ltx.commit(); } @@ -1215,91 +1216,94 @@ TEST_CASE_VERSIONS("revoke from pool", } }; - auto submitRevokeInSandwich = [&](TestAccount& sponsoringAcc, - TestAccount& sponsoredAcc, - bool success, - int32_t - numPoolShareTrustlines) { - auto op = - flagOp == TrustFlagOp::ALLOW_TRUST - ? allowTrust(acc1, cur1, 0) - : setTrustLineFlags( - acc1, cur1, - clearTrustLineFlags(TRUSTLINE_AUTH_FLAGS)); - - std::vector opKeys = {sponsoredAcc}; - if (sponsoringAcc.getAccountId() != root.getAccountId()) - { - opKeys.emplace_back(root); - } - - auto tx = transactionFrameFromOps( - app->getNetworkID(), sponsoringAcc, - {sponsoringAcc.op( - beginSponsoringFutureReserves(sponsoredAcc)), - root.op(op), - sponsoredAcc.op(endSponsoringFutureReserves())}, - opKeys); - - auto preRevokeNumSubEntries = acc1.getNumSubEntries(); - auto preRevokeNumSponsoring = - getNumSponsoring(*app, sponsoringAcc); - bool trustlineIsSponsored = getNumSponsored(*app, acc1) > 0; - - { - LedgerTxn ltx(app->getLedgerTxnRoot()); - TransactionMetaFrame txm( - ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm) == success); - - if (success) + auto submitRevokeInSandwich = + [&](TestAccount& sponsoringAcc, TestAccount& sponsoredAcc, + bool success, int32_t numPoolShareTrustlines) { + auto op = + flagOp == TrustFlagOp::ALLOW_TRUST + ? allowTrust(acc1, cur1, 0) + : setTrustLineFlags(acc1, cur1, + clearTrustLineFlags( + TRUSTLINE_AUTH_FLAGS)); + + std::vector opKeys = {sponsoredAcc}; + if (sponsoringAcc.getAccountId() != root.getAccountId()) { - ltx.commit(); - REQUIRE(tx->getResultCode() == txSUCCESS); + opKeys.emplace_back(root); } - else + + auto tx = transactionFrameFromOps( + app->getNetworkID(), sponsoringAcc, + {sponsoringAcc.op( + beginSponsoringFutureReserves(sponsoredAcc)), + root.op(op), + sponsoredAcc.op(endSponsoringFutureReserves())}, + opKeys); + + auto preRevokeNumSubEntries = acc1.getNumSubEntries(); + auto preRevokeNumSponsoring = + getNumSponsoring(*app, sponsoringAcc); + bool trustlineIsSponsored = + getNumSponsored(*app, acc1) > 0; + { - REQUIRE(tx->getResultCode() == txFAILED); - if (flagOp == TrustFlagOp::ALLOW_TRUST) + LedgerTxn ltx(app->getLedgerTxnRoot()); + TransactionMetaFrame txm( + ltx.loadHeader().current().ledgerVersion); + REQUIRE(tx->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, + txm) == success); + + if (success) { - REQUIRE(tx->getResult() - .result.results()[1] - .tr() - .allowTrustResult() - .code() == ALLOW_TRUST_LOW_RESERVE); + ltx.commit(); + REQUIRE(tx->getResultCode() == txSUCCESS); } else { - REQUIRE(tx->getResult() - .result.results()[1] - .tr() - .setTrustLineFlagsResult() - .code() == - SET_TRUST_LINE_FLAGS_LOW_RESERVE); + REQUIRE(tx->getResultCode() == txFAILED); + if (flagOp == TrustFlagOp::ALLOW_TRUST) + { + REQUIRE(tx->getResult() + .result.results()[1] + .tr() + .allowTrustResult() + .code() == + ALLOW_TRUST_LOW_RESERVE); + } + else + { + REQUIRE(tx->getResult() + .result.results()[1] + .tr() + .setTrustLineFlagsResult() + .code() == + SET_TRUST_LINE_FLAGS_LOW_RESERVE); + } } } - } - if (success) - { - REQUIRE(preRevokeNumSubEntries == - acc1.getNumSubEntries() + - numPoolShareTrustlines * 2); - - // sponsoringAcc will be sponsoring the two - // claimable balances, but if the same account was - // sponsoring the pool share trustline, then the - // delta is 0 - auto delta = trustlineIsSponsored && - sponsoringAcc.getPublicKey() == - acc3.getPublicKey() - ? 0 - : 2; - REQUIRE(preRevokeNumSponsoring == - getNumSponsoring(*app, sponsoringAcc) - delta); - } - }; + if (success) + { + REQUIRE(preRevokeNumSubEntries == + acc1.getNumSubEntries() + + numPoolShareTrustlines * 2); + + // sponsoringAcc will be sponsoring the two + // claimable balances, but if the same account was + // sponsoring the pool share trustline, then the + // delta is 0 + auto delta = trustlineIsSponsored && + sponsoringAcc.getPublicKey() == + acc3.getPublicKey() + ? 0 + : 2; + REQUIRE(preRevokeNumSponsoring == + getNumSponsoring(*app, sponsoringAcc) - + delta); + } + }; auto increaseReserve = [&]() { // double the reserve @@ -1515,8 +1519,9 @@ TEST_CASE_VERSIONS("revoke from pool", LedgerTxn ltx(app->getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(*app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); + REQUIRE(tx->apply(app->getAppConnector(), ltx, txm)); REQUIRE(tx->getResultCode() == txSUCCESS); auto tlAsset = diff --git a/src/transactions/test/SorobanTxTestUtils.cpp b/src/transactions/test/SorobanTxTestUtils.cpp index 654f2739ec..0ae49359f6 100644 --- a/src/transactions/test/SorobanTxTestUtils.cpp +++ b/src/transactions/test/SorobanTxTestUtils.cpp @@ -821,7 +821,7 @@ SorobanTest::invokeArchivalOp(TransactionFrameBaseConstPtr tx, MutableTxResultPtr result; { LedgerTxn ltx(getApp().getLedgerTxnRoot()); - result = tx->checkValid(getApp(), ltx, 0, 0, 0); + result = tx->checkValid(getApp().getAppConnector(), ltx, 0, 0, 0); } REQUIRE(result->isSuccess()); int64_t initBalance = getRoot().getBalance(); @@ -1101,7 +1101,7 @@ bool SorobanTest::isTxValid(TransactionFrameBaseConstPtr tx) { LedgerTxn ltx(getApp().getLedgerTxnRoot()); - auto ret = tx->checkValid(getApp(), ltx, 0, 0, 0); + auto ret = tx->checkValid(getApp().getAppConnector(), ltx, 0, 0, 0); return ret->isSuccess(); } @@ -1111,7 +1111,8 @@ SorobanTest::invokeTx(TransactionFrameBaseConstPtr tx, { { LedgerTxn ltx(getApp().getLedgerTxnRoot()); - REQUIRE(tx->checkValid(getApp(), ltx, 0, 0, 0)->isSuccess()); + REQUIRE(tx->checkValid(getApp().getAppConnector(), ltx, 0, 0, 0) + ->isSuccess()); } auto resultSet = closeLedger(*mApp, {tx}); diff --git a/src/transactions/test/SponsorshipTestUtils.cpp b/src/transactions/test/SponsorshipTestUtils.cpp index e236c6d2c3..35dac85bde 100644 --- a/src/transactions/test/SponsorshipTestUtils.cpp +++ b/src/transactions/test/SponsorshipTestUtils.cpp @@ -151,8 +151,9 @@ createSponsoredEntryButSponsorHasInsufficientBalance( LedgerTxn ltx(app.getLedgerTxnRoot()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(app, ltx, 0, 0, 0)); - REQUIRE(!tx->apply(app, ltx, txm)); + REQUIRE( + tx->checkValidForTesting(app.getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(!tx->apply(app.getAppConnector(), ltx, txm)); REQUIRE(check(getOperationResult(tx, 1))); ltx.commit(); }); @@ -256,8 +257,9 @@ createModifyAndRemoveSponsoredEntry(Application& app, TestAccount& sponsoredAcc, LedgerTxn ltx(app.getLedgerTxnRoot()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx->checkValidForTesting(app, ltx, 0, 0, 0)); - REQUIRE(tx->apply(app, ltx, txm)); + REQUIRE(tx->checkValidForTesting(app.getAppConnector(), ltx, 0, + 0, 0)); + REQUIRE(tx->apply(app.getAppConnector(), ltx, txm)); check(ltx); checkSponsorship(ltx, sponsoredAcc, 0, nullptr, @@ -271,8 +273,9 @@ createModifyAndRemoveSponsoredEntry(Application& app, TestAccount& sponsoredAcc, LedgerTxn ltx2(app.getLedgerTxnRoot()); TransactionMetaFrame txm2( ltx2.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(app, ltx2, 0, 0, 0)); - REQUIRE(tx2->apply(app, ltx2, txm2)); + REQUIRE(tx2->checkValidForTesting(app.getAppConnector(), ltx2, + 0, 0, 0)); + REQUIRE(tx2->apply(app.getAppConnector(), ltx2, txm2)); check(ltx2); checkSponsorship(ltx2, sponsoredAcc, 0, nullptr, @@ -285,8 +288,9 @@ createModifyAndRemoveSponsoredEntry(Application& app, TestAccount& sponsoredAcc, { LedgerTxn ltx3(app.getLedgerTxnRoot()); TransactionMetaFrame txm3(2); - REQUIRE(tx3->checkValidForTesting(app, ltx3, 0, 0, 0)); - REQUIRE(tx3->apply(app, ltx3, txm3)); + REQUIRE(tx3->checkValidForTesting(app.getAppConnector(), ltx3, + 0, 0, 0)); + REQUIRE(tx3->apply(app.getAppConnector(), ltx3, txm3)); check(ltx3); checkSponsorship(ltx3, sponsoredAcc, 0, nullptr, @@ -300,8 +304,9 @@ createModifyAndRemoveSponsoredEntry(Application& app, TestAccount& sponsoredAcc, { LedgerTxn ltx4(app.getLedgerTxnRoot()); TransactionMetaFrame txm4(2); - REQUIRE(tx4->checkValidForTesting(app, ltx4, 0, 0, 0)); - REQUIRE(tx4->apply(app, ltx4, txm4)); + REQUIRE(tx4->checkValidForTesting(app.getAppConnector(), ltx4, + 0, 0, 0)); + REQUIRE(tx4->apply(app.getAppConnector(), ltx4, txm4)); if (rso.type() == REVOKE_SPONSORSHIP_LEDGER_ENTRY) { @@ -398,8 +403,8 @@ submitTooManySponsoringTxs(Application& app, TestAccount& successfulOpAcc, LedgerTxn ltx(app.getLedgerTxnRoot()); TransactionMetaFrame txm1(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app.getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app.getAppConnector(), ltx, txm1)); ltx.commit(); } @@ -412,8 +417,8 @@ submitTooManySponsoringTxs(Application& app, TestAccount& successfulOpAcc, LedgerTxn ltx(app.getLedgerTxnRoot()); TransactionMetaFrame txm2(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(app, ltx, 0, 0, 0)); - REQUIRE(!tx2->apply(app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app.getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(!tx2->apply(app.getAppConnector(), ltx, txm2)); REQUIRE(tx2->getResult().result.results()[1].code() == opTOO_MANY_SPONSORING); } @@ -541,8 +546,8 @@ submitTooManyNumSubEntries(Application& app, TestAccount& testAcc, LedgerTxn ltx(app.getLedgerTxnRoot()); TransactionMetaFrame txm1(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx1->checkValidForTesting(app, ltx, 0, 0, 0)); - REQUIRE(tx1->apply(app, ltx, txm1)); + REQUIRE(tx1->checkValidForTesting(app.getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(tx1->apply(app.getAppConnector(), ltx, txm1)); ltx.commit(); } @@ -552,8 +557,8 @@ submitTooManyNumSubEntries(Application& app, TestAccount& testAcc, LedgerTxn ltx(app.getLedgerTxnRoot()); TransactionMetaFrame txm2(ltx.loadHeader().current().ledgerVersion); - REQUIRE(tx2->checkValidForTesting(app, ltx, 0, 0, 0)); - REQUIRE(!tx2->apply(app, ltx, txm2)); + REQUIRE(tx2->checkValidForTesting(app.getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(!tx2->apply(app.getAppConnector(), ltx, txm2)); REQUIRE(tx2->getResult().result.results()[0].code() == opTOO_MANY_SUBENTRIES); } diff --git a/src/transactions/test/TransactionTestFrame.cpp b/src/transactions/test/TransactionTestFrame.cpp index 9e7278a842..8f4673ffcb 100644 --- a/src/transactions/test/TransactionTestFrame.cpp +++ b/src/transactions/test/TransactionTestFrame.cpp @@ -42,7 +42,7 @@ TransactionTestFrame::createSuccessResult() const } bool -TransactionTestFrame::apply(Application& app, AbstractLedgerTxn& ltx, +TransactionTestFrame::apply(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, Hash const& sorobanBasePrngSeed) { @@ -77,7 +77,7 @@ TransactionTestFrame::addSignature(DecoratedSignature const& signature) } bool -TransactionTestFrame::apply(Application& app, AbstractLedgerTxn& ltx, +TransactionTestFrame::apply(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, MutableTxResultPtr txResult, Hash const& sorobanBasePrngSeed) const @@ -89,7 +89,7 @@ TransactionTestFrame::apply(Application& app, AbstractLedgerTxn& ltx, } MutableTxResultPtr -TransactionTestFrame::checkValid(Application& app, AbstractLedgerTxn& ltxOuter, +TransactionTestFrame::checkValid(AppConnector& app, AbstractLedgerTxn& ltxOuter, SequenceNumber current, uint64_t lowerBoundCloseTimeOffset, uint64_t upperBoundCloseTimeOffset) const @@ -102,7 +102,7 @@ TransactionTestFrame::checkValid(Application& app, AbstractLedgerTxn& ltxOuter, } MutableTxResultPtr -TransactionTestFrame::checkValid(Application& app, LedgerSnapshot const& ls, +TransactionTestFrame::checkValid(AppConnector& app, LedgerSnapshot const& ls, SequenceNumber current, uint64_t lowerBoundCloseTimeOffset, uint64_t upperBoundCloseTimeOffset) const @@ -120,14 +120,15 @@ TransactionTestFrame::processFeeSeqNum(AbstractLedgerTxn& ltx, } void -TransactionTestFrame::processPostApply(Application& app, AbstractLedgerTxn& ltx, +TransactionTestFrame::processPostApply(AppConnector& app, + AbstractLedgerTxn& ltx, TransactionMetaFrame& meta) { mTransactionFrame->processPostApply(app, ltx, meta, mTransactionTxResult); } bool -TransactionTestFrame::checkValidForTesting(Application& app, +TransactionTestFrame::checkValidForTesting(AppConnector& app, AbstractLedgerTxn& ltxOuter, SequenceNumber current, uint64_t lowerBoundCloseTimeOffset, @@ -141,7 +142,8 @@ TransactionTestFrame::checkValidForTesting(Application& app, bool TransactionTestFrame::checkSorobanResourceAndSetError( - Application& app, uint32_t ledgerVersion, MutableTxResultPtr txResult) const + AppConnector& app, uint32_t ledgerVersion, + MutableTxResultPtr txResult) const { auto ret = mTransactionFrame->checkSorobanResourceAndSetError( app, ledgerVersion, txResult); @@ -297,7 +299,8 @@ TransactionTestFrame::processFeeSeqNum(AbstractLedgerTxn& ltx, } void -TransactionTestFrame::processPostApply(Application& app, AbstractLedgerTxn& ltx, +TransactionTestFrame::processPostApply(AppConnector& app, + AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, MutableTxResultPtr txResult) const { diff --git a/src/transactions/test/TransactionTestFrame.h b/src/transactions/test/TransactionTestFrame.h index c13b928664..0efca11fdf 100644 --- a/src/transactions/test/TransactionTestFrame.h +++ b/src/transactions/test/TransactionTestFrame.h @@ -31,11 +31,11 @@ class TransactionTestFrame : public TransactionFrameBase } // Test only functions - bool apply(Application& app, AbstractLedgerTxn& ltx, + bool apply(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, Hash const& sorobanBasePrngSeed = Hash{}); - bool checkValidForTesting(Application& app, AbstractLedgerTxn& ltxOuter, + bool checkValidForTesting(AppConnector& app, AbstractLedgerTxn& ltxOuter, SequenceNumber current, uint64_t lowerBoundCloseTimeOffset, uint64_t upperBoundCloseTimeOffset); @@ -43,7 +43,7 @@ class TransactionTestFrame : public TransactionFrameBase void processFeeSeqNum(AbstractLedgerTxn& ltx, std::optional baseFee); - void processPostApply(Application& app, AbstractLedgerTxn& ltx, + void processPostApply(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta); void addSignature(SecretKey const& secretKey); @@ -57,20 +57,21 @@ class TransactionTestFrame : public TransactionFrameBase TransactionFrameBasePtr getTxFramePtr() const; // Redefinitions of TransactionFrameBase functions - bool apply(Application& app, AbstractLedgerTxn& ltx, + bool apply(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, MutableTxResultPtr txResult, Hash const& sorobanBasePrngSeed = Hash{}) const override; - MutableTxResultPtr checkValid(Application& app, AbstractLedgerTxn& ltxOuter, + MutableTxResultPtr checkValid(AppConnector& app, + AbstractLedgerTxn& ltxOuter, SequenceNumber current, uint64_t lowerBoundCloseTimeOffset, uint64_t upperBoundCloseTimeOffset) const; MutableTxResultPtr - checkValid(Application& app, LedgerSnapshot const& ls, + checkValid(AppConnector& app, LedgerSnapshot const& ls, SequenceNumber current, uint64_t lowerBoundCloseTimeOffset, uint64_t upperBoundCloseTimeOffset) const override; bool - checkSorobanResourceAndSetError(Application& app, uint32_t ledgerVersion, + checkSorobanResourceAndSetError(AppConnector& app, uint32_t ledgerVersion, MutableTxResultPtr txResult) const override; MutableTxResultPtr createSuccessResult() const override; @@ -122,7 +123,7 @@ class TransactionTestFrame : public TransactionFrameBase processFeeSeqNum(AbstractLedgerTxn& ltx, std::optional baseFee) const override; - void processPostApply(Application& app, AbstractLedgerTxn& ltx, + void processPostApply(AppConnector& app, AbstractLedgerTxn& ltx, TransactionMetaFrame& meta, MutableTxResultPtr txResult) const override; diff --git a/src/transactions/test/TxEnvelopeTests.cpp b/src/transactions/test/TxEnvelopeTests.cpp index 54c4ee5d3f..8343fb4145 100644 --- a/src/transactions/test/TxEnvelopeTests.cpp +++ b/src/transactions/test/TxEnvelopeTests.cpp @@ -832,8 +832,8 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") setup(); { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, - 0, 0)); + REQUIRE(!tx->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); } REQUIRE(tx->getResultCode() == txBAD_SEQ); REQUIRE(getAccountSigners(a1, *app).size() == 1); @@ -1439,8 +1439,9 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(insideSignerTx->checkValidForTesting( - *app, ltx, 0, 0, 0)); - REQUIRE(insideSignerTx->apply(*app, ltx, txm)); + app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(insideSignerTx->apply( + app->getAppConnector(), ltx, txm)); REQUIRE(insideSignerTx->getResultCode() == txSUCCESS); ltx.commit(); @@ -1458,8 +1459,9 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(outsideSignerTx->checkValidForTesting( - *app, ltx, 0, 0, 0)); - REQUIRE(outsideSignerTx->apply(*app, ltx, txm)); + app->getAppConnector(), ltx, 0, 0, 0)); + REQUIRE(outsideSignerTx->apply( + app->getAppConnector(), ltx, txm)); REQUIRE(outsideSignerTx->getResultCode() == txSUCCESS); ltx.commit(); @@ -1682,7 +1684,8 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), + ltx, 0, 0, 0)); } applyCheck(tx, *app); @@ -1706,8 +1709,8 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE( - !tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); } applyCheck(tx, *app); REQUIRE(tx->getResultCode() == txFAILED); @@ -1720,8 +1723,8 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE( - tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(tx->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); } applyCheck(tx, *app); REQUIRE(tx->getResultCode() == txSUCCESS); @@ -1738,8 +1741,8 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE( - tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(tx->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); } applyCheck(tx, *app); REQUIRE(tx->getResultCode() == txSUCCESS); @@ -1764,8 +1767,8 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE( - !tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); } applyCheck(tx, *app); @@ -1792,8 +1795,8 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE( - tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(tx->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); } applyCheck(tx, *app); @@ -1819,8 +1822,8 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE( - tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(tx->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); } applyCheck(tx, *app); @@ -1912,8 +1915,8 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") setup(); { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE( - !txFrame->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!txFrame->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); } REQUIRE(txFrame->getResultCode() == txBAD_SEQ); }); @@ -2002,8 +2005,9 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") { LedgerTxn ltx(app->getLedgerTxnRoot()); REQUIRE(txFrame->checkValidForTesting( - *app, ltx, 0, lowerBound, 0) == - expectSuccess); + app->getAppConnector(), ltx, 0, + lowerBound, + 0) == expectSuccess); } REQUIRE( txFrame->getResultCode() == @@ -2083,7 +2087,8 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") { LedgerTxn ltx(app->getLedgerTxnRoot()); REQUIRE(txFrame->checkValidForTesting( - *app, ltx, 0, 0, offset)); + app->getAppConnector(), ltx, 0, 0, + offset)); } REQUIRE(txFrame->getResultCode() == txSUCCESS); @@ -2096,7 +2101,8 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") { LedgerTxn ltx(app->getLedgerTxnRoot()); REQUIRE(!txFrame->checkValidForTesting( - *app, ltx, 0, 0, offset)); + app->getAppConnector(), ltx, 0, 0, + offset)); } REQUIRE(txFrame->getResultCode() == txTOO_LATE); @@ -2124,8 +2130,8 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") setSeqNum(txFrame, txFrame->getSeqNum() - 1); { LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE( - !txFrame->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!txFrame->checkValidForTesting( + app->getAppConnector(), ltx, 0, 0, 0)); } REQUIRE(txFrame->getResultCode() == txBAD_SEQ); @@ -2489,7 +2495,7 @@ TEST_CASE("soroban txs not allowed before protocol upgrade", sorobanTransactionFrameFromOps(app->getNetworkID(), root, {op}, {}, SorobanResources(), 1000, 1'000'000); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); REQUIRE(tx->getResult().result.code() == txMALFORMED); } @@ -2550,12 +2556,14 @@ TEST_CASE_VERSIONS("Soroban extension for non-Soroban tx", .header.ledgerVersion, ProtocolVersion::V_21)) { - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); REQUIRE(tx->getResult().result.code() == txMALFORMED); } else { - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE( + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); } }); } @@ -2575,7 +2583,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op0}, {}, resources, 100, 3'500'000); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0) == valid); + REQUIRE(tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0) == valid); if (!valid) { REQUIRE(tx->getResult().result.code() == txSOROBAN_INVALID); @@ -2586,7 +2595,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") { auto tx = transactionFrameFromOps(app->getNetworkID(), root, {op0}, {}); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE( + !tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); REQUIRE(tx->getResult().result.code() == txMALFORMED); } SorobanResources resources; @@ -2654,7 +2664,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op}, {}, resources, 100, 4'000'000); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE( + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); } SECTION("limit exceeded") { @@ -2663,7 +2674,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op}, {}, resources, 100, 4'000'000); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); REQUIRE(tx->getResult().result.code() == txSOROBAN_INVALID); } } @@ -2675,7 +2687,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") app->getNetworkID(), root, {op0}, {}, resources, 1'000, 100'000); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); REQUIRE(tx->getResult().result.code() == txSOROBAN_INVALID); } SECTION("inclusion fee is too low") @@ -2684,7 +2697,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") app->getNetworkID(), root, {op0}, {}, resources, 1'000'099, 1'000'000); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); REQUIRE(tx->getResult().result.code() == txINSUFFICIENT_FEE); } SECTION("required resource fee is lower than declared") @@ -2692,7 +2706,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") auto tx = sorobanTransactionFrameFromOpsWithTotalFee( app->getNetworkID(), root, {op0}, {}, resources, 1'000'000, 10); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); REQUIRE(tx->getResult().result.code() == txSOROBAN_INVALID); } SECTION("resource fee is negative") @@ -2701,7 +2716,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") app->getNetworkID(), root, {op0}, {}, resources, 1'000'000, std::numeric_limits::min()); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); // Negative resource fee is handled before we get to // Soroban-specific checks. REQUIRE(tx->getResult().result.code() == txMALFORMED); @@ -2713,7 +2729,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") std::numeric_limits::max(), static_cast(std::numeric_limits::max()) + 1); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); REQUIRE(tx->getResult().result.code() == txSOROBAN_INVALID); } SECTION("resource fee is max int64") @@ -2723,7 +2740,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") std::numeric_limits::max(), std::numeric_limits::max()); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); REQUIRE(tx->getResult().result.code() == txMALFORMED); } SECTION("total fee is exactly uint32 max") @@ -2734,7 +2752,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") static_cast(std::numeric_limits::max()) - 100); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE( + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); } SECTION("total fee exceeds uint32 after adding base fee") { @@ -2744,7 +2763,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") static_cast(std::numeric_limits::max()) - 100 + 1); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); // This gets rejected due to insufficient inclusion fee, so // we have the respective error code (even though the fee is // insufficient due to Soroban resource fee). @@ -2762,7 +2782,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") // This could work in theory (because the fee bump has enough // fee to cover the inner tx), it can't work because we still // consider the inner tx invalid due to negative inclusion fee. - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); REQUIRE(tx->getResult().result.code() == txFEE_BUMP_INNER_FAILED); } SECTION("resource fee is negative with fee bump") @@ -2774,7 +2795,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") std::numeric_limits::max(), /* useInclusionAsFullFee */ true); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); REQUIRE(tx->getResult().result.code() == txMALFORMED); } SECTION("resource fee is max int64 with fee bump") @@ -2787,7 +2809,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") std::numeric_limits::max(), /* useInclusionAsFullFee */ true); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); REQUIRE(tx->getResult().result.code() == txMALFORMED); } } @@ -2797,7 +2820,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op0, op0}, {}, resources, 100, 100'000); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE( + !tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); REQUIRE(tx->getResult().result.code() == txMALFORMED); } SECTION("contract size") @@ -2812,7 +2836,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op}, {}, resources, 100, 3'500'000); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE( + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); } SECTION("over limit") { @@ -2821,7 +2846,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op}, {}, resources, 100, 3'500'000); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); } } @@ -2845,7 +2871,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op}, {}, resources, 100, 3'500'000); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE( + tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, 0)); } SECTION("read-only key over size limit") { @@ -2859,7 +2886,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op}, {}, resources, 100, 3'500'000); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); } SECTION("read-write key over size limit") { @@ -2873,7 +2901,8 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op}, {}, resources, 100, 3'500'000); LedgerTxn ltx(app->getLedgerTxnRoot()); - REQUIRE(!tx->checkValidForTesting(*app, ltx, 0, 0, 0)); + REQUIRE(!tx->checkValidForTesting(app->getAppConnector(), ltx, 0, 0, + 0)); } } } From 40b75b2cec19f1b8fcd5e6762726542a6b2208bb Mon Sep 17 00:00:00 2001 From: marta-lokhova Date: Wed, 18 Sep 2024 13:48:44 -0700 Subject: [PATCH 3/4] Cleanup bad usages of READ_ONLY_WITHOUT_SQL_TXN across the codebase --- src/bucket/test/BucketListTests.cpp | 3 +-- src/herder/HerderImpl.cpp | 8 +++----- src/herder/test/TxSetTests.cpp | 3 +-- src/ledger/LedgerManagerImpl.cpp | 10 ++-------- src/ledger/LedgerTxn.h | 2 ++ src/ledger/NetworkConfig.cpp | 2 +- 6 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/bucket/test/BucketListTests.cpp b/src/bucket/test/BucketListTests.cpp index 2730efcca6..edf229d439 100644 --- a/src/bucket/test/BucketListTests.cpp +++ b/src/bucket/test/BucketListTests.cpp @@ -726,8 +726,7 @@ TEST_CASE_VERSIONS("network config snapshots BucketList size", "[bucketlist]") uint64_t correctAverage = sum / correctWindow.size(); - LedgerTxn ltx(app->getLedgerTxnRoot(), false, - TransactionMode::READ_ONLY_WITHOUT_SQL_TXN); + LedgerTxn ltx(app->getLedgerTxnRoot()); REQUIRE(networkConfig.getAverageBucketListSize() == correctAverage); // Check on-disk sliding window diff --git a/src/herder/HerderImpl.cpp b/src/herder/HerderImpl.cpp index e3e1eeb601..d2d3565c1a 100644 --- a/src/herder/HerderImpl.cpp +++ b/src/herder/HerderImpl.cpp @@ -2147,11 +2147,9 @@ HerderImpl::start() { mMaxTxSize = mApp.getHerder().getMaxClassicTxSize(); { - LedgerTxn ltx(mApp.getLedgerTxnRoot(), - /* shouldUpdateLastModified */ true, - TransactionMode::READ_ONLY_WITHOUT_SQL_TXN); - - uint32_t version = ltx.loadHeader().current().ledgerVersion; + uint32_t version = mApp.getLedgerManager() + .getLastClosedLedgerHeader() + .header.ledgerVersion; if (protocolVersionStartsFrom(version, SOROBAN_PROTOCOL_VERSION)) { auto const& conf = diff --git a/src/herder/test/TxSetTests.cpp b/src/herder/test/TxSetTests.cpp index f79fc76f10..389df03161 100644 --- a/src/herder/test/TxSetTests.cpp +++ b/src/herder/test/TxSetTests.cpp @@ -519,8 +519,7 @@ TEST_CASE("generalized tx set XDR conversion", "[txset]") auto txSetFrame = TxSetXDRFrame::makeFromWire(txSetXdr); ApplicableTxSetFrameConstPtr applicableFrame; { - LedgerTxn ltx(app->getLedgerTxnRoot(), false, - TransactionMode::READ_ONLY_WITHOUT_SQL_TXN); + LedgerTxn ltx(app->getLedgerTxnRoot()); applicableFrame = txSetFrame->prepareForApply(*app); } REQUIRE(applicableFrame->checkValid(*app, 0, 0)); diff --git a/src/ledger/LedgerManagerImpl.cpp b/src/ledger/LedgerManagerImpl.cpp index adf556e958..264781e82c 100644 --- a/src/ledger/LedgerManagerImpl.cpp +++ b/src/ledger/LedgerManagerImpl.cpp @@ -1139,8 +1139,7 @@ LedgerManagerImpl::setLastClosedLedger( mRebuildInMemoryState = false; advanceLedgerPointers(lastClosed.header); - LedgerTxn ltx2(mApp.getLedgerTxnRoot(), false, - TransactionMode::READ_ONLY_WITHOUT_SQL_TXN); + LedgerTxn ltx2(mApp.getLedgerTxnRoot()); if (protocolVersionStartsFrom(ltx2.loadHeader().current().ledgerVersion, SOROBAN_PROTOCOL_VERSION)) { @@ -1322,12 +1321,7 @@ LedgerManagerImpl::updateNetworkConfig(AbstractLedgerTxn& rootLtx) { ZoneScoped; - uint32_t ledgerVersion{}; - { - LedgerTxn ltx(rootLtx, false, - TransactionMode::READ_ONLY_WITHOUT_SQL_TXN); - ledgerVersion = ltx.loadHeader().current().ledgerVersion; - } + uint32_t ledgerVersion = rootLtx.loadHeader().current().ledgerVersion; if (protocolVersionStartsFrom(ledgerVersion, SOROBAN_PROTOCOL_VERSION)) { diff --git a/src/ledger/LedgerTxn.h b/src/ledger/LedgerTxn.h index 6e755f651e..b839ddafc5 100644 --- a/src/ledger/LedgerTxn.h +++ b/src/ledger/LedgerTxn.h @@ -262,6 +262,8 @@ enum class LedgerTxnConsistency EXTRA_DELETES }; +// NOTE: Remove READ_ONLY_WITHOUT_SQL_TXN mode when BucketListDB is required +// and we stop supporting SQL backend for ledger state. enum class TransactionMode { READ_ONLY_WITHOUT_SQL_TXN, diff --git a/src/ledger/NetworkConfig.cpp b/src/ledger/NetworkConfig.cpp index 3ca192152c..d4c1de9936 100644 --- a/src/ledger/NetworkConfig.cpp +++ b/src/ledger/NetworkConfig.cpp @@ -933,7 +933,7 @@ SorobanNetworkConfig::loadFromLedger(AbstractLedgerTxn& ltxRoot, { ZoneScoped; - LedgerTxn ltx(ltxRoot, false, TransactionMode::READ_ONLY_WITHOUT_SQL_TXN); + LedgerTxn ltx(ltxRoot); loadMaxContractSize(ltx); loadMaxContractDataKeySize(ltx); loadMaxContractDataEntrySize(ltx); From bcb70b32a060b76d548f964967e1d984e7136a16 Mon Sep 17 00:00:00 2001 From: marta-lokhova Date: Wed, 18 Sep 2024 15:10:47 -0700 Subject: [PATCH 4/4] Fix vnext build --- src/transactions/test/TxEnvelopeTests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transactions/test/TxEnvelopeTests.cpp b/src/transactions/test/TxEnvelopeTests.cpp index 8343fb4145..81abdbcff0 100644 --- a/src/transactions/test/TxEnvelopeTests.cpp +++ b/src/transactions/test/TxEnvelopeTests.cpp @@ -2518,7 +2518,7 @@ TEST_CASE("XDR protocol compatibility validation", "[tx][envelope]") sorobanTransactionFrameFromOps(app->getNetworkID(), root, {op}, {}, SorobanResources(), 1000, 1'000'000); LedgerTxn ltx(app->getLedgerTxnRoot()); - return tx->checkValid(*app, ltx, 0, 0, 0); + return tx->checkValid(app->getAppConnector(), ltx, 0, 0, 0); }; SECTION("XDR not valid in protocol 21") {