Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort Validators like Tendermint in HistoricalInfo #7676

Closed
AdityaSripal opened this issue Oct 26, 2020 · 7 comments · Fixed by #7691
Closed

Sort Validators like Tendermint in HistoricalInfo #7676

AdityaSripal opened this issue Oct 26, 2020 · 7 comments · Fixed by #7691
Assignees

Comments

@AdityaSripal
Copy link
Member

Currently the order of ValidatorSet in staking.HistoricalInfo is not the same as order in tendermint. They should be the same in order to easily verify validatorset equality in IBC

@AdityaSripal
Copy link
Member Author

Turns out we store sdk.Validators in HistoricalInfo rather than tmtypes.Validators, this is unfortunate because we can't use the tendermint sorting function as-is.

3 ways to move forward:

  1. Implement a sort by power function in sdk and store sdk.Validators
  2. Convert sdk.Validators to tendermint (easy), sort, and then reconvert to sdk (idk how to do this at first glance). It is also hacky
  3. Change HistoricalInfo to store tendermint.ValidatorSet. This is the least hacky solution but requires the most changes.

Thoughts? @cwgoes @colin-axner @fedekunze

@fedekunze
Copy link
Collaborator

I would prefer 1)

@cwgoes
Copy link
Contributor

cwgoes commented Oct 26, 2020

Prefer (1) or (3). (1) is fine for now, the sort is simple enough.

@colin-axner
Copy link
Contributor

I prefer 1), it would make SDK support for non-tendermint consensus easier to do in the future

@fedekunze
Copy link
Collaborator

fedekunze commented Oct 27, 2020

Validators are also stored by power on the staking store under ValidatorsByPowerIndexKey. There's also an iterator function for bonded vals: IterateBondedValidatorsByPower which could be a good ref

@AdityaSripal
Copy link
Member Author

AdityaSripal commented Oct 27, 2020

Yup checking to see if that will match tendermints sorting now. I suspect not since it sorts by power than operator address

Wherease tendermint sorts by power than consensus address

@jackzampolin
Copy link
Member

Related to this I was running into issues using stakingtypes.Validators.ToTMValidators to modify historical info.

Before fix
After fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants