Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

types source pure

Constants 5

const EventTypeCreateClient, EventTypeUpdateClient, EventTypeUpgradeClient, EventTypeSubmitMisbehaviour, EventTypeRecoverClient, EventTypeScheduleIBCSoftwareUpgrade, EventTypeUpgradeChain, AttributeKeyClientID, AttributeKeySubjectClientID, AttributeKeySubstituteClientID, AttributeKeyClientType, AttributeKeyConsensusHeights, AttributeKeyConsensusHeight, AttributeKeyUpgradeStore, AttributeKeyUpgradePlanHeight, AttributeKeyUpgradePlanTitle

 1const (
 2	EventTypeCreateClient               = "create_client"
 3	EventTypeUpdateClient               = "update_client"
 4	EventTypeUpgradeClient              = "upgrade_client"
 5	EventTypeSubmitMisbehaviour         = "client_misbehaviour"
 6	EventTypeRecoverClient              = "recover_client"
 7	EventTypeScheduleIBCSoftwareUpgrade = "schedule_ibc_software_upgrade"
 8	EventTypeUpgradeChain               = "upgrade_chain"
 9
10	AttributeKeyClientID           = "client_id"
11	AttributeKeySubjectClientID    = "subject_client_id"
12	AttributeKeySubstituteClientID = "substitute_client_id"
13	AttributeKeyClientType         = "client_type"
14	AttributeKeyConsensusHeights   = "consensus_heights"
15	AttributeKeyConsensusHeight    = "consensus_height"
16	AttributeKeyUpgradeStore       = "upgrade_store"
17	AttributeKeyUpgradePlanHeight  = "upgrade_plan_height"
18	AttributeKeyUpgradePlanTitle   = "title"
19)
source

IBC client events

const EventTypeSendPacket, EventTypeRecvPacket, EventTypeTimeoutPacket, EventTypeAcknowledgePacket, EventTypeWriteAck, AttributeKeySrcClient, AttributeKeyDstClient, AttributeKeySequence, AttributeKeyTimeoutTimestamp, AttributeKeyEncodedPacketHex, AttributeKeyEncodedAckHex

 1const (
 2	EventTypeSendPacket        = "send_packet"
 3	EventTypeRecvPacket        = "recv_packet"
 4	EventTypeTimeoutPacket     = "timeout_packet"
 5	EventTypeAcknowledgePacket = "acknowledge_packet"
 6	EventTypeWriteAck          = "write_acknowledgement"
 7
 8	AttributeKeySrcClient        = "packet_source_client"
 9	AttributeKeyDstClient        = "packet_dest_client"
10	AttributeKeySequence         = "packet_sequence"
11	AttributeKeyTimeoutTimestamp = "packet_timeout_timestamp"
12	AttributeKeyEncodedPacketHex = "encoded_packet_hex"
13	AttributeKeyEncodedAckHex    = "encoded_acknowledgement_hex"
14)
source

IBC core events

const MaximumPayloadsSize

1const MaximumPayloadsSize = 262144 // 256 KiB. This is the maximum size of all payloads combined
source

const PacketStatus_NONE, PacketStatus_Success, PacketStatus_Failure, PacketStatus_Async

 1const (
 2	// PACKET_STATUS_UNSPECIFIED indicates an unknown packet status.
 3	PacketStatus_NONE PacketStatus = 0
 4	// PACKET_STATUS_SUCCESS indicates a successful packet receipt.
 5	PacketStatus_Success PacketStatus = 1
 6	// PACKET_STATUS_FAILURE indicates a failed packet receipt.
 7	PacketStatus_Failure PacketStatus = 2
 8	// PACKET_STATUS_ASYNC indicates that the packet was received and its
 9	// acknowledgement will be written later by the application.
10	PacketStatus_Async PacketStatus = 3
11)
source

const RESPONSE_UNSPECIFIED, RESPONSE_NOOP, RESPONSE_SUCCESS, RESPONSE_FAILURE

 1const (
 2	// Default zero value enumeration
 3	RESPONSE_UNSPECIFIED ResponseResultType = 0
 4	// The message did not call the IBC application callbacks (because, for
 5	// example, the packet had already been relayed)
 6	RESPONSE_NOOP ResponseResultType = 1
 7	// The message was executed successfully
 8	RESPONSE_SUCCESS ResponseResultType = 2
 9	// The message was executed unsuccessfully
10	RESPONSE_FAILURE ResponseResultType = 3
11)
source

Variables 2

var IsClientIDFormat

1var IsClientIDFormat = regexp.MustCompile(`^\w+([\w-]+\w)?-[0-9]{1,20}$`).MatchString
source

