diff --git a/include/xrpl/protocol/SystemParameters.h b/include/xrpl/protocol/SystemParameters.h index 121435dd92..5aa21827fc 100644 --- a/include/xrpl/protocol/SystemParameters.h +++ b/include/xrpl/protocol/SystemParameters.h @@ -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}; diff --git a/include/xrpl/protocol/detail/features.macro b/include/xrpl/protocol/detail/features.macro index d510edaa43..b6bdcd5c06 100644 --- a/include/xrpl/protocol/detail/features.macro +++ b/include/xrpl/protocol/detail/features.macro @@ -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) diff --git a/src/test/app/AmendmentTable_test.cpp b/src/test/app/AmendmentTable_test.cpp index 407b2fafe1..35f59ea2d8 100644 --- a/src/test/app/AmendmentTable_test.cpp +++ b/src/test/app/AmendmentTable_test.cpp @@ -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); } }; diff --git a/src/xrpld/app/misc/detail/AmendmentTable.cpp b/src/xrpld/app/misc/detail/AmendmentTable.cpp index b13e40c3ae..9f73879700 100644 --- a/src/xrpld/app/misc/detail/AmendmentTable.cpp +++ b/src/xrpld/app/misc/detail/AmendmentTable.cpp @@ -316,36 +316,16 @@ class AmendmentSet private: // How many yes votes each amendment received hash_map 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( - (trustedValidations_ * - preFixAmendmentMajorityCalcThreshold.num) / - preFixAmendmentMajorityCalcThreshold.den)) - : std::max( - 1L, - static_cast( - (trustedValidations_ * - postFixAmendmentMajorityCalcThreshold.num) / - postFixAmendmentMajorityCalcThreshold.den)); - } - public: AmendmentSet( Rules const& rules, TrustedVotes const& trustedVotes, std::lock_guard 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( + (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_;