Documentation ¶
Index ¶
- Constants
- Variables
- func AllowIBC(app string) sdk.Actor
- func ChainKey(chainID string) []byte
- func ChainsKey() []byte
- func ErrAlreadyRegistered(chainID string) error
- func ErrCannotSetPermission() error
- func ErrHeaderNotFound(h int64) error
- func ErrInvalidCommit(err error) error
- func ErrInvalidProof() error
- func ErrInvalidProofWithReason(err error) error
- func ErrNeedsIBCPermission() error
- func ErrNotRegistered(chainID string) error
- func ErrPacketAlreadyExists() error
- func ErrPacketOutOfOrder(seq int64) error
- func ErrWrongDestChain(chainID string) error
- func HandlerKey() []byte
- func InputQueue(store state.SimpleDB, chainID string) *state.Queue
- func IsAlreadyRegisteredErr(err error) bool
- func IsCannotSetPermissionErr(err error) bool
- func IsHeaderNotFoundErr(err error) bool
- func IsInvalidCommitErr(err error) bool
- func IsInvalidProofErr(err error) bool
- func IsNeedsIBCPermissionErr(err error) bool
- func IsNotRegisteredErr(err error) bool
- func IsPacketAlreadyExistsErr(err error) bool
- func IsPacketOutOfOrderErr(err error) bool
- func IsWrongDestChainErr(err error) bool
- func NewMissingProvider() lite.Provider
- func OutputQueue(store state.SimpleDB, chainID string) *state.Queue
- func QueueInKey(chainID string) []byte
- func QueueInPacketKey(chainID string, seq int64) []byte
- func QueueOutKey(chainID string) []byte
- func QueueOutPacketKey(chainID string, seq int64) []byte
- type AppChain
- func (a *AppChain) DeliverTx(tx sdk.Tx, perms ...sdk.Actor) (sdk.DeliverResult, error)
- func (a *AppChain) GetStore(app string) state.SimpleDB
- func (a *AppChain) IncrementHeight(delta int64) int64
- func (a *AppChain) InitState(mod, key, value string) (string, error)
- func (a *AppChain) Update(tx UpdateChainTx) error
- type ChainInfo
- type ChainSet
- type CreatePacketTx
- type Handler
- func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error)
- func (h Handler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error)
- func (h Handler) InitState(l log.Logger, store state.SimpleDB, module, key, value string) (log string, err error)
- func (Handler) Name() string
- type HandlerInfo
- type Middleware
- type MockChain
- type Packet
- type PostPacketTx
- type RegisterChainTx
- type UpdateChainTx
Constants ¶
const ( // NameIBC is the name of this module NameIBC = "ibc" // OptionRegistrar is the option name to set the actor // to handle ibc chain registration OptionRegistrar = "registrar" )
const ( // 0x3? series for ibc ByteRegisterChain = byte(0x30) ByteUpdateChain = byte(0x31) ByteCreatePacket = byte(0x32) BytePostPacket = byte(0x33) TypeRegisterChain = NameIBC + "/register" TypeUpdateChain = NameIBC + "/update" TypeCreatePacket = NameIBC + "/create" TypePostPacket = NameIBC + "/post" )
nolint
Variables ¶
var ( IBCCodeChainNotRegistered = uint32(1001) IBCCodeChainAlreadyExists = uint32(1002) IBCCodeUnknownChain = uint32(1003) IBCCodeInvalidPacketSequence = uint32(1004) IBCCodeUnknownHeight = uint32(1005) IBCCodeInvalidCommit = uint32(1006) IBCCodeInvalidProof = uint32(1007) IBCCodeInvalidCall = uint32(1008) )
nolint
Functions ¶
func AllowIBC ¶
AllowIBC returns a specially crafted Actor that enables sending IBC packets for this app type
func ErrAlreadyRegistered ¶
func ErrCannotSetPermission ¶
func ErrCannotSetPermission() error
func ErrHeaderNotFound ¶
func ErrInvalidCommit ¶
func ErrInvalidProof ¶
func ErrInvalidProof() error
func ErrNeedsIBCPermission ¶
func ErrNeedsIBCPermission() error
func ErrNotRegistered ¶
func ErrPacketAlreadyExists ¶
func ErrPacketAlreadyExists() error
func ErrPacketOutOfOrder ¶
func ErrWrongDestChain ¶
func InputQueue ¶
InputQueue returns the queue of input packets from this chain
func IsAlreadyRegisteredErr ¶
func IsHeaderNotFoundErr ¶
func IsInvalidCommitErr ¶
func IsInvalidProofErr ¶
func IsNeedsIBCPermissionErr ¶
func IsNotRegisteredErr ¶
func IsPacketOutOfOrderErr ¶
func IsWrongDestChainErr ¶
func NewMissingProvider ¶ added in v0.8.0
NewMissingProvider returns a provider which does not store anything and always misses.
func OutputQueue ¶
OutputQueue returns the queue of output packets destined for this chain
func QueueInKey ¶
QueueInKey is the key to get newest of the input queue from this chain
func QueueInPacketKey ¶
QueueInPacketKey is the key to get given packet from this chain's input queue
func QueueOutKey ¶
QueueOutKey is the key to get v of the output queue from this chain
func QueueOutPacketKey ¶
QueueOutPacketKey is the key to get given packet from this chain's output queue
Types ¶
type AppChain ¶
type AppChain struct {
// contains filtered or unexported fields
}
AppChain is ready to handle tx
func NewAppChain ¶
NewAppChain returns a chain that is ready to respond to tx
func (*AppChain) DeliverTx ¶
DeliverTx runs the tx and commits the new tree, incrementing height by one.
func (*AppChain) IncrementHeight ¶
IncrementHeight allows us to jump heights, more than the auto-step of 1. It returns the new height we are at.
func (*AppChain) Update ¶
func (a *AppChain) Update(tx UpdateChainTx) error
Update is a shortcut to DeliverTx with this. Also one return value to test inline
type ChainInfo ¶
type ChainInfo struct { RegisteredAt int64 `json:"registered_at"` RemoteBlock int64 `json:"remote_block"` }
ChainInfo is the global info we store for each registered chain, besides the headers, proofs, and packets
type ChainSet ¶
ChainSet is the set of all registered chains
func NewChainSet ¶
NewChainSet loads or initialized the ChainSet
type CreatePacketTx ¶
type CreatePacketTx struct { DestChain string `json:"dest_chain"` Permissions sdk.Actors `json:"permissions"` Tx sdk.Tx `json:"tx"` }
CreatePacketTx is meant to be called by IPC, another module...
this is the tx that will be sent to another app and the permissions it comes with (which must be a subset of the permissions on the current tx)
If must have the special `AllowIBC` permission from the app that can send this packet (so only coins can request SendTx packet)
func (CreatePacketTx) ValidateBasic ¶
func (p CreatePacketTx) ValidateBasic() error
ValidateBasic makes sure this is consistent - used to satisfy TxInner
type Handler ¶
type Handler struct {
sdk.NopInitValidate
}
Handler updates the chain state or creates an ibc packet
func NewHandler ¶
func NewHandler() Handler
NewHandler returns a Handler that allows all chains to connect via IBC. Set a Registrar via InitState to restrict it.
func (Handler) CheckTx ¶
func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error)
CheckTx verifies the packet is formated correctly, and has the proper sequence for a registered chain
func (Handler) DeliverTx ¶
func (h Handler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error)
DeliverTx verifies all signatures on the tx and updates the chain state apropriately
type HandlerInfo ¶
HandlerInfo is the global state of the ibc.Handler
func LoadInfo ¶
func LoadInfo(store state.SimpleDB) (h HandlerInfo)
LoadInfo loads the HandlerInfo from the data store
func (HandlerInfo) Save ¶
func (h HandlerInfo) Save(store state.SimpleDB)
Save the HandlerInfo to the store
type Middleware ¶
type Middleware struct { stack.PassInitState stack.PassInitValidate }
Middleware allows us to verify the IBC proof on a packet and and if valid, attach this permission to the wrapped packet
func NewMiddleware ¶
func NewMiddleware() Middleware
NewMiddleware creates a role-checking middleware
func (Middleware) CheckTx ¶
func (m Middleware) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error)
CheckTx verifies the named chain and height is present, and verifies the merkle proof in the packet
type MockChain ¶
type MockChain struct {
// contains filtered or unexported fields
}
MockChain is used to simulate a chain for ibc tests. It is able to produce ibc packets and all verification for them, but cannot respond to any responses.
func NewMockChain ¶
NewMockChain initializes a teststore and test validators
func (MockChain) GetRegistrationTx ¶
func (m MockChain) GetRegistrationTx(h int64) RegisterChainTx
GetRegistrationTx returns a valid tx to register this chain
func (MockChain) MakePostPacket ¶
func (m MockChain) MakePostPacket(packet Packet, h int64) ( PostPacketTx, UpdateChainTx)
MakePostPacket commits the packet locally and returns the proof, in the form of two packets to update the header and prove this packet.
type Packet ¶
type Packet struct { DestChain string `json:"dest_chain"` Sequence int64 `json:"sequence"` Permissions sdk.Actors `json:"permissions"` Tx sdk.Tx `json:"tx"` }
Packet is a wrapped transaction and permission that we want to send off to another chain.
type PostPacketTx ¶
type PostPacketTx struct { // The immediate source of the packet, not always Packet.SrcChainID FromChainID string `json:"src_chain"` // The block height in which Packet was committed, to check Proof // AppHash for the proof in header for FromChainHeight+1 FromChainHeight int64 `json:"src_height"` // this proof must match the header and the packet.Bytes() Proof *iavl.KeyExistsProof `json:"proof"` Key data.Bytes `json:"key"` Packet Packet `json:"packet"` }
PostPacketTx takes a wrapped packet from another chain and TODO!!! also think... which chains can relay packets??? right now, enforce that these packets are only sent directly, not routed over the hub. add routing later.
func (PostPacketTx) ValidateBasic ¶
func (p PostPacketTx) ValidateBasic() error
ValidateBasic makes sure this is consistent - used to satisfy TxInner
type RegisterChainTx ¶
type RegisterChainTx struct {
Commit lite.FullCommit `json:"seed"`
}
RegisterChainTx allows you to register a new chain on this blockchain
func (RegisterChainTx) ChainID ¶
func (r RegisterChainTx) ChainID() string
ChainID helps get the chain this tx refers to
func (RegisterChainTx) ValidateBasic ¶
func (r RegisterChainTx) ValidateBasic() error
ValidateBasic makes sure this is consistent, without checking the sigs
type UpdateChainTx ¶
type UpdateChainTx struct {
Commit lite.FullCommit `json:"seed"`
}
UpdateChainTx updates the state of this chain
func (UpdateChainTx) ChainID ¶
func (u UpdateChainTx) ChainID() string
ChainID helps get the chain this tx refers to
func (UpdateChainTx) ValidateBasic ¶
func (u UpdateChainTx) ValidateBasic() error
ValidateBasic makes sure this is consistent, without checking the sigs