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/STArray.h>
26 #include <ripple/protocol/SystemParameters.h>
27 #include <ripple/protocol/nftPageMask.h>
51 JLOG(j.
fatal()) <<
"Invariant failed: fee paid was negative: "
60 JLOG(j.
fatal()) <<
"Invariant failed: fee paid exceeds system limit: "
69 JLOG(j.
fatal()) <<
"Invariant failed: fee paid is " << fee.
drops()
70 <<
" exceeds fee specified in transaction.";
94 switch (before->getType())
113 switch (
after->getType())
146 JLOG(j.
fatal()) <<
"Invariant failed: XRP net change was positive: "
154 JLOG(j.
fatal()) <<
"Invariant failed: XRP net change of " <<
drops_
155 <<
" doesn't match fee " << fee.
drops();
170 auto isBad = [](
STAmount const& balance) {
171 if (!balance.native())
174 auto const drops = balance.xrp();
205 JLOG(j.
fatal()) <<
"Invariant failed: incorrect account XRP balance";
222 if (pays < beast::zero)
225 if (gets < beast::zero)
229 return pays.
native() && gets.native();
232 if (before && before->getType() ==
ltOFFER)
249 JLOG(j.
fatal()) <<
"Invariant failed: offer with a bad amount";
264 auto isBad = [](
STAmount const& amount) {
265 if (!amount.native())
277 if (before && before->getType() ==
ltESCROW)
294 JLOG(j.
fatal()) <<
"Invariant failed: escrow specifies invalid amount";
327 JLOG(j.
fatal()) <<
"Invariant failed: account deletion "
328 "succeeded without deleting an account";
330 JLOG(j.
fatal()) <<
"Invariant failed: account deletion "
331 "succeeded but deleted multiple accounts!";
338 JLOG(j.
fatal()) <<
"Invariant failed: an account root was deleted";
350 if (before &&
after && before->getType() !=
after->getType())
355 switch (
after->getType())
394 JLOG(j.
fatal()) <<
"Invariant failed: ledger entry type mismatch";
399 JLOG(j.
fatal()) <<
"Invariant failed: invalid ledger entry type added";
435 JLOG(j.
fatal()) <<
"Invariant failed: an XRP trust line was created";
467 JLOG(j.
fatal()) <<
"Invariant failed: multiple accounts "
468 "created in a single transaction";
480 JLOG(j.
fatal()) <<
"Invariant failed: account created with "
481 "wrong starting sequence number";
487 JLOG(j.
fatal()) <<
"Invariant failed: account root created "
488 "by a non-Payment or by an unsuccessful transaction";
501 static constexpr
uint256 const accountBits = ~pageBits;
504 auto const account = sle->key() & accountBits;
505 auto const limit = sle->key() & pageBits;
509 if (account != (*prev & accountBits))
512 if (limit <= (*prev & pageBits))
518 if (account != (*next & accountBits))
521 if (limit >= (*next & pageBits))
525 for (
auto const& obj : sle->getFieldArray(
sfNFTokens))
530 if (
auto uri = obj[~
sfURI]; uri && uri->empty())
552 JLOG(j.
fatal()) <<
"Invariant failed: NFT page is improperly linked.";
558 JLOG(j.
fatal()) <<
"Invariant failed: NFT found in incorrect page.";
564 JLOG(j.
fatal()) <<
"Invariant failed: NFT contains empty URI.";
604 JLOG(j.
fatal()) <<
"Invariant failed: the number of minted tokens "
605 "changed without a mint transaction!";
611 JLOG(j.
fatal()) <<
"Invariant failed: the number of burned tokens "
612 "changed without a burn transaction!";
624 <<
"Invariant failed: successful minting didn't increase "
625 "the number of minted tokens.";
631 JLOG(j.
fatal()) <<
"Invariant failed: failed minting changed the "
632 "number of minted tokens.";
639 <<
"Invariant failed: minting changed the number of "
652 <<
"Invariant failed: successful burning didn't increase "
653 "the number of burned tokens.";
660 JLOG(j.
fatal()) <<
"Invariant failed: failed burning changed the "
661 "number of burned tokens.";
668 <<
"Invariant failed: burning changed the number of "
TxType getTxnType() const
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
@ ttACCOUNT_DELETE
This transaction type deletes an existing account.
@ ltTICKET
A ledger object which describes a ticket.
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 &)
const SF_UINT256 sfNFTokenID
@ ltLEDGER_HASHES
A ledger object that contains a list of ledger hashes.
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
constexpr value_type drops() const
Returns the number of drops.
const SF_UINT32 sfSequence
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
@ ltSIGNER_LIST
A ledger object which contains a signer list for an account.
const SF_UINT32 sfMintedNFTokens
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 &)
TxType
Transaction type identifiers.
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
std::uint32_t beforeMintedTotal
@ ltCHECK
A ledger object which describes a check.
@ ltFEE_SETTINGS
The ledger object which lists the network's fee settings.
std::uint32_t afterMintedTotal
constexpr XRPAmount INITIAL_XRP
Configure the native currency.
std::uint32_t accountSeq_
@ ltDIR_NODE
A ledger object which contains a list of object identifiers.
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
constexpr uint256 pageMask(std::string_view("0000000000000000000000000000000000000000ffffffffffffffffffffffff"))
const uint256 featureDeletableAccounts
@ ttPAYMENT
This transaction type executes a payment.
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
const SF_AMOUNT sfTakerPays
@ ltAMENDMENTS
The ledger object which lists details about amendments on the network.
const SF_AMOUNT sfLowLimit
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
@ ltOFFER
A ledger object which describes an offer on the DEX.
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 &)
std::uint32_t afterBurnedTotal
@ ltESCROW
A ledger object describing a single escrow.
@ ltNFTOKEN_OFFER
A ledger object which identifies an offer to buy or sell an NFT.
@ ttNFTOKEN_MINT
This transaction mints a new NFT.
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
@ ltDEPOSIT_PREAUTH
A ledger object which describes a deposit preauthorization.
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
const SF_AMOUNT sfTakerGets
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
A generic endpoint for log messages.
const SF_AMOUNT sfHighLimit
bool enabled(uint256 const &id) const
Returns true if a feature is enabled.
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 &)
std::uint32_t beforeBurnedTotal
bool native() const noexcept
@ ltNFTOKEN_PAGE
A ledger object which contains a list of NFTs.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
@ ltNEGATIVE_UNL
The ledger object which tracks the current negative UNL state.
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.
@ ltACCOUNT_ROOT
A ledger object which describes an account.
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
const SF_AMOUNT sfBalance
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
const SF_UINT256 sfNextPageMin
Issue const & xrpIssue()
Returns an asset specifier that represents XRP.
const SF_UINT256 sfPreviousPageMin
@ ttNFTOKEN_BURN
This transaction burns (i.e.
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 &)
@ ltRIPPLE_STATE
A ledger object which describes a bidirectional trust line.
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
const SF_UINT32 sfBurnedNFTokens
STAmount const & getFieldAmount(SField const &field) const
@ ltPAYCHAN
A ledger object describing a single unidirectional XRP payment channel.