mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 19:45:53 +00:00
feat: mark 4 amendments as obsolete: (#4291)
Add the ability to mark amendments as obsolete. There are some known amendments that should not be voted for because they are broken (or similar reasons). This commit marks four amendments as obsolete: 1. `CryptoConditionsSuite` 2. `NonFungibleTokensV1` 3. `fixNFTokenDirV1` 4. `fixNFTokenNegOffer` When an amendment is `Obsolete`, voting for the amendment is prevented. A determined operator can still vote for the amendment by changing the source, and doing so does not break any protocol rules. The "feature" command now does not modify the vote for obsolete amendments. Before this change, there were two options for an amendment's `DefaultVote` behavior: yes and no. After this change, there are three options for an amendment's `VoteBehavior`: DefaultYes, DefaultNo, and Obsolete. To be clear, if an obsolete amendment were to (somehow) be activated by consensus, the server still has the code to process transactions according to that amendment, and would not be amendment blocked. It would function the same as if it had been voting "no" on the amendment. Resolves #4014. Incorporates review feedback from @scottschurr.
This commit is contained in:
@@ -333,19 +333,31 @@ AmendmentTableImpl::AmendmentTableImpl(
|
||||
}();
|
||||
|
||||
// Parse supported amendments
|
||||
for (auto const& [name, amendment, defaultVote] : supported)
|
||||
for (auto const& [name, amendment, votebehavior] : supported)
|
||||
{
|
||||
AmendmentState& s = add(amendment, lock);
|
||||
|
||||
s.name = name;
|
||||
s.supported = true;
|
||||
s.vote = defaultVote == DefaultVote::yes ? AmendmentVote::up
|
||||
: AmendmentVote::down;
|
||||
switch (votebehavior)
|
||||
{
|
||||
case VoteBehavior::DefaultYes:
|
||||
s.vote = AmendmentVote::up;
|
||||
break;
|
||||
|
||||
case VoteBehavior::DefaultNo:
|
||||
s.vote = AmendmentVote::down;
|
||||
break;
|
||||
|
||||
case VoteBehavior::Obsolete:
|
||||
s.vote = AmendmentVote::obsolete;
|
||||
break;
|
||||
}
|
||||
|
||||
JLOG(j_.debug()) << "Amendment " << amendment << " (" << s.name
|
||||
<< ") is supported and will be "
|
||||
<< (s.vote == AmendmentVote::up ? "up" : "down")
|
||||
<< " voted if not enabled on the ledger.";
|
||||
<< " voted by default if not enabled on the ledger.";
|
||||
}
|
||||
|
||||
hash_set<uint256> detect_conflict;
|
||||
@@ -420,7 +432,9 @@ AmendmentTableImpl::AmendmentTableImpl(
|
||||
<< amend_hash << "} is downvoted.";
|
||||
if (!amendment_name->empty())
|
||||
s->name = *amendment_name;
|
||||
s->vote = *vote;
|
||||
// An obsolete amendment's vote can never be changed
|
||||
if (s->vote != AmendmentVote::obsolete)
|
||||
s->vote = *vote;
|
||||
}
|
||||
}
|
||||
else // up-vote
|
||||
@@ -431,7 +445,9 @@ AmendmentTableImpl::AmendmentTableImpl(
|
||||
<< amend_hash << "} is upvoted.";
|
||||
if (!amendment_name->empty())
|
||||
s.name = *amendment_name;
|
||||
s.vote = *vote;
|
||||
// An obsolete amendment's vote can never be changed
|
||||
if (s.vote != AmendmentVote::obsolete)
|
||||
s.vote = *vote;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -489,6 +505,7 @@ AmendmentTableImpl::persistVote(
|
||||
std::string const& name,
|
||||
AmendmentVote vote) const
|
||||
{
|
||||
assert(vote != AmendmentVote::obsolete);
|
||||
auto db = db_.checkoutDb();
|
||||
voteAmendment(*db, amendment, name, vote);
|
||||
}
|
||||
@@ -499,7 +516,7 @@ AmendmentTableImpl::veto(uint256 const& amendment)
|
||||
std::lock_guard lock(mutex_);
|
||||
AmendmentState& s = add(amendment, lock);
|
||||
|
||||
if (s.vote == AmendmentVote::down)
|
||||
if (s.vote != AmendmentVote::up)
|
||||
return false;
|
||||
s.vote = AmendmentVote::down;
|
||||
persistVote(amendment, s.name, s.vote);
|
||||
@@ -512,7 +529,7 @@ AmendmentTableImpl::unVeto(uint256 const& amendment)
|
||||
std::lock_guard lock(mutex_);
|
||||
AmendmentState* const s = get(amendment, lock);
|
||||
|
||||
if (!s || s->vote == AmendmentVote::up)
|
||||
if (!s || s->vote != AmendmentVote::down)
|
||||
return false;
|
||||
s->vote = AmendmentVote::up;
|
||||
persistVote(amendment, s->name, s->vote);
|
||||
@@ -734,7 +751,13 @@ AmendmentTableImpl::injectJson(
|
||||
v[jss::name] = fs.name;
|
||||
|
||||
v[jss::supported] = fs.supported;
|
||||
v[jss::vetoed] = fs.vote == AmendmentVote::down;
|
||||
if (!fs.enabled)
|
||||
{
|
||||
if (fs.vote == AmendmentVote::obsolete)
|
||||
v[jss::vetoed] = "Obsolete";
|
||||
else
|
||||
v[jss::vetoed] = fs.vote == AmendmentVote::down;
|
||||
}
|
||||
v[jss::enabled] = fs.enabled;
|
||||
|
||||
if (!fs.enabled && lastVote_)
|
||||
|
||||
Reference in New Issue
Block a user