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

api!: delete v1 merkle path and register v2 merkle path against interface on cdc #6870

Merged
merged 11 commits into from
Jul 29, 2024
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (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) [\#6633](https://github.com/cosmos/ibc-go/pull/6633) MerklePath has been changed to use `repeated bytes` in favour of `repeated strings`.
* (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.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/05-migrations/13-v8-to-v9.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ The base application is then set by default to nil and thus authentication is as

### 23-commitment

- The `MerklePath` type has been deprecated and a new `commitment.v2.MerklePath` type has been introduced (ref: [#6644](https://github.com/cosmos/ibc-go/pull/6644)). The new `commitment.v2.MerklePath` contains `repeated bytes` in favour of `repeated string`. This allows users to prove values stored under keys which contain non-utf8 encoded symbols. As a result, changes have been made to the 02-client `Query` service and 08-wasm contract API messages for JSON blobs. See [02-client](#02-client) and [08-wasm](#08-wasm), respectively.
- The `commitment.v1.MerklePath` type has been removed and a new `commitment.v2.MerklePath` type has been introduced (ref: [#6644](https://github.com/cosmos/ibc-go/pull/6644)). The new `commitment.v2.MerklePath` contains `repeated bytes` in favour of `repeated string`. This allows users to prove values stored under keys which contain non-utf8 encoded symbols. As a result, changes have been made to the 02-client `Query` service and 08-wasm contract API messages for JSON blobs. See [02-client](#02-client) and [08-wasm](#08-wasm), respectively.

### IBC testing package

Expand Down
3 changes: 2 additions & 1 deletion modules/core/23-commitment/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package types
import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"

"github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2"
"github.com/cosmos/ibc-go/v9/modules/core/exported"
)

Expand Down Expand Up @@ -31,6 +32,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
)
registry.RegisterImplementations(
(*exported.Path)(nil),
&MerklePath{},
&v2.MerklePath{},
)
}
3 changes: 2 additions & 1 deletion modules/core/23-commitment/types/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

ibc "github.com/cosmos/ibc-go/v9/modules/core"
"github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types"
"github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2"
)

func (suite *MerkleTestSuite) TestCodecTypeRegistration() {
Expand All @@ -26,7 +27,7 @@ func (suite *MerkleTestSuite) TestCodecTypeRegistration() {
},
{
"success: MerklePath",
sdk.MsgTypeURL(&types.MerklePath{}),
sdk.MsgTypeURL(&v2.MerklePath{}),
true,
},
{
Expand Down
221 changes: 21 additions & 200 deletions modules/core/23-commitment/types/commitment.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions modules/core/23-commitment/types/merkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package types

import (
"bytes"
"fmt"

"github.com/cosmos/gogoproto/proto"
ics23 "github.com/cosmos/ics23/go"
Expand Down Expand Up @@ -67,28 +66,11 @@ func (mp MerklePrefix) Empty() bool {
return len(mp.Bytes()) == 0
}

var _ exported.Path = (*MerklePath)(nil)

// NewMerklePath creates a new MerklePath instance
// The keys must be passed in from root-to-leaf order.
// NOTE: NewMerklePath returns a commitment/v2 MerklePath.
var NewMerklePath = v2.NewMerklePath

// GetKey will return a byte representation of the key
// Deprecated: Please use commitment/v2 MerklePath instead.
func (mp MerklePath) GetKey(i uint64) (string, error) {
if i >= uint64(len(mp.KeyPath)) {
return "", fmt.Errorf("index out of range. %d (index) >= %d (len)", i, len(mp.KeyPath))
}
return mp.KeyPath[i], nil
}

// Empty returns true if the path is empty
// Deprecated: Please use commitment/v2 MerklePath instead.
func (mp MerklePath) Empty() bool {
return len(mp.KeyPath) == 0
}

// ApplyPrefix constructs a new commitment path from the arguments. It prepends the prefix key
// with the given path.
func ApplyPrefix(prefix exported.Prefix, path v2.MerklePath) (v2.MerklePath, error) {
Expand Down
4 changes: 2 additions & 2 deletions modules/light-clients/06-solomachine/misbehaviour_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"

commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types"
commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2"
"github.com/cosmos/ibc-go/v9/modules/core/exported"
)

Expand Down Expand Up @@ -41,7 +41,7 @@ func (cs ClientState) verifyMisbehaviour(cdc codec.BinaryCodec, misbehaviour *Mi
// unmarshaled into the specified data type.
func (cs ClientState) verifySignatureAndData(cdc codec.BinaryCodec, misbehaviour *Misbehaviour, sigAndData *SignatureAndData) error {
// do not check misbehaviour timestamp since we want to allow processing of past misbehaviour
if err := cdc.Unmarshal(sigAndData.Path, new(commitmenttypes.MerklePath)); err != nil {
if err := cdc.Unmarshal(sigAndData.Path, new(commitmenttypesv2.MerklePath)); err != nil {
damiannolan marked this conversation as resolved.
Show resolved Hide resolved
return err
}

Expand Down
4 changes: 2 additions & 2 deletions modules/light-clients/09-localhost/light_client_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (l LightClientModule) VerifyMembership(

merklePath, ok := path.(commitmenttypesv2.MerklePath)
if !ok {
return errorsmod.Wrapf(ibcerrors.ErrInvalidType, "expected %T, got %T", commitmenttypes.MerklePath{}, path)
return errorsmod.Wrapf(ibcerrors.ErrInvalidType, "expected %T, got %T", commitmenttypesv2.MerklePath{}, path)
}

if len(merklePath.GetKeyPath()) != 2 {
Expand Down Expand Up @@ -142,7 +142,7 @@ func (l LightClientModule) VerifyNonMembership(

merklePath, ok := path.(commitmenttypesv2.MerklePath)
if !ok {
return errorsmod.Wrapf(ibcerrors.ErrInvalidType, "expected %T, got %T", commitmenttypes.MerklePath{}, path)
return errorsmod.Wrapf(ibcerrors.ErrInvalidType, "expected %T, got %T", commitmenttypesv2.MerklePath{}, path)
}

if len(merklePath.GetKeyPath()) != 2 {
Expand Down
Loading
Loading