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

ICS-27-v2 #1122

Draft
wants to merge 33 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
98904c2
set base file
sangier Jun 12, 2024
e8551dc
base skeleton
sangier Jun 14, 2024
7881e4f
wip ica-registration
sangier Jun 17, 2024
40ad2e2
SendTx, RegisterInterchainAccount-host-controller
sangier Jun 18, 2024
22342ac
refactor
sangier Jun 21, 2024
7f7f0d0
wip onRecv
sangier Jun 21, 2024
467e04f
checkpoint
sangier Jun 25, 2024
03fdbb3
skeleton refactor
sangier Jun 28, 2024
704de98
register flow
sangier Jul 1, 2024
072ec67
fixes register flow
sangier Jul 2, 2024
fe079dc
restructure + fixes
sangier Jul 3, 2024
2c2eb11
fixes
sangier Jul 3, 2024
63bf1ec
add register and controlling flow in words
sangier Jul 4, 2024
2a285f7
minor fixes
sangier Jul 4, 2024
607912a
function signature fixes
sangier Jul 4, 2024
7ed54fb
fixes
sangier Jul 4, 2024
8929479
fix markdown lists
sangier Jul 4, 2024
bf944b3
fix markdown
sangier Jul 4, 2024
0044c9d
fixes
sangier Jul 4, 2024
8236aa4
Moved README.md from ics-027-interchain-accounts to ics-027-interchai…
sangier Jul 4, 2024
4429420
adding v2 readme file into new folder structure
sangier Jul 4, 2024
cc9a816
del old folder structure
sangier Jul 4, 2024
e9ce56f
mod history
sangier Jul 4, 2024
b4fc551
grammar fixes
sangier Jul 8, 2024
3e1b64b
add host chain blacklist support
sangier Jul 8, 2024
33a5b5f
started encoding
sangier Jul 8, 2024
1938b46
split chan lifecycle for controller and host
sangier Jul 9, 2024
1ef9d4d
minor fixes
sangier Jul 10, 2024
5e7b576
fix channel management
sangier Jul 10, 2024
d7a171e
add v1-v2 differences summary - fix links
sangier Jul 10, 2024
d39222a
fix v1 links
sangier Jul 10, 2024
435cbb9
fix timeoutTimestamp
sangier Jul 10, 2024
73030d4
add test mermaid diagram
sangier Jul 10, 2024
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
Prev Previous commit
Next Next commit
started encoding
sangier committed Jul 8, 2024
commit 33a5b5f228f106c096d51a44971cae8a4ab82902
63 changes: 45 additions & 18 deletions spec/app/ics-027-interchain-accounts/README.md
Original file line number Diff line number Diff line change
@@ -138,10 +138,25 @@ interface icaExecutePacketSuccess {
}
```

#### **Metadata negotiation**

The ICS-04 allows for each channel version negotiation to be application-specific. ICS-27 takes advantage of [ICS-04 channel version negotiation](../../core/ics-004-channel-and-packet-semantics/README.md#versioning) to negotiate metadata and channel parameters during the channel handshake. In the case of interchain accounts, the channel version will be a string of a JSON struct containing all the relevant metadata intended to be relayed to the counterparty during the channel handshake steps. The metadata used for the ICS-27 version 2 will contain the encoding format along with the channel version itself.

```typescript
version: {
"Version": "ica", // channel version
"Encoding": "requested_encoding_type", // Json, protobuf..
}
```

// Note. For now, may be ok like this, but eventually, we can make the encoding a channelEnd native parameter.

### Sub-protocols

#### Routing module callbacks

// TODO Need to split for controlling and hosting. We may enforce that only controlling can init. This is how is done in ics27v1

The routing module callbacks associated with the channel management are at the base of the interchain account protocol. Any of the chains (controlling or hosting) can start a channel creation handshake.

##### Channel lifecycle management
@@ -163,17 +178,24 @@ function onChanOpenInit(
version: string) => (version: string, err: Error) {
// only unordered channels allowed
abortTransactionUnless(order === UNORDERED)
// assert that version is "ica" or ""
// if empty, we return the default transfer version to core IBC
// as the version for this channel
abortTransactionUnless(version === "ica" || version === "")

if version == "" {
// default to latest supported version
return "ica", nil
metadata = {
Version: "ica",
Encoding: DefaultEncoding, //decide default econding
}
version = marshalJSON(metadata)
return version, nil
} else{
// If the version is not empty and is among those supported, we return the version
metadata = UnmarshalJSON(version)
// assert that version is "ica"
abortTransactionUnless(matadata.Version === "ica")
// assert the choosed encoding is supported.
abortTransactionUnless(IsSupportedEncoding(metadata.Encoding))
return version, nil
}
// If the version is not empty and is among those supported, we return the version
return version, nil
}
```

