mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Improve amendment processing and activation logic:
* The amendment ballot counting code contained a minor technical flaw, caused by the use of integer arithmetic and rounding semantics, that could allow amendments to reach majority with slightly less than 80% support. This commit introduces an amendment which, if enabled, will ensure that activation requires at least 80% support. * This commit also introduces a configuration option to adjust the amendment activation hysteresis. This option is useful on test networks, but should not be used on the main network as is a network-wide consensus parameter that should not be changed on a per-server basis; doing so can result in a hard-fork. Fixes #3396
This commit is contained in:
committed by
Nik Bougalis
parent
fe9922d654
commit
df29e98ea5
@@ -1014,6 +1014,57 @@ r.ripple.com 51235
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testAmendment()
|
||||
{
|
||||
testcase("amendment");
|
||||
struct ConfigUnit
|
||||
{
|
||||
std::string unit;
|
||||
std::uint32_t numSeconds;
|
||||
std::uint32_t configVal;
|
||||
bool shouldPass;
|
||||
};
|
||||
|
||||
std::vector<ConfigUnit> units = {
|
||||
{"seconds", 1, 15 * 60, false},
|
||||
{"minutes", 60, 14, false},
|
||||
{"minutes", 60, 15, true},
|
||||
{"hours", 3600, 10, true},
|
||||
{"days", 86400, 10, true},
|
||||
{"weeks", 604800, 2, true},
|
||||
{"months", 2592000, 1, false},
|
||||
{"years", 31536000, 1, false}};
|
||||
|
||||
std::string space = "";
|
||||
for (auto& [unit, sec, val, shouldPass] : units)
|
||||
{
|
||||
Config c;
|
||||
std::string toLoad(R"rippleConfig(
|
||||
[amendment_majority_time]
|
||||
)rippleConfig");
|
||||
toLoad += std::to_string(val) + space + unit;
|
||||
space = space == "" ? " " : "";
|
||||
|
||||
try
|
||||
{
|
||||
c.loadFromString(toLoad);
|
||||
if (shouldPass)
|
||||
BEAST_EXPECT(
|
||||
c.AMENDMENT_MAJORITY_TIME.count() == val * sec);
|
||||
else
|
||||
fail();
|
||||
}
|
||||
catch (std::runtime_error&)
|
||||
{
|
||||
if (!shouldPass)
|
||||
pass();
|
||||
else
|
||||
fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
run() override
|
||||
{
|
||||
@@ -1027,6 +1078,7 @@ r.ripple.com 51235
|
||||
testWhitespace();
|
||||
testComments();
|
||||
testGetters();
|
||||
testAmendment();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user