IsClientIDFormat checks if a clientID is in the format required on the SDK for parsing client identifiers. The client identifier must be in the form: `{client-type}-{N}` which per the specification only permits ASCII for the {client-type} segment and 1 to 20 digits for the {N} segment. `([\w-]+\w)?` allows for a letter or hyphen, with the {client-type} starting with a letter and ending with a letter, i.e. `letter+(letter|hyphen+letter)?`.

var IsRevisionFormat

1var IsRevisionFormat = regexp.MustCompile(`^.*[^\n-]-{1}[1-9][0-9]*$`).MatchString
source

IsRevisionFormat checks if a chainID is in the format required for parsing revisions The chainID must be in the form: `{chainID}-{revision}`. 24-host may enforce stricter checks on chainID

Functions 20

func CommitAcknowledgement

1func CommitAcknowledgement(acknowledgement Acknowledgement) []byte
source

CommitAcknowledgement returns the V2 acknowledgement commitment bytes. The commitment consists of: sha256_hash(0x02 + sha256_hash(ack1) + sha256_hash(ack2) + ...) from a given acknowledgement.

func CommitPacket

1func CommitPacket(packet Packet) []byte
source

CommitPacket returns the V2 packet commitment bytes. The commitment consists of: ha256_hash(0x02 + sha256_hash(destinationClient) + sha256_hash(timeout) + sha256_hash(payload)) from a given packet. This results in a fixed length preimage of 32 bytes. NOTE: A fixed length preimage is ESSENTIAL to prevent relayers from being able to malleate the packet fields and create a commitment hash that matches the original packet.

func FormatClientIdentifier

1func FormatClientIdentifier(clientType string, sequence uint64) string
source

FormatClientIdentifier returns the client identifier with the sequence appended. This is an SDK specific format not enforced by IBC protocol.

func IsValidClientID

1func IsValidClientID(clientID string) bool
source

IsValidClientID checks if the clientID is valid and can be parsed into the client identifier format.

func ParseChainID

1func ParseChainID(chainID string) uint64
source

ParseChainID is a utility function that returns a revision number from the given ChainID. ParseChainID attempts to parse a chain id in the format: `{chainID}-{revision}` and return the revisionnumber as a uint64. If the chainID is not in the expected format, a default revision value of 0 is returned.

func ParseClientIdentifier

1func ParseClientIdentifier(clientID string) (string, uint64, error)
source

ParseClientIdentifier parses the client type and sequence from the client identifier.

func SetRevisionNumber

1func SetRevisionNumber(chainID string, revision uint64) (string, error)
source

SetRevisionNumber takes a chainID in valid revision format and swaps the revision number in the chainID with the given revision number.

func ValidateClientType

1func ValidateClientType(clientType string) error
source

ValidateClientType validates the client type. It cannot be blank or empty. It must be a valid client identifier when used with '0' or the maximum uint64 as the sequence.

func GetSelfHeight

1func GetSelfHeight() Height
source

GetSelfHeight is a utility function that returns self height given context. Revision number is retrieved from runtime.ChainID()

func ParseHeight

1func ParseHeight(heightStr string) (Height, error)
source

ParseHeight is a utility function that takes a string representation of the height and returns a Height struct.

func ParseHeightNatSort

1func ParseHeightNatSort(heightNatSort string) (h Height)
source

ParseHeightNatSort is a utility function that takes a string nat sorted representation of the height (see StringBatSort) and returns a Height struct.

func BuildMerklePath

1func BuildMerklePath(prefix [][]byte, path []byte) MerklePath
source

BuildMerklePath takes the merkle path prefix and an ICS24 path and builds a new path by appending the ICS24 path to the last element of the merkle path prefix.

func NewMsgSendPacket

1func NewMsgSendPacket(sourceClient string, timeoutTimestamp uint64, payloads ...Payload) *MsgSendPacket
source

NewMsgSendPacket creates a new MsgSendPacket instance.

func NewPacket

1func NewPacket(sequence uint64, sourceClient, destinationClient string, timeoutTimestamp uint64, payloads ...Payload) Packet
source

NewPacket constructs a new packet.

func NewPayload

1func NewPayload(sourcePort, destPort, version, encoding string, value []byte) Payload
source

NewPayload constructs a new Payload

Types 14

type Acknowledgement

struct
1type Acknowledgement struct {
2	AppAcknowledgements [][]byte
3}
source

