-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Have ability to validate with multiple keys on the same node #3324
Description
In refactoring in #3296 we came across the idea that we'd like to have the ability to have multiple "validator keys" in the keystore to be able to run multiple validators from the same node.
So for instance in GRANDPA we would replace something like this:
fn is_voter(
voters: &Arc<VoterSet<AuthorityId>>,
keystore: &Option<KeyStorePtr>,
) -> Option<AuthorityPair> {
match keystore {
Some(keystore) => voters.voters().iter()
.find_map(|(p, _)| keystore.read().key_pair::<AuthorityPair>(&p).ok()),
None => None,
}
}
To something like this:
fn is_voter(
voters: &Arc<VoterSet<AuthorityId>>,
keystore: &Option<KeyStorePtr>,
) -> Vec<AuthorityPair> {
match keystore {
Some(keystore) => voters.voters().iter()
.filter_map(|(p, _)| keystore.read().key_pair::<AuthorityPair>(&p).ok()).collect(),
None => vec![],
}
}
However, the change is not this simple. Currently (as I understand it) a future for GRANDPA is started in run_grandpa_voter which is essentially a state machine keeping track of voting behavior for one validator, picking the key for that validator with the is_voter function above. Basically just picking the first key it finds that matches an active validator for the Era.
If we wanted to vote on behalf of multiple validators, we would need a way to have one of these state machines per key that we have, instead of just looking for the first active key we can find.
This is a bit of an inversion of responsibility, where now the GRANDPA voter is responsible for looking for a key that is active and using that (if there are multiple it would be like an arbitrary choice of any active key). We would need to change this around to have something push the keys to use to the future, which means we need to re-instantiate the future somehow when the keys rotate and we get new session keys in place in the keystore.
This would have some effect on networking as well, as we can't associate an address with a single validator anymore, but behind one address might be multiple validators.
Have talked this through with @andresilva who considers this non-trivial. Would like to hear thoughts from @rphmeier and @tomaka as well who might have some insight into how to best achieve this goal.
Hopefully I'm clear enough in this issue about what needs to be accomplished and the problems I see right now.