add term description, packetdata abstraction in 2/3

This commit is contained in:
mossid 2018-03-13 20:22:03 +01:00
parent ac004be491
commit ded9de18cf
3 changed files with 79 additions and 19 deletions

View File

@ -2,6 +2,16 @@
IBC(Inter-Blockchain Communication) protocol is used by multiple zones on Cosmos. Using IBC, the zones can send coins or arbitrary data to other zones.
## Terms
How IBC module treats incoming IBC packets is simillar with how BaseApp treats incoming transactions. Therefore, the components of IBC module have their corresponding pair in BaseApp.
| BaseApp Terms | IBC Terms |
| ------------- | ---------- |
| Router | Dispatcher |
| Tx | Packet |
| Msg | PacketData |
## MVP Specifications
### [MVP1](./mvp1.md)
@ -18,4 +28,4 @@ Light client verification is added to verify the message from the other chain. R
### [MVP4](./mvp4.md)
ACK verification and messaging queue is implemented to make it failsafe. Modules will register callback to handle failure when they register handlers.
ACK verification / timeout handler helper functions and messaging queue are implemented to make it failsafe. Callbacks will be registered to the dispatcher to handle failure when they register handlers.

View File

@ -11,25 +11,43 @@ IBC module will store its own router for handling custom incoming msgs. `IBCPush
```golang
// User facing API
type IBCPacket struct {
type Packet struct {
Data PacketData
SrcChain string
DestChain string
}
type PacketData interface {
Type() string
ValidateBasic() sdk.Error
}
type TransferPacketData struct {
DestAddr sdk.Address
Coins sdk.Coins
SrcChain string
DestChain string
}
// Implements sdk.Msg
type IBCTransferMsg struct {
IBCPacket
Packet
}
// Implements sdk.Msg
type IBCReceiveMsg struct {
IBCPacket
Packet
}
// Internal API
type rule struct {
r string
f func(sdk.Context, IBCPacket) sdk.Result
}
type Dispatcher struct {
rules []rule
}
func NewHandler(dispatcher Dispatcher, ibcm IBCMapper) sdk.Handler
type IBCMapper struct {

View File

@ -6,29 +6,52 @@
### IBC Module
// Implements sdk.Msg
type IBCTransferMsg struct {
Packet
}
// Implements sdk.Msg
type IBCReceiveMsg struct {
Packet
}
// Internal API
```golang
// User facing API
type IBCTransferData struct {
type Packet struct {
Data PacketData
SrcChain string
DestChain string
}
type PacketData interface {
Type() string
ValidateBasic() sdk.Error
}
type TransferPacketData struct {
SrcAddr sdk.Address
DestAddr sdk.Address
Coins sdk.Coins
}
// Implements ibc.PacketData
type IBCPacket struct {
IBCData
// Implements sdk.Msg
type IBCTransferMsg struct {
Packet
}
// Implements ibc.PacketData
type IBCReceivePacket struct {
IBCData
}
type Packet struct {
Data PacketData
SrcChain string
DestChain string
// Implements sdk.Msg
type IBCReceiveMsg struct {
Packet
Proof iavl.Proof
FromChainID string
FromChainHeight uint64
}
type RootOfTrust struct {
@ -49,6 +72,15 @@ type IBCUpdateMsg struct {
// Internal API
type rule struct {
r string
f func(sdk.Context, IBCPacket) sdk.Result
}
type Dispatcher struct {
rules []rule
}
func NewHandler(dispatcher Dispatcher, ibcm IBCMapper) sdk.Handler
type IBCMapper struct {