Skip to content

Commit

Permalink
Merge pull request #815 from cosmos/colin/backport-v3
Browse files Browse the repository at this point in the history
chore: rebase v3 release branch onto main
  • Loading branch information
colin-axner authored Jan 31, 2022
2 parents 22fbe82 + a536701 commit d3b0a36
Show file tree
Hide file tree
Showing 259 changed files with 4,867 additions and 16,578 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+-?[a-z0-9]*' # Push events to matching v*, i.e. v1.0.0, v20.15.10, v3.0.0-alpha1

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.4.0
with:
fetch-depth: 0

- uses: actions/setup-go@v2
with:
go-version: '1.17'

- name: Release
uses: goreleaser/goreleaser-action@v2
if: startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- uses: actions/setup-go@v2.1.5
with:
go-version: 1.17
- uses: technote-space/get-diff-action@v5
- uses: technote-space/get-diff-action@v6.0.1
id: git_diff
with:
PATTERNS: |
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
- uses: actions/setup-go@v2.1.5
with:
go-version: 1.17
- uses: technote-space/get-diff-action@v5
- uses: technote-space/get-diff-action@v6.0.1
with:
PATTERNS: |
**/**.go
Expand All @@ -113,7 +113,7 @@ jobs:
needs: tests
steps:
- uses: actions/checkout@v2.4.0
- uses: technote-space/get-diff-action@v5
- uses: technote-space/get-diff-action@v6.0.1
with:
PATTERNS: |
**/**.go
Expand Down
35 changes: 35 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
before:
hooks:
- go mod tidy

builds:
- main: ./testing/simapp/simd/main.go
binary: simd
flags:
- -tags=netgo ledger
- -mod=readonly
ldflags:
- -s -w -X github.com/cosmos/cosmos-sdk/version.Name=sim -X github.com/cosmos/cosmos-sdk/version.AppName=simd -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}} -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger"
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
# for goarch use defaults: 386, amd64 and arm64.

checksum:
name_template: SHA256SUMS-{{.Version}}.txt
algorithm: sha256

release:
mode: keep-existing

archives:
- name_template: "{{ .ProjectName }}_simd_v{{ .Version }}_{{ .Os }}_{{ .Arch }}"
files:
- LICENSE
- README.md
- RELEASES.md
- SECURITY.md
- CHANGELOG.md
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,33 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Dependencies

