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

02-client refactor #1871

Merged
merged 76 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
a4b5b8f
chore: Remove GetClientID() From Misbehaviour Interface (#897)
notbdu Mar 9, 2022
841d21d
chore: add 668 functions to localhost client (#908)
notbdu Mar 9, 2022
18abb79
chore: rename 06-solomachine type Misbehaviour to DuplicateSignatures…
damiannolan Mar 10, 2022
a333a73
chore: reverting renaming of Misbehaviour (#1099)
damiannolan Mar 11, 2022
daa01db
remove GetClientID from 07-tendermint misbehaviour (#1097)
colin-axner Mar 11, 2022
2de5f1d
chore: remove GetClientID from 06-solomachine type Misbehaviour (#1100)
damiannolan Mar 11, 2022
12f4ed2
client-02 update to latest from main (#1106)
seantking Mar 11, 2022
ebf40bb
02-client: merge misbehavior & header interfaces (#1107)
seantking Mar 15, 2022
b0fa240
chore: 06-solomachine rename checkHeader to VerifyClientMessage (#1109)
damiannolan Mar 16, 2022
5e9785e
refactor: modify VerifyUpgradeAndUpdateState to set upgraded client a…
colin-axner Mar 16, 2022
4c8b7c5
chore: 06-solomachine rename update to UpdateState (#1110)
damiannolan Mar 16, 2022
bdbaa91
chore: 06-solomachine adding CheckForMisbehaviour and UpdateStateOnMi…
damiannolan Mar 16, 2022
f4480fb
chore: 02-client-refactor: merge main into feature branch (#1149)
seantking Mar 21, 2022
5e3bac0
02-client-refactor: rename update to UpdateState for 07-tendermint (#…
colin-axner Mar 24, 2022
efbc5a1
chore: adding UpdateStateOnMisbehaviour to 07-tendermint (#1168)
damiannolan Mar 24, 2022
b0dd49d
chore: add solomachine client storage (#1144)
damiannolan Mar 28, 2022
17209f7
refactor: adding CheckForMisbehaviour to 07-tendermint client (#1163)
damiannolan Mar 28, 2022
fadd9d0
02-client refactor: Adding VerifyClientMessage helper fn (#1119)
seantking Mar 28, 2022
c2602a5
refactor: removing GetRoot from ConsensusState interface (#1186)
seantking Mar 30, 2022
40183b4
Adding VerifyClientMessage to ClientState interface (#1196)
seantking Mar 30, 2022
a4b3d09
chore: CheckSubstituteAndUpdateState stores client state in lightclie…
damiannolan Mar 30, 2022
2e2bfab
chore: 07-tendermint set client/consensus states in UpdateState (#1199)
damiannolan Mar 30, 2022
18f1382
chore: update 07-tendermint GetConsensusState to return bool over err…
damiannolan Mar 30, 2022
3c7358b
feat: adding UpdateStateOnMisbehaviour to ClientState interface (#1198)
seantking Mar 31, 2022
5cf6528
refactor: remove localhost client implementation (#1187)
seantking Mar 31, 2022
eb48e54
chore: adding UpdateState to ClientState interface (#1206)
damiannolan Mar 31, 2022
d2be6d5
feat: adding CheckForMisbehaviour to ClientState interface (#1197)
seantking Mar 31, 2022
e2f37b8
Replace CheckHeaderAndUpdateState with new ClientState functions (#1208)
colin-axner Apr 1, 2022
8a9978c
refactor: removing CheckHeaderAndUpdateState from ClientState (#1210)
seantking Apr 4, 2022
c43af66
refactor: routing MsgSubmitMisbehaviour to UpdateClient keeper fn (#1…
seantking Apr 4, 2022
e249518
refactor: removing CheckMisbehaviourAndUpdateState from ClientState i…
seantking Apr 4, 2022
e91ee68
fix: rm AllowUpdateAfter... check (#1118)
charleenfei Apr 25, 2022
e1ec9f4
chore: update 02-client-refactor branch with latest main (#1286)
damiannolan Apr 26, 2022
cf893c2
chore: remove GetHeight from ClientMessage interface (#1285)
damiannolan Apr 27, 2022
55b115a
update godoc for VerifyClientMessage (#1281)
colin-axner Apr 27, 2022
48882a9
Add VerifyMembership to 07-tendermint (#1297)
colin-axner Apr 28, 2022
8f46821
chore: MsgUpdateClient rename header to client_message (#1316)
damiannolan May 9, 2022
e1f2103
Add migration docs for 02-client refactor (#1287)
catShaark May 10, 2022
31b6ead
Add revision number tests for 07-tendermint (#1302)
colin-axner May 10, 2022
d120044
ADR 005: update client consensus height events (#1315)
damiannolan May 10, 2022
e2bdd1f
feat: VerifyNonMembership 07-tendermint implementation (#1611)
seantking Jun 30, 2022
aab9ca2
chore: making changes based on nits from 02-client refactor audit (#1…
chatton Jun 30, 2022
4def196
chore: add generic proof verification methods to ClientState interfac…
damiannolan Jul 4, 2022
32c4827
chore: add GetTimestampAtHeight to client state #888 (#1659)
charleenfei Jul 6, 2022
1617de7
chore: modify connection keeper GetTimestampAtHeight to use the clien…
charleenfei Jul 7, 2022
3987a5b
refactor: replace usage of verification funcs in 03-connection (#1647)
damiannolan Jul 7, 2022
81a7cae
Check that client state is zeroed out for ibc client upgrade proposal…
chatton Jul 11, 2022
60e5305
Zero out client state before upgrading client proof (#1674)
chatton Jul 11, 2022
549c181
chore: restructuring 07-tendermint lightclient directory layout (#1677)
damiannolan Jul 12, 2022
04df7cd
chore: adding upgrade handler for 09-localhost removal (#1671)
damiannolan Jul 15, 2022
d8ac28a
Emit event upon setting upgrade consensus state (#1741)
chatton Jul 27, 2022
d3d91ed
chore: removing GetHeight legacy method from 06-solomachine (#1810)
damiannolan Jul 29, 2022
b0a58a8
refactor: solomachine generic verification methods and signbytes simp…
damiannolan Aug 2, 2022
7237c43
bump version from 3 to 5
colin-axner Aug 2, 2022
6cdcc63
merge main
colin-axner Aug 2, 2022
0d8f408
fix merge conflicts
colin-axner Aug 2, 2022
a7d23fd
fix build
colin-axner Aug 3, 2022
f861e0e
go imports
colin-axner Aug 3, 2022
607458a
make format
colin-axner Aug 3, 2022
e9a7fac
fix linter
colin-axner Aug 3, 2022
18eee1a
apply review suggestions
colin-axner Aug 3, 2022
197c2bd
Merge branch 'main' into updated-02-client-refactor
colin-axner Aug 3, 2022
2da9e65
fix: import changes for 02-client-refactor (#1875)
colin-axner Aug 4, 2022
68e8e79
apply suggested changes (#1877)
colin-axner Aug 4, 2022
3d33e8b
documentation fixes (#1876)
colin-axner Aug 4, 2022
163b706
fix: complete changes for CheckSubstituteAndUpdateState (#1878)
colin-axner Aug 4, 2022
3cb1ba8
Merge branch 'main' of github.com:cosmos/ibc-go into updated-02-clien…
colin-axner Aug 4, 2022
81f2d09
02-client refactor: fix changelog (#1873)
seantking Aug 4, 2022
311a563
fix: revert unnecessary change in 02-client-refactor branch (#1883)
colin-axner Aug 5, 2022
173c1fb
updating solomachine to use setClientState helper in update funcs (#1…
damiannolan Aug 8, 2022
f8debd7
Merge branch 'main' of github.com:cosmos/ibc-go into updated-02-clien…
colin-axner Aug 8, 2022
a7407cc
Update CHANGELOG.md
colin-axner Aug 8, 2022
fc4bfaf
Update docs/migrations/v5-to-v6.md
colin-axner Aug 8, 2022
9a4ed68
chore: remove error return in IterateConsensusStateAscending (#1896)
damiannolan Aug 8, 2022
87bae33
removing solomachine consensus state nil check and test cases (#1895)
damiannolan Aug 8, 2022
88936be
Merge branch 'main' into updated-02-client-refactor
colin-axner Aug 8, 2022
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
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking

* (06-solomachine) [\#1679](https://github.com/cosmos/ibc-go/pull/1679) Remove `types` sub-package from `06-solomachine` lightclient directory.
* (07-tendermint) [\#1677](https://github.com/cosmos/ibc-go/pull/1677) Remove `types` sub-package from `07-tendermint` lightclient directory.
* (06-solomachine) [\#1687](https://github.com/cosmos/ibc-go/pull/1687) Bump `06-solomachine` protobuf version from `v2` to `v3`.
* (06-solomachine) [\#1687](https://github.com/cosmos/ibc-go/pull/1687) Removed `DataType` enum and associated message types from `06-solomachine`. `DataType` has been removed from `SignBytes` and `SignatureAndData` in favour of `path`.
* (core/03-connection) [\#1797](https://github.com/cosmos/ibc-go/pull/1797) Remove `PreviousConnectionID` from `NewMsgConnectionOpenTry` arguments. `MsgConnectionOpenTry.ValidateBasic()` returns error if the deprecated `PreviousConnectionID` is not empty.
* (core/04-channel) [\#1792](https://github.com/cosmos/ibc-go/pull/1792) Remove `PreviousChannelID` from `NewMsgChannelOpenTry` arguments. `MsgChannelOpenTry.ValidateBasic()` returns error if the deprecated `PreviousChannelID` is not empty.
* (core/04-channel) [\#1418](https://github.com/cosmos/ibc-go/pull/1418) `NewPacketId` has been renamed to `NewPacketID` to comply with go linting rules.
Expand All @@ -66,6 +70,18 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* (modules/core/02-client) [\#1188](https://github.com/cosmos/ibc-go/pull/1188/files) Routing `MsgSubmitMisbehaviour` to `UpdateClient` keeper function. Deprecating `SubmitMisbehaviour` endpoint.
* (modules/core/02-client) [\#1208](https://github.com/cosmos/ibc-go/pull/1208) Replace `CheckHeaderAndUpdateState` usage in 02-client with calls to `VerifyClientMessage`, `CheckForMisbehaviour`, `UpdateStateOnMisbehaviour` and `UpdateState`.
* (modules/light-clients/09-localhost) [\#1187](https://github.com/cosmos/ibc-go/pull/1187/) Removing localhost light client implementation as it is not functional. An upgrade handler is provided in `modules/migrations/v5` to prune `09-localhost` clients and consensus states from the store.
* [\#1186](https://github.com/cosmos/ibc-go/pull/1186/files) Removing `GetRoot` function from ConsensusState interface in `02-client`. `GetRoot` is unused by core IBC.
* (modules/core/02-client) [\#1196](https://github.com/cosmos/ibc-go/pull/1196) Adding VerifyClientMessage to ClientState interface.
* (modules/core/02-client) [\#1198](https://github.com/cosmos/ibc-go/pull/1198) Adding UpdateStateOnMisbehaviour to ClientState interface.
* (modules/core/02-client) [\#1170](https://github.com/cosmos/ibc-go/pull/1170) Updating `ClientUpdateProposal` to set client state in lightclient implementations `CheckSubstituteAndUpdateState` methods.
* (modules/core/02-client) [\#1197](https://github.com/cosmos/ibc-go/pull/1197) Adding `CheckForMisbehaviour` to `ClientState` interface.
* (modules/core/02-client) [\#1195](https://github.com/cosmos/ibc-go/pull/1210) Removing `CheckHeaderAndUpdateState` from `ClientState` interface & associated light client implementations.
* (modules/core/02-client) [\#1189](https://github.com/cosmos/ibc-go/pull/1212) Removing `CheckMisbehaviourAndUpdateState` from `ClientState` interface & associated light client implementations.
* (modules/core/exported) [\#1206](https://github.com/cosmos/ibc-go/pull/1206) Adding new method `UpdateState` to `ClientState` interface.
* (modules/core/02-client) [\#1741](https://github.com/cosmos/ibc-go/pull/1741) Emitting a new `upgrade_chain` event upon setting upgrade consensus state.
* (linting) [\#1418](https://github.com/cosmos/ibc-go/pull/1418) Fix linting errors, resulting compatiblity with go1.18 linting style, golangci-lint 1.46.2 and the revivie linter. This caused breaking changes in core/04-channel, core/ante, and the testing library.
* (app/20-transfer) [\#1680](https://github.com/cosmos/ibc-go/pull/1680) Adds migration to correct any malformed trace path information of tokens with denoms that contains slashes. The transfer module consensus version has been bumped to 2.
* (app/20-transfer) [\#1730](https://github.com/cosmos/ibc-go/pull/1730) parse the ics20 denomination provided via a packet using the channel identifier format specified by ibc-go.
Expand All @@ -82,6 +98,12 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Features

* [\#276](https://github.com/cosmos/ibc-go/pull/276) Adding the Fee Middleware module v1

### Bug Fixes

* (light-clients/solomachine) [#1839](https://github.com/cosmos/ibc-go/issues/1839) Fixed usage of the new diversifier in validation of changing diversifiers for the solo machine. The current diversifier must sign over the new diversifier.
* (07-tendermint) [\#1674](https://github.com/cosmos/ibc-go/pull/1674) Submitted ClientState is zeroed out before checking the proof in order to prevent the proposal from containing information governance is not actually voting on.
* (modules/core/02-client)[\#1676](https://github.com/cosmos/ibc-go/pull/1676) ClientState must be zeroed out for `UpgradeProposals` to pass validation. This prevents a proposal containing information governance is not actually voting on.
* (apps/29-fee) [\#1229](https://github.com/cosmos/ibc-go/pull/1229) Adding CLI commands for getting all unrelayed incentivized packets and packet by packet-id.
* (apps/29-fee) [\#1224](https://github.com/cosmos/ibc-go/pull/1224) Adding Query/CounterpartyAddress and CLI to ICS29 fee middleware
* (apps/29-fee) [\#1225](https://github.com/cosmos/ibc-go/pull/1225) Adding Query/FeeEnabledChannel and Query/FeeEnabledChannels with CLIs to ICS29 fee middleware.
Expand Down Expand Up @@ -167,6 +189,11 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking

* (02-client) [\#598](https://github.com/cosmos/ibc-go/pull/598) The client state and consensus state return value has been removed from `VerifyUpgradeAndUpdateState`. Light client implementations must update the client state and consensus state after verifying a valid client upgrade.
Copy link
Contributor

@seantking seantking Aug 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be under v3.0.0 I think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I think all the changelogs need to moved to the unreleased section

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And these are added to the v3.0.0 release...

* (06-solomachine) [\#1100](https://github.com/cosmos/ibc-go/pull/1100) Remove `GetClientID` function from 06-solomachine `Misbehaviour` type.
* (06-solomachine) [\#1100](https://github.com/cosmos/ibc-go/pull/1100) Deprecate `ClientId` field in 06-solomachine `Misbehaviour` type.
* (07-tendermint) [\#1097](https://github.com/cosmos/ibc-go/pull/1097) Remove `GetClientID` function from 07-tendermint `Misbehaviour` type.
* (07-tendermint) [\#1097](https://github.com/cosmos/ibc-go/pull/1097) Deprecate `ClientId` field in 07-tendermint `Misbehaviour` type.
* (testing) [\#939](https://github.com/cosmos/ibc-go/pull/939) Support custom power reduction for testing.
* (modules/core/05-port) [\#1086](https://github.com/cosmos/ibc-go/pull/1086) Added `counterpartyChannelID` argument to IBCModule.OnChanOpenAck
* (channel) [\#848](https://github.com/cosmos/ibc-go/pull/848) Added `ChannelId` to MsgChannelOpenInitResponse
Expand All @@ -178,6 +205,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (transfer) [\#517](https://github.com/cosmos/ibc-go/pull/517) Separates the ICS 26 callback functions from `AppModule` into a new type `IBCModule` for ICS 20 transfer.
* (modules/core/02-client) [\#536](https://github.com/cosmos/ibc-go/pull/536) `GetSelfConsensusState` return type changed from bool to error.
* (channel) [\#644](https://github.com/cosmos/ibc-go/pull/644) Removes `CounterpartyHops` function from the ChannelKeeper.
* (modules/core/exported) [\#1107](https://github.com/cosmos/ibc-go/pull/1107) Merging the `Header` and `Misbehaviour` interfaces into a single `ClientMessage` type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in v3.0.0

* (testing) [\#776](https://github.com/cosmos/ibc-go/pull/776) Adding helper fn to generate capability name for testing callbacks
* (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.
* (channel) [\#882](https://github.com/cosmos/ibc-go/pull/882) The `WriteAcknowledgement` API now takes `exported.Acknowledgement` instead of a byte array
Expand All @@ -189,6 +217,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* (client) [\#888](https://github.com/cosmos/ibc-go/pull/888) Add `GetTimestampAtHeight` to `ClientState`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in v3.0.0.

* (interchain-accounts) [\#1037](https://github.com/cosmos/ibc-go/pull/1037) Add a function `InitModule` to the interchain accounts `AppModule`. This function should be called within the upgrade handler when adding the interchain accounts module to a chain. It should be called in place of InitGenesis (set the consensus version in the version map).
* (testing) [\#942](https://github.com/cosmos/ibc-go/pull/942) `NewTestChain` will create 4 validators in validator set by default. A new constructor function `NewTestChainWithValSet` is provided for test writers who want custom control over the validator set of test chains.
* (testing) [\#904](https://github.com/cosmos/ibc-go/pull/904) Add `ParsePacketFromEvents` function to the testing package. Useful when sending/relaying packets via the testing package.
Expand All @@ -198,6 +227,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (channel) [\#692](https://github.com/cosmos/ibc-go/pull/692) Minimize channel logging by only emitting the packet sequence, source port/channel, destination port/channel upon packet receives, acknowledgements and timeouts.
* [\#383](https://github.com/cosmos/ibc-go/pull/383) Adds helper functions for merging and splitting middleware versions from the underlying app version.
* (modules/core/05-port) [\#288](https://github.com/cosmos/ibc-go/issues/288) Making the 05-port keeper function IsBound public. The IsBound function checks if the provided portID is already binded to a module.
* (client) [\#724](https://github.com/cosmos/ibc-go/pull/724) `IsRevisionFormat` and `IsClientIDFormat` have been updated to disallow newlines before the dash used to separate the chainID and revision number, and the client type and client sequence.
* (channel) [\#644](https://github.com/cosmos/ibc-go/pull/644) Adds `GetChannelConnection` to the ChannelKeeper. This function returns the connectionID and connection state associated with a channel.
* (channel) [\647](https://github.com/cosmos/ibc-go/pull/647) Reorganizes channel handshake handling to set channel state after IBC application callbacks.
* (client) [\#724](https://github.com/cosmos/ibc-go/pull/724) `IsRevisionFormat` and `IsClientIDFormat` have been updated to disallow newlines before the dash used to separate the chainID and revision number, and the client type and client sequence.
Expand Down Expand Up @@ -637,6 +667,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Client Breaking Changes

* (02-client/cli) [\#196](https://github.com/cosmos/ibc-go/pull/196) Rename `node-state` cli command to `self-consensus-state`.
* (02-client/cli) [\#897](https://github.com/cosmos/ibc-go/pull/897) Remove `GetClientID()` from `Misbehaviour` interface. Submit client misbehaviour cli command requires an explicit client id now.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entry has been added to the v1.0.0 release...


## IBC in the Cosmos SDK Repository

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ The Inter-Blockchain Communication protocol (IBC) allows blockchains to talk to

3.2 [ICS 06 Solo Machine](https://github.com/cosmos/ibc-go/tree/main/modules/light-clients/06-solomachine)

Note: The localhost client is currently non-functional.

## Roadmap

For an overview of upcoming changes to ibc-go take a look at the [roadmap](./docs/roadmap/roadmap.md).
Expand Down
4 changes: 1 addition & 3 deletions docs/OLD_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ For the general specification please refer to the [Interchain Standards](https:/

3.2 [Tendermint Client](./../light-clients/07-tendermint/spec/README.md)

3.3 [Localhost Client](./../light-clients/09-localhost/spec/README.md)

## Implementation Details

As stated above, the IBC implementation on the Cosmos SDK introduces some changes
Expand Down Expand Up @@ -114,4 +112,4 @@ x/ibc
│   └── 09-localhost/
└── testing/
```
<!-- markdown-link-check-enable-->
<!-- markdown-link-check-enable-->
88 changes: 88 additions & 0 deletions docs/architecture/adr-005-consensus-height-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# ADR 005: UpdateClient Events - ClientState Consensus Heights

## Changelog
* 25/04/2022: initial draft

## Status

Accepted

## Context

The `ibc-go` implementation leverages the [Cosmos-SDK's EventManager](https://github.com/cosmos/cosmos-sdk/blob/v0.45.4/docs/core/events.md#EventManager) to provide subscribers a method of reacting to application specific events.
Some IBC relayers depend on the [`consensus_height`](https://github.com/cosmos/ibc-go/blob/v3.0.0/modules/core/02-client/keeper/events.go#L33) attribute emitted as part of `UpdateClient` events in order to run `07-tendermint` misbehaviour detection by cross-checking the details of the *Header* emitted at a given consensus height against those of the *Header* from the originating chain. This includes such details as:

- The `SignedHeader` containing the commitment root.
- The `ValidatorSet` that signed the *Header*.
- The `TrustedHeight` seen by the client at less than or equal to the height of *Header*.
- The last `TrustedValidatorSet` at the trusted height.

Following the refactor of the `02-client` submodule and associated `ClientState` interfaces, it will now be possible for
light client implementations to perform such actions as batch updates, inserting `N` number of `ConsensusState`s into the application state tree with a single `UpdateClient` message. This flexibility is provided in `ibc-go` by the usage of the [Protobuf `Any`](https://developers.google.com/protocol-buffers/docs/proto3#any) field contained within the [`UpdateClient`](https://github.com/cosmos/ibc-go/blob/v3.0.0/proto/ibc/core/client/v1/tx.proto#L44) message.
For example, a batched client update message serialized as a Protobuf `Any` type for the `07-tendermint` lightclient implementation could be defined as follows:

```protobuf
message BatchedHeaders {
repeated Header headers = 1;
}
```

To complement this flexibility, the `UpdateClient` handler will now support the submission of [client misbehaviour](https://github.com/cosmos/ibc/tree/master/spec/core/ics-002-client-semantics#misbehaviour) by consolidating the `Header` and `Misbehaviour` interfaces into a single `ClientMessage` interface type:

```go
// ClientMessage is an interface used to update an IBC client.
// The update may be done by a single header, a batch of headers, misbehaviour, or any type which when verified produces
// a change to state of the IBC client
type ClientMessage interface {
proto.Message

ClientType() string
ValidateBasic() error
}
```

To support this functionality the `GetHeight()` method has been omitted from the new `ClientMessage` interface.
Emission of standardised events from the `02-client` submodule now becomes problematic and is two-fold:

1. The `02-client` submodule previously depended upon the `GetHeight()` method of `Header` types in order to [retrieve the updated consensus height](https://github.com/cosmos/ibc-go/blob/v3.0.0/modules/core/02-client/keeper/client.go#L90).
2. Emitting a single `consensus_height` event attribute is not sufficient in the case of a batched client update containing multiple *Headers*.

## Decision

The following decisions have been made in order to provide flexibility to consumers of `UpdateClient` events in a non-breaking fashion:

1. Return a list of updated consensus heights `[]exported.Height` from the new `UpdateState` method of the `ClientState` interface.

```go
// UpdateState updates and stores as necessary any associated information for an IBC client, such as the ClientState and corresponding ConsensusState.
// Upon successful update, a list of consensus heights is returned. It assumes the ClientMessage has already been verified.
UpdateState(sdk.Context, codec.BinaryCodec, sdk.KVStore, ClientMessage) []Height
```

2. Maintain the `consensus_height` event attribute emitted from the `02-client` update handler, but mark as deprecated for future removal. For example, with tendermint lightclients this will simply be `consensusHeights[0]` following a successful update using a single *Header*.

3. Add an additional `consensus_heights` event attribute, containing a comma separated list of updated heights. This provides flexibility for emitting a single consensus height or multiple consensus heights in the example use-case of batched header updates.

## Consequences

### Positive

- Subscribers of IBC core events can act upon `UpdateClient` events containing one or more consensus heights.
- Deprecation of the existing `consensus_height` attribute allows consumers to continue to process `UpdateClient` events as normal, with a path to upgrade to using the `consensus_heights` attribute moving forward.

### Negative

- Consumers of IBC core `UpdateClient` events are forced to make future code changes.

### Neutral

## References

Discussions:
- [#1208](https://github.com/cosmos/ibc-go/pull/1208#discussion_r839691927)

Issues:
- [#594](https://github.com/cosmos/ibc-go/issues/594)

PRs:
- [#1285](https://github.com/cosmos/ibc-go/pull/1285)
2 changes: 1 addition & 1 deletion docs/architecture/adr-027-ibc-wasm.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ packaged inside a payload which is json serialized and passed to `callContract`
array of bytes returned by the smart contract. This data is deserialized and passed as return argument.

```go
func (c *ClientState) CheckProposedHeaderAndUpdateState(context sdk.Context, marshaler codec.BinaryMarshaler, store sdk.KVStore, header exported.Header) (exported.ClientState, exported.ConsensusState, error) {
func (c *ClientState) CheckProposedHeaderAndUpdateState(context sdk.Context, marshaler codec.BinaryMarshaler, store sdk.KVStore, header exported.ClientMessage) (exported.ClientState, exported.ConsensusState, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be split up into two functions or we will allow the ADR authors to update?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should change the status of the ADR to "needs update"

// get consensus state corresponding to client state to check if the client is expired
consensusState, err := GetConsensusState(store, marshaler, c.LatestHeight)
if err != nil {
Expand Down
11 changes: 0 additions & 11 deletions docs/ibc/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,6 @@ at each height during the `BeginBlock` call. The historical info is required to
past historical info at any given height in order to verify the light client `ConsensusState` during the
connection handhake.

The IBC module also has
[`BeginBlock`](https://github.com/cosmos/ibc-go/blob/main/modules/core/02-client/abci.go) logic as
well. This is optional as it is only required if your application uses the [localhost
client](https://github.com/cosmos/ibc/blob/master/spec/client/ics-009-loopback-client) to connect two
different modules from the same chain.

::: tip
Only register the ibc module to the `SetOrderBeginBlockers` if your application will use the
localhost (_aka_ loopback) client.
:::

```go
// app.go
func NewApp(...args) *App {
Expand Down
20 changes: 20 additions & 0 deletions docs/ibc/middleware/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,26 @@ func GetAppVersion(

return metadata.AppVersion, true
}

// middleware must return the underlying application version
func GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool) {
version, found := ics4Keeper.GetAppVersion(ctx, portID, channelID)
if !found {
return "", false
}

if !MiddlewareEnabled {
return version, true
}

// unwrap channel version
metadata, err := Unmarshal(version)
if err != nil {
panic(fmt.Errof("unable to unmarshal version: %w", err))
}

return metadata.AppVersion, true
}
```

See [here](https://github.com/cosmos/ibc-go/blob/48a6ae512b4ea42c29fdf6c6f5363f50645591a2/modules/apps/29-fee/ibc_middleware.go#L355-L358) an example implementation of this function for the ICS29 Fee Middleware module.
Loading