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

Fix nits from audit #743

Merged
merged 2 commits into from
Feb 27, 2023
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
19 changes: 9 additions & 10 deletions x/ccv/consumer/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,37 @@ 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)
}

// Validate parameters
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)
}

// Claim channel capability passed back by IBC module
if err := am.keeper.ClaimCapability(
ctx, chanCap, host.ChannelCapabilityPath(portID, channelID),
); err != nil {
return version, err
return "", err
}

if err := am.keeper.VerifyProviderChain(ctx, connectionHops); err != nil {
return "", err
}

return version, am.keeper.VerifyProviderChain(ctx, connectionHops)
return version, nil
}

// validateCCVChannelParams validates a ccv channel
Expand Down
2 changes: 2 additions & 0 deletions x/ccv/consumer/ibc_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/provider/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down