host

package
v4.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 6 Imported by: 236

Documentation

Overview

24-host is an implementation of ICS24.

The storage path supported are defined in [ICS24](https://github.com/cosmos/ibc/blob/master/spec/core/ics-024-host-requirements#path-space).

Hostname validation is implemented as defined in [ICS 24](https://github.com/cosmos/ibc/tree/master/spec/core/ics-024-host-requirements).

Index

Constants

View Source
const (
	// ModuleName is the name of the IBC module
	ModuleName = "ibc"

	// StoreKey is the string store representation
	StoreKey string = ModuleName

	// QuerierRoute is the querier route for the IBC module
	QuerierRoute string = ModuleName

	// RouterKey is the msg router key for the IBC module
	RouterKey string = ModuleName
)
View Source
const (
	KeyClientState             = "clientState"
	KeyConsensusStatePrefix    = "consensusStates"
	KeyConnectionPrefix        = "connections"
	KeyChannelEndPrefix        = "channelEnds"
	KeyChannelPrefix           = "channels"
	KeyPortPrefix              = "ports"
	KeySequencePrefix          = "sequences"
	KeyChannelCapabilityPrefix = "capabilities"
	KeyNextSeqSendPrefix       = "nextSequenceSend"
	KeyNextSeqRecvPrefix       = "nextSequenceRecv"
	KeyNextSeqAckPrefix        = "nextSequenceAck"
	KeyPacketCommitmentPrefix  = "commitments"
	KeyPacketAckPrefix         = "acks"
	KeyPacketReceiptPrefix     = "receipts"
)

KVStore key prefixes for IBC

View Source
const DefaultMaxCharacterLength = 64

DefaultMaxCharacterLength defines the default maximum character length used in validation of identifiers including the client, connection, port and channel identifiers.

NOTE: this restriction is specific to this golang implementation of IBC. If your use case demands a higher limit, please open an issue and we will consider adjusting this restriction.

View Source
const SubModuleName = "host"

SubModuleName defines the ICS 24 host

Variables

View Source
var (
	ErrInvalidID     = sdkerrors.Register(SubModuleName, 2, "invalid identifier")
	ErrInvalidPath   = sdkerrors.Register(SubModuleName, 3, "invalid path")
	ErrInvalidPacket = sdkerrors.Register(SubModuleName, 4, "invalid packet")
)

IBC client sentinel errors

View Source
var DefaultMaxPortCharacterLength = 128

DefaultMaxPortCharacterLength defines the default maximum character length used in validation of port identifiers.

View Source
var IsValidID = regexp.MustCompile(`^[a-zA-Z0-9\.\_\+\-\#\[\]\<\>]+$`).MatchString

IsValidID defines regular expression to check if the string consist of characters in one of the following categories only: - Alphanumeric - `.`, `_`, `+`, `-`, `#` - `[`, `]`, `<`, `>`

View Source
var (
	KeyClientStorePrefix = []byte("clients")
)

KVStore key prefixes for IBC

Functions

func ChannelCapabilityPath

func ChannelCapabilityPath(portID, channelID string) string

ChannelCapabilityPath defines the path under which capability keys associated with a channel are stored

func ChannelIdentifierValidator

func ChannelIdentifierValidator(id string) error

ChannelIdentifierValidator is the default validator function for Channel identifiers. A valid Identifier must be between 8-64 characters and only contain alphanumeric and some allowed special characters (see IsValidID).

func ChannelKey

func ChannelKey(portID, channelID string) []byte

ChannelKey returns the store key for a particular channel

func ChannelPath

func ChannelPath(portID, channelID string) string

ChannelPath defines the path under which channels are stored

func ClientConnectionsKey

func ClientConnectionsKey(clientID string) []byte

ClientConnectionsKey returns the store key for the connections of a given client

func ClientConnectionsPath

func ClientConnectionsPath(clientID string) string

ClientConnectionsPath defines a reverse mapping from clients to a set of connections

func ClientIdentifierValidator

func ClientIdentifierValidator(id string) error

ClientIdentifierValidator is the default validator function for Client identifiers. A valid Identifier must be between 9-64 characters and only contain alphanumeric and some allowed special characters (see IsValidID).

func ClientStateKey

func ClientStateKey() []byte

ClientStateKey returns a store key under which a particular client state is stored in a client prefixed store

func ConnectionIdentifierValidator

func ConnectionIdentifierValidator(id string) error

ConnectionIdentifierValidator is the default validator function for Connection identifiers. A valid Identifier must be between 10-64 characters and only contain alphanumeric and some allowed special characters (see IsValidID).

func ConnectionKey

func ConnectionKey(connectionID string) []byte

ConnectionKey returns the store key for a particular connection

func ConnectionPath

func ConnectionPath(connectionID string) string

ConnectionPath defines the path under which connection paths are stored

func ConsensusStateKey

func ConsensusStateKey(height exported.Height) []byte

ConsensusStateKey returns the store key for a the consensus state of a particular client stored in a client prefixed store.

func ConsensusStatePath

func ConsensusStatePath(height exported.Height) string

ConsensusStatePath returns the suffix store key for the consensus state at a particular height stored in a client prefixed store.

func FullClientKey

func FullClientKey(clientID string, path []byte) []byte

FullClientKey returns the full path of specific client path in the format: "clients/{clientID}/{path}" as a byte array.

func FullClientPath

func FullClientPath(clientID string, path string) string

FullClientPath returns the full path of a specific client path in the format: "clients/{clientID}/{path}" as a string.

func FullClientStateKey

func FullClientStateKey(clientID string) []byte

FullClientStateKey takes a client identifier and returns a Key under which to store a particular client state.

func FullClientStatePath

func FullClientStatePath(clientID string) string

FullClientStatePath takes a client identifier and returns a Path under which to store a particular client state

func FullConsensusStateKey

func FullConsensusStateKey(clientID string, height exported.Height) []byte

FullConsensusStateKey returns the store key for the consensus state of a particular client.

func FullConsensusStatePath

func FullConsensusStatePath(clientID string, height exported.Height) string

FullConsensusStatePath takes a client identifier and returns a Path under which to store the consensus state of a client.

func MustParseChannelPath

func MustParseChannelPath(path string) (string, string)

MustParseChannelPath returns the port and channel ID from a full path. Panics if the provided path is invalid.

func MustParseConnectionPath

func MustParseConnectionPath(path string) string

MustParseConnectionPath returns the connection ID from a full path. Panics if the provided path is invalid.

func NextSequenceAckKey

func NextSequenceAckKey(portID, channelID string) []byte

NextSequenceAckKey returns the store key for the acknowledgement sequence of a particular channel binded to a specific port.

func NextSequenceAckPath

func NextSequenceAckPath(portID, channelID string) string

NextSequenceAckPath defines the next acknowledgement sequence counter store path

func NextSequenceRecvKey

func NextSequenceRecvKey(portID, channelID string) []byte

NextSequenceRecvKey returns the store key for the receive sequence of a particular channel binded to a specific port

func NextSequenceRecvPath

func NextSequenceRecvPath(portID, channelID string) string

NextSequenceRecvPath defines the next receive sequence counter store path.

func NextSequenceSendKey

func NextSequenceSendKey(portID, channelID string) []byte

NextSequenceSendKey returns the store key for the send sequence of a particular channel binded to a specific port.

func NextSequenceSendPath

func NextSequenceSendPath(portID, channelID string) string

NextSequenceSendPath defines the next send sequence counter store path

func PacketAcknowledgementKey

func PacketAcknowledgementKey(portID, channelID string, sequence uint64) []byte

PacketAcknowledgementKey returns the store key of under which a packet acknowledgement is stored

func PacketAcknowledgementPath

func PacketAcknowledgementPath(portID, channelID string, sequence uint64) string

PacketAcknowledgementPath defines the packet acknowledgement store path

func PacketAcknowledgementPrefixPath

func PacketAcknowledgementPrefixPath(portID, channelID string) string

PacketAcknowledgementPrefixPath defines the prefix for commitments to packet data fields store path.

func PacketCommitmentKey

func PacketCommitmentKey(portID, channelID string, sequence uint64) []byte

PacketCommitmentKey returns the store key of under which a packet commitment is stored

func PacketCommitmentPath

func PacketCommitmentPath(portID, channelID string, sequence uint64) string

PacketCommitmentPath defines the commitments to packet data fields store path

func PacketCommitmentPrefixPath

func PacketCommitmentPrefixPath(portID, channelID string) string

PacketCommitmentPrefixPath defines the prefix for commitments to packet data fields store path.

func PacketReceiptKey

func PacketReceiptKey(portID, channelID string, sequence uint64) []byte

PacketReceiptKey returns the store key of under which a packet receipt is stored

func PacketReceiptPath

func PacketReceiptPath(portID, channelID string, sequence uint64) string

PacketReceiptPath defines the packet receipt store path

func ParseChannelPath

func ParseChannelPath(path string) (string, string, error)

ParseChannelPath returns the port and channel ID from a full path. It returns an error if the provided path is invalid.

func ParseConnectionPath

func ParseConnectionPath(path string) (string, error)

ParseConnectionPath returns the connection ID from a full path. It returns an error if the provided path is invalid.

func ParseIdentifier

func ParseIdentifier(identifier, prefix string) (uint64, error)

ParseIdentifier parses the sequence from the identifier using the provided prefix. This function does not need to be used by counterparty chains. SDK generated connection and channel identifiers are required to use this format.

func PortIdentifierValidator

func PortIdentifierValidator(id string) error

PortIdentifierValidator is the default validator function for Port identifiers. A valid Identifier must be between 2-64 characters and only contain alphanumeric and some allowed special characters (see IsValidID).

func PortPath

func PortPath(portID string) string

PortPath defines the path under which ports paths are stored on the capability module

Types

type ValidateFn

type ValidateFn func(string) error

ValidateFn function type to validate path and identifier bytestrings

func NewPathValidator

func NewPathValidator(idValidator ValidateFn) ValidateFn

NewPathValidator takes in a Identifier Validator function and returns a Path Validator function which requires path to consist of `/`-separated valid identifiers, where a valid identifier is between 1-64 characters, contains only alphanumeric and some allowed special characters (see IsValidID), and satisfies the custom `idValidator` function.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL