Skip to content

Commit c11cecb

Browse files
fix: invalid identifier error in validate genesis
backports cosmos#7397
1 parent 864049e commit c11cecb

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
4848

4949
### Bug Fixes
5050

51+
* (core/03-connection) [\#7397](https://github.com/cosmos/ibc-go/pull/7397) Skip the genesis validation connectionID for localhost client.
52+
5153
## [v7.4.1](https://github.com/cosmos/ibc-go/releases/tag/v7.4.1) - 2024-05-22
5254

5355
### Improvements

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55

66
host "github.com/cosmos/ibc-go/v7/modules/core/24-host"
7+
"github.com/cosmos/ibc-go/v7/modules/core/exported"
78
)
89

910
// NewConnectionPaths creates a ConnectionPaths instance.
@@ -45,13 +46,15 @@ func (gs GenesisState) Validate() error {
4546
var maxSequence uint64
4647

4748
for i, conn := range gs.Connections {
48-
sequence, err := ParseConnectionSequence(conn.Id)
49-
if err != nil {
50-
return err
51-
}
49+
if conn.Id != exported.LocalhostConnectionID {
50+
sequence, err := ParseConnectionSequence(conn.Id)
51+
if err != nil {
52+
return err
53+
}
5254

53-
if sequence > maxSequence {
54-
maxSequence = sequence
55+
if sequence > maxSequence {
56+
maxSequence = sequence
57+
}
5558
}
5659

5760
if err := conn.ValidateBasic(); err != nil {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
99
commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types"
10+
"github.com/cosmos/ibc-go/v7/modules/core/exported"
1011
ibctesting "github.com/cosmos/ibc-go/v7/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(

0 commit comments

Comments
 (0)