Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow version compatibility between chains upgrade from v0.8.x to v0.9.x #7847

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (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.
* (light-clients/09-localhost) [\#7847](https://github.com/cosmos/ibc-go/pull/7847) Add back legacy localhost RegisterInterfaces to allow version compatibility between chains upgrade from v0.8.x to v0.9.x.

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

Expand Down
2 changes: 2 additions & 0 deletions modules/core/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types"
channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types"
commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types"
localhost "github.com/cosmos/ibc-go/v9/modules/light-clients/09-localhost"
)

// RegisterInterfaces registers ibc types against interfaces using the global InterfaceRegistry.
Expand All @@ -16,4 +17,5 @@ func RegisterInterfaces(registry coreregistry.InterfaceRegistrar) {
connectiontypes.RegisterInterfaces(registry)
channeltypes.RegisterInterfaces(registry)
commitmenttypes.RegisterInterfaces(registry)
localhost.RegisterInterfaces(registry)
}
20 changes: 20 additions & 0 deletions modules/core/types/codec_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package types

import (
"testing"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
gogoprotoany "github.com/cosmos/gogoproto/types/any"
"github.com/cosmos/ibc-go/v9/modules/core/exported"
"github.com/stretchr/testify/require"
)

func TestInterfaceRegistrationOfLocalhost(t *testing.T) {
registry := codectypes.NewInterfaceRegistry()
RegisterInterfaces(registry)
val := &gogoprotoany.Any{
TypeUrl: "/ibc.lightclients.localhost.v2.ClientState",
Value: []byte{},
}
require.NoError(t, registry.UnpackAny(val, new(exported.ClientState)))
}
16 changes: 16 additions & 0 deletions modules/light-clients/09-localhost/codec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package localhost

import (
coreregistry "cosmossdk.io/core/registry"

"github.com/cosmos/ibc-go/v9/modules/core/exported"
)

// RegisterInterfaces registers the tendermint concrete client-related
// implementations and interfaces.
func RegisterInterfaces(registry coreregistry.InterfaceRegistrar) {
registry.RegisterImplementations(
(*exported.ClientState)(nil),
&ClientState{},
)
}
20 changes: 20 additions & 0 deletions modules/light-clients/09-localhost/localhost.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package localhost

import (
errorsmod "cosmossdk.io/errors"
ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors"
"github.com/cosmos/ibc-go/v9/modules/core/exported"
)

var _ exported.ClientState = (*ClientState)(nil)

func (cs *ClientState) ClientType() string {

Check failure on line 11 in modules/light-clients/09-localhost/localhost.go

View workflow job for this annotation

GitHub Actions / lint

unused-receiver: method receiver 'cs' is not referenced in method's body, consider removing or renaming it as _ (revive)
return exported.Localhost
}

func (cs *ClientState) Validate() error {
if cs.LatestHeight.RevisionHeight == 0 {
return errorsmod.Wrapf(ibcerrors.ErrInvalidHeight, "local revision height cannot be zero")
}
return nil
}
Loading
Loading