rippled
Loading...
Searching...
No Matches
include
xrpl
tx
invariants
InvariantCheckPrivilege.h
1
#pragma once
2
3
#include <xrpl/protocol/STTx.h>
4
5
#include <
type_traits
>
6
7
namespace
xrpl
{
8
9
/*
10
assert(enforce)
11
12
There are several asserts (or XRPL_ASSERTs) in invariant check files that check
13
a variable named `enforce` when an invariant fails. At first glance, those
14
asserts may look incorrect, but they are not.
15
16
Those asserts take advantage of two facts:
17
1. `asserts` are not (normally) executed in release builds.
18
2. Invariants should *never* fail, except in tests that specifically modify
19
the open ledger to break them.
20
21
This makes `assert(enforce)` sort of a second-layer of invariant enforcement
22
aimed at _developers_. It's designed to fire if a developer writes code that
23
violates an invariant, and runs it in unit tests or a develop build that _does
24
not have the relevant amendments enabled_. It's intentionally a pain in the neck
25
so that bad code gets caught and fixed as early as possible.
26
*/
27
28
enum
Privilege
{
29
noPriv
= 0x0000,
// The transaction can not do any of the enumerated operations
30
createAcct
= 0x0001,
// The transaction can create a new ACCOUNT_ROOT object.
31
createPseudoAcct
= 0x0002,
// The transaction can create a pseudo account,
32
// which implies createAcct
33
mustDeleteAcct
= 0x0004,
// The transaction must delete an ACCOUNT_ROOT object
34
mayDeleteAcct
= 0x0008,
// The transaction may delete an ACCOUNT_ROOT
35
// object, but does not have to
36
overrideFreeze
= 0x0010,
// The transaction can override some freeze rules
37
changeNFTCounts
= 0x0020,
// The transaction can mint or burn an NFT
38
createMPTIssuance
= 0x0040,
// The transaction can create a new MPT issuance
39
destroyMPTIssuance
= 0x0080,
// The transaction can destroy an MPT issuance
40
mustAuthorizeMPT
= 0x0100,
// The transaction MUST create or delete an MPT
41
// object (except by issuer)
42
mayAuthorizeMPT
= 0x0200,
// The transaction MAY create or delete an MPT
43
// object (except by issuer)
44
mayDeleteMPT
= 0x0400,
// The transaction MAY delete an MPT object. May not create.
45
mustModifyVault
= 0x0800,
// The transaction must modify, delete or create, a vault
46
mayModifyVault
= 0x1000,
// The transaction MAY modify, delete or create, a vault
47
};
48
49
constexpr
Privilege
50
operator|
(
Privilege
lhs,
Privilege
rhs)
51
{
52
return
safe_cast<Privilege>(
53
safe_cast
<
std::underlying_type_t<Privilege>
>(lhs) |
54
safe_cast
<
std::underlying_type_t<Privilege>
>(rhs));
55
}
56
57
bool
58
hasPrivilege
(STTx
const
& tx,
Privilege
priv);
59
60
}
// namespace xrpl
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::operator|
constexpr base_uint< Bits, Tag > operator|(base_uint< Bits, Tag > const &a, base_uint< Bits, Tag > const &b)
Definition
base_uint.h:587
xrpl::Privilege
Privilege
Definition
InvariantCheckPrivilege.h:28
xrpl::mayModifyVault
@ mayModifyVault
Definition
InvariantCheckPrivilege.h:46
xrpl::mustModifyVault
@ mustModifyVault
Definition
InvariantCheckPrivilege.h:45
xrpl::mayDeleteAcct
@ mayDeleteAcct
Definition
InvariantCheckPrivilege.h:34
xrpl::destroyMPTIssuance
@ destroyMPTIssuance
Definition
InvariantCheckPrivilege.h:39
xrpl::createAcct
@ createAcct
Definition
InvariantCheckPrivilege.h:30
xrpl::changeNFTCounts
@ changeNFTCounts
Definition
InvariantCheckPrivilege.h:37
xrpl::mustDeleteAcct
@ mustDeleteAcct
Definition
InvariantCheckPrivilege.h:33
xrpl::createPseudoAcct
@ createPseudoAcct
Definition
InvariantCheckPrivilege.h:31
xrpl::mayDeleteMPT
@ mayDeleteMPT
Definition
InvariantCheckPrivilege.h:44
xrpl::createMPTIssuance
@ createMPTIssuance
Definition
InvariantCheckPrivilege.h:38
xrpl::mustAuthorizeMPT
@ mustAuthorizeMPT
Definition
InvariantCheckPrivilege.h:40
xrpl::noPriv
@ noPriv
Definition
InvariantCheckPrivilege.h:29
xrpl::overrideFreeze
@ overrideFreeze
Definition
InvariantCheckPrivilege.h:36
xrpl::mayAuthorizeMPT
@ mayAuthorizeMPT
Definition
InvariantCheckPrivilege.h:42
xrpl::hasPrivilege
bool hasPrivilege(STTx const &tx, Privilege priv)
Definition
InvariantCheck.cpp:32
xrpl::safe_cast
constexpr std::enable_if_t< std::is_integral_v< Dest > &&std::is_integral_v< Src >, Dest > safe_cast(Src s) noexcept
Definition
safe_cast.h:21
type_traits
std::underlying_type_t
Generated by
1.9.8