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

ChannelUpgradeInit refactor #5287

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
2bd29c0
Add a helper function to create a mock contract. (#5162)
DimitrisJim Nov 22, 2023
d62a66c
docs: improved channel closure docs (#5170)
srdtrk Nov 27, 2023
7eb1b84
chore: use `GetPrefixedDenom` to create IBC token denom (#5175)
0xstepit Nov 27, 2023
2eb0b84
build(deps): Bump DavidAnson/markdownlint-cli2-action from 13 to 14 (…
dependabot[bot] Nov 27, 2023
251d6f0
docs: readme improvements (#5171)
crodriguezvega Nov 27, 2023
2c9017f
chore(08-wasm): `Pin` code during app initialisation (#5161)
vuong177 Nov 28, 2023
82c5021
e2e: timeout transfer with grandpa light client (#5018)
charleenfei Nov 28, 2023
10bb80b
Change to StoreCodeUnchecked in Genesis and snapshotter (#5167)
GNaD13 Nov 28, 2023
eeab4d5
build(deps): Bump JamesIves/github-pages-deploy-action from 4.4.3 to …
dependabot[bot] Nov 28, 2023
e329e28
build(deps): Bump github.com/hashicorp/go-metrics from 0.5.2 to 0.5.3…
dependabot[bot] Nov 28, 2023
e42fcc8
build(deps): Bump github.com/cometbft/cometbft from 0.38.1 to 0.38.2 …
dependabot[bot] Nov 28, 2023
bf01efd
build(deps): Bump github.com/spf13/cast from 1.5.1 to 1.6.0 (#5181)
dependabot[bot] Nov 28, 2023
88d07d5
chore: update swagger (#5179)
crodriguezvega Nov 28, 2023
1889759
docs: add IBC overview diagram (#5166)
crodriguezvega Nov 28, 2023
9f0002f
Drop step installing tparse. (#5191)
DimitrisJim Nov 28, 2023
5c93d41
Add capability to dependabot. (#5193)
DimitrisJim Nov 28, 2023
0c2d2ba
build(deps): Bump sigs.k8s.io/yaml in /modules/capability (#5194)
dependabot[bot] Nov 28, 2023
a9cf9d2
build(deps): Bump github.com/cometbft/cometbft in /modules/capability…
dependabot[bot] Nov 28, 2023
9bce130
build(deps): Bump cosmossdk.io/store from 1.0.0 to 1.0.1 (#5199)
dependabot[bot] Nov 29, 2023
8716791
remove unnecessary code
hieuvubk Nov 30, 2023
51b3e29
merge main
hieuvubk Nov 30, 2023
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
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@ updates:
labels:
- dependencies

- package-ecosystem: gomod
directory: "/modules/capability"
schedule:
interval: daily
open-pull-requests-limit: 10
labels:
- dependencies


2 changes: 1 addition & 1 deletion .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: make build-docs

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4.4.3
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
branch: gh-pages
folder: docs/build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
files: '**/*.md'
separator: ","
- uses: DavidAnson/markdownlint-cli2-action@v13
- uses: DavidAnson/markdownlint-cli2-action@v14
if: steps.changed-files.outputs.any_changed == 'true'
with:
globs: ${{ steps.changed-files.outputs.all_changed_files }}
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,6 @@ jobs:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'"

install-tparse:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Display go version
run: go version
- name: install tparse
run: |
go install github.com/mfridman/[email protected]
- uses: actions/cache@v3
with:
path: ~/go/bin
key: ${{ runner.os }}-go-tparse-binary

build:
runs-on: ubuntu-latest
strategy:
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<img alt="E2E Status" src="https://github.com/cosmos/ibc-go/workflows/Tests%20/%20E2E/badge.svg" />
</div>

The [Inter-Blockchain Communication protocol (IBC)](https://ibcprotocol.dev/) allows blockchains to talk to each other. This end-to-end, connection-oriented, stateful protocol provides reliable, ordered, and authenticated communication between heterogeneous blockchains.
The [Inter-Blockchain Communication protocol (IBC)](https://ibcprotocol.dev/) allows blockchains to talk to each other. This end-to-end, connection-oriented, stateful protocol provides reliable, ordered, and authenticated communication between heterogeneous blockchains. For a high-level explanation of what IBC is and how it works, please read [this blog post](https://medium.com/the-interchain-foundation/eli5-what-is-ibc-def44d7b5b4c).

This IBC implementation in Golang is built as a Cosmos SDK module. To understand more about how to use the `ibc-go` module as well as about the IBC protocol, please check out the Interchain Developer Academy [section on IBC](https://tutorials.cosmos.network/academy/3-ibc/), or [our docs](https://ibc.cosmos.network/main/ibc/overview.html).

Expand All @@ -47,8 +47,6 @@ This roadmap is also available as a [project board](https://github.com/orgs/cosm

For the latest expected release timelines, please check [here](https://github.com/cosmos/ibc-go/wiki/Release-timeline).

For the latest information on the progress of the work or the decisions made that might influence the roadmap, please follow our [engineering updates](https://github.com/cosmos/ibc-go/wiki/Engineering-updates).

## Releases

The release lines currently supported are v6, v7 and v8.
Expand All @@ -61,14 +59,16 @@ Please refer to our [versioning guide](https://github.com/cosmos/ibc-go/blob/mai

Discover more applications and middleware in the [cosmos/ibc-apps repository](https://github.com/cosmos/ibc-apps#-bonus-content).

## Support
## Community

We have active, helpful communities on Discord and Telegram.

For questions and support please use the `developers` channel in the [Cosmos Network Discord server](https://discord.com/channels/669268347736686612/1019978171367559208) or join the [IBC Gang Discord server](https://discord.gg/RdpdkaXKpZ). The issue list of this repo is exclusively for bug reports and feature requests.
For questions and support please use the `developers` channel in the [Cosmos Network Discord server](https://discord.com/channels/669268347736686612/1019978171367559208) or join the [IBC Gang Discord server](https://discord.gg/Wtmk6ZNa8G). The issue list of this repo is exclusively for bug reports and feature requests.

To receive announcements of new releases or other technical updates, please join the [Telegram group that we administer](https://t.me/ibc_is_expansive).

We run biweekly community calls to update the community with our current direction and gather feedback on what to work on next. The community calls are also a platform for you to update everyone else with what you're working on, ask questions and find opportunities to collaborate. Please join [this Google group](https://groups.google.com/g/ibc-community) to receive a calendar invitation for the meeting.

## Contributing

If you're interested in contributing to ibc-go, please take a look at the [contributing guidelines](./CONTRIBUTING.md). We welcome and appreciate community contributions!
Expand All @@ -92,7 +92,7 @@ To report a security vulnerability, see our [Coordinated Vulnerability Disclosur

The following audits have been performed on the `ibc-go` source code:

- [ICS27 Interchain Accounts](https://github.com/cosmos/ibc-go/blob/main/docs/audits/Trail%20of%20Bits%20audit%20-%20Final%20Report.pdf) by Trail of Bits
- [ICS27 Interchain Accounts](https://github.com/cosmos/ibc-go/blob/main/docs/audits/Trail%20of%20Bits%20audit%20-%20Final%20Report.pdf) by Trail of Bits.

## Quick Navigation

Expand Down Expand Up @@ -138,3 +138,7 @@ The following audits have been performed on the `ibc-go` source code:
- [IBC Protocol Specification](https://github.com/cosmos/ibc)
- [Documentation](https://ibc.cosmos.network/main/ibc/overview.html)
- [Interchain Developer Academy](https://tutorials.cosmos.network/academy/3-ibc/)

---

The development of ibc-go is led primarily by Interchain GmbH. Funding for this development comes primarily from the [Interchain Foundation](https://interchain.io), a Swiss non-profit.
187 changes: 27 additions & 160 deletions docs/client/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13610,17 +13610,25 @@ paths:
type: string
tags:
- Query
/ibc/core/channel/v1/channels/{channel_id}/ports/{port_id}/upgrade_error:
/ibc/lightclients/wasm/v1/checksums:
get:
summary: UpgradeError returns the error receipt if the upgrade handshake failed.
operationId: UpgradeError
summary: Get all Wasm checksums
operationId: Checksums
responses:
'200':
description: A successful response.
schema:
type: object
properties:
error_receipt:
checksums:
type: array
items:
type: string
description: >-
checksums is a list of the hex encoded checksums of all wasm
codes stored.
pagination:
description: pagination defines the pagination in the response.
type: object
properties:
sequence:
Expand All @@ -13634,11 +13642,21 @@ paths:
ErrorReceipt defines a type which encapsulates the upgrade
sequence and error associated with the

upgrade handshake failure. When a channel upgrade handshake is
aborted both chains are expected to increment to the

next sequence.
proof:
was set, its value is undefined otherwise
description: >-
QueryChecksumsResponse is the response type for the
Query/Checksums RPC method.
default:
description: An unexpected error response.
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
format: byte
title: merkle proof of existence
Expand Down Expand Up @@ -20372,157 +20390,6 @@ definitions:
ready to send and receive packets.
- STATE_CLOSED: A channel has been closed and can no longer be used to send or receive
packets.
- STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets.
- STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets.
ibc.core.channel.v1.Timeout:
type: object
properties:
height:
title: block height after which the packet or upgrade times out
type: object
properties:
revision_number:
type: string
format: uint64
title: the revision that the client is currently on
revision_height:
type: string
format: uint64
title: the height within the given revision
description: >-
Normally the RevisionHeight is incremented at each height while
keeping

RevisionNumber the same. However some consensus algorithms may choose
to

reset the height in certain conditions e.g. hard forks, state-machine

breaking changes In these cases, the RevisionNumber is incremented so
that

height continues to be monitonically increasing even as the
RevisionHeight

gets reset
timestamp:
type: string
format: uint64
title: >-
block timestamp (in nanoseconds) after which the packet or upgrade
times out
description: >-
Timeout defines an execution deadline structure for 04-channel handlers.

This includes packet lifecycle handlers as well as the upgrade handshake
handlers.

A valid Timeout contains either one or both of a timestamp and block
height (sequence).
ibc.core.channel.v1.Upgrade:
type: object
properties:
fields:
type: object
properties:
ordering:
type: string
enum:
- ORDER_NONE_UNSPECIFIED
- ORDER_UNORDERED
- ORDER_ORDERED
default: ORDER_NONE_UNSPECIFIED
description: |-
- ORDER_NONE_UNSPECIFIED: zero-value for channel ordering
- ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in
which they were sent.
- ORDER_ORDERED: packets are delivered exactly in the order which they were sent
title: Order defines if a channel is ORDERED or UNORDERED
connection_hops:
type: array
items:
type: string
version:
type: string
description: |-
UpgradeFields are the fields in a channel end which may be changed
during a channel upgrade.
timeout:
type: object
properties:
height:
title: block height after which the packet or upgrade times out
type: object
properties:
revision_number:
type: string
format: uint64
title: the revision that the client is currently on
revision_height:
type: string
format: uint64
title: the height within the given revision
description: >-
Normally the RevisionHeight is incremented at each height while
keeping

RevisionNumber the same. However some consensus algorithms may
choose to

reset the height in certain conditions e.g. hard forks,
state-machine

breaking changes In these cases, the RevisionNumber is incremented
so that

height continues to be monitonically increasing even as the
RevisionHeight

gets reset
timestamp:
type: string
format: uint64
title: >-
block timestamp (in nanoseconds) after which the packet or upgrade
times out
description: >-
Timeout defines an execution deadline structure for 04-channel
handlers.

This includes packet lifecycle handlers as well as the upgrade
handshake handlers.

A valid Timeout contains either one or both of a timestamp and block
height (sequence).
description: |-
Upgrade is a verifiable type which contains the relevant information
for an attempted upgrade. It provides the proposed changes to the channel
end and the timeout for this upgrade attempt.
ibc.core.channel.v1.UpgradeFields:
type: object
properties:
ordering:
type: string
enum:
- ORDER_NONE_UNSPECIFIED
- ORDER_UNORDERED
- ORDER_ORDERED
default: ORDER_NONE_UNSPECIFIED
description: |-
- ORDER_NONE_UNSPECIFIED: zero-value for channel ordering
- ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in
which they were sent.
- ORDER_ORDERED: packets are delivered exactly in the order which they were sent
title: Order defines if a channel is ORDERED or UNORDERED
connection_hops:
type: array
items:
type: string
version:
type: string
description: |-
UpgradeFields are the fields in a channel end which may be changed
during a channel upgrade.
ibc.lightclients.wasm.v1.QueryChecksumsResponse:
type: object
properties:
Expand Down
20 changes: 20 additions & 0 deletions docs/docs/00-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,23 @@ IBC is a protocol that allows blockchains to talk to each other. Chains that spe
The protocol realizes this interoperability by specifying a set of data structures, abstractions, and semantics that can be implemented by any distributed ledger that satisfies a small set of requirements.

IBC can be used to build a wide range of cross-chain applications that include token transfers, atomic swaps, multi-chain smart contracts (with or without mutually comprehensible VMs), cross-chain account control, and data and code sharding of various kinds.

## High-level overview of IBC

The following diagram shows how IBC works at a high level:

![IBC overview - two connected chains](./images/ibcoverview.png)

The transport layer (TAO) provides the necessary infrastructure to establish secure connections and authenticate data packets between chains. The application layer builds on top of the transport layer and defines exactly how data packets should be packaged and interpreted by the sending and receiving chains.

IBC provides a reliable, permissionless, and generic base layer (allowing for the secure relaying of data packets), while allowing for composability and modularity with separation of concerns by moving application designs (interpreting and acting upon the packet data) to a higher-level layer. This separation is reflected in the categories:

- **IBC/TAO** comprises the Transport, Authentication, and Ordering of packets, i.e. the infrastructure layer.
- **IBC/APP** consists of the application handlers for the data packets being passed over the transport layer. These include but are not limited to fungible token transfers (ICS-20), NFT transfers (ICS-721), and interchain accounts (ICS-27).
- **Application module:** groups any application, middleware or smart contract that may wrap downsteam application handlers to provide enhanced functionality.

Note three crucial elements in the diagram:

- The chains depend on relayers to communicate. Relayers are the "physical" connection layer of IBC: off-chain processes responsible for relaying data between two chains running the IBC protocol by scanning the state of each chain, constructing appropriate datagrams, and executing them on the opposite chain as is allowed by the protocol.
- Many relayers can serve one or more channels to send messages between the chains.
- Each side of the connection uses the light client of the other chain to quickly verify incoming messages.
26 changes: 19 additions & 7 deletions docs/docs/01-ibc/01-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,27 @@ handshake; either `OnChanOpenInit` on the initializing chain or `OnChanOpenTry`
#### Closing channels

Closing a channel occurs in 2 handshake steps as defined in [ICS 04](https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics).
Once a channel is closed, it cannot be reopened. The channel handshake steps are:

`ChanCloseInit` closes a channel on the executing chain if the channel exists, it is not
already closed and the connection it exists upon is OPEN. Channels can only be closed by a
calling module or in the case of a packet timeout on an ORDERED channel.
**`ChanCloseInit`** closes a channel on the executing chain if

`ChanCloseConfirm` is a response to a counterparty channel executing `ChanCloseInit`. The channel
on the executing chain closes if the channel exists, the channel is not already closed,
the connection the channel exists upon is OPEN and the executing chain successfully verifies
that the counterparty channel has been closed.
- the channel exists and it is not already closed,
- the connection it exists upon is OPEN,
- the [IBC module callback `OnChanCloseInit`](./03-apps/02-ibcmodule.md#channel-closing-callbacks) returns `nil`.

`ChanCloseInit` can be initiated by any user by submitting a `MsgChannelCloseInit` transaction.
Note that channels are automatically closed when a packet times out on an `ORDERED` channel.
A timeout on an `ORDERED` channel skips the `ChanCloseInit` step and immediately closes the channel.

**`ChanCloseConfirm`** is a response to a counterparty channel executing `ChanCloseInit`. The channel
on the executing chain closes if

- the channel exists and is not already closed,
- the connection the channel exists upon is OPEN,
- the executing chain successfully verifies that the counterparty channel has been closed
- the [IBC module callback `OnChanCloseConfirm`](./03-apps/02-ibcmodule.md#channel-closing-callbacks) returns `nil`.

Currently, none of the IBC applications provided in ibc-go support `ChanCloseInit`.

### [Packets](https://github.com/cosmos/ibc-go/blob/main/modules/core/04-channel)

Expand Down
4 changes: 4 additions & 0 deletions docs/docs/01-ibc/03-apps/02-ibcmodule.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,12 @@ func (im IBCModule) OnChanOpenConfirm(
}
```

### Channel closing callbacks

The channel closing handshake will also invoke module callbacks that can return errors to abort the closing handshake. Closing a channel is a 2-step handshake, the initiating chain calls `ChanCloseInit` and the finalizing chain calls `ChanCloseConfirm`.

Currently, all IBC modules in this repository return an error for `OnChanCloseInit` to prevent the channels from closing. This is because any user can call `ChanCloseInit` by submitting a `MsgChannelCloseInit` transaction.

```go
// Called by IBC Handler on MsgCloseInit
func (im IBCModule) OnChanCloseInit(
Expand Down
Loading
Loading