Skip to content

Commit

Permalink
Proposal, builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel committed Oct 25, 2022
1 parent 8c1f7d9 commit b54de67
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions x/ccv/provider/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, chainID string, initialHei
}
k.SetConsumerClientId(ctx, chainID, clientID)

consumerGen, err := k.MakeConsumerGenesis(ctx)
consumerGen, err := k.MakeConsumerGenesis(ctx, chainID)
if err != nil {
return err
}
Expand Down Expand Up @@ -189,7 +189,7 @@ func (k Keeper) StopConsumerChain(ctx sdk.Context, chainID string, lockUbd, clos
}

// MakeConsumerGenesis constructs a consumer genesis state.
func (k Keeper) MakeConsumerGenesis(ctx sdk.Context) (gen consumertypes.GenesisState, err error) {
func (k Keeper) MakeConsumerGenesis(ctx sdk.Context, chainID string) (gen consumertypes.GenesisState, err error) {
unbondingTime := k.stakingKeeper.UnbondingTime(ctx)
height := clienttypes.GetSelfHeight(ctx)

Expand Down Expand Up @@ -218,7 +218,7 @@ func (k Keeper) MakeConsumerGenesis(ctx sdk.Context) (gen consumertypes.GenesisS
return false
})

updates := []abci.ValidatorUpdate{}
providerUpdates := []abci.ValidatorUpdate{}

for _, p := range lastPowers {
addr, err := sdk.ValAddressFromBech32(p.Address)
Expand All @@ -236,13 +236,28 @@ func (k Keeper) MakeConsumerGenesis(ctx sdk.Context) (gen consumertypes.GenesisS
panic(err)
}

updates = append(updates, abci.ValidatorUpdate{
providerUpdates = append(providerUpdates, abci.ValidatorUpdate{
PubKey: tmProtoPk,
Power: p.Power,
})
}

gen.InitialValSet = updates
// TODO: deduplicate these blocks
for _, u := range providerUpdates {
if _, found := k.KeyMap(ctx, chainID).GetCurrentConsumerPubKeyFromProviderPubKey(u.PubKey); !found {
// The provider has not designated a key to use for the consumer chain. Use the provider key
// by default.
k.KeyMap(ctx, chainID).SetProviderPubKeyToConsumerPubKey(u.PubKey, u.PubKey)
}
}

// Map the updates through any key transformations
// TODO: check vscid
consumerUpdates := k.KeyMap(ctx, chainID).ComputeUpdates(0, providerUpdates)

gen.InitialValSet = consumerUpdates

gen.InitialValSet = providerUpdates

return gen, nil
}
Expand Down

0 comments on commit b54de67

Please sign in to comment.