xrpld
Loading...
Searching...
No Matches
InvariantCheckPrivilege.h
1#pragma once
2
3#include <xrpl/protocol/STTx.h>
4
5#include <type_traits>
6
7namespace xrpl {
8
9/*
10assert(enforce)
11
12There are several asserts (or XRPL_ASSERTs) in invariant check files that check
13a variable named `enforce` when an invariant fails. At first glance, those
14asserts may look incorrect, but they are not.
15
16Those asserts take advantage of two facts:
171. `asserts` are not (normally) executed in release builds.
182. Invariants should *never* fail, except in tests that specifically modify
19 the open ledger to break them.
20
21This makes `assert(enforce)` sort of a second-layer of invariant enforcement
22aimed at _developers_. It's designed to fire if a developer writes code that
23violates an invariant, and runs it in unit tests or a develop build that _does
24not have the relevant amendments enabled_. It's intentionally a pain in the neck
25so that bad code gets caught and fixed as early as possible.
26*/
27
28// Bitwise flags, 86 files, used in macros files
29// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
31 NoPriv = 0x0000, // The transaction can not do any of the enumerated operations
32 CreateAcct = 0x0001, // The transaction can create a new ACCOUNT_ROOT object.
33 CreatePseudoAcct = 0x0002, // The transaction can create a pseudo account,
34 // which implies createAcct
35 MustDeleteAcct = 0x0004, // The transaction must delete an ACCOUNT_ROOT object
36 MayDeleteAcct = 0x0008, // The transaction may delete an ACCOUNT_ROOT
37 // object, but does not have to
38 OverrideFreeze = 0x0010, // The transaction can override some freeze rules
39 ChangeNftCounts = 0x0020, // The transaction can mint or burn an NFT
40 CreateMptIssuance = 0x0040, // The transaction can create a new MPT issuance
41 DestroyMptIssuance = 0x0080, // The transaction can destroy an MPT issuance
42 MustAuthorizeMpt = 0x0100, // The transaction MUST create or delete an MPT
43 // object (except by issuer)
44 MayAuthorizeMpt = 0x0200, // The transaction MAY create or delete an MPT
45 // object (except by issuer)
46 MayDeleteMpt = 0x0400, // The transaction MAY delete an MPT object. May not create.
47 MustModifyVault = 0x0800, // The transaction must modify, delete or create, a vault
48 MayModifyVault = 0x1000, // The transaction MAY modify, delete or create, a vault
49 MayCreateMpt = 0x2000, // The transaction MAY create an MPT object, except for issuer.
50};
51
52constexpr Privilege
59
60bool
61hasPrivilege(STTx const& tx, Privilege priv);
62
63} // namespace xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
constexpr BaseUInt< Bits, Tag > operator|(BaseUInt< Bits, Tag > const &a, BaseUInt< Bits, Tag > const &b)
Definition base_uint.h:618
constexpr std::enable_if_t< std::is_integral_v< Dest > &&std::is_integral_v< Src >, Dest > safeCast(Src s) noexcept
Definition safe_cast.h:21
bool hasPrivilege(STTx const &tx, Privilege priv)