Skip to content

Commit

Permalink
[fold] address review
Browse files Browse the repository at this point in the history
- fix comments
- rename batch executions
  • Loading branch information
dangell7 committed Nov 11, 2024
1 parent 04519e6 commit 8029c30
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion include/xrpl/protocol/TxFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ constexpr std::uint32_t tfAMMClawbackMask = ~(tfUniversal | tfClawTwoAssets);
constexpr std::uint32_t tfClearAccountCreateAmount = 0x00010000;
constexpr std::uint32_t tfBridgeModifyMask = ~(tfUniversalV2 | tfClearAccountCreateAmount);

// Batch Flags
// Batch Flags:
constexpr std::uint32_t tfAllOrNothing = 0x00010000;
constexpr std::uint32_t tfOnlyOne = 0x00020000;
constexpr std::uint32_t tfUntilFailure = 0x00040000;
Expand Down
8 changes: 4 additions & 4 deletions src/test/app/Batch_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Batch_test : public beast::unit_test::suite

void
validateBatchMeta(
Json::Value meta,
Json::Value const& meta,
STAmount const& balance,
std::uint32_t const& sequence,
std::optional<std::uint32_t> ownerCount = std::nullopt,
Expand Down Expand Up @@ -390,7 +390,7 @@ class Batch_test : public beast::unit_test::suite
env.close();
}

// temMALFORMED: Batch: txn hash does not match TxIDs hash.
// temMALFORMED: Batch: order of inner transactions does not match TxIDs.
{
auto const batchFee = ((1 + 2) * feeDrops) + feeDrops * 2;
Json::Value jv =
Expand Down Expand Up @@ -449,7 +449,7 @@ class Batch_test : public beast::unit_test::suite
auto const seq = env.seq(alice);
auto const batchFee = ((1 + 2) * feeDrops) + feeDrops * 2;
env(batch::batch(alice, seq, batchFee, tfAllOrNothing),
batch::add(pay(alice, bob, XRP(10)), seq + 0),
batch::add(pay(alice, bob, XRP(10)), seq + 1),
batch::add(pay(bob, alice, XRP(5)), env.seq(bob)),
batch::sig(carol),
ter(temBAD_SIGNER));
Expand All @@ -461,7 +461,7 @@ class Batch_test : public beast::unit_test::suite
auto const seq = env.seq(alice);
auto const batchFee = ((1 + 2) * feeDrops) + feeDrops * 2;
env(batch::batch(alice, seq, batchFee, tfAllOrNothing),
batch::add(pay(alice, bob, XRP(10)), seq + 0),
batch::add(pay(alice, bob, XRP(10)), seq + 1),
batch::add(pay(bob, alice, XRP(5)), env.seq(bob)),
batch::sig(bob, carol),
ter(temBAD_SIGNER));
Expand Down
2 changes: 1 addition & 1 deletion src/xrpld/app/misc/NetworkOPs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ NetworkOPsImp::submitTransaction(std::shared_ptr<STTx const> const& iTrans)
view->rules().enabled(featureBatch) && iTrans->isFlag(tfInnerBatchTxn))
{
JLOG(m_journal.error())
<< "Submitted transaction invalid: BatchTxn present.";
<< "Submitted transaction invalid: tfInnerBatchTxn flag present.";
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/xrpld/app/tx/detail/Batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Batch::doApply()
meta.setFieldU16(sfTransactionType, stx.getTxnType());
if (ter == tesSUCCESS || isTecClaim(ter))
meta.setFieldH256(sfTransactionHash, stx.getTransactionID());
avi.addBatchExecutionMetaData(std::move(meta));
avi.addBatchExecution(std::move(meta));

if (ter != tesSUCCESS)
{
Expand Down
2 changes: 1 addition & 1 deletion src/xrpld/app/tx/detail/Transactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ Transactor::reset(XRPAmount fee)
avi.copyBatchMetaData(executions);
ctx_.discard();
ApplyViewImpl& avi2 = dynamic_cast<ApplyViewImpl&>(ctx_.view());
avi2.setBatchMetaData(std::move(executions));
avi2.setBatchExecutions(std::move(executions));

auto const txnAcct =
view().peek(keylet::account(ctx_.tx.getAccountID(sfAccount)));
Expand Down
2 changes: 1 addition & 1 deletion src/xrpld/app/tx/detail/apply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ checkValidity(
auto const id = tx.getTransactionID();
auto const flags = router.getFlags(id);

// Validate Inner BatchTxn
// Validate tfInnerBatchTxn
if (rules.enabled(featureBatch) && tx.isFlag(tfInnerBatchTxn))
{
// batched transactions do not contain signatures
Expand Down
14 changes: 7 additions & 7 deletions src/xrpld/ledger/ApplyViewImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,23 @@ class ApplyViewImpl final : public detail::ApplyViewBase
}

void
addBatchExecutionMetaData(STObject&& batchExecution)
addBatchExecution(STObject&& batchExecution)
{
batchExecution_.push_back(std::move(batchExecution));
batchExecutions_.push_back(std::move(batchExecution));
}

void
setBatchMetaData(std::vector<STObject>&& batch)
setBatchExecutions(std::vector<STObject>&& batchExecutions)
{
batchExecution_ = std::move(batch);
batchExecutions_ = std::move(batchExecutions);
}

void
copyBatchMetaData(std::vector<STObject>& execution)
{
std::copy(
batchExecution_.begin(),
batchExecution_.end(),
batchExecutions_.begin(),
batchExecutions_.end(),
std::back_inserter(execution));
}

Expand All @@ -122,7 +122,7 @@ class ApplyViewImpl final : public detail::ApplyViewBase

private:
std::optional<STAmount> deliver_;
std::vector<STObject> batchExecution_;
std::vector<STObject> batchExecutions_;
std::optional<STObject> batchPrevAcctRootFields_;
};

Expand Down
7 changes: 4 additions & 3 deletions src/xrpld/ledger/detail/ApplyStateTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ ApplyStateTable::apply(
STTx const& tx,
TER ter,
std::optional<STAmount> const& deliver,
std::vector<STObject> const& batchExecution,
std::vector<STObject> const& batchExecutions,
std::optional<STObject> const& batchPrevAcctRootFields,
beast::Journal j)
{
Expand All @@ -130,10 +130,11 @@ ApplyStateTable::apply(
if (deliver)
meta.setDeliveredAmount(*deliver);

if (!batchExecution.empty())
if (!batchExecutions.empty())
{
assert(isBatch);
auto array = STArray{sfBatchExecutions};
for (auto element : batchExecution)
for (auto const& element : batchExecutions)
array.push_back(element);
meta.setBatchExecutions(array);
}
Expand Down
2 changes: 1 addition & 1 deletion src/xrpld/ledger/detail/ApplyViewImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void
ApplyViewImpl::apply(OpenView& to, STTx const& tx, TER ter, beast::Journal j)
{
items_.apply(
to, tx, ter, deliver_, batchExecution_, batchPrevAcctRootFields_, j);
to, tx, ter, deliver_, batchExecutions_, batchPrevAcctRootFields_, j);
}

std::size_t
Expand Down

0 comments on commit 8029c30

Please sign in to comment.