From 1ed9c34a17482ae02788ab239a200d3a1d7afe58 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 7 Oct 2024 22:36:52 +0800 Subject: [PATCH 1/2] 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 ff2b668cfd270dc15ab698667ca1442fc590eab4) # Conflicts: # CHANGELOG.md --- CHANGELOG.md | 7 +++++++ modules/core/03-connection/types/genesis.go | 16 +++++++++------- modules/core/03-connection/types/genesis_test.go | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f694212bb16..a894a5211b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,13 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +<<<<<<< HEAD +======= +* (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. +* (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. +* (core/03-connection) [\#7397](https://github.com/cosmos/ibc-go/pull/7397) Skip the genesis validation connectionID for localhost client. + +>>>>>>> ff2b668c (fix: avoid invalid identifier error when validate genesis (#7397)) ## [v9.0.0](https://github.com/cosmos/ibc-go/releases/tag/v9.0.0) - 2024-10-01 ### Dependencies diff --git a/modules/core/03-connection/types/genesis.go b/modules/core/03-connection/types/genesis.go index 941b441f7e1..fc6689a0704 100644 --- a/modules/core/03-connection/types/genesis.go +++ b/modules/core/03-connection/types/genesis.go @@ -4,6 +4,7 @@ import ( "fmt" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + "github.com/cosmos/ibc-go/v9/modules/core/exported" ) // NewConnectionPaths creates a ConnectionPaths instance. @@ -45,13 +46,14 @@ func (gs GenesisState) Validate() error { var maxSequence uint64 for i, conn := range gs.Connections { - sequence, err := ParseConnectionSequence(conn.Id) - if err != nil { - return err - } - - if sequence > maxSequence { - maxSequence = sequence + if conn.Id != exported.LocalhostConnectionID { + sequence, err := ParseConnectionSequence(conn.Id) + if err != nil { + return err + } + if sequence > maxSequence { + maxSequence = sequence + } } if err := conn.ValidateBasic(); err != nil { diff --git a/modules/core/03-connection/types/genesis_test.go b/modules/core/03-connection/types/genesis_test.go index c009d6410fb..39a930c1433 100644 --- a/modules/core/03-connection/types/genesis_test.go +++ b/modules/core/03-connection/types/genesis_test.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + "github.com/cosmos/ibc-go/v9/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v9/testing" ) @@ -91,6 +92,20 @@ func TestValidateGenesis(t *testing.T) { ), expPass: false, }, + { + name: "localhost connection identifier", + genState: types.NewGenesisState( + []types.IdentifiedConnection{ + types.NewIdentifiedConnection(exported.LocalhostConnectionID, types.NewConnectionEnd(types.INIT, clientID, types.Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []*types.Version{ibctesting.ConnectionVersion}, 500)), + }, + []types.ConnectionPaths{ + {clientID, []string{connectionID}}, + }, + 0, + types.DefaultParams(), + ), + expPass: true, + }, { name: "next connection sequence is not greater than maximum connection identifier sequence provided", genState: types.NewGenesisState( From 4d12b51d8a0a8c61b98506cd2d5d00bb0b48266f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Mon, 7 Oct 2024 16:55:40 +0200 Subject: [PATCH 2/2] chore: changelog cleanup --- CHANGELOG.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a894a5211b3..d1a95ebb4e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,13 +48,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes -<<<<<<< HEAD -======= -* (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. -* (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. * (core/03-connection) [\#7397](https://github.com/cosmos/ibc-go/pull/7397) Skip the genesis validation connectionID for localhost client. ->>>>>>> ff2b668c (fix: avoid invalid identifier error when validate genesis (#7397)) ## [v9.0.0](https://github.com/cosmos/ibc-go/releases/tag/v9.0.0) - 2024-10-01 ### Dependencies