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

minor channel fixes #8229

Merged
Merged
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
24 changes: 13 additions & 11 deletions x/ibc/core/04-channel/keeper/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ func (k Keeper) CounterpartyHops(ctx sdk.Context, ch types.Channel) ([]string, b
if len(ch.ConnectionHops) != 1 {
return []string{}, false
}
counterPartyHops := make([]string, 1)
counterpartyHops := make([]string, 1)
hop := ch.ConnectionHops[0]
conn, found := k.connectionKeeper.GetConnection(ctx, hop)
if !found {
return []string{}, false
}

counterPartyHops[0] = conn.GetCounterparty().GetConnectionID()
return counterPartyHops, true
counterpartyHops[0] = conn.GetCounterparty().GetConnectionID()
return counterpartyHops, true
}

// ChanOpenInit is called by a module to initiate a channel opening handshake with
Expand All @@ -51,19 +51,20 @@ func (k Keeper) ChanOpenInit(
return "", nil, sdkerrors.Wrap(connectiontypes.ErrConnectionNotFound, connectionHops[0])
}

if len(connectionEnd.GetVersions()) != 1 {
getVersions := connectionEnd.GetVersions()
if len(getVersions) != 1 {
return "", nil, sdkerrors.Wrapf(
connectiontypes.ErrInvalidVersion,
"single version must be negotiated on connection before opening channel, got: %v",
connectionEnd.GetVersions(),
getVersions,
)
}

if !connectiontypes.VerifySupportedFeature(connectionEnd.GetVersions()[0], order.String()) {
if !connectiontypes.VerifySupportedFeature(getVersions[0], order.String()) {
return "", nil, sdkerrors.Wrapf(
connectiontypes.ErrInvalidVersion,
"connection version %s does not support channel ordering: %s",
connectionEnd.GetVersions()[0], order.String(),
getVersions[0], order.String(),
)
}

Expand Down Expand Up @@ -157,19 +158,20 @@ func (k Keeper) ChanOpenTry(
)
}

if len(connectionEnd.GetVersions()) != 1 {
getVersions := connectionEnd.GetVersions()
if len(getVersions) != 1 {
return "", nil, sdkerrors.Wrapf(
connectiontypes.ErrInvalidVersion,
"single version must be negotiated on connection before opening channel, got: %v",
connectionEnd.GetVersions(),
getVersions,
)
}

if !connectiontypes.VerifySupportedFeature(connectionEnd.GetVersions()[0], order.String()) {
if !connectiontypes.VerifySupportedFeature(getVersions[0], order.String()) {
return "", nil, sdkerrors.Wrapf(
connectiontypes.ErrInvalidVersion,
"connection version %s does not support channel ordering: %s",
connectionEnd.GetVersions()[0], order.String(),
getVersions[0], order.String(),
)
}

Expand Down