Acknowledgement contains a list of all ack results associated with a single packet. In the case of a successful receive, the acknowledgement will contain an app acknowledgement for each application that received a payload in the same order that the payloads were sent in the packet. If the receive is not successful, the acknowledgement will contain a single app acknowledgment which will be a constant error acknowledgment as defined by the IBC v2 protocol.

Methods on Acknowledgement

func ProtoMarshal

method on Acknowledgement
1func (ack Acknowledgement) ProtoMarshal() (buf []byte)
source

ProtoMarshal returns the protobuf encoding of a Acknowledgement.

Example
1message Acknowledgement {
2  repeated bytes app_acknowledgements = 1;
3}

func Success

method on Acknowledgement
1func (ack Acknowledgement) Success() bool
source

Success returns true if the acknowledgement is successful it implements the exported.Acknowledgement interface

func Validate

method on Acknowledgement
1func (ack Acknowledgement) Validate() error
source

Validate performs a basic validation of the acknowledgement

type AppAcknowledgement

struct
1type AppAcknowledgement struct {
2	Response AppAcknowledgementResponse
3}
source

AppAcknowledgement is the recommended acknowledgement format to be used by app-specific protocols.

Methods on AppAcknowledgement

func MarshalJSON

method on AppAcknowledgement
1func (a *AppAcknowledgement) MarshalJSON() []byte
source

func Success

method on AppAcknowledgement
1func (a AppAcknowledgement) Success() bool
source

func UnmarshalJSON

method on AppAcknowledgement
1func (a *AppAcknowledgement) UnmarshalJSON(bz []byte) error
source

type Height

struct
1type Height struct {
2	// the revision that the client is currently on
3	RevisionNumber uint64
4	// the height within the given revision
5	RevisionHeight uint64
6}
source

Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients

Normally the RevisionHeight is incremented at each height while keeping RevisionNumber the same. However some consensus algorithms may choose to reset the height in certain conditions e.g. hard forks, state-machine breaking changes In these cases, the RevisionNumber is incremented so that height continues to be monitonically increasing even as the RevisionHeight gets reset

Please note that json tags for generated Go code are overridden to explicitly exclude the omitempty jsontag. This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height.

Methods on Height

func Compare

method on Height
1func (h Height) Compare(height Height) int64
source

Compare implements a method to compare two heights. When comparing two heights a, b we can call a.Compare(b) which will return -1 if a < b 0 if a = b 1 if a > b

It first compares based on revision numbers, whichever has the higher revision number is the higher height If revision number is the same, then the revision height is compared

func EQ

method on Height
1func (h Height) EQ(other Height) bool
source

EQ Helper comparison function returns true if h == other

func GT

method on Height
1func (h Height) GT(other Height) bool
source

GT Helper comparison function returns true if h > other

func GTE

method on Height
1func (h Height) GTE(other Height) bool
source

GTE Helper comparison function returns true if h >= other

func IsZero

method on Height
1func (h Height) IsZero() bool
source

IsZero returns true if height revision and revision-height are both 0

func LT

method on Height
1func (h Height) LT(other Height) bool
source

LT Helper comparison function returns true if h < other

func LTE

method on Height
1func (h Height) LTE(other Height) bool
source

LTE Helper comparison function returns true if h <= other

func String

method on Height
1func (h Height) String() string
source

func StringNatSort

method on Height
1func (h Height) StringNatSort() string
source

StringNatSort returns a natural sortable representation of height that can be used for store keys.

type MerklePath

struct
1type MerklePath struct {
2	KeyPath [][]byte
3}
source

MerklePath is the path used to verify commitment proofs, which can be an arbitrary structured object (defined by a commitment type). ICS-23 verification supports membership proofs for nested merkle trees. The ICS-24 standard provable keys MUST be stored in the lowest level tree with an optional prefix. The IC24 provable tree may then be stored in a higher level tree(s) that hash up to the root hash stored in the consensus state of the client. Each element of the path represents the key of a merkle tree from the root to the leaf. The elements of the path before the final element must be the path to the tree that contains the ICS24 provable store. Thus, it should remain constant for all ICS24 proofs. The final element of the path is the key of the leaf in the ICS24 provable store, thus IBC core will append the ICS24 path to the final element of the MerklePath stored in the counterparty to create the full path to the leaf for proof verification.

Examples: Cosmos SDK: The Cosmos SDK commits to a multi-tree where each store is an IAVL tree and all store hashes are hashed in a simple merkle tree to get the final root hash. Thus, the MerklePath in the counterparty MerklePrefix has the following structure: ["ibc", ""] The core IBC handler will append the ICS24 path to the final element of the MerklePath like so: ["ibc", "{packetCommitmentPath}"] which will then be used for final verification.

