-
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
Internal amendment vetoes: #3458
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1342,26 +1342,34 @@ ApplicationImp::setup() | |
|
||
// Configure the amendments the server supports | ||
{ | ||
auto const& sa = detail::supportedAmendments(); | ||
std::vector<std::string> saHashes; | ||
saHashes.reserve(sa.size()); | ||
for (auto const& name : sa) | ||
{ | ||
auto const f = getRegisteredFeature(name); | ||
BOOST_ASSERT(f); | ||
if (f) | ||
saHashes.push_back(to_string(*f) + " " + name); | ||
} | ||
Section supportedAmendments("Supported Amendments"); | ||
supportedAmendments.append(saHashes); | ||
auto buildAmendmentList = | ||
[](Section section, std::vector<std::string> const& amendments) { | ||
std::vector<std::string> hashes; | ||
hashes.reserve(amendments.size()); | ||
for (auto const& name : amendments) | ||
{ | ||
auto const f = getRegisteredFeature(name); | ||
assert(f); | ||
if (f) | ||
hashes.push_back(to_string(*f) + " " + name); | ||
} | ||
section.append(hashes); | ||
return section; | ||
}; | ||
Section const supportedAmendments = buildAmendmentList( | ||
Section("Supported Amendments"), detail::supportedAmendments()); | ||
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. There are getting to be enough places that use 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. I'm torn. This example isn't new new place where My opinion is to leave it. |
||
|
||
Section const downVotedAmendments = buildAmendmentList( | ||
config_->section(SECTION_VETO_AMENDMENTS), | ||
detail::downVotedAmendments()); | ||
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. Consider moving 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. Wherever they end up, they should definitely be left together. |
||
|
||
Section enabledAmendments = config_->section(SECTION_AMENDMENTS); | ||
Section const enabledAmendments = config_->section(SECTION_AMENDMENTS); | ||
|
||
m_amendmentTable = make_AmendmentTable( | ||
config().AMENDMENT_MAJORITY_TIME, | ||
supportedAmendments, | ||
enabledAmendments, | ||
config_->section(SECTION_VETO_AMENDMENTS), | ||
downVotedAmendments, | ||
logs_->journal("Amendments")); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,9 +36,15 @@ | |
* 2) add a uint256 declaration for the feature to the bottom of this file | ||
* 3) add a uint256 definition for the feature to the corresponding source | ||
* file (Feature.cpp) | ||
* 4) if the feature is going to be supported in the near future, add its | ||
* sha512half value and name (matching exactly the featureName here) to | ||
* the supportedAmendments in Feature.cpp. | ||
* 4) use the uint256 as the parameter to `view.rules.enabled()` to | ||
* control flow into new code that this feature limits. | ||
* 5) if the feature development is COMPLETE, and the feature is ready to be | ||
* SUPPORTED, add its name (matching exactly the featureName here) to the | ||
* supportedAmendments in Feature.cpp. | ||
* 6) if the feature is not ready to be ENABLED, add its name (matching exactly | ||
* the featureName here) to the downVotedAmendments in Feature.cpp. | ||
* In general, any new amendments added to supportedAmendments should also be | ||
* added to downVotedAmendments for at least one full release cycle. | ||
* | ||
*/ | ||
|
||
|
@@ -136,12 +142,22 @@ class FeatureCollections | |
|
||
uint256 const& | ||
bitsetIndexToFeature(size_t i) const; | ||
|
||
std::string | ||
featureToName(uint256 const& f) const; | ||
}; | ||
|
||
/** Amendments that this server supports, but doesn't enable by default */ | ||
/** Amendments that this server supports and will vote for by default. | ||
Whether they are enabled depends on the Rules defined in the validated | ||
ledger */ | ||
std::vector<std::string> const& | ||
supportedAmendments(); | ||
|
||
/** Amendments that this server won't vote for by default. Overrides the default | ||
vote behavior of `supportedAmendments()` */ | ||
std::vector<std::string> const& | ||
downVotedAmendments(); | ||
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. Have you tested how 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. That's a good question. There is the |
||
|
||
} // namespace detail | ||
|
||
boost::optional<uint256> | ||
|
@@ -153,6 +169,9 @@ featureToBitsetIndex(uint256 const& f); | |
uint256 | ||
bitsetIndexToFeature(size_t i); | ||
|
||
std::string | ||
featureToName(uint256 const& f); | ||
|
||
class FeatureBitset | ||
: private std::bitset<detail::FeatureCollections::numFeatures()> | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,14 +74,32 @@ detail::FeatureCollections::bitsetIndexToFeature(size_t i) const | |
return features[i]; | ||
} | ||
|
||
std::string | ||
detail::FeatureCollections::featureToName(uint256 const& f) const | ||
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.
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. Done. |
||
{ | ||
auto const i = featureToIndex.find(f); | ||
assert(featureToIndex.size() == numFeatures()); | ||
return i == featureToIndex.end() ? to_string(f) : featureNames[i->second]; | ||
} | ||
|
||
static detail::FeatureCollections const featureCollections; | ||
|
||
/** Amendments that this server supports, but doesn't enable by default */ | ||
/** Amendments that this server supports and will vote for by default. | ||
Whether they are enabled depends on the Rules defined in the validated | ||
ledger */ | ||
std::vector<std::string> const& | ||
detail::supportedAmendments() | ||
{ | ||
// Commented out amendments will be supported in a future release (and | ||
// uncommented at that time). | ||
// uncommented at that time). Including an amendment here indicates | ||
// that development of the feature is complete. Any future behavior | ||
// changes will require another amendment. | ||
// | ||
// In general, any new non-fix amendments added to this list should also be | ||
// added to downVotedAmendments for at least one full release cycle to | ||
// prevent rippled from automatically voting to enable that amendment by | ||
// default for some time. Fix amendments should be carefully considered | ||
// based on the risk and severity of the thing they are fixing. | ||
// | ||
// There are also unconditionally supported amendments in the list. | ||
// Those are amendments that were enabled some time ago and the | ||
|
@@ -137,6 +155,38 @@ detail::supportedAmendments() | |
return supported; | ||
} | ||
|
||
/** Amendments that this server won't vote for by default. Overrides the default | ||
vote behavior of `supportedAmendments()` */ | ||
std::vector<std::string> const& | ||
detail::downVotedAmendments() | ||
{ | ||
// Amendment names included in this list should also be present and | ||
// uncommented in supportedAmendments above. This allows a particular | ||
// version of rippled to be able to understand the amendment if it gets | ||
// enabled, but not vote for the amendment by default. Additionally, some | ||
// tests will fail if an entry in this list is not in supportedAmendments. | ||
// | ||
// Note that this list can be overridden by the "feature" admin RPC command. | ||
// | ||
// For example, if amendment FOO is first complete and released in 2.1, but | ||
// down voted (included in this list) until 2.3 when it is removed from this | ||
// list, then when it is finally enabled by receiving votes from the | ||
// majority of UNL validators some time after 2.3 is released, versions 2.1 | ||
// and later will know how to handle the new behavior and will NOT be | ||
// amendment blocked. | ||
// | ||
// Suggested format for entries in the string vector: | ||
// "AmendmentName", // Added in 2.1, planned to enable in 2.3 | ||
// | ||
// To enable automatically voting for the amendment, simply remove it from | ||
// this list. There should never be a need to comment entries out aside from | ||
// testing. | ||
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. Nice comment! 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. Thanks! |
||
static std::vector<std::string> const vetoed{ | ||
"CryptoConditionsSuite", // Added in 0.60.0, incomplete, do not enable | ||
}; | ||
return vetoed; | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
|
||
boost::optional<uint256> | ||
|
@@ -157,6 +207,12 @@ bitsetIndexToFeature(size_t i) | |
return featureCollections.bitsetIndexToFeature(i); | ||
} | ||
|
||
std::string | ||
featureToName(uint256 const& f) | ||
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. This 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. Done. |
||
{ | ||
return featureCollections.featureToName(f); | ||
} | ||
|
||
// clang-format off | ||
|
||
uint256 const | ||
|
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.
Just curious: How do we decide when to use
BOOST_ASSERT
vsassert
? I guess they are synonymous?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.
They're basically synonymous, but the boost version adds the dependency on boost. In general, AFAIK, we're moving away from
BOOST_ASSERT
, but nobody has bothered to do a global search and replace.