Skip to content

Commit 1ed9c34

Browse files
mmsqemergify[bot]
authored andcommitted
fix: avoid invalid identifier error when validate genesis (#7397)
* fix: avoid invalid identifier error when validate genesis that contains localhost client * Apply suggestions from code review * skip (cherry picked from commit ff2b668) # Conflicts: # CHANGELOG.md
1 parent a5f6fa1 commit 1ed9c34

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ Ref: https://keepachangelog.com/en/1.0.0/
4848

4949
### Bug Fixes
5050

51+
<<<<<<< HEAD
52+
=======
53+
* (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.
54+
* (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.
55+
* (core/03-connection) [\#7397](https://github.com/cosmos/ibc-go/pull/7397) Skip the genesis validation connectionID for localhost client.
56+
57+
>>>>>>> ff2b668c (fix: avoid invalid identifier error when validate genesis (#7397))
5158
## [v9.0.0](https://github.com/cosmos/ibc-go/releases/tag/v9.0.0) - 2024-10-01
5259

5360
### Dependencies

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

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55

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

910
// NewConnectionPaths creates a ConnectionPaths instance.
@@ -45,13 +46,14 @@ 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-
}
52-
53-
if sequence > maxSequence {
54-
maxSequence = sequence
49+
if conn.Id != exported.LocalhostConnectionID {
50+
sequence, err := ParseConnectionSequence(conn.Id)
51+
if err != nil {
52+
return err
53+
}
54+
if sequence > maxSequence {
55+
maxSequence = sequence
56+
}
5557
}
5658

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

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(

0 commit comments

Comments
 (0)