host

package
v9.5.5 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: MIT Imports: 6 Imported by: 0

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 ChannelCounterpartyUpgradePath

func ChannelCounterpartyUpgradePath(portID, channelID string) string

ChannelCounterpartyUpgradePath defines the path under which the upgrade used on the counterparty channel is 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 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 ChannelUpgradeErrorPath

func ChannelUpgradeErrorPath(portID, channelID string) string

ChannelUpgradeErrorPath defines the path under which the ErrorReceipt is stored 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 ChannelUpgradePath

func ChannelUpgradePath(portID, channelID string) string

ChannelUpgradePath defines the path which stores the information related to an upgrade attempt

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

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 PrefixedClientStorePath

func PrefixedClientStorePath(prefix []byte) string

PrefixedClientStorePath returns a key path 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 PruningSequenceStartPath

func PruningSequenceStartPath(portID, channelID string) string

PruningSequenceStartPath defines the path under which the pruning sequence starting value is stored

func RecvStartSequenceKey

func RecvStartSequenceKey(portID, channelID string) []byte

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

func RecvStartSequencePath

func RecvStartSequencePath(portID, channelID string) string

RecvStartSequencePath defines the path under which the recv start sequence is stored

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