add term description, packetdata abstraction in 2/3
This commit is contained in:
parent
ac004be491
commit
ded9de18cf
|
@ -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.
|
||||
|
|
|
@ -11,25 +11,43 @@ IBC module will store its own router for handling custom incoming msgs. `IBCPush
|
|||
```golang
|
||||
// User facing API
|
||||
|
||||
type IBCPacket struct {
|
||||
DestAddr sdk.Address
|
||||
Coins sdk.Coins
|
||||
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
|
||||
}
|
||||
|
||||
// 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 {
|
||||
|
|
|
@ -6,31 +6,54 @@
|
|||
|
||||
### 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 {
|
||||
SrcAddr sdk.Address
|
||||
DestAddr sdk.Address
|
||||
Coins sdk.Coins
|
||||
}
|
||||
|
||||
// Implements ibc.PacketData
|
||||
type IBCPacket struct {
|
||||
IBCData
|
||||
}
|
||||
|
||||
// Implements ibc.PacketData
|
||||
type IBCReceivePacket struct {
|
||||
IBCData
|
||||
}
|
||||
|
||||
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 sdk.Msg
|
||||
type IBCTransferMsg struct {
|
||||
Packet
|
||||
}
|
||||
|
||||
// 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 {
|
||||
|
|
Loading…
Reference in New Issue