mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +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. */
|
* used in asserts and tests. */
|
||||||
static constexpr std::uint32_t XRP_LEDGER_EARLIEST_FEES{562177u};
|
static constexpr std::uint32_t XRP_LEDGER_EARLIEST_FEES{562177u};
|
||||||
|
|
||||||
/** The minimum amount of support an amendment should have.
|
/** The minimum amount of support an amendment should have. */
|
||||||
|
constexpr std::ratio<80, 100> amendmentMajorityCalcThreshold;
|
||||||
@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 time an amendment must hold a majority */
|
/** The minimum amount of time an amendment must hold a majority */
|
||||||
constexpr std::chrono::seconds const defaultAmendmentMajorityTime = weeks{2};
|
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(FlowSortStrands, Supported::yes, VoteBehavior::DefaultYes)
|
||||||
XRPL_FEATURE(TicketBatch, Supported::yes, VoteBehavior::DefaultYes)
|
XRPL_FEATURE(TicketBatch, Supported::yes, VoteBehavior::DefaultYes)
|
||||||
XRPL_FEATURE(NegativeUNL, 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(HardenedValidations, Supported::yes, VoteBehavior::DefaultYes)
|
||||||
XRPL_FEATURE(RequireFullyCanonicalSig, Supported::yes, VoteBehavior::DefaultYes)
|
XRPL_FEATURE(RequireFullyCanonicalSig, Supported::yes, VoteBehavior::DefaultYes)
|
||||||
XRPL_FEATURE(DeletableAccounts, Supported::yes, VoteBehavior::DefaultYes)
|
XRPL_FEATURE(DeletableAccounts, Supported::yes, VoteBehavior::DefaultYes)
|
||||||
@@ -139,6 +138,7 @@ XRPL_RETIRE(fix1571)
|
|||||||
XRPL_RETIRE(fix1578)
|
XRPL_RETIRE(fix1578)
|
||||||
XRPL_RETIRE(fix1623)
|
XRPL_RETIRE(fix1623)
|
||||||
XRPL_RETIRE(fix1781)
|
XRPL_RETIRE(fix1781)
|
||||||
|
XRPL_RETIRE(fixAmendmentMajorityCalc)
|
||||||
XRPL_RETIRE(fixCheckThreading)
|
XRPL_RETIRE(fixCheckThreading)
|
||||||
XRPL_RETIRE(fixQualityUpperBound)
|
XRPL_RETIRE(fixQualityUpperBound)
|
||||||
XRPL_RETIRE(fixRmSmallIncreasedQOffers)
|
XRPL_RETIRE(fixRmSmallIncreasedQOffers)
|
||||||
|
|||||||
@@ -545,8 +545,7 @@ public:
|
|||||||
|
|
||||||
for (auto const& [hash, nVotes] : votes)
|
for (auto const& [hash, nVotes] : votes)
|
||||||
{
|
{
|
||||||
if (rules.enabled(fixAmendmentMajorityCalc) ? nVotes >= i
|
if (nVotes >= i)
|
||||||
: nVotes > i)
|
|
||||||
{
|
{
|
||||||
// We vote yes on this amendment
|
// We vote yes on this amendment
|
||||||
field.push_back(hash);
|
field.push_back(hash);
|
||||||
@@ -982,10 +981,6 @@ public:
|
|||||||
void
|
void
|
||||||
testChangedUNL(FeatureBitset const& feat)
|
testChangedUNL(FeatureBitset const& feat)
|
||||||
{
|
{
|
||||||
// This test doesn't work without fixAmendmentMajorityCalc enabled.
|
|
||||||
if (!feat[fixAmendmentMajorityCalc])
|
|
||||||
return;
|
|
||||||
|
|
||||||
testcase("changedUNL");
|
testcase("changedUNL");
|
||||||
|
|
||||||
auto const testAmendment = amendmentId("changedUNL");
|
auto const testAmendment = amendmentId("changedUNL");
|
||||||
@@ -1143,10 +1138,6 @@ public:
|
|||||||
void
|
void
|
||||||
testValidatorFlapping(FeatureBitset const& feat)
|
testValidatorFlapping(FeatureBitset const& feat)
|
||||||
{
|
{
|
||||||
// This test doesn't work without fixAmendmentMajorityCalc enabled.
|
|
||||||
if (!feat[fixAmendmentMajorityCalc])
|
|
||||||
return;
|
|
||||||
|
|
||||||
testcase("validatorFlapping");
|
testcase("validatorFlapping");
|
||||||
|
|
||||||
// We run a test where a validator flaps on and off every 23 hours
|
// We run a test where a validator flaps on and off every 23 hours
|
||||||
@@ -1289,14 +1280,12 @@ public:
|
|||||||
run() override
|
run() override
|
||||||
{
|
{
|
||||||
FeatureBitset const all{test::jtx::testable_amendments()};
|
FeatureBitset const all{test::jtx::testable_amendments()};
|
||||||
FeatureBitset const fixMajorityCalc{fixAmendmentMajorityCalc};
|
|
||||||
|
|
||||||
testConstruct();
|
testConstruct();
|
||||||
testGet();
|
testGet();
|
||||||
testBadConfig();
|
testBadConfig();
|
||||||
testEnableVeto();
|
testEnableVeto();
|
||||||
testHasUnsupported();
|
testHasUnsupported();
|
||||||
testFeature(all - fixMajorityCalc);
|
|
||||||
testFeature(all);
|
testFeature(all);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -316,36 +316,16 @@ class AmendmentSet
|
|||||||
private:
|
private:
|
||||||
// How many yes votes each amendment received
|
// How many yes votes each amendment received
|
||||||
hash_map<uint256, int> votes_;
|
hash_map<uint256, int> votes_;
|
||||||
Rules const& rules_;
|
|
||||||
// number of trusted validations
|
// number of trusted validations
|
||||||
int trustedValidations_ = 0;
|
int trustedValidations_ = 0;
|
||||||
// number of votes needed
|
// number of votes needed
|
||||||
int threshold_ = 0;
|
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:
|
public:
|
||||||
AmendmentSet(
|
AmendmentSet(
|
||||||
Rules const& rules,
|
Rules const& rules,
|
||||||
TrustedVotes const& trustedVotes,
|
TrustedVotes const& trustedVotes,
|
||||||
std::lock_guard<std::mutex> const& lock)
|
std::lock_guard<std::mutex> const& lock)
|
||||||
: rules_(rules)
|
|
||||||
{
|
{
|
||||||
// process validations for ledger before flag ledger.
|
// process validations for ledger before flag ledger.
|
||||||
auto [trustedCount, newVotes] = trustedVotes.getVotes(rules, lock);
|
auto [trustedCount, newVotes] = trustedVotes.getVotes(rules, lock);
|
||||||
@@ -353,7 +333,11 @@ public:
|
|||||||
trustedValidations_ = trustedCount;
|
trustedValidations_ = trustedCount;
|
||||||
votes_.swap(newVotes);
|
votes_.swap(newVotes);
|
||||||
|
|
||||||
computeThreshold(trustedValidations_, rules);
|
threshold_ = std::max(
|
||||||
|
1L,
|
||||||
|
static_cast<long>(
|
||||||
|
(trustedValidations_ * amendmentMajorityCalcThreshold.num) /
|
||||||
|
amendmentMajorityCalcThreshold.den));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -364,13 +348,9 @@ public:
|
|||||||
if (it == votes_.end())
|
if (it == votes_.end())
|
||||||
return false;
|
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
|
// One validator is an exception, otherwise it is not possible
|
||||||
// to gain majority.
|
// to gain majority.
|
||||||
if (!rules_.enabled(fixAmendmentMajorityCalc) ||
|
if (trustedValidations_ == 1)
|
||||||
trustedValidations_ == 1)
|
|
||||||
return it->second >= threshold_;
|
return it->second >= threshold_;
|
||||||
|
|
||||||
return it->second > threshold_;
|
return it->second > threshold_;
|
||||||
|
|||||||
Reference in New Issue
Block a user