Skip to content

Commit

Permalink
Rebase fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
SirTyson committed Jul 30, 2024
1 parent 86f6f34 commit ba0d9f5
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 31 deletions.
8 changes: 5 additions & 3 deletions src/herder/TxSetFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "main/Application.h"
#include "main/Config.h"
#include "overlay/Peer.h"
#include "transactions/MutableTransactionResult.h"
#include "transactions/TransactionUtils.h"
#include "util/GlobalChecks.h"
#include "util/Logging.h"
Expand Down Expand Up @@ -241,14 +242,15 @@ phaseTxsAreValid(TxSetTransactions const& phase, Application& app,
app.getLedgerManager().getLastClosedLedgerNum() + 1;
for (auto const& tx : phase)
{
if (!tx->checkValid(app, ltx, 0, lowerBoundCloseTimeOffset,
upperBoundCloseTimeOffset))
auto txResult = tx->checkValid(app, ltx, 0, lowerBoundCloseTimeOffset,
upperBoundCloseTimeOffset);
if (!txResult->isSuccess())
{

CLOG_DEBUG(
Herder, "Got bad txSet: tx invalid tx: {} result: {}",
xdrToCerealString(tx->getEnvelope(), "TransactionEnvelope"),
tx->getResultCode());
txResult->getResultCode());
return false;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/herder/TxSetUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ TxSetUtils::getInvalidTxList(TxSetTransactions const& txs, Application& app,

for (auto const& tx : txs)
{
if (!tx->checkValid(app, ltx, 0, lowerBoundCloseTimeOffset,
upperBoundCloseTimeOffset))
auto txResult = tx->checkValid(app, ltx, 0, lowerBoundCloseTimeOffset,
upperBoundCloseTimeOffset);
if (!txResult->isSuccess())
{
invalidTxs.emplace_back(tx);
}
Expand Down
5 changes: 4 additions & 1 deletion src/herder/test/HerderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "transactions/TransactionBridge.h"
#include "transactions/TransactionFrame.h"
#include "transactions/TransactionUtils.h"
#include "transactions/test/TransactionTestFrame.h"
#include "util/Math.h"
#include "util/ProtocolVersion.h"

Expand All @@ -45,6 +46,7 @@
#include "xdrpp/marshal.h"
#include <algorithm>
#include <fmt/format.h>
#include <memory>
#include <numeric>
#include <optional>

Expand Down Expand Up @@ -356,7 +358,8 @@ testTxSet(uint32 protocolVersion)
}
SECTION("sequence gap")
{
setSeqNum(std::static_pointer_cast<TransactionFrame>(txs[0]),
auto txPtr = std::const_pointer_cast<TransactionFrameBase>(txs[0]);
setSeqNum(std::static_pointer_cast<TransactionTestFrame>(txPtr),
txs[0]->getSeqNum() + 5);

TxSetTransactions removed;
Expand Down
47 changes: 25 additions & 22 deletions src/herder/test/TransactionQueueTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ TEST_CASE("TransactionQueue with PreconditionsV2", "[herder][transactionqueue]")
auto tx = transactionWithV2Precondition(*app, account1, 5, 200, cond);

TransactionQueueTest test{queue};
test.add(tx, TransactionQueue::AddResult::ADD_STATUS_ERROR);
test.add(tx, TransactionQueue::AddResultCode::ADD_STATUS_ERROR);
}
SECTION("fee bump only existing tx")
{
Expand All @@ -898,24 +898,25 @@ TEST_CASE("TransactionQueue with PreconditionsV2", "[herder][transactionqueue]")
auto tx = transactionWithV2Precondition(*app, account1, 5, 200, cond);

TransactionQueueTest test{queue};
test.add(tx, TransactionQueue::AddResult::ADD_STATUS_PENDING);
test.add(tx, TransactionQueue::AddResultCode::ADD_STATUS_PENDING);

auto fb = feeBump(*app, account1, tx, 4000);
test.add(fb, TransactionQueue::AddResult::ADD_STATUS_PENDING);
test.add(fb, TransactionQueue::AddResultCode::ADD_STATUS_PENDING);

test.check({{{account1, 0, {fb}}, {account2}}, {}});
}
SECTION("fee bump existing tx and add minSeqNum")
{
TransactionQueueTest test{queue};
test.add(txSeqA1S1, TransactionQueue::AddResult::ADD_STATUS_PENDING);
test.add(txSeqA1S1,
TransactionQueue::AddResultCode::ADD_STATUS_PENDING);

PreconditionsV2 cond;
cond.minSeqNum.activate() = 2;

auto tx = transactionWithV2Precondition(*app, account1, 1, 200, cond);
auto fb = feeBump(*app, account1, tx, 4000);
test.add(fb, TransactionQueue::AddResult::ADD_STATUS_PENDING);
test.add(fb, TransactionQueue::AddResultCode::ADD_STATUS_PENDING);

test.check({{{account1, 0, {fb}}, {account2}}, {}});
}
Expand All @@ -927,10 +928,10 @@ TEST_CASE("TransactionQueue with PreconditionsV2", "[herder][transactionqueue]")
cond.minSeqNum.activate() = 2;

auto tx = transactionWithV2Precondition(*app, account1, 1, 200, cond);
test.add(tx, TransactionQueue::AddResult::ADD_STATUS_PENDING);
test.add(tx, TransactionQueue::AddResultCode::ADD_STATUS_PENDING);

auto fb = feeBump(*app, account1, txSeqA1S1, 4000);
test.add(fb, TransactionQueue::AddResult::ADD_STATUS_PENDING);
test.add(fb, TransactionQueue::AddResultCode::ADD_STATUS_PENDING);

test.check({{{account1, 0, {fb}}, {account2}}, {}});
}
Expand All @@ -949,10 +950,10 @@ TEST_CASE("TransactionQueue with PreconditionsV2", "[herder][transactionqueue]")
{
auto tx =
transactionWithV2Precondition(*app, account1, 1, 200, cond);
test.add(tx, TransactionQueue::AddResult::ADD_STATUS_ERROR);
test.add(tx, TransactionQueue::AddResultCode::ADD_STATUS_ERROR);

tx->addSignature(account2.getSecretKey());
test.add(tx, TransactionQueue::AddResult::ADD_STATUS_PENDING);
test.add(tx, TransactionQueue::AddResultCode::ADD_STATUS_PENDING);
}

SECTION("two signers")
Expand All @@ -966,12 +967,12 @@ TEST_CASE("TransactionQueue with PreconditionsV2", "[herder][transactionqueue]")
transactionWithV2Precondition(*app, account1, 1, 200, cond);

// no signature
test.add(tx, TransactionQueue::AddResult::ADD_STATUS_ERROR);
test.add(tx, TransactionQueue::AddResultCode::ADD_STATUS_ERROR);

SECTION("first signature missing")
{
tx->addSignature(root.getSecretKey());
test.add(tx, TransactionQueue::AddResult::ADD_STATUS_ERROR);
test.add(tx, TransactionQueue::AddResultCode::ADD_STATUS_ERROR);

tx->addSignature(account2.getSecretKey());
test.add(tx,
Expand All @@ -981,10 +982,11 @@ TEST_CASE("TransactionQueue with PreconditionsV2", "[herder][transactionqueue]")
SECTION("second signature missing")
{
tx->addSignature(account2.getSecretKey());
test.add(tx, TransactionQueue::AddResult::ADD_STATUS_ERROR);
test.add(tx, TransactionQueue::AddResultCode::ADD_STATUS_ERROR);

tx->addSignature(root.getSecretKey());
test.add(tx, TransactionQueue::AddResult::ADD_STATUS_PENDING);
test.add(tx,
TransactionQueue::AddResultCode::ADD_STATUS_PENDING);
}
}
}
Expand All @@ -1003,8 +1005,8 @@ TEST_CASE("TransactionQueue with PreconditionsV2", "[herder][transactionqueue]")
auto& herder = static_cast<HerderImpl&>(app->getHerder());
auto& tq = herder.getTransactionQueue();

REQUIRE(herder.recvTransaction(tx, false) ==
TransactionQueue::AddResult::ADD_STATUS_PENDING);
REQUIRE(herder.recvTransaction(tx, false).code ==
TransactionQueue::AddResultCode::ADD_STATUS_PENDING);

REQUIRE(tq.getTransactions({}).size() == 1);
closeLedger(*app);
Expand All @@ -1024,34 +1026,35 @@ TEST_CASE("TransactionQueue with PreconditionsV2", "[herder][transactionqueue]")
auto tx =
transactionWithV2Precondition(*app, account1, 5, 200, cond);

test.add(tx, TransactionQueue::AddResult::ADD_STATUS_ERROR);
test.add(tx, TransactionQueue::AddResultCode::ADD_STATUS_ERROR);
}

test.add(txSeqA1S5MinSeqNum,
TransactionQueue::AddResult::ADD_STATUS_PENDING);
TransactionQueue::AddResultCode::ADD_STATUS_PENDING);

// make sure duplicates are identified correctly
test.add(txSeqA1S5MinSeqNum,
TransactionQueue::AddResult::ADD_STATUS_DUPLICATE);
TransactionQueue::AddResultCode::ADD_STATUS_DUPLICATE);

