cosmos-sdk/docs/spec/ibc/mvp1.md

62 lines
1.4 KiB
Markdown
Raw Normal View History

2018-03-13 09:10:26 -07:00
# IBC Spec
*This is a living document and should be edited as the IBC spec and implementation change*
## MVP1
The initial implementation of IBC will include just enough for simple coin transfers between chains, with safety features such as ACK messages being added later.
### IBC Module
```golang
2018-03-13 11:05:27 -07:00
// User facing API
type IBCTransferPacket struct {
DestAddr sdk.Address
Coins sdk.Coins
2018-03-13 09:10:26 -07:00
}
2018-03-13 11:05:27 -07:00
type IBCTransferMsg struct {
IBCTransferPacket
DestChain string
2018-03-13 09:10:26 -07:00
}
2018-03-13 11:05:27 -07:00
type IBCReceiveMsg struct {
IBCTransferPacket
SrcChain string
2018-03-13 09:10:26 -07:00
}
2018-03-13 11:05:27 -07:00
// Internal API
2018-03-13 09:10:26 -07:00
type IBCMapper struct {
ingressKey sdk.StoreKey // Source Chain ID => last income msg's sequence
egressKey sdk.StoreKey // (Dest chain ID, Msg index) => length / indexed msg
}
type IngressKey struct {
2018-03-13 11:05:27 -07:00
SrcChain string
2018-03-13 09:10:26 -07:00
}
type EgressKey struct {
DestChain string
Index int64
}
```
`egressKey` stores the outgoing `IBCTransfer`s as a list. Its getter takes an `EgressKey` and returns the length if `egressKey.Index == -1`, an element if `egressKey.Index > 0`.
`ingressKey` stores the last income `IBCTransfer`'s sequence. Its getter takes an `IngressKey`.
## Relayer
**Packets**
- Connect to 2 Tendermint RPC endpoints
- Query for IBC outgoing `IBCOutMsg` queue (can poll on a certain time interval, or check after each new block, etc)
- For any new `IBCOutMsg`, build `IBCInMsg` and post to destination chain
## CLI
- Load relay process
- Execute `IBCOutMsg`