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

77 lines
1.7 KiB
Markdown
Raw Normal View History

2018-03-13 09:10:26 -07:00
# IBC Spec
2018-03-15 06:54:44 -07:00
*This is a living document and should be edited as the IBC spec and
implementation change*
2018-03-13 09:10:26 -07:00
## MVP1
2018-03-15 06:54:44 -07:00
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.
2018-03-13 09:10:26 -07:00
2018-03-18 05:32:16 -07:00
It is a complete stand-alone module. It includes the commands to send IBC
packets as well as to post them to the destination chain.
2018-03-13 09:10:26 -07:00
### IBC Module
2018-03-15 06:54:44 -07:00
```go
2018-03-13 11:05:27 -07:00
// User facing API
2018-03-13 11:55:38 -07:00
type IBCPacket struct {
2018-03-14 05:11:33 -07:00
SrcAddr sdk.Address
DestAddr sdk.Address
Coins sdk.Coins
SrcChain string
2018-03-13 11:47:02 -07:00
DestChain string
2018-03-13 09:10:26 -07:00
}
// Implements sdk.Msg
2018-03-13 11:05:27 -07:00
type IBCTransferMsg struct {
2018-03-13 11:55:38 -07:00
IBCPacket
2018-03-13 09:10:26 -07:00
}
// Implements sdk.Msg
2018-03-13 11:05:27 -07:00
type IBCReceiveMsg struct {
2018-03-13 11:55:38 -07:00
IBCPacket
2018-03-14 05:11:33 -07:00
Relayer sdk.Address
Sequence int64
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 {
2018-03-13 11:55:38 -07:00
ibcKey sdk.StoreKey // IngressKey / EgressKey => Value
// Ingress: Source Chain ID => last income msg's sequence
// Egress: (Dest chain ID, Msg index) => length / indexed msg
2018-03-13 09:10:26 -07:00
}
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
}
```
2018-03-15 06:54:44 -07:00
`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`.
2018-03-13 09:10:26 -07:00
2018-03-15 06:54:44 -07:00
`ingressKey` stores the latest income `IBCTransfer`'s sequence. It's getter
takes an `IngressKey`.
2018-03-13 09:10:26 -07:00
## 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`