Skip to content

Commit

Permalink
Merge branch 'client-id' into keeper-unit-tests-consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
shaspitz committed Aug 22, 2022
2 parents 6ceff72 + d9290b6 commit 4326ce5
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# CODEOWNERS: https://help.github.com/articles/about-codeowners/

* @adityasripal @jtremback @mpoke @sainoe @danwt
* @jtremback @mpoke @sainoe @danwt
8 changes: 4 additions & 4 deletions x/ccv/consumer/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *types.GenesisState) []abci.V
// Set default value for valset update ID
k.SetHeightValsetUpdateID(ctx, uint64(ctx.BlockHeight()), uint64(0))
// set provider client id.
k.SetProviderClient(ctx, clientID)
k.SetProviderClientID(ctx, clientID)
} else {
// verify that latest consensus state on provider client matches the initial validator set of restarted chain
// thus, IBC genesis MUST run before CCV consumer genesis
Expand Down Expand Up @@ -87,7 +87,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *types.GenesisState) []abci.V
k.SetUnbondingTime(ctx, unbondingTime)

// set provider client id
k.SetProviderClient(ctx, state.ProviderClientId)
k.SetProviderClientID(ctx, state.ProviderClientId)
// set provider channel id.
k.SetProviderChannel(ctx, state.ProviderChannelId)
// set all unbonding sequences
Expand All @@ -110,7 +110,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
}

if channelID, ok := k.GetProviderChannel(ctx); ok {
clientID, ok := k.GetProviderClient(ctx)
clientID, ok := k.GetProviderClientID(ctx)
if !ok {
panic("provider client does not exist")
}
Expand All @@ -131,7 +131,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
gs.MaturingPackets = maturingPackets
return gs
}
clientID, ok := k.GetProviderClient(ctx)
clientID, ok := k.GetProviderClientID(ctx)
// if provider clientID and channelID don't exist on the consumer chain, then CCV protocol is disabled for this chain
// return a disabled genesis state
if !ok {
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/consumer/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (suite *KeeperTestSuite) TestGenesis() {
portId := suite.consumerChain.App.(*app.App).ConsumerKeeper.GetPort(ctx)
suite.Require().Equal(consumertypes.PortID, portId)

clientId, ok := suite.consumerChain.App.(*app.App).ConsumerKeeper.GetProviderClient(ctx)
clientId, ok := suite.consumerChain.App.(*app.App).ConsumerKeeper.GetProviderClientID(ctx)
suite.Require().True(ok)
clientState, ok := suite.consumerChain.App.GetIBCKeeper().ClientKeeper.GetClientState(ctx, clientId)
suite.Require().True(ok)
Expand Down
14 changes: 7 additions & 7 deletions x/ccv/consumer/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,17 @@ func (k Keeper) DeleteUnbondingTime(ctx sdk.Context) {
store.Delete(types.UnbondingTimeKey())
}

// SetProviderClient sets the provider clientID that is validating the chain.
// SetProviderClientID sets the provider clientID that is validating the chain.
// Set in InitGenesis
func (k Keeper) SetProviderClient(ctx sdk.Context, clientID string) {
func (k Keeper) SetProviderClientID(ctx sdk.Context, clientID string) {
store := ctx.KVStore(k.storeKey)
store.Set(types.ProviderClientKey(), []byte(clientID))
store.Set(types.ProviderClientIDKey(), []byte(clientID))
}

// GetProviderClient gets the provider clientID that is validating the chain.
func (k Keeper) GetProviderClient(ctx sdk.Context) (string, bool) {
// GetProviderClientID gets the provider clientID that is validating the chain.
func (k Keeper) GetProviderClientID(ctx sdk.Context) (string, bool) {
store := ctx.KVStore(k.storeKey)
clientIdBytes := store.Get(types.ProviderClientKey())
clientIdBytes := store.Get(types.ProviderClientIDKey())
if clientIdBytes == nil {
return "", false
}
Expand Down Expand Up @@ -288,7 +288,7 @@ func (k Keeper) VerifyProviderChain(ctx sdk.Context, channelID string, connectio
return sdkerrors.Wrapf(conntypes.ErrConnectionNotFound, "connection not found for connection ID: %s", connectionID)
}
// Verify that client id is expected clientID
expectedClientId, ok := k.GetProviderClient(ctx)
expectedClientId, ok := k.GetProviderClientID(ctx)
if !ok {
return sdkerrors.Wrapf(clienttypes.ErrInvalidClient, "could not find provider client id")
}
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/consumer/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (suite *ConsumerTestSuite) SetupTest() {
suite.Require().True(found, "consumer client not found")
suite.path.EndpointB.ClientID = consumerClient
// - set consumer endpoint's clientID
providerClient, found := suite.consumerChain.App.(*appConsumer.App).ConsumerKeeper.GetProviderClient(suite.consumerChain.GetContext())
providerClient, found := suite.consumerChain.App.(*appConsumer.App).ConsumerKeeper.GetProviderClientID(suite.consumerChain.GetContext())
suite.Require().True(found, "provider client not found")
suite.path.EndpointA.ClientID = providerClient
// - client config
Expand Down
4 changes: 2 additions & 2 deletions x/ccv/consumer/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func UnbondingTimeKey() []byte {
return []byte{UnbondingTimeByteKey}
}

// ProviderClientKey returns the key for storing clientID of the provider
func ProviderClientKey() []byte {
// ProviderClientIDKey returns the key for storing clientID of the provider
func ProviderClientIDKey() []byte {
return []byte{ProviderClientByteKey}
}

Expand Down
2 changes: 1 addition & 1 deletion x/ccv/consumer/types/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func getSingleByteKeys() [][]byte {
keys[i], i = PortKey(), i+1
keys[i], i = LastDistributionTransmissionKey(), i+1
keys[i], i = UnbondingTimeKey(), i+1
keys[i], i = ProviderClientKey(), i+1
keys[i], i = ProviderClientIDKey(), i+1
keys[i], i = ProviderChannelKey(), i+1
keys[i], i = PendingChangesKey(), i+1
keys[i], i = []byte{HistoricalInfoBytePrefix}, i+1
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/provider/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (suite *KeeperTestSuite) SetupTest() {
suite.Require().True(found, "consumer client not found")
suite.path.EndpointB.ClientID = consumerClient
// - set consumer endpoint's clientID
providerClient, found := suite.consumerChain.App.(*appConsumer.App).ConsumerKeeper.GetProviderClient(suite.consumerChain.GetContext())
providerClient, found := suite.consumerChain.App.(*appConsumer.App).ConsumerKeeper.GetProviderClientID(suite.consumerChain.GetContext())
suite.Require().True(found, "provider client not found")
suite.path.EndpointA.ClientID = providerClient
// - client config
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (suite *ProviderTestSuite) SetupTest() {
suite.Require().True(found, "consumer client not found")
suite.path.EndpointB.ClientID = consumerClient
// - set consumer endpoint's clientID
providerClient, found := suite.consumerChain.App.(*appConsumer.App).ConsumerKeeper.GetProviderClient(suite.consumerChain.GetContext())
providerClient, found := suite.consumerChain.App.(*appConsumer.App).ConsumerKeeper.GetProviderClientID(suite.consumerChain.GetContext())
suite.Require().True(found, "provider client not found")
suite.path.EndpointA.ClientID = providerClient
// - client config
Expand Down

0 comments on commit 4326ce5

Please sign in to comment.