-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calculate numFeatures automatically #5324
Open
ximinez
wants to merge
4
commits into
develop
Choose a base branch
from
ximinez/numFeatures
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,35 +33,36 @@ | |
* | ||
* Steps required to add new features to the code: | ||
* | ||
* 1) In this file, increment `numFeatures` and add a uint256 declaration | ||
* for the feature at the bottom | ||
* 2) Add a uint256 definition for the feature to the corresponding source | ||
* file (Feature.cpp). Use `registerFeature` to create the feature with | ||
* the feature's name, `Supported::no`, and `VoteBehavior::DefaultNo`. This | ||
* should be the only place the feature's name appears in code as a string. | ||
* 3) Use the uint256 as the parameter to `view.rules.enabled()` to | ||
* control flow into new code that this feature limits. | ||
* 4) If the feature development is COMPLETE, and the feature is ready to be | ||
* SUPPORTED, change the `registerFeature` parameter to Supported::yes. | ||
* 5) When the feature is ready to be ENABLED, change the `registerFeature` | ||
* parameter to `VoteBehavior::DefaultYes`. | ||
* In general, any newly supported amendments (`Supported::yes`) should have | ||
* a `VoteBehavior::DefaultNo` for at least one full release cycle. High | ||
* priority bug fixes can be an exception to this rule of thumb. | ||
* 1) Add the appropriate XRPL_FEATURE or XRPL_FIX macro definition for the | ||
* feature to features.macro with the feature's name, `Supported::no`, and | ||
* `VoteBehavior::DefaultNo`. | ||
* | ||
* 2) Use the generated variable name as the parameter to `view.rules.enabled()` | ||
* to control flow into new code that this feature limits. (featureName or | ||
* fixName) | ||
* | ||
* 3) If the feature development is COMPLETE, and the feature is ready to be | ||
* SUPPORTED, change the macro parameter in features.macro to Supported::yes. | ||
* | ||
* 4) In general, any newly supported amendments (`Supported::yes`) should have | ||
* a `VoteBehavior::DefaultNo` indefinitely so that external governance can | ||
* make the decision on when to activate it. High priority bug fixes can be | ||
* an exception to this rule. In such cases, change the macro parameter in | ||
* features.macro to `VoteBehavior::DefaultYes`. | ||
* | ||
* | ||
* When a feature has been enabled for several years, the conditional code | ||
* may be removed, and the feature "retired". To retire a feature: | ||
* 1) Remove the uint256 declaration from this file. | ||
* 2) MOVE the uint256 definition in Feature.cpp to the "retired features" | ||
* section at the end of the file. | ||
* 3) CHANGE the name of the variable to start with "retired". | ||
* 4) CHANGE the parameters of the `registerFeature` call to `Supported::yes` | ||
* and `VoteBehavior::DefaultNo`. | ||
* | ||
* 1) MOVE the macro definition in features.macro to the "retired features" | ||
* section at the end of the file, and change the macro to XRPL_RETIRE. | ||
* | ||
* The feature must remain registered and supported indefinitely because it | ||
* still exists in the ledger, but there is no need to vote for it because | ||
* there's nothing to vote for. If it is removed completely from the code, any | ||
* instances running that code will get amendment blocked. Removing the | ||
* feature from the ledger is beyond the scope of these instructions. | ||
* may exist in the Amendments object on ledger. There is no need to vote | ||
* for it because there's nothing to vote for. If the feature definition is | ||
* removed completely from the code, any instances running that code will get | ||
* amendment blocked. Removing the feature from the ledger is beyond the scope | ||
* of these instructions. | ||
* | ||
*/ | ||
|
||
|
@@ -76,11 +77,32 @@ allAmendments(); | |
|
||
namespace detail { | ||
|
||
#pragma push_macro("XRPL_FEATURE") | ||
#undef XRPL_FEATURE | ||
#pragma push_macro("XRPL_FIX") | ||
#undef XRPL_FIX | ||
#pragma push_macro("XRPL_RETIRE") | ||
#undef XRPL_RETIRE | ||
|
||
#define XRPL_FEATURE(name, supported, vote) +1 | ||
#define XRPL_FIX(name, supported, vote) +1 | ||
#define XRPL_RETIRE(name) +1 | ||
|
||
// This value SHOULD be equal to the number of amendments registered in | ||
// Feature.cpp. Because it's only used to reserve storage, and determine how | ||
// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than | ||
// the actual number of amendments. A LogicError on startup will verify this. | ||
static constexpr std::size_t numFeatures = 88; | ||
static constexpr std::size_t numFeatures = | ||
(0 + | ||
#include <xrpl/protocol/detail/features.macro> | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. love this ! |
||
|
||
#undef XRPL_RETIRE | ||
#pragma pop_macro("XRPL_RETIRE") | ||
#undef XRPL_FIX | ||
#pragma pop_macro("XRPL_FIX") | ||
#undef XRPL_FEATURE | ||
#pragma pop_macro("XRPL_FEATURE") | ||
|
||
/** Amendments that this server supports and the default voting behavior. | ||
Whether they are enabled depends on the Rules defined in the validated | ||
|
@@ -320,12 +342,17 @@ foreachFeature(FeatureBitset bs, F&& f) | |
#undef XRPL_FEATURE | ||
#pragma push_macro("XRPL_FIX") | ||
#undef XRPL_FIX | ||
#pragma push_macro("XRPL_RETIRE") | ||
#undef XRPL_RETIRE | ||
|
||
#define XRPL_FEATURE(name, supported, vote) extern uint256 const feature##name; | ||
#define XRPL_FIX(name, supported, vote) extern uint256 const fix##name; | ||
#define XRPL_RETIRE(name) | ||
|
||
#include <xrpl/protocol/detail/features.macro> | ||
|
||
#undef XRPL_RETIRE | ||
#pragma pop_macro("XRPL_RETIRE") | ||
#undef XRPL_FIX | ||
#pragma pop_macro("XRPL_FIX") | ||
#undef XRPL_FEATURE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps add something like
... and ensure that the fix has been clearly communicated to the community, using the appropriate channels.
. Or even swap the order i.e. ensure the communication in the first place, then change the macro parameter.I know this goes implied, but we must assume that not everyone reading this comment will grasp the significance of clear communication in this case.