3535 *
3636 * Steps required to add new features to the code:
3737 *
38- * 1) In this file, increment `numFeatures` and add a uint256 declaration
39- * for the feature at the bottom
40- * 2) Add a uint256 definition for the feature to the corresponding source
41- * file (Feature.cpp). Use `registerFeature` to create the feature with
42- * the feature's name, `Supported::no`, and `VoteBehavior::DefaultNo`. This
43- * should be the only place the feature's name appears in code as a string.
44- * 3) Use the uint256 as the parameter to `view.rules.enabled()` to
45- * control flow into new code that this feature limits.
46- * 4) If the feature development is COMPLETE, and the feature is ready to be
47- * SUPPORTED, change the `registerFeature` parameter to Supported::yes.
48- * 5) When the feature is ready to be ENABLED, change the `registerFeature`
49- * parameter to `VoteBehavior::DefaultYes`.
50- * In general, any newly supported amendments (`Supported::yes`) should have
51- * a `VoteBehavior::DefaultNo` for at least one full release cycle. High
52- * priority bug fixes can be an exception to this rule of thumb.
38+ * 1) Add the appropriate XRPL_FEATURE or XRPL_FIX macro definition for the
39+ * feature to features.macro with the feature's name, `Supported::no`, and
40+ * `VoteBehavior::DefaultNo`.
41+ *
42+ * 2) Use the generated variable name as the parameter to `view.rules.enabled()`
43+ * to control flow into new code that this feature limits. (featureName or
44+ * fixName)
45+ *
46+ * 3) If the feature development is COMPLETE, and the feature is ready to be
47+ * SUPPORTED, change the macro parameter in features.macro to Supported::yes.
48+ *
49+ * 4) In general, any newly supported amendments (`Supported::yes`) should have
50+ * a `VoteBehavior::DefaultNo` indefinitely so that external governance can
51+ * make the decision on when to activate it. High priority bug fixes can be
52+ * an exception to this rule. In such cases, ensure the fix has been
53+ * clearly communicated to the community using appropriate channels,
54+ * then change the macro parameter in features.macro to
55+ * `VoteBehavior::DefaultYes`. The communication process is beyond
56+ * the scope of these instructions.
57+ *
5358 *
5459 * When a feature has been enabled for several years, the conditional code
5560 * may be removed, and the feature "retired". To retire a feature:
56- * 1) Remove the uint256 declaration from this file.
57- * 2) MOVE the uint256 definition in Feature.cpp to the "retired features"
58- * section at the end of the file.
59- * 3) CHANGE the name of the variable to start with "retired".
60- * 4) CHANGE the parameters of the `registerFeature` call to `Supported::yes`
61- * and `VoteBehavior::DefaultNo`.
61+ *
62+ * 1) MOVE the macro definition in features.macro to the "retired features"
63+ * section at the end of the file, and change the macro to XRPL_RETIRE.
64+ *
6265 * The feature must remain registered and supported indefinitely because it
63- * still exists in the ledger, but there is no need to vote for it because
64- * there's nothing to vote for. If it is removed completely from the code, any
65- * instances running that code will get amendment blocked. Removing the
66- * feature from the ledger is beyond the scope of these instructions.
66+ * may exist in the Amendments object on ledger. There is no need to vote
67+ * for it because there's nothing to vote for. If the feature definition is
68+ * removed completely from the code, any instances running that code will get
69+ * amendment blocked. Removing the feature from the ledger is beyond the scope
70+ * of these instructions.
6771 *
6872 */
6973
@@ -78,11 +82,32 @@ allAmendments();
7882
7983namespace detail {
8084
85+ #pragma push_macro("XRPL_FEATURE")
86+ #undef XRPL_FEATURE
87+ #pragma push_macro("XRPL_FIX")
88+ #undef XRPL_FIX
89+ #pragma push_macro("XRPL_RETIRE")
90+ #undef XRPL_RETIRE
91+
92+ #define XRPL_FEATURE (name, supported, vote ) +1
93+ #define XRPL_FIX (name, supported, vote ) +1
94+ #define XRPL_RETIRE (name ) +1
95+
8196// This value SHOULD be equal to the number of amendments registered in
8297// Feature.cpp. Because it's only used to reserve storage, and determine how
8398// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than
8499// the actual number of amendments. A LogicError on startup will verify this.
85- static constexpr std::size_t numFeatures = 88 ;
100+ static constexpr std::size_t numFeatures =
101+ (0 +
102+ #include < xrpl/protocol/detail/features.macro>
103+ );
104+
105+ #undef XRPL_RETIRE
106+ #pragma pop_macro("XRPL_RETIRE")
107+ #undef XRPL_FIX
108+ #pragma pop_macro("XRPL_FIX")
109+ #undef XRPL_FEATURE
110+ #pragma pop_macro("XRPL_FEATURE")
86111
87112/* * Amendments that this server supports and the default voting behavior.
88113 Whether they are enabled depends on the Rules defined in the validated
@@ -322,12 +347,17 @@ foreachFeature(FeatureBitset bs, F&& f)
322347#undef XRPL_FEATURE
323348#pragma push_macro("XRPL_FIX")
324349#undef XRPL_FIX
350+ #pragma push_macro("XRPL_RETIRE")
351+ #undef XRPL_RETIRE
325352
326353#define XRPL_FEATURE (name, supported, vote ) extern uint256 const feature##name;
327354#define XRPL_FIX (name, supported, vote ) extern uint256 const fix##name;
355+ #define XRPL_RETIRE (name )
328356
329357#include < xrpl/protocol/detail/features.macro>
330358
359+ #undef XRPL_RETIRE
360+ #pragma pop_macro("XRPL_RETIRE")
331361#undef XRPL_FIX
332362#pragma pop_macro("XRPL_FIX")
333363#undef XRPL_FEATURE
0 commit comments