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.
|
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
|
## MVP Specifications
|
||||||
|
|
||||||
### [MVP1](./mvp1.md)
|
### [MVP1](./mvp1.md)
|
||||||
|
@ -18,4 +28,4 @@ Light client verification is added to verify the message from the other chain. R
|
||||||
|
|
||||||
### [MVP4](./mvp4.md)
|
### [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
|
```golang
|
||||||
// User facing API
|
// User facing API
|
||||||
|
|
||||||
type IBCPacket struct {
|
type Packet struct {
|
||||||
DestAddr sdk.Address
|
Data PacketData
|
||||||
Coins sdk.Coins
|
|
||||||
SrcChain string
|
SrcChain string
|
||||||
DestChain string
|
DestChain string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PacketData interface {
|
||||||
|
Type() string
|
||||||
|
ValidateBasic() sdk.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
type TransferPacketData struct {
|
||||||
|
DestAddr sdk.Address
|
||||||
|
Coins sdk.Coins
|
||||||
|
}
|
||||||
|
|
||||||
// Implements sdk.Msg
|
// Implements sdk.Msg
|
||||||
type IBCTransferMsg struct {
|
type IBCTransferMsg struct {
|
||||||
IBCPacket
|
Packet
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements sdk.Msg
|
// Implements sdk.Msg
|
||||||
type IBCReceiveMsg struct {
|
type IBCReceiveMsg struct {
|
||||||
IBCPacket
|
Packet
|
||||||
}
|
}
|
||||||
|
|
||||||
// Internal API
|
// 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
|
func NewHandler(dispatcher Dispatcher, ibcm IBCMapper) sdk.Handler
|
||||||
|
|
||||||
type IBCMapper struct {
|
type IBCMapper struct {
|
||||||
|
|
|
@ -6,31 +6,54 @@
|
||||||
|
|
||||||
### IBC Module
|
### IBC Module
|
||||||
|
|
||||||
|
|
||||||
|
// Implements sdk.Msg
|
||||||
|
type IBCTransferMsg struct {
|
||||||
|
Packet
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implements sdk.Msg
|
||||||
|
type IBCReceiveMsg struct {
|
||||||
|
Packet
|
||||||
|
}
|
||||||
|
|
||||||
|
// Internal API
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
// User facing API
|
// 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 {
|
type Packet struct {
|
||||||
Data PacketData
|
Data PacketData
|
||||||
SrcChain string
|
SrcChain string
|
||||||
DestChain 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 {
|
type RootOfTrust struct {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
@ -49,6 +72,15 @@ type IBCUpdateMsg struct {
|
||||||
|
|
||||||
// Internal API
|
// 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
|
func NewHandler(dispatcher Dispatcher, ibcm IBCMapper) sdk.Handler
|
||||||
|
|
||||||
type IBCMapper struct {
|
type IBCMapper struct {
|
||||||
|
|
Loading…
Reference in New Issue