Skip to content

Commit 0f4bc90

Browse files
committed
Apply suggestions from code review
1 parent 4c04818 commit 0f4bc90

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
6464

6565
* (apps/27-interchain-accounts) [\#7277](https://github.com/cosmos/ibc-go/pull/7277) Use `GogoResolver` when populating module query safe allow list to avoid panics from unresolvable protobuf dependencies.
6666
* (core/04-channel) [\#7342](https://github.com/cosmos/ibc-go/pull/7342) Read Tx cmd flags including from address to avoid Address cannot be empty error when upgrade-channels via cli.
67-
* (core/03-connection) [\#7397](https://github.com/cosmos/ibc-go/pull/7397) Skip the validation connectionID for localhost client.
67+
* (core/03-connection) [\#7397](https://github.com/cosmos/ibc-go/pull/7397) Skip the genesis validation connectionID for localhost client.
6868

6969
## [v9.0.0](https://github.com/cosmos/ibc-go/releases/tag/v9.0.0) - 2024-10-01
7070

modules/core/03-connection/types/genesis.go

+5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package types
22

33
import (
44
"fmt"
5+
"strings"
56

67
host "github.com/cosmos/ibc-go/v9/modules/core/24-host"
8+
"github.com/cosmos/ibc-go/v9/modules/core/exported"
79
)
810

911
// NewConnectionPaths creates a ConnectionPaths instance.
@@ -47,6 +49,9 @@ func (gs GenesisState) Validate() error {
4749
for i, conn := range gs.Connections {
4850
sequence, err := ParseConnectionSequence(conn.Id)
4951
if err != nil {
52+
if conn.Id == exported.LocalhostConnectionID && strings.Contains(err.Error(), host.ErrInvalidID.Error()) {
53+
continue
54+
}
5055
return err
5156
}
5257

modules/core/03-connection/types/genesis_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/cosmos/ibc-go/v9/modules/core/03-connection/types"
99
commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types"
10+
"github.com/cosmos/ibc-go/v9/modules/core/exported"
1011
ibctesting "github.com/cosmos/ibc-go/v9/testing"
1112
)
1213

@@ -91,6 +92,20 @@ func TestValidateGenesis(t *testing.T) {
9192
),
9293
expPass: false,
9394
},
95+
{
96+
name: "localhost connection identifier",
97+
genState: types.NewGenesisState(
98+
[]types.IdentifiedConnection{
99+
types.NewIdentifiedConnection(exported.LocalhostConnectionID, types.NewConnectionEnd(types.INIT, clientID, types.Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []*types.Version{ibctesting.ConnectionVersion}, 500)),
100+
},
101+
[]types.ConnectionPaths{
102+
{clientID, []string{connectionID}},
103+
},
104+
0,
105+
types.DefaultParams(),
106+
),
107+
expPass: true,
108+
},
94109
{
95110
name: "next connection sequence is not greater than maximum connection identifier sequence provided",
96111
genState: types.NewGenesisState(

modules/core/03-connection/types/keys.go

-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
errorsmod "cosmossdk.io/errors"
88

99
host "github.com/cosmos/ibc-go/v9/modules/core/24-host"
10-
"github.com/cosmos/ibc-go/v9/modules/core/exported"
1110
)
1211

1312
const (
@@ -53,9 +52,6 @@ func IsValidConnectionID(connectionID string) bool {
5352

5453
// ParseConnectionSequence parses the connection sequence from the connection identifier.
5554
func ParseConnectionSequence(connectionID string) (uint64, error) {
56-
if connectionID == exported.LocalhostConnectionID {
57-
return 0, nil
58-
}
5955
if !IsConnectionIDFormat(connectionID) {
6056
return 0, errorsmod.Wrap(host.ErrInvalidID, "connection identifier is not in the format: `connection-{N}`")
6157
}

modules/core/03-connection/types/keys_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ func TestParseConnectionSequence(t *testing.T) {
3030
{"blank id", " ", 0, false},
3131
{"empty id", "", 0, false},
3232
{"negative sequence", "connection--1", 0, false},
33-
{"localhost", "connection-localhost", 0, true},
3433
}
3534

3635
for _, tc := range testCases {

0 commit comments

Comments
 (0)