Skip to content

Commit ebf40bb

Browse files
seantkingcolin-axnerfedekunzecrodriguezvegaAdityaSripal
authored
02-client: merge misbehavior & header interfaces (#1107)
* refactor: allow the mock module to be used multiple times as base ibc application in middleware stack (#892) ## Description Currently the `AppModule` assumes a single scoped keeper. This doesn't allow the mock module to be used as a base application for different middleware stack (ica stack, fee stack, etc) I broke the API because I think it is cleaner. If we want this to be non API breaking, I can try to readjust ref: #891 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes * feat: adding Pack/Unpack acknowledgement helper fns (#895) * feat: adding Pack/Unpack acknowledgement helper fns * chore: changelog * fix: docs * Update modules/core/04-channel/types/codec.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * imp: support custom keys for testing (#893) * chore: add ParsePacketFromEvents testing helper function (#904) ## Description ref: #891 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes * fix: correctly claim capability for mock module, handle genesis exports (#921) ## Description This contains two fixes: - the capability being claimed by the scoped keeper was incorrect (mock.ModuleName -> port ID) - the mock module wasn't accounting for non empty genesis state in capabilities (after genesis export, capability will create the bound ports so rebinding doesn't need to happen) closes: #XXXX --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes * docs: update migration docs for upgrade proposal in relation to ICS27 (#920) ## Description closes: #XXXX --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes * chore(ica): add trail of bits audit report (#903) * chore(ica): add trail of bits audit report * relocate the audit report for ICA Co-authored-by: Carlos Rodriguez <crodveg@gmail.com> * testing: adding multiple sender accounts for testing purposes (#935) * testing: adding multiple sender accounts for testing puproses * fix genesis setup (#936) * Update testing/chain.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * refactor: code hygiene * Update testing/chain.go Co-authored-by: Aditya <adityasripal@gmail.com> * fix: setting totalySupply to empty * nit: CamelCase not UPPERCASE Co-authored-by: Aditya <adityasripal@gmail.com> Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * Create test chain with multiple validators (#942) * testing: adding multiple sender accounts for testing puproses * fix genesis setup (#936) * Update testing/chain.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * refactor: code hygiene * Update testing/chain.go Co-authored-by: Aditya <adityasripal@gmail.com> * multi validator commit taken from @Saione * add function to pass custom valset * add changelog Co-authored-by: Sean King <sean@seking.dev> Co-authored-by: Sean King <seantking@users.noreply.github.com> Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * add changelog entry for SDK bump * fix: classify client states without consensus states as expired (#941) ## Description closes: #850 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes * chore: fix broken link (#972) * add backport actions for v1.3.x and v2.1.x (#958) * Revert "feat: adding Pack/Unpack acknowledgement helper fns (#895)" (#973) This reverts commit 843b459. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * chore: update migration docs (#985) * chore: update migration docs * Update docs/migrations/v2-to-v3.md Co-authored-by: Damian Nolan <damiannolan@gmail.com> Co-authored-by: Damian Nolan <damiannolan@gmail.com> * chore: fix mispelled words (#991) * fix: remove go mod tidy from proto-gen script (#989) * bug: support base denoms with slashes (#978) * bug: support base denoms with slashes * add changelog entry Co-authored-by: Carlos Rodriguez <crodveg@gmail.com> * upgrade ics23 to v0.7 (#948) * upgrade ics23 to v0.7-rc * add changelog entry * update ics23 to final 0.7 Co-authored-by: Carlos Rodriguez <crodveg@gmail.com> * ibctesting: make `testing.T` public (#1020) * add changelog entry for #941 * fix package import (#1007) * feat: Add a function to initialize the ICS27 module via an upgrade proposal (#1037) ## Description closes: #1034 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes * docs: add missing args to NewKeeper in integration docs (#1038) ## Description This add some missing arguments to `ibckeeper.NewKeeper` and `ibctransferkeeper.NewKeeper` in integration docs --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [x] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing) - [x] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes * small fixes for v2 to v3 migration (#1016) * small fixes for v2 to v3 migration * review comment * Update v2-to-v3.md * add store upgrade documentation Co-authored-by: Carlos Rodriguez <crodveg@gmail.com> * add missing slash * build(deps): bump actions/checkout from 2.4.0 to 3 (#1045) Bumps [actions/checkout](https://github.com/actions/checkout) from 2.4.0 to 3. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/actions/checkout/releases">actions/checkout's releases</a>.</em></p> <blockquote> <h2>v3.0.0</h2> <ul> <li>Update default runtime to node16</li> </ul> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/actions/checkout/blob/main/CHANGELOG.md">actions/checkout's changelog</a>.</em></p> <blockquote> <h1>Changelog</h1> <h2>v2.3.1</h2> <ul> <li><a href="https://github-redirect.dependabot.com/actions/checkout/pull/284">Fix default branch resolution for .wiki and when using SSH</a></li> </ul> <h2>v2.3.0</h2> <ul> <li><a href="https://github-redirect.dependabot.com/actions/checkout/pull/278">Fallback to the default branch</a></li> </ul> <h2>v2.2.0</h2> <ul> <li><a href="https://github-redirect.dependabot.com/actions/checkout/pull/258">Fetch all history for all tags and branches when fetch-depth=0</a></li> </ul> <h2>v2.1.1</h2> <ul> <li>Changes to support GHES (<a href="https://github-redirect.dependabot.com/actions/checkout/pull/236">here</a> and <a href="https://github-redirect.dependabot.com/actions/checkout/pull/248">here</a>)</li> </ul> <h2>v2.1.0</h2> <ul> <li><a href="https://github-redirect.dependabot.com/actions/checkout/pull/191">Group output</a></li> <li><a href="https://github-redirect.dependabot.com/actions/checkout/pull/199">Changes to support GHES alpha release</a></li> <li><a href="https://github-redirect.dependabot.com/actions/checkout/pull/184">Persist core.sshCommand for submodules</a></li> <li><a href="https://github-redirect.dependabot.com/actions/checkout/pull/163">Add support ssh</a></li> <li><a href="https://github-redirect.dependabot.com/actions/checkout/pull/179">Convert submodule SSH URL to HTTPS, when not using SSH</a></li> <li><a href="https://github-redirect.dependabot.com/actions/checkout/pull/157">Add submodule support</a></li> <li><a href="https://github-redirect.dependabot.com/actions/checkout/pull/144">Follow proxy settings</a></li> <li><a href="https://github-redirect.dependabot.com/actions/checkout/pull/141">Fix ref for pr closed event when a pr is merged</a></li> <li><a href="https://github-redirect.dependabot.com/actions/checkout/pull/128">Fix issue checking detached when git less than 2.22</a></li> </ul> <h2>v2.0.0</h2> <ul> <li><a href="https://github-redirect.dependabot.com/actions/checkout/pull/108">Do not pass cred on command line</a></li> <li><a href="https://github-redirect.dependabot.com/actions/checkout/pull/107">Add input persist-credentials</a></li> <li><a href="https://github-redirect.dependabot.com/actions/checkout/pull/104">Fallback to REST API to download repo</a></li> </ul> <h2>v2 (beta)</h2> <ul> <li>Improved fetch performance <ul> <li>The default behavior now fetches only the SHA being checked-out</li> </ul> </li> <li>Script authenticated git commands <ul> <li>Persists <code>with.token</code> in the local git config</li> <li>Enables your scripts to run authenticated git commands</li> <li>Post-job cleanup removes the token</li> <li>Coming soon: Opt out by setting <code>with.persist-credentials</code> to <code>false</code></li> </ul> </li> <li>Creates a local branch <ul> <li>No longer detached HEAD when checking out a branch</li> <li>A local branch is created with the corresponding upstream branch set</li> </ul> </li> <li>Improved layout</li> </ul> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/actions/checkout/commit/a12a3943b4bdde767164f792f33f40b04645d846"><code>a12a394</code></a> update readme for v3 (<a href="https://github-redirect.dependabot.com/actions/checkout/issues/708">#708</a>)</li> <li><a href="https://github.com/actions/checkout/commit/8f9e05e482293f862823fcca12d9eddfb3723131"><code>8f9e05e</code></a> Update to node 16 (<a href="https://github-redirect.dependabot.com/actions/checkout/issues/689">#689</a>)</li> <li><a href="https://github.com/actions/checkout/commit/230611dbd0eb52da1e1f4f7bc8bb0c3a339fc8b7"><code>230611d</code></a> Change secret name for PAT to not start with GITHUB_ (<a href="https://github-redirect.dependabot.com/actions/checkout/issues/623">#623</a>)</li> <li>See full diff in <a href="https://github.com/actions/checkout/compare/v2.4.0...v3">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=2.4.0&new-version=3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> * call packet.GetSequence() rather than passing the func as argument (#995) * Add counterpartyChannelID param to IBCModule.OnChanOpenAck (#1086) * add counterpartyChannelID param to IBCModule OnChanOpenAck() * change testing mock * change ica IBCModules ChannelOpenAck * change transfer IBCModules ChannelOpenAck * change core keeper ChannelOpenAck() * CHANGELOG.md * update v2-to-v3 migration doc * Update docs/migrations/v2-to-v3.md Co-authored-by: Carlos Rodriguez <carlos@interchain.io> Co-authored-by: Carlos Rodriguez <carlos@interchain.io> * fix mirgation docs (#1091) * fix: handle testing update client errors (#1094) * replace channel keeper with IBC keeper in AnteDecorator (#950) * replace channel keeper with IBC keeper in AnteDecorator and pass message to rpc handler * fix error checking condition * fix for proper way of getting go context * refactor tests for ante handler * review comment * review comments and some fixes * review comments * execute message for update client as well * add migration Co-authored-by: Carlos Rodriguez <crodveg@gmail.com> * add backport rules for v1.4.x and v2.2.x (#1085) * ibctesting: custom voting power reduction for testing (#939) * ibctesting: custom voting power reduction for testing * changelog * fix * make T public * fix * revert changes * fix test * merging Header & Misbehavior interfaces into ClientMessage & fixing associated 02-client helpers * fix: update related functions * chore: comments * Update modules/core/02-client/types/encoding.go Co-authored-by: Damian Nolan <damiannolan@gmail.com> * chore: changelog * chore: comment Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Carlos Rodriguez <carlos@interchain.io> Co-authored-by: Carlos Rodriguez <crodveg@gmail.com> Co-authored-by: Aditya <adityasripal@gmail.com> Co-authored-by: Tim Lind <tim@incremental.co> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Damian Nolan <damiannolan@gmail.com> Co-authored-by: daeMOn <flavien.binet@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Joe Bowman <joe@ingenuity.build> Co-authored-by: khanh <50263489+catShaark@users.noreply.github.com>
1 parent 12f4ed2 commit ebf40bb

29 files changed

+99
-171
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
6363
* (testing) [\#892](https://github.com/cosmos/ibc-go/pull/892) IBC Mock modules store the scoped keeper and portID within the IBCMockApp. They also maintain reference to the AppModule to update the AppModule's list of IBC applications it references. Allows for the mock module to be reused as a base application in middleware stacks.
6464
* (channel) [\#882](https://github.com/cosmos/ibc-go/pull/882) The `WriteAcknowledgement` API now takes `exported.Acknowledgement` instead of a byte array
6565
* (modules/core/ante) [\#950](https://github.com/cosmos/ibc-go/pull/950) Replaces the channel keeper with the IBC keeper in the IBC `AnteDecorator` in order to execute the entire message and be able to reject redundant messages that are in the same block as the non-redundant messages.
66+
* (modules/core/exported) [\#1107](https://github.com/cosmos/ibc-go/pull/1107) Merging the `Header` and `Misbehaviour` interfaces into a single `ClientMessage` type
67+
6668

6769
### State Machine Breaking
6870

docs/architecture/adr-027-ibc-wasm.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ packaged inside a payload which is json serialized and passed to `callContract`
100100
array of bytes returned by the smart contract. This data is deserialized and passed as return argument.
101101

102102
```go
103-
func (c *ClientState) CheckProposedHeaderAndUpdateState(context sdk.Context, marshaler codec.BinaryMarshaler, store sdk.KVStore, header exported.Header) (exported.ClientState, exported.ConsensusState, error) {
103+
func (c *ClientState) CheckProposedHeaderAndUpdateState(context sdk.Context, marshaler codec.BinaryMarshaler, store sdk.KVStore, header exported.ClientMessage) (exported.ClientState, exported.ConsensusState, error) {
104104
// get consensus state corresponding to client state to check if the client is expired
105105
consensusState, err := GetConsensusState(store, marshaler, c.LatestHeight)
106106
if err != nil {

modules/core/02-client/client/cli/tx.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func NewUpdateClientCmd() *cobra.Command {
100100

101101
cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry)
102102

103-
var header exported.Header
103+
var header exported.ClientMessage
104104
headerContentOrFileName := args[1]
105105
if err := cdc.UnmarshalInterfaceJSON([]byte(headerContentOrFileName), &header); err != nil {
106106

@@ -141,7 +141,7 @@ func NewSubmitMisbehaviourCmd() *cobra.Command {
141141
}
142142
cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry)
143143

144-
var misbehaviour exported.Misbehaviour
144+
var misbehaviour exported.ClientMessage
145145
clientID := args[0]
146146
misbehaviourContentOrFileName := args[1]
147147
if err := cdc.UnmarshalInterfaceJSON([]byte(misbehaviourContentOrFileName), &misbehaviour); err != nil {

modules/core/02-client/keeper/client.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (k Keeper) CreateClient(
5757
}
5858

5959
// UpdateClient updates the consensus state and the state root from a provided header.
60-
func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, header exported.Header) error {
60+
func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, header exported.ClientMessage) error {
6161
clientState, found := k.GetClientState(ctx, clientID)
6262
if !found {
6363
return sdkerrors.Wrapf(types.ErrClientNotFound, "cannot update client with ID %s", clientID)
@@ -85,7 +85,7 @@ func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, header exported.H
8585
// Marshal the Header as an Any and encode the resulting bytes to hex.
8686
// This prevents the event value from containing invalid UTF-8 characters
8787
// which may cause data to be lost when JSON encoding/decoding.
88-
headerStr = hex.EncodeToString(types.MustMarshalHeader(k.cdc, header))
88+
headerStr = hex.EncodeToString(types.MustMarshalClientMessage(k.cdc, header))
8989
// set default consensus height with header height
9090
consensusHeight = header.GetHeight()
9191

@@ -188,7 +188,7 @@ func (k Keeper) UpgradeClient(ctx sdk.Context, clientID string, upgradedClient e
188188

189189
// CheckMisbehaviourAndUpdateState checks for client misbehaviour and freezes the
190190
// client if so.
191-
func (k Keeper) CheckMisbehaviourAndUpdateState(ctx sdk.Context, clientID string, misbehaviour exported.Misbehaviour) error {
191+
func (k Keeper) CheckMisbehaviourAndUpdateState(ctx sdk.Context, clientID string, misbehaviour exported.ClientMessage) error {
192192
clientState, found := k.GetClientState(ctx, clientID)
193193
if !found {
194194
return sdkerrors.Wrapf(types.ErrClientNotFound, "cannot check misbehaviour for client with ID %s", clientID)

modules/core/02-client/keeper/client_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ func (suite *KeeperTestSuite) TestUpdateClientEventEmission() {
691691
bz, err := hex.DecodeString(string(attr.Value))
692692
suite.Require().NoError(err)
693693

694-
emittedHeader, err := types.UnmarshalHeader(suite.chainA.App.AppCodec(), bz)
694+
emittedHeader, err := types.UnmarshalClientMessage(suite.chainA.App.AppCodec(), bz)
695695
suite.Require().NoError(err)
696696
suite.Require().Equal(header, emittedHeader)
697697
}

modules/core/02-client/legacy/v100/solomachine.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ func (cs ClientState) ExportMetadata(_ sdk.KVStore) []exported.GenesisMetadata {
9090

9191
// CheckHeaderAndUpdateState panics!
9292
func (cs *ClientState) CheckHeaderAndUpdateState(
93-
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.Header,
93+
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.ClientMessage,
9494
) (exported.ClientState, exported.ConsensusState, error) {
9595
panic("legacy solo machine is deprecated!")
9696
}
9797

9898
// CheckMisbehaviourAndUpdateState panics!
9999
func (cs ClientState) CheckMisbehaviourAndUpdateState(
100-
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.Misbehaviour,
100+
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.ClientMessage,
101101
) (exported.ClientState, error) {
102102
panic("legacy solo machine is deprecated!")
103103
}

modules/core/02-client/types/codec.go

+14-46
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
2323
)
2424
registry.RegisterInterface(
2525
"ibc.core.client.v1.Header",
26-
(*exported.Header)(nil),
26+
(*exported.ClientMessage)(nil),
2727
)
2828
registry.RegisterInterface(
2929
"ibc.core.client.v1.Height",
@@ -32,7 +32,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
3232
)
3333
registry.RegisterInterface(
3434
"ibc.core.client.v1.Misbehaviour",
35-
(*exported.Misbehaviour)(nil),
35+
(*exported.ClientMessage)(nil),
3636
)
3737
registry.RegisterImplementations(
3838
(*govtypes.Content)(nil),
@@ -124,66 +124,34 @@ func UnpackConsensusState(any *codectypes.Any) (exported.ConsensusState, error)
124124
return consensusState, nil
125125
}
126126

127-
// PackHeader constructs a new Any packed with the given header value. It returns
128-
// an error if the header can't be casted to a protobuf message or if the concrete
127+
// PackClientMessage constructs a new Any packed with the given value. It returns
128+
// an error if the value can't be casted to a protobuf message or if the concrete
129129
// implemention is not registered to the protobuf codec.
130-
func PackHeader(header exported.Header) (*codectypes.Any, error) {
131-
msg, ok := header.(proto.Message)
130+
func PackClientMessage(clientMessage exported.ClientMessage) (*codectypes.Any, error) {
131+
msg, ok := clientMessage.(proto.Message)
132132
if !ok {
133-
return nil, sdkerrors.Wrapf(sdkerrors.ErrPackAny, "cannot proto marshal %T", header)
133+
return nil, sdkerrors.Wrapf(sdkerrors.ErrPackAny, "cannot proto marshal %T", clientMessage)
134134
}
135135

136-
anyHeader, err := codectypes.NewAnyWithValue(msg)
136+
any, err := codectypes.NewAnyWithValue(msg)
137137
if err != nil {
138138
return nil, sdkerrors.Wrap(sdkerrors.ErrPackAny, err.Error())
139139
}
140140

141-
return anyHeader, nil
141+
return any, nil
142142
}
143143

144-
// UnpackHeader unpacks an Any into a Header. It returns an error if the
145-
// consensus state can't be unpacked into a Header.
146-
func UnpackHeader(any *codectypes.Any) (exported.Header, error) {
144+
// UnpackClientMessage unpacks an Any into a ClientMessage. It returns an error if the
145+
// consensus state can't be unpacked into a ClientMessage.
146+
func UnpackClientMessage(any *codectypes.Any) (exported.ClientMessage, error) {
147147
if any == nil {
148148
return nil, sdkerrors.Wrap(sdkerrors.ErrUnpackAny, "protobuf Any message cannot be nil")
149149
}
150150

151-
header, ok := any.GetCachedValue().(exported.Header)
151+
clientMessage, ok := any.GetCachedValue().(exported.ClientMessage)
152152
if !ok {
153153
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnpackAny, "cannot unpack Any into Header %T", any)
154154
}
155155

156-
return header, nil
157-
}
158-
159-
// PackMisbehaviour constructs a new Any packed with the given misbehaviour value. It returns
160-
// an error if the misbehaviour can't be casted to a protobuf message or if the concrete
161-
// implemention is not registered to the protobuf codec.
162-
func PackMisbehaviour(misbehaviour exported.Misbehaviour) (*codectypes.Any, error) {
163-
msg, ok := misbehaviour.(proto.Message)
164-
if !ok {
165-
return nil, sdkerrors.Wrapf(sdkerrors.ErrPackAny, "cannot proto marshal %T", misbehaviour)
166-
}
167-
168-
anyMisbhaviour, err := codectypes.NewAnyWithValue(msg)
169-
if err != nil {
170-
return nil, sdkerrors.Wrap(sdkerrors.ErrPackAny, err.Error())
171-
}
172-
173-
return anyMisbhaviour, nil
174-
}
175-
176-
// UnpackMisbehaviour unpacks an Any into a Misbehaviour. It returns an error if the
177-
// Any can't be unpacked into a Misbehaviour.
178-
func UnpackMisbehaviour(any *codectypes.Any) (exported.Misbehaviour, error) {
179-
if any == nil {
180-
return nil, sdkerrors.Wrap(sdkerrors.ErrUnpackAny, "protobuf Any message cannot be nil")
181-
}
182-
183-
misbehaviour, ok := any.GetCachedValue().(exported.Misbehaviour)
184-
if !ok {
185-
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnpackAny, "cannot unpack Any into Misbehaviour %T", any)
186-
}
187-
188-
return misbehaviour, nil
156+
return clientMessage, nil
189157
}

modules/core/02-client/types/codec_test.go

+7-54
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ func (suite *TypesTestSuite) TestPackConsensusState() {
116116
}
117117
}
118118

119-
func (suite *TypesTestSuite) TestPackHeader() {
119+
func (suite *TypesTestSuite) TestPackClientMessage() {
120120
testCases := []struct {
121-
name string
122-
header exported.Header
123-
expPass bool
121+
name string
122+
clientMessage exported.ClientMessage
123+
expPass bool
124124
}{
125125
{
126126
"solo machine header",
@@ -142,7 +142,7 @@ func (suite *TypesTestSuite) TestPackHeader() {
142142
testCasesAny := []caseAny{}
143143

144144
for _, tc := range testCases {
145-
clientAny, err := types.PackHeader(tc.header)
145+
clientAny, err := types.PackClientMessage(tc.clientMessage)
146146
if tc.expPass {
147147
suite.Require().NoError(err, tc.name)
148148
} else {
@@ -153,57 +153,10 @@ func (suite *TypesTestSuite) TestPackHeader() {
153153
}
154154

155155
for i, tc := range testCasesAny {
156-
cs, err := types.UnpackHeader(tc.any)
156+
cs, err := types.UnpackClientMessage(tc.any)
157157
if tc.expPass {
158158
suite.Require().NoError(err, tc.name)
159-
suite.Require().Equal(testCases[i].header, cs, tc.name)
160-
} else {
161-
suite.Require().Error(err, tc.name)
162-
}
163-
}
164-
}
165-
166-
func (suite *TypesTestSuite) TestPackMisbehaviour() {
167-
testCases := []struct {
168-
name string
169-
misbehaviour exported.Misbehaviour
170-
expPass bool
171-
}{
172-
{
173-
"solo machine misbehaviour",
174-
ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2).CreateMisbehaviour(),
175-
true,
176-
},
177-
{
178-
"tendermint misbehaviour",
179-
ibctmtypes.NewMisbehaviour("tendermint", suite.chainA.LastHeader, suite.chainA.LastHeader),
180-
true,
181-
},
182-
{
183-
"nil",
184-
nil,
185-
false,
186-
},
187-
}
188-
189-
testCasesAny := []caseAny{}
190-
191-
for _, tc := range testCases {
192-
clientAny, err := types.PackMisbehaviour(tc.misbehaviour)
193-
if tc.expPass {
194-
suite.Require().NoError(err, tc.name)
195-
} else {
196-
suite.Require().Error(err, tc.name)
197-
}
198-
199-
testCasesAny = append(testCasesAny, caseAny{tc.name, clientAny, tc.expPass})
200-
}
201-
202-
for i, tc := range testCasesAny {
203-
cs, err := types.UnpackMisbehaviour(tc.any)
204-
if tc.expPass {
205-
suite.Require().NoError(err, tc.name)
206-
suite.Require().Equal(testCases[i].misbehaviour, cs, tc.name)
159+
suite.Require().Equal(testCases[i].clientMessage, cs, tc.name)
207160
} else {
208161
suite.Require().Error(err, tc.name)
209162
}

modules/core/02-client/types/encoding.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -86,29 +86,29 @@ func UnmarshalConsensusState(cdc codec.BinaryCodec, bz []byte) (exported.Consens
8686
return consensusState, nil
8787
}
8888

89-
// MarshalHeader protobuf serializes a Header interface
90-
func MarshalHeader(cdc codec.BinaryCodec, h exported.Header) ([]byte, error) {
91-
return cdc.MarshalInterface(h)
89+
// MarshalClientMessage protobuf serializes a ClientMessage interface
90+
func MarshalClientMessage(cdc codec.BinaryCodec, clientMessage exported.ClientMessage) ([]byte, error) {
91+
return cdc.MarshalInterface(clientMessage)
9292
}
9393

94-
// MustMarshalHeader attempts to encode a Header object and returns the
94+
// MustMarshalClientMessage attempts to encode a ClientMessage object and returns the
9595
// raw encoded bytes. It panics on error.
96-
func MustMarshalHeader(cdc codec.BinaryCodec, header exported.Header) []byte {
97-
bz, err := MarshalHeader(cdc, header)
96+
func MustMarshalClientMessage(cdc codec.BinaryCodec, clientMessage exported.ClientMessage) []byte {
97+
bz, err := MarshalClientMessage(cdc, clientMessage)
9898
if err != nil {
99-
panic(fmt.Errorf("failed to encode header: %w", err))
99+
panic(fmt.Errorf("failed to encode ClientMessage: %w", err))
100100
}
101101

102102
return bz
103103
}
104104

105-
// UnmarshalHeader returns a Header interface from raw proto encoded header bytes.
105+
// UnmarshalClientMessage returns a ClientMessage interface from raw proto encoded header bytes.
106106
// An error is returned upon decoding failure.
107-
func UnmarshalHeader(cdc codec.BinaryCodec, bz []byte) (exported.Header, error) {
108-
var header exported.Header
109-
if err := cdc.UnmarshalInterface(bz, &header); err != nil {
107+
func UnmarshalClientMessage(cdc codec.BinaryCodec, bz []byte) (exported.ClientMessage, error) {
108+
var clientMessage exported.ClientMessage
109+
if err := cdc.UnmarshalInterface(bz, &clientMessage); err != nil {
110110
return nil, err
111111
}
112112

113-
return header, nil
113+
return clientMessage, nil
114114
}

modules/core/02-client/types/encoding_test.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,17 @@ func (suite *TypesTestSuite) TestMarshalHeader() {
1313
}
1414

1515
// marshal header
16-
bz, err := types.MarshalHeader(cdc, h)
16+
bz, err := types.MarshalClientMessage(cdc, h)
1717
suite.Require().NoError(err)
1818

1919
// unmarshal header
20-
newHeader, err := types.UnmarshalHeader(cdc, bz)
20+
newHeader, err := types.UnmarshalClientMessage(cdc, bz)
2121
suite.Require().NoError(err)
2222

2323
suite.Require().Equal(h, newHeader)
2424

2525
// use invalid bytes
26-
invalidHeader, err := types.UnmarshalHeader(cdc, []byte("invalid bytes"))
26+
invalidHeader, err := types.UnmarshalClientMessage(cdc, []byte("invalid bytes"))
2727
suite.Require().Error(err)
2828
suite.Require().Nil(invalidHeader)
29-
3029
}

modules/core/02-client/types/msgs.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ func (msg MsgCreateClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) err
104104

105105
// NewMsgUpdateClient creates a new MsgUpdateClient instance
106106
//nolint:interfacer
107-
func NewMsgUpdateClient(id string, header exported.Header, signer string) (*MsgUpdateClient, error) {
108-
anyHeader, err := PackHeader(header)
107+
func NewMsgUpdateClient(id string, header exported.ClientMessage, signer string) (*MsgUpdateClient, error) {
108+
anyHeader, err := PackClientMessage(header)
109109
if err != nil {
110110
return nil, err
111111
}
@@ -123,7 +123,7 @@ func (msg MsgUpdateClient) ValidateBasic() error {
123123
if err != nil {
124124
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err)
125125
}
126-
header, err := UnpackHeader(msg.Header)
126+
header, err := UnpackClientMessage(msg.Header)
127127
if err != nil {
128128
return err
129129
}
@@ -147,7 +147,7 @@ func (msg MsgUpdateClient) GetSigners() []sdk.AccAddress {
147147

148148
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
149149
func (msg MsgUpdateClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
150-
var header exported.Header
150+
var header exported.ClientMessage
151151
return unpacker.UnpackAny(msg.Header, &header)
152152
}
153153

@@ -229,8 +229,8 @@ func (msg MsgUpgradeClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) er
229229

230230
// NewMsgSubmitMisbehaviour creates a new MsgSubmitMisbehaviour instance.
231231
//nolint:interfacer
232-
func NewMsgSubmitMisbehaviour(clientID string, misbehaviour exported.Misbehaviour, signer string) (*MsgSubmitMisbehaviour, error) {
233-
anyMisbehaviour, err := PackMisbehaviour(misbehaviour)
232+
func NewMsgSubmitMisbehaviour(clientID string, misbehaviour exported.ClientMessage, signer string) (*MsgSubmitMisbehaviour, error) {
233+
anyMisbehaviour, err := PackClientMessage(misbehaviour)
234234
if err != nil {
235235
return nil, err
236236
}
@@ -248,7 +248,7 @@ func (msg MsgSubmitMisbehaviour) ValidateBasic() error {
248248
if err != nil {
249249
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err)
250250
}
251-
misbehaviour, err := UnpackMisbehaviour(msg.Misbehaviour)
251+
misbehaviour, err := UnpackClientMessage(msg.Misbehaviour)
252252
if err != nil {
253253
return err
254254
}
@@ -270,6 +270,6 @@ func (msg MsgSubmitMisbehaviour) GetSigners() []sdk.AccAddress {
270270

271271
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
272272
func (msg MsgSubmitMisbehaviour) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
273-
var misbehaviour exported.Misbehaviour
273+
var misbehaviour exported.ClientMessage
274274
return unpacker.UnpackAny(msg.Misbehaviour, &misbehaviour)
275275
}

0 commit comments

Comments
 (0)