Skip to content

Commit

Permalink
Make Genesis return consensus validators
Browse files Browse the repository at this point in the history
  • Loading branch information
p-offtermatt committed May 15, 2024
1 parent d21cf9a commit 87742aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 11 additions & 1 deletion x/ccv/provider/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package keeper
import (
"fmt"

abci "github.com/cometbft/cometbft/abci/types"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmos/interchain-security/v4/x/ccv/provider/types"
ccv "github.com/cosmos/interchain-security/v4/x/ccv/types"
)

// InitGenesis initializes the CCV provider state and binds to PortID.
func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) {
func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) []abci.ValidatorUpdate {
k.SetPort(ctx, ccv.ProviderPortID)

// Only try to bind to port if it is not already bound, since we may already own
Expand Down Expand Up @@ -136,6 +137,15 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) {

k.SetLastProviderConsensusValSet(ctx, reducedValSet)
k.InitializeSlashMeter(ctx)

valUpdates := make([]abci.ValidatorUpdate, len(reducedValSet))
for i, val := range reducedValSet {
valUpdates[i] = abci.ValidatorUpdate{
PubKey: *val.ConsumerPublicKey,
Power: val.Power,
}
}
return valUpdates
}

// ExportGenesis returns the CCV provider module's exported genesis
Expand Down
4 changes: 1 addition & 3 deletions x/ccv/provider/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
var genesisState providertypes.GenesisState
cdc.MustUnmarshalJSON(data, &genesisState)

am.keeper.InitGenesis(ctx, &genesisState)

return []abci.ValidatorUpdate{}
return am.keeper.InitGenesis(ctx, &genesisState)
}

// ExportGenesis returns the exported genesis state as raw bytes for the provider
Expand Down

0 comments on commit 87742aa

Please sign in to comment.