// try to fill in gap with a tx
test.add(txSeqA1S2, TransactionQueue::AddResult::ADD_STATUS_ERROR);
test.add(txSeqA1S2, TransactionQueue::AddResultCode::ADD_STATUS_ERROR);

// try to fill in gap with a minSeqNum tx
test.add(txSeqA1S4MinSeqNum,
TransactionQueue::AddResult::ADD_STATUS_ERROR);
TransactionQueue::AddResultCode::ADD_STATUS_ERROR);

test.check({{{account1, 0, {txSeqA1S5MinSeqNum}}, {account2}}, {}});

// fee bump the existing minSeqNum tx
auto fb = feeBump(*app, account1, txSeqA1S5MinSeqNum, 4000);
test.add(fb, TransactionQueue::AddResult::ADD_STATUS_PENDING);
test.add(fb, TransactionQueue::AddResultCode::ADD_STATUS_PENDING);

test.check({{{account1, 0, {fb}}, {account2}}, {}});

// fee bump a new minSeqNum tx fails due to account limit
auto fb2 = feeBump(*app, account1, txSeqA1S8MinSeqNum, 400);
test.add(fb2, TransactionQueue::AddResult::ADD_STATUS_TRY_AGAIN_LATER);
test.add(fb2,
TransactionQueue::AddResultCode::ADD_STATUS_TRY_AGAIN_LATER);

