Skip to content

Commit

Permalink
Start implementing unbonded validators for consumer chains
Browse files Browse the repository at this point in the history
  • Loading branch information
p-offtermatt committed May 16, 2024
1 parent 1294f90 commit 879f1d0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
26 changes: 24 additions & 2 deletions x/ccv/provider/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,30 @@ func (k Keeper) SendVSCPacketsToChain(ctx sdk.Context, chainID, channelID string
func (k Keeper) QueueVSCPackets(ctx sdk.Context) {
valUpdateID := k.GetValidatorSetUpdateId(ctx) // current valset update ID

// get the bonded validators from the staking module
bondedValidators := k.stakingKeeper.GetLastValidators(ctx)
// get all validators from the staking module
validatorIterator := k.stakingKeeper.ValidatorsPowerStoreIterator(ctx)

// get the first N validators
// TODO make this a param
maxTotalValidators := 500

validators := make([]stakingtypes.Validator, 0, maxTotalValidators)
defer validatorIterator.Close()

i := 0
for ; validatorIterator.Valid() && i < int(maxTotalValidators); validatorIterator.Next() {
address := validatorIterator.Value()
validator, found := k.stakingKeeper.GetValidatorByConsAddr(ctx, address)
if !found {
k.Logger(ctx).Error("validator not found", "address", address.String())

Check failure on line 235 in x/ccv/provider/keeper/relay.go

View workflow job for this annotation

GitHub Actions / Analyze

address.String undefined (type []byte has no field or method String)
continue
}

if validator.IsBonded() {
validators[i] = validator
i++
}
}

for _, chain := range k.GetAllConsumerChains(ctx) {
currentValidators := k.GetConsumerValSet(ctx, chain.ChainId)
Expand Down
1 change: 1 addition & 0 deletions x/ccv/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type StakingKeeper interface {
GetRedelegationsFromSrcValidator(ctx sdk.Context, valAddr sdk.ValAddress) (reds []stakingtypes.Redelegation)
GetUnbondingType(ctx sdk.Context, id uint64) (unbondingType stakingtypes.UnbondingType, found bool)
MinCommissionRate(ctx sdk.Context) math.LegacyDec
ValidatorsPowerStoreIterator(ctx sdk.Context) sdk.Iterator
}

// SlashingKeeper defines the contract expected to perform ccv slashing
Expand Down

0 comments on commit 879f1d0

Please sign in to comment.