From 0c8971ec740fd74a868e20695f4b018c2e573d53 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 24 Feb 2023 10:05:13 -0800 Subject: [PATCH 1/2] fixes --- x/ccv/consumer/ibc_module.go | 13 ++++--------- x/ccv/provider/keeper/proposal.go | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/x/ccv/consumer/ibc_module.go b/x/ccv/consumer/ibc_module.go index 80f7a96df7..2dc14b58e2 100644 --- a/x/ccv/consumer/ibc_module.go +++ b/x/ccv/consumer/ibc_module.go @@ -38,14 +38,9 @@ func (am AppModule) OnChanOpenInit( version = types.Version } - // check that provided version is correct - if version != types.Version { - return "", sdkerrors.Wrapf(types.ErrInvalidVersion, "got %s, expected %s", version, types.Version) - } - // ensure provider channel hasn't already been created if providerChannel, ok := am.keeper.GetProviderChannel(ctx); ok { - return version, sdkerrors.Wrapf(ccv.ErrDuplicateChannel, + return "", sdkerrors.Wrapf(ccv.ErrDuplicateChannel, "provider channel: %s already set", providerChannel) } @@ -53,12 +48,12 @@ func (am AppModule) OnChanOpenInit( if err := validateCCVChannelParams( ctx, am.keeper, order, portID, version, ); err != nil { - return version, err + return "", err } // ensure the counterparty port ID matches the expected provider port ID if counterparty.PortId != ccv.ProviderPortID { - return version, sdkerrors.Wrapf(porttypes.ErrInvalidPort, + return "", sdkerrors.Wrapf(porttypes.ErrInvalidPort, "invalid counterparty port: %s, expected %s", counterparty.PortId, ccv.ProviderPortID) } @@ -66,7 +61,7 @@ func (am AppModule) OnChanOpenInit( if err := am.keeper.ClaimCapability( ctx, chanCap, host.ChannelCapabilityPath(portID, channelID), ); err != nil { - return version, err + return "", err } return version, am.keeper.VerifyProviderChain(ctx, connectionHops) diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index 30f0c6b12e..6dab76f932 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -60,7 +60,7 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, prop *types.ConsumerAdditi fmt.Sprintf("cannot create client for existent consumer chain: %s", chainID)) } - // Consumers always start out with the default unbonding period + // Consumers start out with the unbonding period from the consumer addition prop consumerUnbondingPeriod := prop.UnbondingPeriod // Create client state by getting template client from parameters and filling in zeroed fields from proposal. From 32585d9a51ff08360025a0838e24c1e9b1fcfaf0 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 24 Feb 2023 10:10:33 -0800 Subject: [PATCH 2/2] ver string empty unless success --- x/ccv/consumer/ibc_module.go | 6 +++++- x/ccv/consumer/ibc_module_test.go | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/x/ccv/consumer/ibc_module.go b/x/ccv/consumer/ibc_module.go index 2dc14b58e2..eadd6d7cea 100644 --- a/x/ccv/consumer/ibc_module.go +++ b/x/ccv/consumer/ibc_module.go @@ -64,7 +64,11 @@ func (am AppModule) OnChanOpenInit( return "", err } - return version, am.keeper.VerifyProviderChain(ctx, connectionHops) + if err := am.keeper.VerifyProviderChain(ctx, connectionHops); err != nil { + return "", err + } + + return version, nil } // validateCCVChannelParams validates a ccv channel diff --git a/x/ccv/consumer/ibc_module_test.go b/x/ccv/consumer/ibc_module_test.go index cfa4e61166..ac71b7cfaf 100644 --- a/x/ccv/consumer/ibc_module_test.go +++ b/x/ccv/consumer/ibc_module_test.go @@ -160,6 +160,8 @@ func TestOnChanOpenInit(t *testing.T) { require.NoError(t, err) } else { require.Error(t, err) + // assert version string is empty + require.Empty(t, version) } // Confirm there are no unexpected external keeper calls ctrl.Finish()