Skip to content

Commit

Permalink
Remove redundant passing around of protocol version
Browse files Browse the repository at this point in the history
  • Loading branch information
bboston7 committed Jan 15, 2025
1 parent 7bb9da0 commit 1697978
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/herder/TransactionQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ TransactionQueue::canAdd(
{
auto txResult = tx->createSuccessResult();
if (!tx->checkSorobanResourceAndSetError(
*mValidationSnapshot, ledgerVersion, txResult))
*mValidationSnapshot, txResult))
{
return AddResult(AddResultCode::ADD_STATUS_ERROR, txResult);
}
Expand Down
6 changes: 2 additions & 4 deletions src/transactions/FeeBumpTransactionFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,9 @@ FeeBumpTransactionFrame::checkValid(ValidationConnector const& vc,

bool
FeeBumpTransactionFrame::checkSorobanResourceAndSetError(
ValidationConnector const& vc, uint32_t ledgerVersion,
MutableTxResultPtr txResult) const
ValidationConnector const& vc, MutableTxResultPtr txResult) const
{
return mInnerTx->checkSorobanResourceAndSetError(vc, ledgerVersion,
txResult);
return mInnerTx->checkSorobanResourceAndSetError(vc, txResult);
}

bool
Expand Down
1 change: 0 additions & 1 deletion src/transactions/FeeBumpTransactionFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class FeeBumpTransactionFrame : public TransactionFrameBase
uint64_t upperBoundCloseTimeOffset) const override;
bool
checkSorobanResourceAndSetError(ValidationConnector const& app,
uint32_t ledgerVersion,
MutableTxResultPtr txResult) const override;

MutableTxResultPtr createSuccessResult() const override;
Expand Down
15 changes: 7 additions & 8 deletions src/transactions/TransactionFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,12 @@ TransactionFrame::validateSorobanOpsConsistency() const
}

bool
TransactionFrame::validateSorobanResources(SorobanNetworkConfig const& config,
Config const& appConfig,
uint32_t protocolVersion,
TransactionFrame::validateSorobanResources(ValidationConnector const& vc,
SorobanTxData& sorobanData) const
{
SorobanNetworkConfig const& config = vc.getSorobanNetworkConfig();
Config const& appConfig = vc.getConfig();
uint32_t protocolVersion = vc.getCurrentProtocolVersion();
auto const& resources = sorobanResources();
auto const& readEntries = resources.footprint.readOnly;
auto const& writeEntries = resources.footprint.readWrite;
Expand Down Expand Up @@ -945,7 +946,7 @@ TransactionFrame::commonValidPreSeqNum(
return false;
}

if (!checkSorobanResourceAndSetError(vc, ledgerVersion, txResult))
if (!checkSorobanResourceAndSetError(vc, txResult))
{
return false;
}
Expand Down Expand Up @@ -1501,11 +1502,9 @@ TransactionFrame::checkValid(ValidationConnector const& vc,

bool
TransactionFrame::checkSorobanResourceAndSetError(
ValidationConnector const& vc, uint32_t ledgerVersion,
MutableTxResultPtr txResult) const
ValidationConnector const& vc, MutableTxResultPtr txResult) const
{
if (!validateSorobanResources(vc.getSorobanNetworkConfig(), vc.getConfig(),
ledgerVersion, *txResult->getSorobanData()))
if (!validateSorobanResources(vc, *txResult->getSorobanData()))
{
txResult->setInnermostResultCode(txSOROBAN_INVALID);
return false;
Expand Down
5 changes: 1 addition & 4 deletions src/transactions/TransactionFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ class TransactionFrame : public TransactionFrameBase
bool extraSignersExist() const;

bool validateSorobanOpsConsistency() const;
bool validateSorobanResources(SorobanNetworkConfig const& config,
Config const& appConfig,
uint32_t protocolVersion,
bool validateSorobanResources(ValidationConnector const& vc,
SorobanTxData& sorobanData) const;
int64_t refundSorobanFee(AbstractLedgerTxn& ltx, AccountID const& feeSource,
MutableTransactionResultBase& txResult) const;
Expand Down Expand Up @@ -218,7 +216,6 @@ class TransactionFrame : public TransactionFrameBase
uint64_t upperBoundCloseTimeOffset) const override;
bool
checkSorobanResourceAndSetError(ValidationConnector const& vc,
uint32_t ledgerVersion,
MutableTxResultPtr txResult) const override;

MutableTxResultPtr createSuccessResult() const override;
Expand Down
1 change: 0 additions & 1 deletion src/transactions/TransactionFrameBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class TransactionFrameBase
uint64_t upperBoundCloseTimeOffset) const = 0;
virtual bool
checkSorobanResourceAndSetError(ValidationConnector const& vc,
uint32_t ledgerVersion,
MutableTxResultPtr txResult) const = 0;

virtual MutableTxResultPtr createSuccessResult() const = 0;
Expand Down
6 changes: 2 additions & 4 deletions src/transactions/test/TransactionTestFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,9 @@ TransactionTestFrame::checkValidForTesting(AppConnector& app,

bool
TransactionTestFrame::checkSorobanResourceAndSetError(
ValidationConnector const& vc, uint32_t ledgerVersion,
MutableTxResultPtr txResult) const
ValidationConnector const& vc, MutableTxResultPtr txResult) const
{
auto ret = mTransactionFrame->checkSorobanResourceAndSetError(
vc, ledgerVersion, txResult);
auto ret = mTransactionFrame->checkSorobanResourceAndSetError(vc, txResult);
mTransactionTxResult = txResult;
return ret;
}
Expand Down
1 change: 0 additions & 1 deletion src/transactions/test/TransactionTestFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class TransactionTestFrame : public TransactionFrameBase
uint64_t upperBoundCloseTimeOffset) const override;
bool
checkSorobanResourceAndSetError(ValidationConnector const& vc,
uint32_t ledgerVersion,
MutableTxResultPtr txResult) const override;

MutableTxResultPtr createSuccessResult() const override;
Expand Down

0 comments on commit 1697978

Please sign in to comment.