Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
AmendmentCenter.hpp
1#pragma once
2
3#include "data/AmendmentCenterInterface.hpp"
4#include "data/BackendInterface.hpp"
5#include "data/Types.hpp"
6
7#include <boost/asio/spawn.hpp>
8#include <boost/preprocessor.hpp>
9#include <boost/preprocessor/seq/for_each.hpp>
10#include <boost/preprocessor/stringize.hpp>
11#include <boost/preprocessor/variadic/to_seq.hpp>
12#include <xrpl/basics/Slice.h>
13#include <xrpl/basics/base_uint.h>
14#include <xrpl/protocol/Feature.h>
15#include <xrpl/protocol/Indexes.h>
16#include <xrpl/protocol/SField.h>
17#include <xrpl/protocol/STLedgerEntry.h>
18#include <xrpl/protocol/Serializer.h>
19#include <xrpl/protocol/digest.h>
20
21#include <cstdint>
22#include <map>
23#include <memory>
24#include <optional>
25#include <string>
26#include <vector>
27
28#define REGISTER(name) \
29 inline static impl::WritingAmendmentKey const name = \
30 impl::WritingAmendmentKey(std::string(BOOST_PP_STRINGIZE(name)))
31
32namespace data {
33namespace impl {
34
35struct WritingAmendmentKey : AmendmentKey {
36 explicit WritingAmendmentKey(std::string amendmentName);
37};
38
39} // namespace impl
40
44struct Amendments {
45 // NOTE: if Clio wants to report it supports an Amendment it should be listed here.
46 // Whether an amendment is obsolete and/or supported by libxrpl is extracted directly from
47 // libxrpl. If an amendment is in the list below it just means Clio did whatever changes needed
48 // to support it. Most of the time it's going to be no changes at all.
49
51 // NOLINTBEGIN(readability-identifier-naming)
52 REGISTER(Flow);
53 REGISTER(FlowCross);
54 REGISTER(fix1513);
55 REGISTER(DepositAuth);
56 REGISTER(Checks);
57 REGISTER(fix1571);
58 REGISTER(fix1543);
59 REGISTER(fix1623);
60 REGISTER(DepositPreauth);
61 REGISTER(fix1515);
62 REGISTER(fix1578);
63 REGISTER(MultiSignReserve);
64 REGISTER(fixTakerDryOfferRemoval);
65 REGISTER(fixMasterKeyAsRegularKey);
66 REGISTER(fixCheckThreading);
67 REGISTER(fixPayChanRecipientOwnerDir);
68 REGISTER(DeletableAccounts);
69 REGISTER(fixQualityUpperBound);
70 REGISTER(RequireFullyCanonicalSig);
71 REGISTER(fix1781);
72 REGISTER(HardenedValidations);
73 REGISTER(fixAmendmentMajorityCalc);
74 REGISTER(NegativeUNL);
75 REGISTER(TicketBatch);
76 REGISTER(FlowSortStrands);
77 REGISTER(fixSTAmountCanonicalize);
78 REGISTER(fixRmSmallIncreasedQOffers);
79 REGISTER(CheckCashMakesTrustLine);
80 REGISTER(ExpandedSignerList);
81 REGISTER(NonFungibleTokensV1_1);
82 REGISTER(fixTrustLinesToSelf);
83 REGISTER(fixRemoveNFTokenAutoTrustLine);
84 REGISTER(ImmediateOfferKilled);
85 REGISTER(DisallowIncoming);
86 REGISTER(XRPFees);
87 REGISTER(fixUniversalNumber);
88 REGISTER(fixNonFungibleTokensV1_2);
89 REGISTER(fixNFTokenRemint);
90 REGISTER(fixReducedOffersV1);
91 REGISTER(Clawback);
92 REGISTER(AMM);
93 REGISTER(XChainBridge);
94 REGISTER(fixDisallowIncomingV1);
95 REGISTER(DID);
96 REGISTER(fixFillOrKill);
97 REGISTER(fixNFTokenReserve);
98 REGISTER(fixInnerObjTemplate);
99 REGISTER(fixAMMOverflowOffer);
100 REGISTER(PriceOracle);
101 REGISTER(fixEmptyDID);
102 REGISTER(fixXChainRewardRounding);
103 REGISTER(fixPreviousTxnID);
104 REGISTER(fixAMMv1_1);
105 REGISTER(NFTokenMintOffer);
106 REGISTER(fixReducedOffersV2);
107 REGISTER(fixEnforceNFTokenTrustline);
108 REGISTER(fixInnerObjTemplate2);
109 REGISTER(fixNFTokenPageLinks);
110 REGISTER(InvariantsV1_1);
111 REGISTER(MPTokensV1);
112 REGISTER(fixAMMv1_2);
113 REGISTER(AMMClawback);
114 REGISTER(Credentials);
115 REGISTER(DynamicNFT);
116 REGISTER(PermissionedDomains);
117 REGISTER(fixInvalidTxFlags);
118 REGISTER(fixFrozenLPTokenTransfer);
119 REGISTER(DeepFreeze);
120 REGISTER(PermissionDelegation);
121 REGISTER(fixPayChanCancelAfter);
122 REGISTER(Batch);
123 REGISTER(PermissionedDEX);
124 REGISTER(SingleAssetVault);
125 REGISTER(TokenEscrow);
126 REGISTER(fixAMMv1_3);
127 REGISTER(fixEnforceNFTokenTrustlineV2);
128 REGISTER(fixAMMClawbackRounding);
129 REGISTER(fixMPTDeliveredAmount);
130 REGISTER(fixPriceOracleOrder);
131 REGISTER(DynamicMPT);
132 REGISTER(fixDelegateV1_1);
133 REGISTER(fixDirectoryLimit);
134 REGISTER(fixIncludeKeyletFields);
135 REGISTER(fixTokenEscrowV1);
136 REGISTER(LendingProtocol);
137
138 // Obsolete but supported by libxrpl
139 REGISTER(CryptoConditionsSuite);
140 REGISTER(NonFungibleTokensV1);
141 REGISTER(fixNFTokenDirV1);
142 REGISTER(fixNFTokenNegOffer);
143
144 // Retired amendments
145 REGISTER(OwnerPaysFee); // Removed in xrpl 2.6.0 (https://github.com/XRPLF/rippled/pull/5435)
146 REGISTER(MultiSign);
147 REGISTER(TrustSetAuth);
148 REGISTER(FeeEscalation);
149 REGISTER(PayChan);
150 REGISTER(fix1368);
151 REGISTER(CryptoConditions);
152 REGISTER(Escrow);
153 REGISTER(TickSize);
154 REGISTER(fix1373);
155 REGISTER(EnforceInvariants);
156 REGISTER(SortedDirectories);
157 REGISTER(fix1201);
158 REGISTER(fix1512);
159 REGISTER(fix1523);
160 REGISTER(fix1528);
161 REGISTER(fixBatchInnerSigs);
162 // NOLINTEND(readability-identifier-naming)
164};
165
166#undef REGISTER
167
172 std::shared_ptr<data::BackendInterface> backend_;
173
174 std::map<std::string, Amendment> supported_;
175 std::vector<Amendment> all_;
176
177public:
183 explicit AmendmentCenter(std::shared_ptr<data::BackendInterface> const& backend);
184
191 [[nodiscard]] bool
192 isSupported(AmendmentKey const& key) const final;
193
199 [[nodiscard]] std::map<std::string, Amendment> const&
200 getSupported() const final;
201
207 [[nodiscard]] std::vector<Amendment> const&
208 getAll() const final;
209
217 [[nodiscard]] bool
218 isEnabled(AmendmentKey const& key, uint32_t seq) const final;
219
228 [[nodiscard]] bool
229 isEnabled(boost::asio::yield_context yield, AmendmentKey const& key, uint32_t seq) const final;
230
239 [[nodiscard]] std::vector<bool>
240 isEnabled(
241 boost::asio::yield_context yield,
242 std::vector<AmendmentKey> const& keys,
243 uint32_t seq
244 ) const final;
245
252 [[nodiscard]] Amendment const&
253 getAmendment(AmendmentKey const& key) const final;
254
261 [[nodiscard]] Amendment const&
262 operator[](AmendmentKey const& key) const final;
263
264private:
265 [[nodiscard]] std::optional<std::vector<ripple::uint256>>
266 fetchAmendmentsList(boost::asio::yield_context yield, uint32_t seq) const;
267};
268
269} // namespace data
The interface of an amendment center.
Definition AmendmentCenterInterface.hpp:17
Amendment const & getAmendment(AmendmentKey const &key) const final
Get an amendment.
Definition AmendmentCenter.cpp:194
Amendment const & operator[](AmendmentKey const &key) const final
Get an amendment by its key.
Definition AmendmentCenter.cpp:205
bool isEnabled(AmendmentKey const &key, uint32_t seq) const final
Check whether an amendment was/is enabled for a given sequence.
Definition AmendmentCenter.cpp:144
bool isSupported(AmendmentKey const &key) const final
Check whether an amendment is supported by Clio.
Definition AmendmentCenter.cpp:126
std::map< std::string, Amendment > const & getSupported() const final
Get all supported amendments as a map.
Definition AmendmentCenter.cpp:132
AmendmentCenter(std::shared_ptr< data::BackendInterface > const &backend)
Construct a new AmendmentCenter instance.
Definition AmendmentCenter.cpp:88
std::vector< Amendment > const & getAll() const final
Get all known amendments.
Definition AmendmentCenter.cpp:138
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:56
A helper for amendment name to feature conversions.
Definition Types.hpp:285
AmendmentKey(std::convertible_to< std::string > auto &&val)
Construct a new AmendmentKey.
Definition Types.hpp:292
Represents an amendment in the XRPL.
Definition Types.hpp:254
List of supported amendments.
Definition AmendmentCenter.hpp:44