From 87742aa4c5b45dcc42ca8f001fcc0301931495ce Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Wed, 15 May 2024 10:40:43 +0200
Subject: [PATCH] Make Genesis return consensus validators
---
x/ccv/provider/keeper/genesis.go | 12 +++++++++++-
x/ccv/provider/module.go | 4 +---
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/x/ccv/provider/keeper/genesis.go b/x/ccv/provider/keeper/genesis.go
index 722843398d..54290a2587 100644
--- a/x/ccv/provider/keeper/genesis.go
+++ b/x/ccv/provider/keeper/genesis.go
@@ -3,6 +3,7 @@ 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"
@@ -10,7 +11,7 @@ import (
)
// 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
@@ -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
diff --git a/x/ccv/provider/module.go b/x/ccv/provider/module.go
index 723d1080e8..748f5fc023 100644
--- a/x/ccv/provider/module.go
+++ b/x/ccv/provider/module.go
@@ -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