Skip to content

Commit 27e4c4f

Browse files
committed
Add the LendingProtocol amendment. Make numFeatures automatic
1 parent 87d8881 commit 27e4c4f

File tree

3 files changed

+56
-27
lines changed

3 files changed

+56
-27
lines changed

include/xrpl/protocol/Feature.h

+26-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,27 @@ namespace detail {
8080
// Feature.cpp. Because it's only used to reserve storage, and determine how
8181
// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than
8282
// the actual number of amendments. A LogicError on startup will verify this.
83-
static constexpr std::size_t numFeatures = 88;
83+
static constexpr std::size_t numFeatures = 0
84+
#pragma push_macro("XRPL_FEATURE")
85+
#undef XRPL_FEATURE
86+
#pragma push_macro("XRPL_FIX")
87+
#undef XRPL_FIX
88+
#pragma push_macro("XRPL_RETIRE")
89+
#undef XRPL_RETIRE
90+
91+
#define XRPL_FEATURE(name, supported, vote) +1
92+
#define XRPL_FIX(name, supported, vote) +1
93+
#define XRPL_RETIRE(name) +1
94+
95+
#include <xrpl/protocol/detail/features.macro>
96+
97+
#undef XRPL_RETIRE
98+
#pragma pop_macro("XRPL_RETIRE")
99+
#undef XRPL_FIX
100+
#pragma pop_macro("XRPL_FIX")
101+
#undef XRPL_FEATURE
102+
#pragma pop_macro("XRPL_FEATURE")
103+
;
84104

85105
/** Amendments that this server supports and the default voting behavior.
86106
Whether they are enabled depends on the Rules defined in the validated
@@ -320,12 +340,17 @@ foreachFeature(FeatureBitset bs, F&& f)
320340
#undef XRPL_FEATURE
321341
#pragma push_macro("XRPL_FIX")
322342
#undef XRPL_FIX
343+
#pragma push_macro("XRPL_RETIRE")
344+
#undef XRPL_RETIRE
323345

324346
#define XRPL_FEATURE(name, supported, vote) extern uint256 const feature##name;
325347
#define XRPL_FIX(name, supported, vote) extern uint256 const fix##name;
348+
#define XRPL_RETIRE(name)
326349

327350
#include <xrpl/protocol/detail/features.macro>
328351

352+
#undef XRPL_RETIRE
353+
#pragma pop_macro("XRPL_RETIRE")
329354
#undef XRPL_FIX
330355
#pragma pop_macro("XRPL_FIX")
331356
#undef XRPL_FEATURE

include/xrpl/protocol/detail/features.macro

+23
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@
2323
#if !defined(XRPL_FIX)
2424
#error "undefined macro: XRPL_FIX"
2525
#endif
26+
#if !defined(XRPL_RETIRE)
27+
#error "undefined macro: XRPL_RETIRE"
28+
#endif
2629

2730
// Add new amendments to the top of this list.
2831
// Keep it sorted in reverse chronological order.
2932
// If you add an amendment here, then do not forget to increment `numFeatures`
3033
// in include/xrpl/protocol/Feature.h.
3134

35+
XRPL_FEATURE(LendingProtocol, Supported::yes, VoteBehavior::DefaultNo)
3236
XRPL_FEATURE(SingleAssetVault, Supported::yes, VoteBehavior::DefaultNo)
3337
XRPL_FIX (FrozenLPTokenTransfer, Supported::yes, VoteBehavior::DefaultNo)
3438
XRPL_FEATURE(DeepFreeze, Supported::yes, VoteBehavior::DefaultNo)
@@ -120,3 +124,22 @@ XRPL_FIX (NFTokenDirV1, Supported::yes, VoteBehavior::Obsolete)
120124
XRPL_FEATURE(NonFungibleTokensV1, Supported::yes, VoteBehavior::Obsolete)
121125
XRPL_FEATURE(CryptoConditionsSuite, Supported::yes, VoteBehavior::Obsolete)
122126

127+
// The following amendments have been active for at least two years. Their
128+
// pre-amendment code has been removed and the identifiers are deprecated.
129+
// All known amendments and amendments that may appear in a validated
130+
// ledger must be registered either here or above with the "active" amendments
131+
XRPL_RETIRE(MultiSign)
132+
XRPL_RETIRE(TrustSetAuth)
133+
XRPL_RETIRE(FeeEscalation)
134+
XRPL_RETIRE(PayChan)
135+
XRPL_RETIRE(CryptoConditions)
136+
XRPL_RETIRE(TickSize)
137+
XRPL_RETIRE(fix1368)
138+
XRPL_RETIRE(Escrow)
139+
XRPL_RETIRE(fix1373)
140+
XRPL_RETIRE(EnforceInvariants)
141+
XRPL_RETIRE(SortedDirectories)
142+
XRPL_RETIRE(fix1201)
143+
XRPL_RETIRE(fix1512)
144+
XRPL_RETIRE(fix1523)
145+
XRPL_RETIRE(fix1528)

src/libxrpl/protocol/Feature.cpp

+7-26
Original file line numberDiff line numberDiff line change
@@ -424,45 +424,26 @@ featureToName(uint256 const& f)
424424
#undef XRPL_FEATURE
425425
#pragma push_macro("XRPL_FIX")
426426
#undef XRPL_FIX
427+
#pragma push_macro("XRPL_RETIRE")
428+
#undef XRPL_RETIRE
427429

428430
#define XRPL_FEATURE(name, supported, vote) \
429431
uint256 const feature##name = registerFeature(#name, supported, vote);
430432
#define XRPL_FIX(name, supported, vote) \
431433
uint256 const fix##name = registerFeature("fix" #name, supported, vote);
434+
#define XRPL_RETIRE(name) \
435+
[[deprecated("The referenced amendment has been retired"), maybe_unused]] \
436+
uint256 const retired##name = retireFeature(#name);
432437

433438
#include <xrpl/protocol/detail/features.macro>
434439

440+
#undef XRPL_RETIRE
441+
#pragma pop_macro("XRPL_RETIRE")
435442
#undef XRPL_FIX
436443
#pragma pop_macro("XRPL_FIX")
437444
#undef XRPL_FEATURE
438445
#pragma pop_macro("XRPL_FEATURE")
439446

440-
// clang-format off
441-
442-
// The following amendments have been active for at least two years. Their
443-
// pre-amendment code has been removed and the identifiers are deprecated.
444-
// All known amendments and amendments that may appear in a validated
445-
// ledger must be registered either here or above with the "active" amendments
446-
[[deprecated("The referenced amendment has been retired"), maybe_unused]]
447-
uint256 const
448-
retiredMultiSign = retireFeature("MultiSign"),
449-
retiredTrustSetAuth = retireFeature("TrustSetAuth"),
450-
retiredFeeEscalation = retireFeature("FeeEscalation"),
451-
retiredPayChan = retireFeature("PayChan"),
452-
retiredCryptoConditions = retireFeature("CryptoConditions"),
453-
retiredTickSize = retireFeature("TickSize"),
454-
retiredFix1368 = retireFeature("fix1368"),
455-
retiredEscrow = retireFeature("Escrow"),
456-
retiredFix1373 = retireFeature("fix1373"),
457-
retiredEnforceInvariants = retireFeature("EnforceInvariants"),
458-
retiredSortedDirectories = retireFeature("SortedDirectories"),
459-
retiredFix1201 = retireFeature("fix1201"),
460-
retiredFix1512 = retireFeature("fix1512"),
461-
retiredFix1523 = retireFeature("fix1523"),
462-
retiredFix1528 = retireFeature("fix1528");
463-
464-
// clang-format on
465-
466447
// All of the features should now be registered, since variables in a cpp file
467448
// are initialized from top to bottom.
468449
//

0 commit comments

Comments
 (0)