Main source, a trie that stores [validatorIndex: Validator]
Index, a key-value source [pubKey: validatorIndex]
According to potential use cases this schema doesn't look optimal.
Proposal
Switch trie to ~[pubKey: Validator]~ [blake2b(pubKey): Validator] schema, since in almost all use cases validator can be accessed by its pubKey.
Switch Index to [validatorIndex: pubKey] which is useful for signature aggregation checks where validators are gonna be accessed by their indices. This seems to be the only case for the index.
What's wrong
Currently there are two sources in TrieValidatorSet:
[validatorIndex: Validator]
[pubKey: validatorIndex]
According to potential use cases this schema doesn't look optimal.
Proposal
[pubKey: Validator]
~[blake2b(pubKey): Validator]
schema, since in almost all use cases validator can be accessed by itspubKey
.[validatorIndex: pubKey]
which is useful for signature aggregation checks where validators are gonna be accessed by their indices. This seems to be the only case for the index.