Skip to content

Commit

Permalink
GetConsensusPower should have reduction as input
Browse files Browse the repository at this point in the history
  • Loading branch information
leonz789 committed May 13, 2024
1 parent dc3621d commit 6328c42
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions x/dogfood/keeper/impl_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,16 @@ func (k Keeper) IterateBondedValidatorsByPower(
// will only happen if there is an error in deserialization.
continue
}
found, addr := k.operatorKeeper.GetOperatorAddressForChainIDAndConsAddr(
ctx, ctx.ChainID(), sdk.GetConsAddress(pk),
)
if !found {
// this should never happen. should we panic?
continue
}
val, err := stakingtypes.NewValidator(
// TODO: this is not the correct address, which is derived from
// sdk.ValAddress(sdk.AccAddress)
sdk.ValAddress(pk.Address()),
sdk.ValAddress(addr),
pk, stakingtypes.Description{},
)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions x/oracle/keeper/single.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ func recacheAggregatorContext(ctx sdk.Context, agc *aggregator.AggregatorContext
totalPower := big.NewInt(0)
validatorPowers := make(map[string]*big.Int)
k.IterateBondedValidatorsByPower(ctx, func(_ int64, validator stakingtypes.ValidatorI) bool {
power := big.NewInt(validator.GetConsensusPower(validator.GetBondedTokens()))
addr := string(validator.GetOperator())
power := big.NewInt(validator.GetConsensusPower(sdk.DefaultPowerReduction))
addr := validator.GetOperator().String()
validatorPowers[addr] = power
totalPower = new(big.Int).Add(totalPower, power)
return false
Expand Down Expand Up @@ -141,7 +141,7 @@ func initAggregatorContext(ctx sdk.Context, agc *aggregator.AggregatorContext, k
totalPower := big.NewInt(0)
validatorPowers := make(map[string]*big.Int)
k.IterateBondedValidatorsByPower(ctx, func(_ int64, validator stakingtypes.ValidatorI) bool {
power := big.NewInt(validator.GetConsensusPower(validator.GetBondedTokens()))
power := big.NewInt(validator.GetConsensusPower(sdk.DefaultPowerReduction))
addr := validator.GetOperator().String()
validatorPowers[addr] = power
totalPower = new(big.Int).Add(totalPower, power)
Expand Down

0 comments on commit 6328c42

Please sign in to comment.