diff --git a/docs/spec/ibc/ibc.md b/docs/spec/ibc/ibc.md index a7f5e8f8e..42fd7639a 100644 --- a/docs/spec/ibc/ibc.md +++ b/docs/spec/ibc/ibc.md @@ -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. diff --git a/docs/spec/ibc/mvp2.md b/docs/spec/ibc/mvp2.md index acfd45e22..a785c3002 100644 --- a/docs/spec/ibc/mvp2.md +++ b/docs/spec/ibc/mvp2.md @@ -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 { diff --git a/docs/spec/ibc/mvp3.md b/docs/spec/ibc/mvp3.md index 1f12b3bfe..87f789bb2 100644 --- a/docs/spec/ibc/mvp3.md +++ b/docs/spec/ibc/mvp3.md @@ -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 {