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 REGISTER(MPTokensV2);
138 REGISTER(PermissionDelegationV1_1);
139 REGISTER(fixBatchInnerSigs);
140 REGISTER(fixCleanup3_1_3);
141 REGISTER(fixCleanup3_2_0);
142
143 // Obsolete but supported by libxrpl
144 REGISTER(CryptoConditionsSuite);
145 REGISTER(NonFungibleTokensV1);
146 REGISTER(fixNFTokenDirV1);
147 REGISTER(fixNFTokenNegOffer);
148
149 // Retired amendments
150 REGISTER(OwnerPaysFee); // Removed in xrpl 2.6.0 (https://github.com/XRPLF/rippled/pull/5435)
151 REGISTER(MultiSign);
152 REGISTER(TrustSetAuth);
153 REGISTER(FeeEscalation);
154 REGISTER(PayChan);
155 REGISTER(fix1368);
156 REGISTER(CryptoConditions);
157 REGISTER(Escrow);
158 REGISTER(TickSize);
159 REGISTER(fix1373);
160 REGISTER(EnforceInvariants);
161 REGISTER(SortedDirectories);
162 REGISTER(fix1201);
163 REGISTER(fix1512);
164 REGISTER(fix1523);
165 REGISTER(fix1528);
166 // NOLINTEND(readability-identifier-naming)
168};
169
170#undef REGISTER
171
176 std::shared_ptr<data::BackendInterface> backend_;
177
178 std::map<std::string, Amendment> supported_;
179 std::vector<Amendment> all_;
180
181public:
187 explicit AmendmentCenter(std::shared_ptr<data::BackendInterface> const& backend);
188
195 [[nodiscard]] bool
196 isSupported(AmendmentKey const& key) const final;
197
203 [[nodiscard]] std::map<std::string, Amendment> const&
204 getSupported() const final;
205
211 [[nodiscard]] std::vector<Amendment> const&
212 getAll() const final;
213
221 [[nodiscard]] bool
222 isEnabled(AmendmentKey const& key, uint32_t seq) const final;
223
232 [[nodiscard]] bool
233 isEnabled(boost::asio::yield_context yield, AmendmentKey const& key, uint32_t seq) const final;
234
243 [[nodiscard]] std::vector<bool>
244 isEnabled(
245 boost::asio::yield_context yield,
246 std::vector<AmendmentKey> const& keys,
247 uint32_t seq
248 ) const final;
249
256 [[nodiscard]] Amendment const&
257 getAmendment(AmendmentKey const& key) const final;
258
265 [[nodiscard]] Amendment const&
266 operator[](AmendmentKey const& key) const final;
267
268private:
269 [[nodiscard]] std::optional<std::vector<xrpl::uint256>>
270 fetchAmendmentsList(boost::asio::yield_context yield, uint32_t seq) const;
271};
272
273} // 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