20#include <xrpld/app/tx/applySteps.h>
21#pragma push_macro("TRANSACTION")
25#define TRANSACTION(...)
26#define TRANSACTION_INCLUDE 1
28#include <xrpl/protocol/detail/transactions.macro>
31#pragma pop_macro("TRANSACTION")
36#include <xrpl/protocol/TxFormats.h>
47 UnknownTxnType(
TxType t) : txnType{t}
56with_txn_type(
TxType txnType, F&& f)
60#pragma push_macro("TRANSACTION")
63#define TRANSACTION(tag, value, name, ...) \
65 return f.template operator()<name>();
67#include <xrpl/protocol/detail/transactions.macro>
70#pragma pop_macro("TRANSACTION")
72 throw UnknownTxnType(txnType);
112 return T::makeTxConsequences(ctx);
121 return with_txn_type(ctx.
tx.
getTxnType(), [&]<
typename T>() {
122 auto const tec = Transactor::invokePreflight<T>(ctx);
123 return std::make_pair(
125 isTesSuccess(tec) ? consequences_helper<T>(ctx)
126 : TxConsequences{tec});
129 catch (UnknownTxnType
const& e)
134 <<
"Unknown transaction type in preflight: " << e.txnType;
135 UNREACHABLE(
"ripple::invoke_preflight : unknown transaction type");
148 return with_txn_type(ctx.
tx.
getTxnType(), [&]<
typename T>() {
152 auto const id = ctx.tx.getAccountID(sfAccount);
154 if (id != beast::zero)
156 TER result = T::checkSeqProxy(ctx.view, ctx.tx, ctx.j);
158 if (result != tesSUCCESS)
161 result = T::checkPriorTxAndLastLedger(ctx);
163 if (result != tesSUCCESS)
166 result = T::checkFee(ctx, calculateBaseFee(ctx.view, ctx.tx));
168 if (result != tesSUCCESS)
171 result = T::checkPermission(ctx.view, ctx.tx);
173 if (result != tesSUCCESS)
176 result = T::checkSign(ctx);
178 if (result != tesSUCCESS)
182 return T::preclaim(ctx);
185 catch (UnknownTxnType
const& e)
190 <<
"Unknown transaction type in preclaim: " << e.txnType;
191 UNREACHABLE(
"ripple::invoke_preclaim : unknown transaction type");
218 return with_txn_type(tx.
getTxnType(), [&]<
typename T>() {
219 return T::calculateBaseFee(view, tx);
222 catch (UnknownTxnType
const& e)
226 "ripple::invoke_calculateBaseFee : unknown transaction type");
232TxConsequences::TxConsequences(
NotTEC pfresult)
235 , potentialSpend_(
beast::zero)
237 , sequencesConsumed_(0)
241 "ripple::TxConsequences::TxConsequences : is not tesSUCCESS");
247 tx[sfFee].native() && !tx[sfFee].negative() ? tx[sfFee].xrp()
249 , potentialSpend_(
beast::zero)
250 , seqProx_(tx.getSeqProxy())
251 , sequencesConsumed_(tx.getSeqProxy().isSeq() ? 1 : 0)
278 return with_txn_type(ctx.
tx.
getTxnType(), [&]<
typename T>() {
283 catch (UnknownTxnType
const& e)
288 <<
"Unknown transaction type in apply: " << e.txnType;
289 UNREACHABLE(
"ripple::invoke_apply : unknown transaction type");
310 JLOG(j.
fatal()) <<
"apply (preflight): " << e.
what();
331 JLOG(j.
fatal()) <<
"apply (preflight): " << e.
what();
345 auto secondFlight = [&]() {
352 preflightResult.
flags,
359 preflightResult.
flags,
369 secondFlight.parentBatchId,
379 preflightResult.
flags,
387 return {*ctx, ctx->preflightResult};
392 JLOG(ctx->j.fatal()) <<
"apply (preclaim): " << e.
what();
421 return {preclaimResult.
ter,
false};
429 preclaimResult.
flags,
435 JLOG(preclaimResult.
j.
fatal()) <<
"apply: " << e.
what();
A generic endpoint for log messages.
State information when applying a tx.
beast::Journal const journal
Writable ledger view that accumulates state and tx changes.
Rules const & rules() const override
Returns the tx processing rules.
LedgerIndex seq() const
Returns the sequence number of the base ledger.
Rules controlling protocol behavior.
TxType getTxnType() const
A type that represents either a sequence value or a ticket value.
static XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
Class describing the consequences to the account of applying a transaction if the transaction consume...
std::uint32_t sequencesConsumed() const
Sequences consumed.
TxConsequences(NotTEC pfresult)
std::uint32_t sequencesConsumed_
Number of sequences consumed.
XRPAmount const & potentialSpend() const
Potential Spend.
bool isBlocker_
Describes how the transaction affects subsequent transactions.
Category
Describes how the transaction affects subsequent transactions.
@ blocker
Affects the ability of subsequent transactions to claim a fee.
XRPAmount potentialSpend_
Does NOT include the fee.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
PreflightResult preflight(Application &app, Rules const &rules, STTx const &tx, ApplyFlags flags, beast::Journal j)
Gate a transaction based on static information.
ApplyResult doApply(PreclaimResult const &preclaimResult, Application &app, OpenView &view)
Apply a prechecked transaction to an OpenView.
TxType
Transaction type identifiers.
XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
Compute only the expected base fee for a transaction.
static XRPAmount invoke_calculateBaseFee(ReadView const &view, STTx const &tx)
Calculates the base fee for a given transaction.
PreclaimResult preclaim(PreflightResult const &preflightResult, Application &app, OpenView const &view)
Gate a transaction based on static ledger information.
static std::pair< NotTEC, TxConsequences > invoke_preflight(PreflightContext const &ctx)
static TER invoke_preclaim(PreclaimContext const &ctx)
bool isTesSuccess(TER x) noexcept
static ApplyResult invoke_apply(ApplyContext &ctx)
TERSubset< CanCvtToTER > TER
TxConsequences consequences_helper(PreflightContext const &ctx)
XRPAmount calculateDefaultBaseFee(ReadView const &view, STTx const &tx)
Return the minimum fee that an "ordinary" transaction would pay.
State information when determining if a tx is likely to claim a fee.
Describes the results of the preclaim check.
ApplyFlags const flags
From the input - the flags.
TER const ter
Intermediate transaction result.
bool const likelyToClaimFee
Success flag - whether the transaction is likely to claim a fee.
ReadView const & view
From the input - the ledger view.
beast::Journal const j
From the input - the journal.
std::optional< uint256 const > const parentBatchId
From the input - the batch identifier, if part of a batch.
STTx const & tx
From the input - the transaction.
State information when preflighting a tx.
Describes the results of the preflight check.
Rules const rules
From the input - the rules.
ApplyFlags const flags
From the input - the flags.
beast::Journal const j
From the input - the journal.
NotTEC const ter
Intermediate transaction result.
std::optional< uint256 const > const parentBatchId
From the input - the batch identifier, if part of a batch.
STTx const & tx
From the input - the transaction.