Methods on MerklePath

func String

method on MerklePath
1func (mp MerklePath) String() string
source

type MsgAcknowledgement

struct
1type MsgAcknowledgement struct {
2	Packet          Packet
3	Acknowledgement Acknowledgement
4	ProofAcked      []ics23.CommitmentProof
5	ProofHeight     Height
6}
source

MsgAcknowledgement receives incoming IBC acknowledgement.

Methods on MsgAcknowledgement

func ValidateBasic

method on MsgAcknowledgement
1func (msg *MsgAcknowledgement) ValidateBasic() error
source

ValidateBasic performs basic checks on a MsgAcknowledgement.

type MsgRecvPacket

struct
1type MsgRecvPacket struct {
2	Packet          Packet
3	ProofCommitment []ics23.CommitmentProof
4	ProofHeight     Height
5}
source

MsgRecvPacket receives an incoming IBC packet.

Methods on MsgRecvPacket

func ValidateBasic

method on MsgRecvPacket
1func (msg *MsgRecvPacket) ValidateBasic() error
source

ValidateBasic performs basic checks on a MsgRecvPacket.

type MsgSendPacket

struct
1type MsgSendPacket struct {
2	SourceClient string
3	// TimeoutTimestamp holds the seconds after which the packet times out.
4	TimeoutTimestamp uint64
5	Payloads         []Payload
6}
source

MsgSendPacket sends an outgoing IBC packet.

Methods on MsgSendPacket

func ValidateBasic

method on MsgSendPacket
1func (msg *MsgSendPacket) ValidateBasic() error
source

ValidateBasic performs basic checks on a MsgSendPacket.

type MsgTimeout

struct
1type MsgTimeout struct {
2	Packet          Packet
3	ProofUnreceived []ics23.CommitmentProof
4	ProofHeight     Height
5}
source

MsgTimeout receives timed-out packet

Methods on MsgTimeout

type Packet

struct
 1type Packet struct {
 2	// number corresponds to the order of sends and receives, where a Packet
 3	// with an earlier sequence number must be sent and received before a Packet
 4	// with a later sequence number.
 5	Sequence uint64
 6	// identifies the sending client on the sending chain.
 7	SourceClient string
 8	// identifies the receiving client on the receiving chain.
 9	DestinationClient string
10	// timeout timestamp in seconds after which the packet times out.
11	TimeoutTimestamp uint64
12	// a list of payloads, each one for a specific application.
13	Payloads []Payload
14}
source

Packet defines a type that carries data across different chains through IBC

Methods on Packet

func ProtoMarshal

method on Packet
1func (p Packet) ProtoMarshal() (buf []byte)
source

ProtoMarshal returns the protobuf encoding of a Packet.

Example
1message Packet {
2  uint64 sequence = 1;
3  string source_client = 2;
4  string destination_client = 3;
5  uint64 timeout_timestamp = 4;
6  repeated Payload payloads = 5 [(gogoproto.nullable) = false];
7}

func ValidateBasic

method on Packet
1func (p Packet) ValidateBasic() error
source

ValidateBasic validates that a Packet satisfies the basic requirements.

type PacketStatus

ident
1type PacketStatus int32
source

PacketStatus specifies the status of a RecvPacketResult.

type Payload

struct
 1type Payload struct {
 2	// specifies the source port of the packet.
 3	SourcePort string
 4	// specifies the destination port of the packet.
 5	DestinationPort string
 6	// version of the specified application.
 7	Version string
 8	// the encoding used for the provided value.
 9	Encoding string
10	// the raw bytes for the payload.
11	Value []byte
12}
source

Methods on Payload

func ProtoMarshal

method on Payload
1func (p Payload) ProtoMarshal() []byte
source

ProtoMarshal returns the protobuf encoding of a Payload.

Example
1message Payload {
2  string source_port = 1;
3  string destination_port = 2;
4  string version = 3;
5  string encoding = 4;
6  bytes value = 5;
7}

func ValidateBasic

method on Payload
1func (p Payload) ValidateBasic() error
source

ValidateBasic validates a Payload.

type RecvPacketResult

struct
1type RecvPacketResult struct {
2	// status of the packet
3	Status PacketStatus
4	// acknowledgement of the packet
5	Acknowledgement []byte
6}
source

RecvPacketResult speecifies the status of a packet as well as the acknowledgement bytes.

type ResponseResultType

ident
1type ResponseResultType int32
source

ResponseResultType defines the possible outcomes of the execution of a message

Imports 16

Source Files 13