Always check the sequence when adding to the transaction queue:

* If multiple transactions are queued for the account, change the
  account's sequence number in a temporary view before processing the
  transaction.
* Adds a new "at()" interface to STObject which is identical to the
  operator[], but easier to write and read when dealing with ptrs.
* Split the TxQ tests into two suites to speed up parallel run times.
This commit is contained in:
Edward Hennis
2020-10-08 19:15:16 -04:00
committed by manojsdoshi
parent a3f2196d4e
commit 77ec62e9c8
7 changed files with 146 additions and 169 deletions

View File

@@ -1120,6 +1120,14 @@ TxQ::apply(
std::min(balance - std::min(balance, reserve), potentialSpend);
assert(potentialTotalSpend > XRPAmount{0});
sleBump->setFieldAmount(sfBalance, balance - potentialTotalSpend);
// The transaction's sequence/ticket will be valid when the other
// transactions in the queue have been processed. If the tx has a
// sequence, set the account to match it. If it has a ticket, use
// the next queueable sequence, which is the closest approximation
// to the most successful case.
sleBump->at(sfSequence) = txSeqProx.isSeq()
? txSeqProx.value()
: nextQueuableSeqImpl(sleAccount, lock).value();
}
}
@@ -1134,8 +1142,8 @@ TxQ::apply(
// Note that earlier code has already verified that the sequence/ticket
// is valid. So we use a special entry point that runs all of the
// preclaim checks with the exception of the sequence check.
auto const pcresult = ForTxQ::preclaimWithoutSeqCheck(
pfresult, app, multiTxn ? multiTxn->openView : view);
auto const pcresult =
preclaim(pfresult, app, multiTxn ? multiTxn->openView : view);
if (!pcresult.likelyToClaimFee)
return {pcresult.ter, false};