Skip to content

Commit

Permalink
Error and exit on validator configs that contain only LOW validators
Browse files Browse the repository at this point in the history
Closes #4526

This change raises an error when a node is a validator and all of the
validators in its config (including itself) are marked `LOW` quality.
This represents a misconfiguration because `LOW` quality validators
cannot win leader election, and so if every validator is `LOW` quality,
then there are no eligible nomination leader.
  • Loading branch information
bboston7 committed Oct 30, 2024
1 parent acf111d commit 437dfaf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2467,6 +2467,14 @@ Config::setValidatorWeightConfig(std::vector<ValidatorEntry> const& validators)
homeDomainsByQuality[v.mQuality].insert(v.mHomeDomain);
}

if (NODE_IS_VALIDATOR &&
highestQuality == ValidatorQuality::VALIDATOR_LOW_QUALITY)
{
throw std::invalid_argument(
"At least one validator must have a quality "
"level higher than LOW");
}

// Highest quality level has weight UINT64_MAX
vwc.mQualityWeights[highestQuality] = UINT64_MAX;

Expand Down
32 changes: 32 additions & 0 deletions src/main/test/ConfigTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,3 +572,35 @@ TEST_CASE("operation filter configuration", "[config]")
loadConfig(vals);
}
}

// Test that the config loader rejects validator configs with all validators
// marked low quality (including 'self').
TEST_CASE("reject all low quality validators config", "[config]")
{
Config c;
std::string const configStr = R"(
NODE_SEED="SA7FGJMMUIHNE3ZPI2UO5I632A7O5FBAZTXFAIEVFA4DSSGLHXACLAIT a3"
NODE_HOME_DOMAIN="domain"
NODE_IS_VALIDATOR=true
DEPRECATED_SQL_LEDGER_STATE=false
UNSAFE_QUORUM=true
[[HOME_DOMAINS]]
HOME_DOMAIN="domain"
QUALITY="LOW"
[[VALIDATORS]]
NAME="a1"
HOME_DOMAIN="domain"
PUBLIC_KEY="GDUTST3TG4MNDLY6WLB5CIASIBZAWWWJKZDHA4HFEVKQOVTYQ2F5GKYZ"
[[VALIDATORS]]
NAME="a2"
HOME_DOMAIN="domain"
PUBLIC_KEY="GBVZFVEARURUJTN5ABZPKW36FHKVJK2GHXEVY2SZCCNU5I3CQMTZ3OES"
)";
std::stringstream ss(configStr);
REQUIRE_THROWS_WITH(
c.load(ss),
"At least one validator must have a quality level higher than LOW");
}

0 comments on commit 437dfaf

Please sign in to comment.