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
34#define REGISTER(name) \
35 inline static impl::WritingAmendmentKey const name = \
36 impl::WritingAmendmentKey(std::string(BOOST_PP_STRINGIZE(name)))
37
38namespace data {
39namespace impl {
40
41struct WritingAmendmentKey : AmendmentKey {
42 explicit WritingAmendmentKey(std::string amendmentName);
43};
44
45} // namespace impl
46
50struct Amendments {
51 // NOTE: if Clio wants to report it supports an Amendment it should be listed here.
52 // Whether an amendment is obsolete and/or supported by libxrpl is extracted directly from
53 // libxrpl. If an amendment is in the list below it just means Clio did whatever changes needed
54 // to support it. Most of the time it's going to be no changes at all.
55
57 // NOLINTBEGIN(readability-identifier-naming)
58 REGISTER(Flow);
59 REGISTER(FlowCross);
60 REGISTER(fix1513);
61 REGISTER(DepositAuth);
62 REGISTER(Checks);
63 REGISTER(fix1571);
64 REGISTER(fix1543);
65 REGISTER(fix1623);
66 REGISTER(DepositPreauth);
67 REGISTER(fix1515);
68 REGISTER(fix1578);
69 REGISTER(MultiSignReserve);
70 REGISTER(fixTakerDryOfferRemoval);
71 REGISTER(fixMasterKeyAsRegularKey);
72 REGISTER(fixCheckThreading);
73 REGISTER(fixPayChanRecipientOwnerDir);
74 REGISTER(DeletableAccounts);
75 REGISTER(fixQualityUpperBound);
76 REGISTER(RequireFullyCanonicalSig);
77 REGISTER(fix1781);
78 REGISTER(HardenedValidations);
79 REGISTER(fixAmendmentMajorityCalc);
80 REGISTER(NegativeUNL);
81 REGISTER(TicketBatch);
82 REGISTER(FlowSortStrands);
83 REGISTER(fixSTAmountCanonicalize);
84 REGISTER(fixRmSmallIncreasedQOffers);
85 REGISTER(CheckCashMakesTrustLine);
86 REGISTER(ExpandedSignerList);
87 REGISTER(NonFungibleTokensV1_1);
88 REGISTER(fixTrustLinesToSelf);
89 REGISTER(fixRemoveNFTokenAutoTrustLine);
90 REGISTER(ImmediateOfferKilled);
91 REGISTER(DisallowIncoming);
92 REGISTER(XRPFees);
93 REGISTER(fixUniversalNumber);
94 REGISTER(fixNonFungibleTokensV1_2);
95 REGISTER(fixNFTokenRemint);
96 REGISTER(fixReducedOffersV1);
97 REGISTER(Clawback);
98 REGISTER(AMM);
99 REGISTER(XChainBridge);
100 REGISTER(fixDisallowIncomingV1);
101 REGISTER(DID);
102 REGISTER(fixFillOrKill);
103 REGISTER(fixNFTokenReserve);
104 REGISTER(fixInnerObjTemplate);
105 REGISTER(fixAMMOverflowOffer);
106 REGISTER(PriceOracle);
107 REGISTER(fixEmptyDID);
108 REGISTER(fixXChainRewardRounding);
109 REGISTER(fixPreviousTxnID);
110 REGISTER(fixAMMv1_1);
111 REGISTER(NFTokenMintOffer);
112 REGISTER(fixReducedOffersV2);
113 REGISTER(fixEnforceNFTokenTrustline);
114 REGISTER(fixInnerObjTemplate2);
115 REGISTER(fixNFTokenPageLinks);
116 REGISTER(InvariantsV1_1);
117 REGISTER(MPTokensV1);
118 REGISTER(fixAMMv1_2);
119 REGISTER(AMMClawback);
120 REGISTER(Credentials);
121 REGISTER(DynamicNFT);
122 REGISTER(PermissionedDomains);
123 REGISTER(fixInvalidTxFlags);
124 REGISTER(fixFrozenLPTokenTransfer);
125 REGISTER(DeepFreeze);
126 REGISTER(PermissionDelegation);
127 REGISTER(fixPayChanCancelAfter);
128 REGISTER(Batch);
129 REGISTER(PermissionedDEX);
130 REGISTER(SingleAssetVault);
131 REGISTER(TokenEscrow);
132 REGISTER(fixAMMv1_3);
133 REGISTER(fixEnforceNFTokenTrustlineV2);
134 REGISTER(fixAMMClawbackRounding);
135 REGISTER(fixMPTDeliveredAmount);
136 REGISTER(fixPriceOracleOrder);
137 REGISTER(DynamicMPT);
138 REGISTER(fixDelegateV1_1);
139 REGISTER(fixDirectoryLimit);
140 REGISTER(fixIncludeKeyletFields);
141 REGISTER(fixTokenEscrowV1);
142 REGISTER(LendingProtocol);
143 REGISTER(MPTokensV2);
144 REGISTER(PermissionDelegationV1_1);
145 REGISTER(fixBatchInnerSigs);
146 REGISTER(fixCleanup3_1_3);
147 REGISTER(fixCleanup3_2_0);
148 REGISTER(ConfidentialTransfer);
149 REGISTER(LendingProtocolV1_1);
150 REGISTER(BatchV1_1);
151 REGISTER(Sponsor);
152 REGISTER(fixCleanup3_3_0);
153 REGISTER(fixCleanup3_4_0);
154
155 // These amendments are added because of libxrpl 3.5.0
156 REGISTER(fixBatchV1_2);
157 REGISTER(fixCleanup3_5_0);
158
159 // These amendments are added because of libxrpl 3.5.0, but they are not supported by xrpld
160 // 3.5.0 yet. They change the protocol, so Clio might need some work once xrpld supports them
161 REGISTER(ConfidentialMPTKeyRotation);
162 REGISTER(LendingProtocolV1_2);
163 REGISTER(SmartEscrow);
164 REGISTER(Cosign);
165
166 // Obsolete but supported by libxrpl
167 REGISTER(CryptoConditionsSuite);
168 REGISTER(NonFungibleTokensV1);
169 REGISTER(fixNFTokenDirV1);
170 REGISTER(fixNFTokenNegOffer);
171
172 // Retired amendments
173 REGISTER(OwnerPaysFee); // Removed in xrpl 2.6.0 (https://github.com/XRPLF/rippled/pull/5435)
174 REGISTER(MultiSign);
175 REGISTER(TrustSetAuth);
176 REGISTER(FeeEscalation);
177 REGISTER(PayChan);
178 REGISTER(fix1368);
179 REGISTER(CryptoConditions);
180 REGISTER(Escrow);
181 REGISTER(TickSize);
182 REGISTER(fix1373);
183 REGISTER(EnforceInvariants);
184 REGISTER(SortedDirectories);
185 REGISTER(fix1201);
186 REGISTER(fix1512);
187 REGISTER(fix1523);
188 REGISTER(fix1528);
189 // NOLINTEND(readability-identifier-naming)
191};
192
193#undef REGISTER
194
199 std::shared_ptr<data::BackendInterface> backend_;
200
201 std::map<std::string, Amendment> supported_;
202 std::vector<Amendment> all_;
203
204public:
210 explicit AmendmentCenter(std::shared_ptr<data::BackendInterface> const& backend);
211
218 [[nodiscard]] bool
219 isSupported(AmendmentKey const& key) const final;
220
226 [[nodiscard]] std::map<std::string, Amendment> const&
227 getSupported() const final;
228
234 [[nodiscard]] std::vector<Amendment> const&
235 getAll() const final;
236
244 [[nodiscard]] bool
245 isEnabled(AmendmentKey const& key, uint32_t seq) const final;
246
255 [[nodiscard]] bool
256 isEnabled(boost::asio::yield_context yield, AmendmentKey const& key, uint32_t seq) const final;
257
266 [[nodiscard]] std::vector<bool>
267 isEnabled(
268 boost::asio::yield_context yield,
269 std::vector<AmendmentKey> const& keys,
270 uint32_t seq
271 ) const final;
272
279 [[nodiscard]] Amendment const&
280 getAmendment(AmendmentKey const& key) const final;
281
288 [[nodiscard]] Amendment const&
289 operator[](AmendmentKey const& key) const final;
290
291private:
292 [[nodiscard]] std::optional<std::vector<xrpl::uint256>>
293 fetchAmendmentsList(boost::asio::yield_context yield, uint32_t seq) const;
294};
295
296} // 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:288
AmendmentKey(std::convertible_to< std::string > auto &&val)
Construct a new AmendmentKey.
Definition Types.hpp:295
Represents an amendment in the XRPL.
Definition Types.hpp:257
List of supported amendments.
Definition AmendmentCenter.hpp:50