ethereum / ethereumj

DEPRECATED! Java implementation of the Ethereum yellowpaper. For JSON-RPC and other client features check Ethereum Harmony
GNU Lesser General Public License v3.0
2.18k stars 1.09k forks source link

Refactor TrieValidatorSet to close issue #1186 #1259

Closed jskskjnekd closed 5 years ago

jskskjnekd commented 5 years ago

Original Problem #1186

Optimize TrieValidatorSet.

Currently, the two main sources are

trie -> [validatorIndex: Validator] index -> a key-value source [pubKey: validatorIndex]

Proposal of #1186

trie -> [blake2b(pubKey): validator] index -> a key-value source [validatorIndex: pubKey]

Main problem of this proposal is that, after the refactoring, when we use the function getSnapshotTo, the validator could not be found from source index.

The main reason is that, trie got updated through getSnapshotTo but not the source of index. We can conclude that, validatorIndex is the data source we should also keep update. It means that, if we need to get access to validators through indices, the indices are always updated and correct.

New Proposal

As a result, I propose to make a small modification on two sources.

trie -> [validatorIndex: pubKey] index -> [blake2b(pubKey): validator]

mkalinin commented 5 years ago

We are not maintaining this implementation anymore. Sorry about that. Let me close all related issues to avoid any further confusion.