Skip to content

Commit 76e2ef2

Browse files
gjermundgarabawomensrights
authored andcommitted
docs: add versioned docs for v10 (#8279)
* delete v9 docs * add v10.1.x versioned docs * fix broken links * more link fixes --------- Co-authored-by: Susannah Evans <65018876+womensrights@users.noreply.github.com>
1 parent 554de1c commit 76e2ef2

File tree

183 files changed

+1386
-2090
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+1386
-2090
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ write a little note why.
3636

3737
- [ ] Targeted PR against the correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/main/docs/dev/pull-requests.md#pull-request-targeting)).
3838
- [ ] Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
39-
- [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/main/docs/build/building-modules/11-structure.md) and [Go style guide](../docs/dev/go-style-guide.md).
39+
- [ ] Code follows the [module structure standards](https://docs.cosmos.network/main/build/building-modules/intro) and [Go style guide](../docs/dev/go-style-guide.md).
4040
- [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/main/testing/README.md#ibc-testing-package).
4141
- [ ] Updated relevant documentation (`docs/`).
4242
- [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code).

docs/dev/project-structure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Project structure
22

3-
If you're not familiar with the overall module structure from the SDK modules, please check this [document](https://github.com/cosmos/cosmos-sdk/blob/main/docs/build/building-modules/11-structure.md) as prerequisite reading.
3+
If you're not familiar with the overall module structure from the SDK modules, please check this [document](https://docs.cosmos.network/main/build/building-modules/intro) as prerequisite reading.
44

55
Every Interchain Standard (ICS) has been developed in its own package. The development team separated the IBC TAO (Transport, Authentication, Ordering) ICS specifications from the IBC application level specification. The following sections describe the architecture of the most relevant directories that comprise this repository.
66

docs/docs/01-ibc/02-integration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ With IBC v2, there is a new [router](https://github.com/cosmos/ibc-go/blob/main/
197197
198198
### Module `Manager` and `SimulationManager`
199199
200-
In order to use IBC, we need to add the new modules to the module `Manager` and to the `SimulationManager`, in case your application supports [simulations](https://github.com/cosmos/cosmos-sdk/blob/main/docs/build/building-modules/14-simulator.md).
200+
In order to use IBC, we need to add the new modules to the module `Manager` and to the `SimulationManager`, in case your application supports [simulations](https://docs.cosmos.network/main/learn/advanced/simulation).
201201
202202
```go title="app.go"
203203
import (

docs/docs/01-ibc/07-relayer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ slug: /ibc/relayer
1212
## Pre-requisite readings
1313

1414
- [IBC Overview](01-overview.md)
15-
- [Events](https://github.com/cosmos/cosmos-sdk/blob/main/docs/learn/advanced/08-events.md)
15+
- [Events](https://docs.cosmos.network/v0.47/learn/advanced/events)
1616

1717
:::
1818

docs/docs/02-apps/01-transfer/06-metrics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ slug: /apps/transfer/ics20-v1/metrics
77

88
# Metrics
99

10-
The IBC transfer application module exposes the following set of [metrics](https://github.com/cosmos/cosmos-sdk/blob/main/docs/learn/advanced/09-telemetry.md).
10+
The IBC transfer application module exposes the following set of [metrics](https://docs.cosmos.network/main/learn/advanced/telemetry).
1111

1212
| Metric | Description | Unit | Type |
1313
|:--------------------------------|:------------------------------------------------------------------------------------------|:----------------|:--------|

docs/docusaurus.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const config = {
4949
// Exclude template markdown files from the docs
5050
exclude: ["**/*.template.md"],
5151
// Select the latest version
52-
lastVersion: "v8.5.x",
52+
lastVersion: "v10.1.x",
5353
// Assign banners to specific versions
5454
versions: {
5555
current: {

docs/versioned_docs/version-v9.0.x/00-intro.md renamed to docs/versioned_docs/version-v10.1.x/00-intro.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@ sidebar_position: 0
55

66
# IBC-Go Documentation
77

8-
Welcome to the documentation for IBC-Go, the Golang implementation of the Inter-Blockchain Communication Protocol! Looking for information on ibc-rs? [Click here to go to the ibc-rs github repo](https://github.com/cosmos/ibc-rs).
8+
Welcome to the documentation for IBC-Go, the Golang implementation of the Inter-Blockchain Communication Protocol!
99

10-
The Inter-Blockchain Communication Protocol (IBC) is an end-to-end, connection-oriented, stateful protocol for reliable, ordered, and authenticated communication between heterogeneous blockchains arranged in an unknown and dynamic topology.
11-
12-
IBC is a protocol that allows blockchains to talk to each other. Chains that speak IBC can share any type of data as long as it's encoded in bytes, enabling the industry’s most feature-rich cross-chain interactions. IBC is secure and permissionless.
10+
The Inter-Blockchain Communication Protocol (IBC) is a protocol that allows blockchains to talk to each other. Chains that speak IBC can share any type of data as long as it's encoded in bytes, enabling the industry’s most feature-rich cross-chain interactions. 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), and cross-chain account control. IBC is secure and permissionless.
1311

1412
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.
1513

16-
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.
14+
:::note Notice
15+
Since ibc-go v10, there are two versions of the protocol in the same release: IBC classic and IBC v2. The protocols are seperate - a connection uses either IBC classic or IBC v2
16+
:::
17+
18+
## High-level overview of IBC v2
19+
20+
For a high level overview of IBC v2, please refer to [this blog post.](https://ibcprotocol.dev/blog/ibc-v2-announcement) For a more detailed understanding of the IBC v2 protocol, please refer to the [IBC v2 protocol specification.](https://github.com/cosmos/ibc/tree/main/spec/IBC_V2)
21+
22+
If you are interested in using the cannonical deployment of IBC v2, connecting Cosmos chains and Ethereum, take a look at the [IBC Eureka](https://docs.skip.build/go/eureka/eureka-overview) documentation to get started.
1723

18-
## High-level overview of IBC
24+
## High-level overview of IBC Classic
1925

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

File renamed without changes.

docs/versioned_docs/version-v9.0.x/01-ibc/02-integration.md renamed to docs/versioned_docs/version-v10.1.x/01-ibc/02-integration.md

Lines changed: 100 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ slug: /ibc/integration
88
# Integration
99

1010
:::note Synopsis
11-
Learn how to integrate IBC to your application and send data packets to other chains.
11+
Learn how to integrate IBC to your application
1212
:::
1313

1414
This document outlines the required steps to integrate and configure the [IBC
15-
module](https://github.com/cosmos/ibc-go/tree/main/modules/core) to your Cosmos SDK application and
16-
send fungible token transfers to other chains.
15+
module](https://github.com/cosmos/ibc-go/tree/main/modules/core) to your Cosmos SDK application and enable sending fungible token transfers to other chains. An [example app using ibc-go v10 is linked](https://github.com/gjermundgaraba/probe/tree/ibc/v10).
1716

1817
## Integrating the IBC module
1918

2019
Integrating the IBC module to your SDK-based application is straightforward. The general changes can be summarized in the following steps:
2120

2221
- [Define additional `Keeper` fields for the new modules on the `App` type](#add-application-fields-to-app).
2322
- [Add the module's `StoreKey`s and initialize their `Keeper`s](#configure-the-keepers).
23+
- [Create Application Stacks with Middleware](#create-application-stacks-with-middleware)
2424
- [Set up IBC router and add route for the `transfer` module](#register-module-routes-in-the-ibc-router).
2525
- [Grant permissions to `transfer`'s `ModuleAccount`](#module-account-permissions).
2626
- [Add the modules to the module `Manager`](#module-manager-and-simulationmanager).
@@ -30,14 +30,17 @@ Integrating the IBC module to your SDK-based application is straightforward. The
3030

3131
### Add application fields to `App`
3232

33-
We need to register the core `ibc` and `transfer` `Keeper`s as follows:
33+
We need to register the core `ibc` and `transfer` `Keeper`s. To support the use of IBC v2, `transferv2` and `callbacksv2` must also be registered as follows:
3434

3535
```go title="app.go"
3636
import (
3737
// other imports
3838
// ...
3939
ibckeeper "github.com/cosmos/ibc-go/v10/modules/core/keeper"
4040
ibctransferkeeper "github.com/cosmos/ibc-go/v10/modules/apps/transfer/keeper"
41+
// ibc v2 imports
42+
transferv2 "github.com/cosmos/ibc-go/v10/modules/apps/transfer/v2"
43+
ibccallbacksv2 "github.com/cosmos/ibc-go/v10/modules/apps/callbacks/v2"
4144
)
4245

4346
type App struct {
@@ -55,16 +58,18 @@ type App struct {
5558

5659
### Configure the `Keeper`s
5760

58-
During initialization, besides initializing the IBC `Keeper`s (for core `ibc` and `transfer` modules), we need to grant specific capabilities through the capability module `ScopedKeeper`s so that we can authenticate the object-capability permissions for each of the IBC channels.
61+
Initialize the IBC `Keeper`s (for core `ibc` and `transfer` modules), and any additional modules you want to include.
62+
63+
:::note Notice
64+
The capability module has been removed in ibc-go v10, therefore the `ScopedKeeper` has also been removed
65+
:::
5966

6067
```go
6168
import (
6269
// other imports
6370
// ...
6471
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
6572

66-
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
67-
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
6873
ibcexported "github.com/cosmos/ibc-go/v10/modules/core/exported"
6974
ibckeeper "github.com/cosmos/ibc-go/v10/modules/core/keeper"
7075
"github.com/cosmos/ibc-go/v10/modules/apps/transfer"
@@ -75,48 +80,73 @@ import (
7580
func NewApp(...args) *App {
7681
// define codecs and baseapp
7782

78-
// add capability keeper and ScopeToModule for ibc module
79-
app.CapabilityKeeper = capabilitykeeper.NewKeeper(
80-
appCodec,
81-
keys[capabilitytypes.StoreKey],
82-
memKeys[capabilitytypes.MemStoreKey],
83-
)
84-
85-
// grant capabilities for the ibc and transfer modules
86-
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName)
87-
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
88-
8983
// ... other module keepers
9084

9185
// Create IBC Keeper
9286
app.IBCKeeper = ibckeeper.NewKeeper(
93-
appCodec,
94-
keys[ibcexported.StoreKey],
95-
app.GetSubspace(ibcexported.ModuleName),
96-
app.UpgradeKeeper,
97-
scopedIBCKeeper,
98-
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
99-
)
87+
appCodec,
88+
runtime.NewKVStoreService(keys[ibcexported.StoreKey]),
89+
app.GetSubspace(ibcexported.ModuleName),
90+
app.UpgradeKeeper,
91+
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
92+
)
10093

10194
// Create Transfer Keeper
10295
app.TransferKeeper = ibctransferkeeper.NewKeeper(
103-
appCodec,
104-
keys[ibctransfertypes.StoreKey],
105-
app.GetSubspace(ibctransfertypes.ModuleName),
106-
app.IBCKeeper.ChannelKeeper,
107-
app.IBCKeeper.ChannelKeeper,
108-
app.IBCKeeper.PortKeeper,
109-
app.AccountKeeper,
110-
app.BankKeeper,
111-
scopedTransferKeeper,
112-
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
113-
)
114-
transferModule := transfer.NewIBCModule(app.TransferKeeper)
96+
appCodec,
97+
runtime.NewKVStoreService(keys[ibctransfertypes.StoreKey]),
98+
app.GetSubspace(ibctransfertypes.ModuleName),
99+
app.IBCKeeper.ChannelKeeper,
100+
app.IBCKeeper.ChannelKeeper,
101+
app.MsgServiceRouter(),
102+
app.AccountKeeper,
103+
app.BankKeeper,
104+
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
105+
)
115106

116107
// ... continues
117108
}
118109
```
119110

111+
### Create Application Stacks with Middleware
112+
113+
Middleware stacks in IBC allow you to wrap an `IBCModule` with additional logic for packets and acknowledgements. This is a chain of handlers that execute in order. The transfer stack below shows how to wire up transfer to use packet forward middleware, and the callbacks middleware. Note that the order is important.
114+
115+
```go
116+
// Create Transfer Stack for IBC Classic
117+
maxCallbackGas := uint64(10_000_000)
118+
wasmStackIBCHandler := wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper)
119+
120+
var transferStack porttypes.IBCModule
121+
transferStack = transfer.NewIBCModule(app.TransferKeeper)
122+
// callbacks wraps the transfer stack as its base app, and uses PacketForwardKeeper as the ICS4Wrapper
123+
// i.e. packet-forward-middleware is higher on the stack and sits between callbacks and the ibc channel keeper
124+
// Since this is the lowest level middleware of the transfer stack, it should be the first entrypoint for transfer keeper's
125+
// WriteAcknowledgement.
126+
cbStack := ibccallbacks.NewIBCMiddleware(transferStack, app.PacketForwardKeeper, wasmStackIBCHandler, maxCallbackGas)
127+
transferStack = packetforward.NewIBCMiddleware(
128+
cbStack,
129+
app.PacketForwardKeeper,
130+
0, // retries on timeout
131+
packetforwardkeeper.DefaultForwardTransferPacketTimeoutTimestamp,
132+
)
133+
```
134+
135+
#### IBC v2 Application Stack
136+
137+
For IBC v2, an example transfer stack is shown below. In this case the transfer stack is using the callbacks middleware.
138+
139+
```go
140+
// Create IBC v2 transfer middleware stack
141+
// the callbacks gas limit is recommended to be 10M for use with wasm contracts
142+
maxCallbackGas := uint64(10_000_000)
143+
wasmStackIBCHandler := wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper)
144+
145+
var ibcv2TransferStack ibcapi.IBCModule
146+
ibcv2TransferStack = transferv2.NewIBCModule(app.TransferKeeper)
147+
ibcv2TransferStack = ibccallbacksv2.NewIBCMiddleware(transferv2.NewIBCModule(app.TransferKeeper), app.IBCKeeper.ChannelKeeperV2, wasmStackIBCHandler, app.IBCKeeper.ChannelKeeperV2, maxCallbackGas)
148+
```
149+
120150
### Register module routes in the IBC `Router`
121151

122152
IBC needs to know which module is bound to which port so that it can route packets to the
@@ -126,8 +156,7 @@ by the port
126156
[`Router`](https://github.com/cosmos/ibc-go/blob/main/modules/core/05-port/types/router.go) on the
127157
`ibc` module.
128158

129-
Adding the module routes allows the IBC handler to call the appropriate callback when processing a
130-
channel handshake or a packet.
159+
Adding the module routes allows the IBC handler to call the appropriate callback when processing a channel handshake or a packet.
131160

132161
Currently, a `Router` is static so it must be initialized and set correctly on app initialization.
133162
Once the `Router` has been set, no new routes can be added.
@@ -145,17 +174,30 @@ func NewApp(...args) *App {
145174

146175
// Create static IBC router, add transfer module route, then set and seal it
147176
ibcRouter := porttypes.NewRouter()
148-
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule)
177+
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferStack)
149178
// Setting Router will finalize all routes by sealing router
150179
// No more routes can be added
151180
app.IBCKeeper.SetRouter(ibcRouter)
152181

153182
// ... continues
154183
```
155184
185+
#### IBC v2 Router
186+
187+
With IBC v2, there is a new [router](https://github.com/cosmos/ibc-go/blob/main/modules/core/api/router.go) that needs to register the routes for a portID to a given IBCModule.
188+
189+
```go
190+
// IBC v2 router creation
191+
ibcRouterV2 := ibcapi.NewRouter()
192+
ibcRouterV2.AddRoute(ibctransfertypes.PortID, ibcv2TransferStack)
193+
// Setting Router will finalize all routes by sealing router
194+
// No more routes can be added
195+
app.IBCKeeper.SetRouterV2(ibcRouterV2)
196+
```
197+
156198
### Module `Manager` and `SimulationManager`
157199
158-
In order to use IBC, we need to add the new modules to the module `Manager` and to the `SimulationManager`, in case your application supports [simulations](https://github.com/cosmos/cosmos-sdk/blob/main/docs/build/building-modules/14-simulator.md).
200+
In order to use IBC, we need to add the new modules to the module `Manager` and to the `SimulationManager`, in case your application supports [simulations](https://docs.cosmos.network/main/learn/advanced/simulation).
159201
160202
```go title="app.go"
161203
import (
@@ -218,13 +260,11 @@ var (
218260
)
219261
```
220262
221-
#### Integrating light clients
222-
223-
> Note that from v9 onwards, all light clients are expected to implement the [`LightClientInterface` interface](../03-light-clients/01-developer-guide/02-light-client-module.md#implementing-the-lightclientmodule-interface) defined by core IBC, and have to be explicitly registered in a chain's app.go. This is in contrast to earlier versions of ibc-go when `07-tendermint` and `06-solomachine` were added out of the box. Follow the steps below to integrate the `07-tendermint` light client.
263+
### Integrating light clients
224264
225-
All light clients must be registered with `module.Manager` in a chain's app.go file.
265+
> Note that from v10 onwards, all light clients are expected to implement the [`LightClientInterface` interface](../03-light-clients/01-developer-guide/02-light-client-module.md#implementing-the-lightclientmodule-interface) defined by core IBC, and have to be explicitly registered in a chain's app.go. This is in contrast to earlier versions of ibc-go when `07-tendermint` and `06-solomachine` were added out of the box. Follow the steps below to integrate the `07-tendermint` light client.
226266
227-
The following code example shows how to instantiate `07-tendermint` light client module and register its `ibctm.AppModule`.
267+
All light clients must be registered with `module.Manager` in a chain's app.go file. The following code example shows how to instantiate `07-tendermint` light client module and register its `ibctm.AppModule`.
228268
229269
```go title="app.go"
230270
import (
@@ -237,11 +277,12 @@ import (
237277

238278
// app.go
239279
// after sealing the IBC router
240-
280+
clientKeeper := app.IBCKeeper.ClientKeeper
241281
storeProvider := app.IBCKeeper.ClientKeeper.GetStoreProvider()
242282

243283
tmLightClientModule := ibctm.NewLightClientModule(appCodec, storeProvider)
244-
app.IBCKeeper.ClientKeeper.AddRoute(ibctm.ModuleName, &tmLightClientModule)
284+
clientKeeper.AddRoute(ibctm.ModuleName, &tmLightClientModule)
285+
// ...
245286
app.ModuleManager = module.NewManager(
246287
// ...
247288
ibc.NewAppModule(app.IBCKeeper),
@@ -253,9 +294,19 @@ app.ModuleManager = module.NewManager(
253294
)
254295
```
255296
297+
#### Allowed Clients Params
298+
299+
The allowed clients parameter defines an allow list of client types supported by the chain. The
300+
default value is a single-element list containing the [`AllowedClients`](https://github.com/cosmos/ibc-go/blob/main/modules/core/02-client/types/client.pb.go#L248-L253) wildcard (`"*"`). Alternatively, the parameter
301+
may be set with a list of client types (e.g. `"06-solomachine","07-tendermint","09-localhost"`).
302+
A client type that is not registered on this list will fail upon creation or on genesis validation.
303+
Note that, since the client type is an arbitrary string, chains must not register two light clients
304+
which return the same value for the `ClientType()` function, otherwise the allow list check can be
305+
bypassed.
306+
256307
### Application ABCI ordering
257308
258-
One addition from IBC is the concept of `HistoricalInfo` which is stored in the Cosmos SDK `x/staking` module. The number of records stored by `x/staking` is controlled by the `HistoricalEntries` parameter which stores `HistoricalInfo` on a per height basis.
309+
One addition from IBC is the concept of `HistoricalInfo` which is stored in the Cosmos SDK `x/staking` module. The number of records stored by `x/staking` is controlled by the `HistoricalEntries` parameter which stores `HistoricalInfo` on a per-height basis.
259310
Each entry contains the historical information for the `Header` and `ValidatorSet` of this chain which is stored
260311
at each height during the `BeginBlock` call. The `HistoricalInfo` is required to introspect a blockchain's prior state at a given height in order to verify the light client `ConsensusState` during the
261312
connection handshake.

0 commit comments

Comments
 (0)