Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetProviderClient -> GetProviderClientID #276

Merged
merged 2 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -164,17 +164,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 @@ -289,7 +289,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
6 changes: 3 additions & 3 deletions x/ccv/consumer/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ 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())
providerClientID, found := suite.consumerChain.App.(*appConsumer.App).ConsumerKeeper.GetProviderClientID(suite.consumerChain.GetContext())
suite.Require().True(found, "provider client not found")
suite.path.EndpointA.ClientID = providerClient
suite.path.EndpointA.ClientID = providerClientID
// - client config
providerUnbondingPeriod := suite.providerChain.App.(*appProvider.App).GetStakingKeeper().UnbondingTime(suite.providerChain.GetContext())
suite.path.EndpointB.ClientConfig.(*ibctesting.TendermintConfig).UnbondingPeriod = providerUnbondingPeriod
Expand Down Expand Up @@ -146,7 +146,7 @@ func (suite *KeeperTestSuite) TestUnbondingTime() {
}

func (suite *KeeperTestSuite) TestProviderClient() {
providerClient, ok := suite.consumerChain.App.(*appConsumer.App).ConsumerKeeper.GetProviderClient(suite.ctx)
providerClient, ok := suite.consumerChain.App.(*appConsumer.App).ConsumerKeeper.GetProviderClientID(suite.ctx)
suite.Require().True(ok)

clientState, _ := suite.consumerChain.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.ctx, providerClient)
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