From 1e4d2dd3482ed9e5c1854d1d0a32c7d02479b18a Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Fri, 18 Nov 2022 15:07:18 +0100 Subject: [PATCH 1/2] updating v6 to v7 migration doc with generic state verification methods --- docs/.vuepress/config.js | 10 ++++++++++ docs/migrations/v6-to-v7.md | 31 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 53febba7e5e..3c4ea705609 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -370,6 +370,16 @@ module.exports = { directory: false, path: "/migrations/v4-to-v5.html", }, + { + title: "IBC-Go v5 to v6", + directory: false, + path: "/migrations/v5-to-v6.html", + }, + { + title: "IBC-Go v6 to v7", + directory: false, + path: "/migrations/v6-to-v7.html", + }, ], }, { diff --git a/docs/migrations/v6-to-v7.md b/docs/migrations/v6-to-v7.md index 70e9519f4e3..a3a3664ce07 100644 --- a/docs/migrations/v6-to-v7.md +++ b/docs/migrations/v6-to-v7.md @@ -45,6 +45,37 @@ The `CheckMisbehaviourAndUpdateState` function has been removed from `ClientStat The function `GetTimestampAtHeight` has been added to the `ClientState` interface. It should return the timestamp for a consensus state associated with the provided height. +The state verification functions for all IBC data types have been consolidated into two generic methods, `VerifyMembership` and `VerifyNonMembership`. +Both are expected to be provided with a standardised key path, `exported.Path`, as defined in [ICS 24 host requirements](https://github.com/cosmos/ibc/tree/main/spec/core/ics-024-host-requirements). Membership verification requires callers to provide the marshalled value `[]byte`. Delay period values should be zero for non-packet processing verification. + +See below for an example of how ibc-go now performs channel state verification. + +```go +merklePath := commitmenttypes.NewMerklePath(host.ChannelPath(portID, channelID)) +merklePath, err := commitmenttypes.ApplyPrefix(connection.GetCounterparty().GetPrefix(), merklePath) +if err != nil { + return err +} + +channelEnd, ok := channel.(channeltypes.Channel) +if !ok { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "invalid channel type %T", channel) +} + +bz, err := k.cdc.Marshal(&channelEnd) +if err != nil { + return err +} + +if err := clientState.VerifyMembership( + ctx, clientStore, k.cdc, height, + 0, 0, // skip delay period checks for non-packet processing verification + proof, merklePath, bz, +); err != nil { + return sdkerrors.Wrapf(err, "failed channel state verification for client (%s)", clientID) +} +``` + ### `Header` and `Misbehaviour` `exported.Header` and `exported.Misbehaviour` interface types have been merged and renamed to `ClientMessage` interface. From 574b60a58abd9e4d6f3968c29152fb6d98d5eb61 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Fri, 25 Nov 2022 12:32:04 +0100 Subject: [PATCH 2/2] add note about state verification prior to ibc-go/v7 --- docs/migrations/v6-to-v7.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/migrations/v6-to-v7.md b/docs/migrations/v6-to-v7.md index a3a3664ce07..2d67fc74dee 100644 --- a/docs/migrations/v6-to-v7.md +++ b/docs/migrations/v6-to-v7.md @@ -45,6 +45,7 @@ The `CheckMisbehaviourAndUpdateState` function has been removed from `ClientStat The function `GetTimestampAtHeight` has been added to the `ClientState` interface. It should return the timestamp for a consensus state associated with the provided height. +Prior to ibc-go/v7 the `ClientState` interface defined a method for each data type which was being verified in the counterparty state store. The state verification functions for all IBC data types have been consolidated into two generic methods, `VerifyMembership` and `VerifyNonMembership`. Both are expected to be provided with a standardised key path, `exported.Path`, as defined in [ICS 24 host requirements](https://github.com/cosmos/ibc/tree/main/spec/core/ics-024-host-requirements). Membership verification requires callers to provide the marshalled value `[]byte`. Delay period values should be zero for non-packet processing verification.