Add cookie to validation (RIPD-1586):

Each validator will generate a random cookie on startup that it will
include in each of its validations. This will allow validators to detect
when more than one validator is accidentally operating with the same
validation keys.
This commit is contained in:
Brad Chase
2018-03-12 12:41:09 -04:00
committed by Nikolaos D. Bougalis
parent 3dc0714273
commit f7a4a94c3b
21 changed files with 313 additions and 106 deletions

View File

@@ -330,14 +330,13 @@ public:
BEAST_EXPECT(ret.second == post_state.end());
}
std::vector <PublicKey> makeValidators (int num)
std::vector<std::pair<PublicKey,SecretKey>> makeValidators (int num)
{
std::vector <PublicKey> ret;
std::vector <std::pair<PublicKey, SecretKey>> ret;
ret.reserve (num);
for (int i = 0; i < num; ++i)
{
ret.push_back (
randomKeyPair(KeyType::secp256k1).first);
ret.emplace_back(randomKeyPair(KeyType::secp256k1));
}
return ret;
}
@@ -351,7 +350,7 @@ public:
void doRound(
AmendmentTable& table,
weeks week,
std::vector <PublicKey> const& validators,
std::vector <std::pair<PublicKey, SecretKey>> const& validators,
std::vector <std::pair <uint256, int>> const& votes,
std::vector <uint256>& ourVotes,
std::set <uint256>& enabled,
@@ -377,11 +376,8 @@ public:
int i = 0;
for (auto const& val : validators)
{
auto v = std::make_shared<STValidation>(
uint256(), uint256(), roundTime, val, calcNodeID(val), true);
++i;
STVector256 field (sfAmendments);
std::vector<uint256> field;
for (auto const& amendment : votes)
{
@@ -391,10 +387,20 @@ public:
field.push_back (amendment.first);
}
}
if (!field.empty ())
v->setFieldV256 (sfAmendments, field);
v->setTrusted();
auto v = std::make_shared<STValidation>(
uint256(),
i,
uint256(),
roundTime,
val.first,
val.second,
calcNodeID(val.first),
true,
STValidation::FeeSettings{},
field,
boost::none);
validations.emplace_back(v);
}