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