mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-18 18:15:50 +00:00
refactor: Retire fixAmendmentMajorityCalc amendment (#5961)
Amendments activated for more than 2 years can be retired. This change retires the fixAmendmentMajorityCalc amendment.
This commit is contained in:
@@ -73,14 +73,8 @@ static constexpr std::uint32_t XRP_LEDGER_EARLIEST_SEQ{32570u};
|
||||
* used in asserts and tests. */
|
||||
static constexpr std::uint32_t XRP_LEDGER_EARLIEST_FEES{562177u};
|
||||
|
||||
/** The minimum amount of support an amendment should have.
|
||||
|
||||
@note This value is used by legacy code and will become obsolete
|
||||
once the fixAmendmentMajorityCalc amendment activates.
|
||||
*/
|
||||
constexpr std::ratio<204, 256> preFixAmendmentMajorityCalcThreshold;
|
||||
|
||||
constexpr std::ratio<80, 100> postFixAmendmentMajorityCalcThreshold;
|
||||
/** The minimum amount of support an amendment should have. */
|
||||
constexpr std::ratio<80, 100> amendmentMajorityCalcThreshold;
|
||||
|
||||
/** The minimum amount of time an amendment must hold a majority */
|
||||
constexpr std::chrono::seconds const defaultAmendmentMajorityTime = weeks{2};
|
||||
|
||||
@@ -92,7 +92,6 @@ XRPL_FEATURE(CheckCashMakesTrustLine, Supported::yes, VoteBehavior::DefaultNo
|
||||
XRPL_FEATURE(FlowSortStrands, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FEATURE(TicketBatch, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FEATURE(NegativeUNL, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FIX (AmendmentMajorityCalc, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FEATURE(HardenedValidations, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FEATURE(RequireFullyCanonicalSig, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FEATURE(DeletableAccounts, Supported::yes, VoteBehavior::DefaultYes)
|
||||
@@ -139,6 +138,7 @@ XRPL_RETIRE(fix1571)
|
||||
XRPL_RETIRE(fix1578)
|
||||
XRPL_RETIRE(fix1623)
|
||||
XRPL_RETIRE(fix1781)
|
||||
XRPL_RETIRE(fixAmendmentMajorityCalc)
|
||||
XRPL_RETIRE(fixCheckThreading)
|
||||
XRPL_RETIRE(fixQualityUpperBound)
|
||||
XRPL_RETIRE(fixRmSmallIncreasedQOffers)
|
||||
|
||||
@@ -545,8 +545,7 @@ public:
|
||||
|
||||
for (auto const& [hash, nVotes] : votes)
|
||||
{
|
||||
if (rules.enabled(fixAmendmentMajorityCalc) ? nVotes >= i
|
||||
: nVotes > i)
|
||||
if (nVotes >= i)
|
||||
{
|
||||
// We vote yes on this amendment
|
||||
field.push_back(hash);
|
||||
@@ -982,10 +981,6 @@ public:
|
||||
void
|
||||
testChangedUNL(FeatureBitset const& feat)
|
||||
{
|
||||
// This test doesn't work without fixAmendmentMajorityCalc enabled.
|
||||
if (!feat[fixAmendmentMajorityCalc])
|
||||
return;
|
||||
|
||||
testcase("changedUNL");
|
||||
|
||||
auto const testAmendment = amendmentId("changedUNL");
|
||||
@@ -1143,10 +1138,6 @@ public:
|
||||
void
|
||||
testValidatorFlapping(FeatureBitset const& feat)
|
||||
{
|
||||
// This test doesn't work without fixAmendmentMajorityCalc enabled.
|
||||
if (!feat[fixAmendmentMajorityCalc])
|
||||
return;
|
||||
|
||||
testcase("validatorFlapping");
|
||||
|
||||
// We run a test where a validator flaps on and off every 23 hours
|
||||
@@ -1289,14 +1280,12 @@ public:
|
||||
run() override
|
||||
{
|
||||
FeatureBitset const all{test::jtx::testable_amendments()};
|
||||
FeatureBitset const fixMajorityCalc{fixAmendmentMajorityCalc};
|
||||
|
||||
testConstruct();
|
||||
testGet();
|
||||
testBadConfig();
|
||||
testEnableVeto();
|
||||
testHasUnsupported();
|
||||
testFeature(all - fixMajorityCalc);
|
||||
testFeature(all);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -316,36 +316,16 @@ class AmendmentSet
|
||||
private:
|
||||
// How many yes votes each amendment received
|
||||
hash_map<uint256, int> votes_;
|
||||
Rules const& rules_;
|
||||
// number of trusted validations
|
||||
int trustedValidations_ = 0;
|
||||
// number of votes needed
|
||||
int threshold_ = 0;
|
||||
|
||||
void
|
||||
computeThreshold(int trustedValidations, Rules const& rules)
|
||||
{
|
||||
threshold_ = !rules_.enabled(fixAmendmentMajorityCalc)
|
||||
? std::max(
|
||||
1L,
|
||||
static_cast<long>(
|
||||
(trustedValidations_ *
|
||||
preFixAmendmentMajorityCalcThreshold.num) /
|
||||
preFixAmendmentMajorityCalcThreshold.den))
|
||||
: std::max(
|
||||
1L,
|
||||
static_cast<long>(
|
||||
(trustedValidations_ *
|
||||
postFixAmendmentMajorityCalcThreshold.num) /
|
||||
postFixAmendmentMajorityCalcThreshold.den));
|
||||
}
|
||||
|
||||
public:
|
||||
AmendmentSet(
|
||||
Rules const& rules,
|
||||
TrustedVotes const& trustedVotes,
|
||||
std::lock_guard<std::mutex> const& lock)
|
||||
: rules_(rules)
|
||||
{
|
||||
// process validations for ledger before flag ledger.
|
||||
auto [trustedCount, newVotes] = trustedVotes.getVotes(rules, lock);
|
||||
@@ -353,7 +333,11 @@ public:
|
||||
trustedValidations_ = trustedCount;
|
||||
votes_.swap(newVotes);
|
||||
|
||||
computeThreshold(trustedValidations_, rules);
|
||||
threshold_ = std::max(
|
||||
1L,
|
||||
static_cast<long>(
|
||||
(trustedValidations_ * amendmentMajorityCalcThreshold.num) /
|
||||
amendmentMajorityCalcThreshold.den));
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -364,13 +348,9 @@ public:
|
||||
if (it == votes_.end())
|
||||
return false;
|
||||
|
||||
// Before this fix, it was possible for an amendment to activate with a
|
||||
// percentage slightly less than 80% because we compared for "greater
|
||||
// than or equal to" instead of strictly "greater than".
|
||||
// One validator is an exception, otherwise it is not possible
|
||||
// to gain majority.
|
||||
if (!rules_.enabled(fixAmendmentMajorityCalc) ||
|
||||
trustedValidations_ == 1)
|
||||
if (trustedValidations_ == 1)
|
||||
return it->second >= threshold_;
|
||||
|
||||
return it->second > threshold_;
|
||||
|
||||
Reference in New Issue
Block a user