test.check({{{account1, 0, {fb}}, {account2}}, {}});
}
Expand Down
5 changes: 3 additions & 2 deletions src/transactions/test/TransactionTestFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,10 @@ TransactionTestFrame::insertKeysForFeeProcessing(
}

void
TransactionTestFrame::insertKeysForTxApply(UnorderedSet<LedgerKey>& keys) const
TransactionTestFrame::insertKeysForTxApply(UnorderedSet<LedgerKey>& keys,
LedgerKeyMeter* lkMeter) const
{
mTransactionFrame->insertKeysForTxApply(keys);
mTransactionFrame->insertKeysForTxApply(keys, lkMeter);
}

MutableTxResultPtr
Expand Down
3 changes: 2 additions & 1 deletion src/transactions/test/TransactionTestFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ class TransactionTestFrame : public TransactionFrameBase

void
insertKeysForFeeProcessing(UnorderedSet<LedgerKey>& keys) const override;
void insertKeysForTxApply(UnorderedSet<LedgerKey>& keys) const override;
void insertKeysForTxApply(UnorderedSet<LedgerKey>& keys,
LedgerKeyMeter* lkMeter) const override;

MutableTxResultPtr
processFeeSeqNum(AbstractLedgerTxn& ltx,
Expand Down

0 comments on commit ba0d9f5

Please sign in to comment.