@@ -187,9 +209,12 @@ function onChanOpenTry(
counterpartyVersion: string) => (version: string, err: Error) {
// only unordered channels allowed
abortTransactionUnless(order === UNORDERED)
// assert that version is "ica" or "ica-2"
abortTransactionUnless(counterpartyVersion === "ica")

// unmarshal version
metadata = UnmarshalJSON(counterpartyVersion)
// assert that version is "ica"
abortTransactionUnless(matadata.Version === "ica")
// assert the choosed encoding is supported.
abortTransactionUnless(IsSupportedEncoding(metadata.Encoding))
// return the same version as counterparty version so long as we support it
return counterpartyVersion, nil
}
@@ -396,7 +421,7 @@ function registerInterchainAccount(

##### Packet relay

`sendRegisterTx` and `sendExecuteTx` must be called by a transaction handler in the controller chain module which performs appropriate signature checks. In particular, the transaction handlers must verify that `icaOwnerAddress` is the actual signer of the tx.
`sendRegisterTx` and `sendExecuteTx` must be called by a transaction handler in the controller chain module which performs appropriate signature checks. In particular, the transaction handlers must verify that the `icaOwnerAddress` is the actual signer of the TX.

//TODO CLARIFY WAY BETTER THE CONCEPT // May be in a different section
Thinking about a smart contract system, then the system should verify that the tx the user generates to call the `sendRegisterTx` and `sendExecuteTx` contract function has been signed by the `icaOwnerAddress`.
@@ -578,13 +603,11 @@ function setup() {

The interchain account module on the host chain must track the `hostAccounts` and should track the blacklist of msgs associated with a particular controller account in the state. Fields of the `ModuleState` are assumed to be in scope.

// Should be the blacklist icaOwnerAccounts specific?

```typescript
interface ModuleState {
hostAccounts: Map<portId, Map <channelId, Map <icaOwnerAddress, Map<hostAccountId, hostAccount>>>>,
// Generic msg blacklist. It can be icaOwnerAddress specific, or only portId,channelId specific.
msgBlackList: Map<portId, Map <channelId, Map <icaOwnerAddress, set(msg)>>>,
msgBlacklist: Map<portId, Map <channelId, Map <icaOwnerAddress, set(msg)>>>,

}
```
@@ -594,9 +617,7 @@ interface ModuleState {
```typescript
// Stores the address of the interchain account in state.
function setInterchainAccountAddress(portId: string, channelId: string, icaOwnerAccount: string, hostAccountId: uint64) : string {

// Generate new address
// newAddress MUST generate deterministically the host account address
// While the setInterchainAccountAddress of the controller chain only stores the passed in addresses, in the hosting subprotocol this function has to generate new addresses deterministically based on the passed-in parameters and then store it in the module state in the hostAccounts map.
address=newAddress(portId,channelId, icaOwnerAccount, seq)
// Set in the host chain module state the generated address
hostAccounts[portId][channelId][icaOwnerAccount][hostAccountId].hostAccountAddress=address
@@ -905,9 +926,15 @@ In the case the controller chain wants to know the host account balance after ce

Since we are allowing only unordered channels and disallowing channel closure procedures, we don't need a procedure for recovering. The channel cannot be closed or get stuck.

### MsgBlacklist

// TODO
Should be the blacklist icaOwnerAccounts specific?
What happens if controller chain registers and funds a hostAccount and then the host chain blacklist the transfers? Are funds lost?

## Example Implementations

- Implementation of ICS 27 version 1 in Go can be found in [ibc-go repository](https://github.com/cosmos/ibc-go).
- Implementation of ICS 27 version 1 in Go can be found in the [ibc-go repository](https://github.com/cosmos/ibc-go).

- Implementation of ICS 27 version 2 in Go COMING SOON.