* [\#404](https://github.com/cosmos/ibc-go/pull/404) Bump Go version to 1.17
* (core) [\#709](https://github.com/cosmos/ibc-go/pull/709) Replace github.com/pkg/errors with stdlib errors

### API Breaking

* (testing( [\#813](https://github.com/cosmos/ibc-go/pull/813) The `ack` argument to the testing function `RelayPacket` has been removed as it is no longer needed.
* (testing) [\#774](https://github.com/cosmos/ibc-go/pull/774) Added `ChainID` arg to `SetupWithGenesisValSet` on the testing app. `Coordinator` generated ChainIDs now starts at index 1
* (transfer) [\#675](https://github.com/cosmos/ibc-go/pull/675) Transfer `NewKeeper` now takes in an ICS4Wrapper. The ICS4Wrapper may be the IBC Channel Keeper when ICS20 is not used in a middleware stack. The ICS4Wrapper is required for applications wishing to connect middleware to ICS20.
* (core) [\#650](https://github.com/cosmos/ibc-go/pull/650) Modify `OnChanOpenTry` IBC application module callback to return the negotiated app version. The version passed into the `MsgChanOpenTry` has been deprecated and will be ignored by core IBC.
* (core) [\#629](https://github.com/cosmos/ibc-go/pull/629) Removes the `GetProofSpecs` from the ClientState interface. This function was previously unused by core IBC.
* (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.
* (testing) [\#776](https://github.com/cosmos/ibc-go/pull/776) Adding helper fn to generate capability name for testing callbacks


### State Machine Breaking

### Improvements

* (testing) [\#810](https://github.com/cosmos/ibc-go/pull/810) Additional testing function added to `Endpoint` type called `RecvPacketWithResult`. Performs the same functionality as the existing `RecvPacket` function but also returns the message result. `path.RelayPacket` no longer uses the provided acknowledgement argument and instead obtains the acknowledgement via MsgRecvPacket events.
* (connection) [\#721](https://github.com/cosmos/ibc-go/pull/721) Simplify connection handshake error messages when unpacking client state.
* (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.
* (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.

### Features

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 COSMOS
Copyright (c) 2022 COSMOS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ build-docs:
cp ~/output/$${path_prefix}/index.html ~/output ; \
done < versions ;

view-docs:
@cd docs && \
npm install && npm run serve

.PHONY: build-docs

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

2.1 [ICS 20 Fungible Token Transfers](https://github.com/cosmos/ibc-go/tree/main/modules/apps/transfer)

2.2 [ICS 27 Interchain Accounts](https://github.com/cosmos/ibc-go/tree/main/modules/apps/27-interchain-accounts)

3. **Light Clients**

3.1 [ICS 07 Tendermint](https://github.com/cosmos/ibc-go/tree/main/modules/light-clients/07-tendermint)
Expand Down
31 changes: 28 additions & 3 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,42 @@ module.exports = {
{
title: "Interchain Accounts",
directory: true,
path: "/app_modules",
path: "/app-modules",
children: [
{
title: "Overview",
directory: false,
path: "/app_modules/interchain-accounts/overview.html"
path: "/app-modules/interchain-accounts/overview.html"
},
{
title: "Authentication Modules",
directory: false,
path: "/app-modules/interchain-accounts/auth-modules.html"
},
{
title: "Active Channels",
directory: false,
path: "/app-modules/interchain-accounts/active-channels.html"
},
{
title: "Integration",
directory: false,
path: "/app_modules/interchain-accounts/integration.html"
path: "/app-modules/interchain-accounts/integration.html"
},
{
title: "Parameters",
directory: false,
path: "/app-modules/interchain-accounts/parameters.html"
},
{
title: "Transactions",
directory: false,
path: "/app-modules/interchain-accounts/transactions.html"
},
{
title: "Authentication module development",
directory: false,
path: "/app_modules/interchain-accounts/ica_auth.html"
},
]
},
Expand Down
25 changes: 25 additions & 0 deletions docs/app-modules/interchain-accounts/active-channels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
order: 3
-->

# Understanding Active Channels

The Interchain Accounts module uses [ORDERED channels](https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#ordering) to maintain the order of transactions when sending packets from a controller to a host chain. A limitation when using ORDERED channels is that when a packet times out the channel will be closed.

In the case of a channel closing, a controller chain needs to be able to regain access to the interchain account registered on this channel. `Active Channels` enable this functionality. Future versions of the ICS-27 protocol and the Interchain Accounts module will likely use a new
channel type that provides ordering of packets without the channel closing on timing out, thus removing the need for `Active Channels` entirely.

When an Interchain Account is registered using the `RegisterInterchainAccount` API, a new channel is created on a particular port. During the `OnChanOpenAck` and `OnChanOpenConfirm` steps (controller & host chain) the `Active Channel` for this interchain account
is stored in state.

It is possible to create a new channel using the same controller chain portID if the previously set `Active Channel` is now in a `CLOSED` state. This channel creation can be initialized programatically by sending a new `OnChanOpenInit` message like so:

```go
msg := channeltypes.NewMsgChannelOpenInit(portID, string(versionBytes), channeltypes.ORDERED, []string{connectionID}, icatypes.PortID, icatypes.ModuleName)
handler := k.msgRouter.Handler(msg)
```

Alternatively, any relayer operator may initiate a new channel handshake for this interchain account once the previously set `Active Channel` is in a `CLOSED` state. This is done by initiating the channel handshake on the controller chain using the same portID associated with the interchain account in question.

It is important to note that once a channel has been opened for a given Interchain Account, new channels can not be opened for this account until the currently set `Active Channel` is set to `CLOSED`.

Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<!--
order: 3
order: 2
-->

# Building an ICA authentication module
# Building an authentication module

The controller module is used for account registration and packet sending.
Authentication modules play the role of the `Base Application` as described in [ICS30 IBC Middleware](https://github.com/cosmos/ibc/tree/master/spec/app/ics-030-middleware), and enable application developers to perform custom logic when working with the Interchain Accounts controller API. {synopsis}

The controller submodule is used for account registration and packet sending.
It executes only logic required of all controllers of interchain accounts.
The type of authentication used to manage the interchain accounts remains unspecified.
There may exist many different types of authentication which are desirable for different use cases.
Expand Down Expand Up @@ -108,9 +110,8 @@ func (im IBCModule) OnChanOpenTry(
channelID string,
chanCap *capabilitytypes.Capability,
counterparty channeltypes.Counterparty,
version,
counterpartyVersion string,
) error {
) (string, error) {
panic("UNIMPLEMENTED")
}

Expand Down Expand Up @@ -142,53 +143,40 @@ func (im IBCModule) OnRecvPacket(
) ibcexported.Acknowledgement {
panic("UNIMPLEMENTED")
}

// NegotiateAppVersion implements the IBCModule interface
func (im IBCModule) NegotiateAppVersion(
ctx sdk.Context,
order channeltypes.Order,
connectionID string,
portID string,
counterparty channeltypes.Counterparty,
proposedVersion string,
) (string, error) {
panic("UNIMPLEMENTED")
}
```

## `InitInterchainAccount`
## `RegisterInterchainAccount`

The authentication module can begin registering interchain accounts by calling `InitInterchainAccount`:
The authentication module can begin registering interchain accounts by calling `RegisterInterchainAccount`:

```go
if err := keeper.icaControllerKeeper.InitInterchainAccount(ctx, connectionID, counterpartyConnectionID, owner.String()); err != nil {
if err := keeper.icaControllerKeeper.RegisterInterchainAccount(ctx, connectionID, owner.String()); err != nil {
return err
}

return nil
```

## `TrySendTx`
## `SendTx`

The authentication module can attempt to send a packet by calling `TrySendTx`:
The authentication module can attempt to send a packet by calling `SendTx`:
```go

// Authenticate owner
// perform custom logic

// Lookup portID based on interchain account owner address
portID, err := icatypes.GeneratePortID(owner.String(), connectionID, counterpartyConnectionID)
// Construct controller portID based on interchain account owner address
portID, err := icatypes.NewControllerPortID(owner.String())
if err != nil {
return err
}

channelID, found := keeper.icaControllerKeeper.GetActiveChannelID(ctx, portID)
if !found {
return sdkerrors.Wrapf(icatypes.ErrActiveChannelNotFound, "failed to retrieve active channel for port %s", portId)
return sdkerrors.Wrapf(icatypes.ErrActiveChannelNotFound, "failed to retrieve active channel for port %s", portID)
}

// Obtain the channel capability.
// The channel capability should have been claimed by the authentication module in OnChanOpenInit
// Obtain the channel capability, claimed in OnChanOpenInit
chanCap, found := keeper.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(portID, channelID))
if !found {
return sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability")
Expand All @@ -210,7 +198,13 @@ packetData := icatypes.InterchainAccountPacketData{
Data: data,
}

_, err = keeper.icaControllerKeeper.TrySendTx(ctx, chanCap, p, packetData)
// Obtain timeout timestamp
// An appropriate timeout timestamp must be determined based on the usage of the interchain account.
// If the packet times out, the channel will be closed requiring a new channel to be created
timeoutTimestamp := obtainTimeoutTimestamp()

// Send the interchain accounts packet, returning the packet sequence
seq, err = keeper.icaControllerKeeper.SendTx(ctx, chanCap, portID, packetData, timeoutTimestamp)
```

The data within an `InterchainAccountPacketData` must be serialized using a format supported by the host chain.
Expand Down
Loading

0 comments on commit d3b0a36

Please sign in to comment.