host

package
v9.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 6 Imported by: 4

Documentation

Overview

24-host is an implementation of ICS 24.

The storage path supported are defined in ICS 24 (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 (
	KeyChannelEndPrefix        = "channelEnds"
	KeyChannelPrefix           = "channels"
	KeyChannelUpgradePrefix    = "channelUpgrades"
	KeyUpgradePrefix           = "upgrades"
	KeyUpgradeErrorPrefix      = "upgradeError"
	KeyCounterpartyUpgrade     = "counterpartyUpgrade"
	KeyChannelCapabilityPrefix = "capabilities"
)
View Source
const (
	KeyClientState          = "clientState"
	KeyConsensusStatePrefix = "consensusStates"
)
View Source
const (
	KeySequencePrefix         = "sequences"
	KeyNextSeqSendPrefix      = "nextSequenceSend"
	KeyNextSeqRecvPrefix      = "nextSequenceRecv"
	KeyNextSeqAckPrefix       = "nextSequenceAck"
	KeyPacketCommitmentPrefix = "commitments"
	KeyPacketAckPrefix        = "acks"
	KeyPacketReceiptPrefix    = "receipts"
	KeyPruningSequenceStart   = "pruningSequenceStart"
	KeyRecvStartSequence      = "recvStartSequence"
)
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 KeyConnectionPrefix = "connections"
View Source
const (
	KeyPortPrefix = "ports"
)
View Source
const SubModuleName = "host"

SubModuleName defines the ICS 24 host

Variables

View Source
var (
	ErrInvalidID     = errorsmod.Register(SubModuleName, 2, "invalid identifier")
	ErrInvalidPath   = errorsmod.Register(SubModuleName, 3, "invalid path")
	ErrInvalidPacket = errorsmod.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")

KeyClientStorePrefix defines the KVStore key prefix for IBC clients

Functions

func ChannelCapabilityPath

func ChannelCapabilityPath(portID, channelID string) string

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

func ChannelCounterpartyUpgradeKey

func ChannelCounterpartyUpgradeKey(portID, channelID string) []byte

ChannelCounterpartyUpgradeKey returns the store key for the upgrade used on the counterparty channel.

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 ChannelUpgradeErrorKey

func ChannelUpgradeErrorKey(portID, channelID string) []byte

ChannelUpgradeErrorKey returns the store key for a particular channelEnd used to stor the ErrorReceipt in the case that a chain does not accept the proposed upgrade

func ChannelUpgradeKey

func ChannelUpgradeKey(portID, channelID string) []byte

ChannelUpgradeKey returns the store key for a particular channel upgrade attempt

func ClientConnectionsKey

func ClientConnectionsKey(clientID string) []byte

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

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 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 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 FullClientStateKey

func FullClientStateKey(clientID string) []byte

FullClientStateKey takes a client identifier and returns a Key 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 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 MustParseClientStatePath

func MustParseClientStatePath(path string) string

MustParseClientStatePath returns the client ID from a client state path. It panics if the provided path is invalid or if the clientID is empty.

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 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 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 PacketAcknowledgementKey

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

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

func PacketAcknowledgementPrefixKey

func PacketAcknowledgementPrefixKey(portID, channelID string) []byte

PacketAcknowledgementPrefixKey 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 PacketCommitmentPrefixKey

func PacketCommitmentPrefixKey(portID, channelID string) []byte

PacketCommitmentPrefixKey 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 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

func PrefixedClientStoreKey

func PrefixedClientStoreKey(prefix []byte) []byte

PrefixedClientStoreKey returns a key which can be used for prefixed key store iteration. The prefix may be a clientType, clientID, or any valid key prefix which may be concatenated with the client store constant.

func PruningSequenceStartKey

func PruningSequenceStartKey(portID, channelID string) []byte

PruningSequenceStartKey returns the store key for the pruning sequence start of a particular channel

func RecvStartSequenceKey

func RecvStartSequenceKey(portID, channelID string) []byte

RecvStartSequenceKey returns the store key for the recv start sequence of a particular channel

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