Skip to content

Commit

Permalink
fix: avoid invalid identifier error when validate genesis (#7397)
Browse files Browse the repository at this point in the history
* 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
#	modules/core/03-connection/types/genesis.go
#	modules/core/03-connection/types/genesis_test.go
  • Loading branch information
mmsqe authored and mergify[bot] committed Oct 7, 2024
1 parent e0d73d4 commit 8a46534
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 7 deletions.
61 changes: 61 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,67 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes

* (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.
<<<<<<< HEAD
=======
* (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.

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

### Dependencies

* [\#6828](https://github.com/cosmos/ibc-go/pull/6828) Bump Cosmos SDK to v0.50.9.
* [\#6193](https://github.com/cosmos/ibc-go/pull/6193) Bump `cosmossdk.io/store` to v1.1.0.
* [\#7126](https://github.com/cosmos/ibc-go/pull/7126) Bump CometBFT to v0.38.11.
* [\#6380](https://github.com/cosmos/ibc-go/pull/6380) Bump go to v1.22.
* [\#7223](https://github.com/cosmos/ibc-go/pull/7223) Update ics23 to v0.11.0.

### API Breaking

* (core/02-client, light-clients) [\#5806](https://github.com/cosmos/ibc-go/pull/5806) Decouple light client routing from their encoding structure.
* (core/04-channel) [\#5991](https://github.com/cosmos/ibc-go/pull/5991) The client CLI `QueryLatestConsensusState` has been removed.
* (light-clients/06-solomachine) [\#6037](https://github.com/cosmos/ibc-go/pull/6037) Remove `Initialize` function from `ClientState` and move logic to `Initialize` function of `LightClientModule`.
* (light-clients/06-solomachine) [\#6230](https://github.com/cosmos/ibc-go/pull/6230) Remove `GetTimestampAtHeight`, `Status` and `UpdateStateOnMisbehaviour` functions from `ClientState` and move logic to functions of `LightClientModule`.
* (core/02-client) [\#6084](https://github.com/cosmos/ibc-go/pull/6084) Removed `stakingKeeper` as an argument to `NewKeeper` and replaced with a `ConsensusHost` implementation.
* (testing) [\#6070](https://github.com/cosmos/ibc-go/pull/6070) Remove `AssertEventsLegacy` function.
* (core) [\#6138](https://github.com/cosmos/ibc-go/pull/6138) Remove `Router` reference from IBC core keeper and use instead the router on the existing `PortKeeper` reference.
* (core/04-channel) [\#6023](https://github.com/cosmos/ibc-go/pull/6023) Remove emission of non-hexlified event attributes `packet_data` and `packet_ack`.
* (core) [\#6320](https://github.com/cosmos/ibc-go/pull/6320) Remove unnecessary `Proof` interface from `exported` package.
* (core/05-port) [\#6341](https://github.com/cosmos/ibc-go/pull/6341) Modify `UnmarshalPacketData` interface to take in the context, portID, and channelID. This allows for packet data's to be unmarshaled based on the channel version.
* (apps/27-interchain-accounts) [\#6433](https://github.com/cosmos/ibc-go/pull/6433) Use UNORDERED as the default ordering for new ICA channels.
* (apps/transfer) [\#6440](https://github.com/cosmos/ibc-go/pull/6440) Remove `GetPrefixedDenom`.
* (apps/transfer) [\#6508](https://github.com/cosmos/ibc-go/pull/6508) Remove the `DenomTrace` type.
* (apps/27-interchain-accounts) [\#6598](https://github.com/cosmos/ibc-go/pull/6598) Mark the `requests` repeated field of `MsgModuleQuerySafe` non-nullable.
* (23-commmitment) [\#6644](https://github.com/cosmos/ibc-go/pull/6644) Introduce `commitment.v2.MerklePath` to include `repeated bytes` in favour of `repeated string`. This supports using merkle path keys which include non UTF-8 encoded runes.
* (23-commmitment) [\#6870](https://github.com/cosmos/ibc-go/pull/6870) Remove `commitment.v1.MerklePath` in favour of `commitment.v2.MerklePath`.
* (apps/27-interchain-accounts) [\#6749](https://github.com/cosmos/ibc-go/pull/6749) The ICA controller `NewIBCMiddleware` constructor function sets by default the auth module to nil.
* (core, core/02-client) [\#6763](https://github.com/cosmos/ibc-go/pull/6763) Move prometheus metric labels for 02-client and core into a separate `metrics` package on core.
* (core/02-client) [\#6777](https://github.com/cosmos/ibc-go/pull/6777) The `NewClientProposalHandler` of `02-client` has been removed.
* (core/types) [\#6794](https://github.com/cosmos/ibc-go/pull/6794) The composite interface `QueryServer` has been removed from package `core/types`. Please use the granular `QueryServer` interfaces provided by each core submodule.
* (light-clients/06-solomachine) [\#6888](https://github.com/cosmos/ibc-go/pull/6888) Remove `TypeClientMisbehaviour` constant and the `Type` method on `Misbehaviour`.
* (light-clients/06-solomachine, light-clients/07-tendermint) [\#6891](https://github.com/cosmos/ibc-go/pull/6891) The `VerifyMembership` and `VerifyNonMembership` functions of solomachine's `ClientState` have been made private. The `VerifyMembership`, `VerifyNonMembership`, `GetTimestampAtHeight`, `Status` and `Initialize` functions of tendermint's `ClientState` have been made private.
* (core/04-channel) [\#6902](https://github.com/cosmos/ibc-go/pull/6902) Add channel version to core application callbacks.
* (core/03-connection, core/02-client) [\#6937](https://github.com/cosmos/ibc-go/pull/6937) Remove 'ConsensusHost' interface, also removing self client and consensus state validation in the connection handshake.
* (core/24-host) [\#6882](https://github.com/cosmos/ibc-go/issues/6882) All functions ending in `Path` have been removed from 24-host in favour of their sybling functions ending in `Key`.

### State Machine Breaking

* (light-clients/06-solomachine) [\#6313](https://github.com/cosmos/ibc-go/pull/6313) Fix: No-op to avoid panicking on `UpdateState` for invalid misbehaviour submissions.

### Improvements

* (apps/27-interchain-accounts) [\#5533](https://github.com/cosmos/ibc-go/pull/5533) ICA host sets the host connection ID on `OnChanOpenTry`, so that ICA controller implementations are not obliged to set the value on `OnChanOpenInit` if they are not able.
* (core/02-client, core/03-connection, apps/27-interchain-accounts) [\#6256](https://github.com/cosmos/ibc-go/pull/6256) Add length checking of array fields in messages.

### Features

* (apps/transfer) [\#6492](https://github.com/cosmos/ibc-go/pull/6492) Added new `Tokens` field to `MsgTransfer` to enable sending of multiple denoms, and deprecated the `Token` field.
* (apps/transfer) [\#6693](https://github.com/cosmos/ibc-go/pull/6693) Added new `Forwarding` field to `MsgTransfer` to enable forwarding tokens through multiple intermediary chains with a single transaction. This also enables automatic unwinding of tokens to their native chain. `x/authz` support for transfer allows granters to specify a set of possible forwarding hops that are allowed for grantees.

### Bug Fixes

* (apps/27-interchain-accounts) [\#6377](https://github.com/cosmos/ibc-go/pull/6377) Generate ICA simtest proposals only for provided keepers.
>>>>>>> ff2b668c (fix: avoid invalid identifier error when validate genesis (#7397))
## [v8.5.0](https://github.com/cosmos/ibc-go/releases/tag/v8.5.0) - 2024-08-30

Expand Down
20 changes: 13 additions & 7 deletions modules/core/03-connection/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ package types
import (
"fmt"

<<<<<<< HEAD

Check failure on line 6 in modules/core/03-connection/types/genesis.go

View workflow job for this annotation

GitHub Actions / build (amd64)

missing import path

Check failure on line 6 in modules/core/03-connection/types/genesis.go

View workflow job for this annotation

GitHub Actions / build (arm64)

missing import path

Check failure on line 6 in modules/core/03-connection/types/genesis.go

View workflow job for this annotation

GitHub Actions / build (arm)

missing import path

Check failure on line 6 in modules/core/03-connection/types/genesis.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)

Check failure on line 6 in modules/core/03-connection/types/genesis.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)
host "github.com/cosmos/ibc-go/v8/modules/core/24-host"
=======

Check failure on line 8 in modules/core/03-connection/types/genesis.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)

Check failure on line 8 in modules/core/03-connection/types/genesis.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)
host "github.com/cosmos/ibc-go/v9/modules/core/24-host"
"github.com/cosmos/ibc-go/v9/modules/core/exported"
>>>>>>> ff2b668c (fix: avoid invalid identifier error when validate genesis (#7397))

Check failure on line 11 in modules/core/03-connection/types/genesis.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)

Check failure on line 11 in modules/core/03-connection/types/genesis.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)
)

// NewConnectionPaths creates a ConnectionPaths instance.
Expand Down Expand Up @@ -45,13 +50,14 @@ func (gs GenesisState) Validate() error {
var maxSequence uint64

Check failure on line 50 in modules/core/03-connection/types/genesis.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)

Check failure on line 50 in modules/core/03-connection/types/genesis.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)

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 {
Expand Down
21 changes: 21 additions & 0 deletions modules/core/03-connection/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ import (

"github.com/stretchr/testify/require"

<<<<<<< HEAD
"github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
=======
"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"
>>>>>>> ff2b668c (fix: avoid invalid identifier error when validate genesis (#7397))
)

func TestValidateGenesis(t *testing.T) {
Expand Down Expand Up @@ -91,6 +98,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(
Expand Down

0 comments on commit 8a46534

Please sign in to comment.