20 #include <ripple/app/tx/impl/InvariantCheck.h>
21 #include <ripple/basics/FeeUnits.h>
22 #include <ripple/basics/Log.h>
23 #include <ripple/ledger/ReadView.h>
24 #include <ripple/protocol/Feature.h>
25 #include <ripple/protocol/SystemParameters.h>
49 JLOG(j.
fatal()) <<
"Invariant failed: fee paid was negative: "
58 JLOG(j.
fatal()) <<
"Invariant failed: fee paid exceeds system limit: "
67 JLOG(j.
fatal()) <<
"Invariant failed: fee paid is " << fee.
drops()
68 <<
" exceeds fee specified in transaction.";
92 switch (before->getType())
111 switch (
after->getType())
144 JLOG(j.
fatal()) <<
"Invariant failed: XRP net change was positive: "
152 JLOG(j.
fatal()) <<
"Invariant failed: XRP net change of " <<
drops_
153 <<
" doesn't match fee " << fee.
drops();
168 auto isBad = [](
STAmount const& balance) {
169 if (!balance.native())
172 auto const drops = balance.xrp();
203 JLOG(j.
fatal()) <<
"Invariant failed: incorrect account XRP balance";
220 if (pays < beast::zero)
223 if (gets < beast::zero)
227 return pays.
native() && gets.native();
230 if (before && before->getType() ==
ltOFFER)
247 JLOG(j.
fatal()) <<
"Invariant failed: offer with a bad amount";
262 auto isBad = [](
STAmount const& amount) {
263 if (!amount.native())
275 if (before && before->getType() ==
ltESCROW)
292 JLOG(j.
fatal()) <<
"Invariant failed: escrow specifies invalid amount";
325 JLOG(j.
fatal()) <<
"Invariant failed: account deletion "
326 "succeeded without deleting an account";
328 JLOG(j.
fatal()) <<
"Invariant failed: account deletion "
329 "succeeded but deleted multiple accounts!";
336 JLOG(j.
fatal()) <<
"Invariant failed: an account root was deleted";
348 if (before &&
after && before->getType() !=
after->getType())
353 switch (
after->getType())
390 JLOG(j.
fatal()) <<
"Invariant failed: ledger entry type mismatch";
395 JLOG(j.
fatal()) <<
"Invariant failed: invalid ledger entry type added";
431 JLOG(j.
fatal()) <<
"Invariant failed: an XRP trust line was created";
463 JLOG(j.
fatal()) <<
"Invariant failed: multiple accounts "
464 "created in a single transaction";
476 JLOG(j.
fatal()) <<
"Invariant failed: account created with "
477 "wrong starting sequence number";
483 JLOG(j.
fatal()) <<
"Invariant failed: account root created "
484 "by a non-Payment or by an unsuccessful transaction";
TxType getTxnType() const
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
constexpr value_type drops() const
Returns the number of drops.
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
const SF_U32 sfSequence(access, STI_UINT32, 4, "Sequence")
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
const SF_Amount sfTakerPays(access, STI_AMOUNT, 4, "TakerPays")
const SF_Amount sfAmount(access, STI_AMOUNT, 1, "Amount")
const SF_Amount sfHighLimit(access, STI_AMOUNT, 7, "HighLimit")
const SF_Amount sfLowLimit(access, STI_AMOUNT, 6, "LowLimit")
constexpr XRPAmount INITIAL_XRP
Configure the native currency.
std::uint32_t accountSeq_
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
const uint256 featureDeletableAccounts
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
A generic endpoint for log messages.
bool enabled(uint256 const &id) const
Returns true if a feature is enabled.
const SF_Amount sfFee(access, STI_AMOUNT, 8, "Fee")
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
bool native() const noexcept
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
const SF_Amount sfBalance(access, STI_AMOUNT, 2, "Balance")
LedgerIndex seq() const
Returns the sequence number of the base ledger.
std::uint32_t accountsCreated_
virtual Rules const & rules() const =0
Returns the tx processing rules.
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
const SF_Amount sfTakerGets(access, STI_AMOUNT, 5, "TakerGets")
Issue const & xrpIssue()
Returns an asset specifier that represents XRP.
static bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
std::uint32_t accountsDeleted_
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
@ ltDIR_NODE
Directory node.
STAmount const & getFieldAmount(SField const &field) const