cosmos / interchain-security

Interchain Security is an open sourced IBC application which allows cosmos blockchains to lease their proof-of-stake security to one another.
https://cosmos.github.io/interchain-security/
Other
154 stars 115 forks source link

Replace calls to GetLastValidators with IterateLastValidatorPowers #1947

Closed mpoke closed 3 months ago

mpoke commented 4 months ago

Problem

The GetLastValidators method of the staking module has a panic in it. Calling this from BeginBlock or EndBlock might lead to the chain to halt.

Closing criteria

All the calls to GetLastValidators are replaced with IterateLastValidatorPowers.

MSalopek commented 4 months ago

Would it be possible to have a utility function that returns the active portion of the validator set instead of adding IterateLastValidatorPowers in all places?

e.g.

providerKeeper.GetLastActiveValidatorPowers()

func (k *Keeper) GetLastActiveValidatorPowers() <return-type> {
  ...
  k.stakingKeeper.IterateLastValidatorPowers(...)
  return <return-type>
}