types

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeMsgCreateClient             string = "create_client"
	TypeMsgUpdateClient             string = "update_client"
	TypeMsgSubmitClientMisbehaviour string = "submit_client_misbehaviour"
)

Message types for the IBC client

View Source
const (
	SubModuleName = "tendermint"
)

Variables

View Source
var (
	ErrInvalidTrustingPeriod  = sdkerrors.Register(SubModuleName, 2, "invalid trusting period")
	ErrInvalidUnbondingPeriod = sdkerrors.Register(SubModuleName, 3, "invalid unbonding period")
	ErrInvalidHeader          = sdkerrors.Register(SubModuleName, 4, "invalid header")
	ErrInvalidMaxClockDrift   = sdkerrors.Register(SubModuleName, 5, "invalid max clock drift")
	ErrTrustingPeriodExpired  = sdkerrors.Register(SubModuleName, 6, "time since latest trusted state has passed the trusting period")
	ErrUnbondingPeriodExpired = sdkerrors.Register(SubModuleName, 7, "time since latest trusted state has passed the unbonding period")
)

IBC tendermint client sentinel errors

View Source
var SubModuleCdc *codec.Codec

SubModuleCdc defines the IBC tendermint client codec.

Functions

func MakeBlockID

func MakeBlockID(hash []byte, partSetSize int, partSetHash []byte) tmtypes.BlockID

Copied unimported test functions from tmtypes to use them here

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers the Tendermint types

func SetSubModuleCodec

func SetSubModuleCodec(cdc *codec.Codec)

SetSubModuleCodec sets the ibc tendermint client codec

func ValidCommit

func ValidCommit(chainID string, commit *tmtypes.Commit, valSet *tmtypes.ValidatorSet) (err error)

ValidCommit checks if the given commit is a valid commit from the passed-in validatorset

CommitToVoteSet will panic if the commit cannot be converted to a valid voteset given the validatorset This implies that someone tried to submit evidence that wasn't actually committed by the validatorset thus we should return an error here and reject the evidence rather than panicing.

Types

type ClientState

type ClientState struct {
	// Client ID
	ID string `json:"id" yaml:"id"`

	TrustLevel tmmath.Fraction `json:"trust_level" yaml:"trust_level"`

	// Duration of the period since the LastestTimestamp during which the
	// submitted headers are valid for upgrade
	TrustingPeriod time.Duration `json:"trusting_period" yaml:"trusting_period"`

	// Duration of the staking unbonding period
	UnbondingPeriod time.Duration `json:"unbonding_period" yaml:"unbonding_period"`

	// MaxClockDrift defines how much new (untrusted) header's Time can drift into
	// the future.
	MaxClockDrift time.Duration

	// Block height when the client was frozen due to a misbehaviour
	FrozenHeight uint64 `json:"frozen_height" yaml:"frozen_height"`

	// Last Header that was stored by client
	LastHeader Header `json:"last_header" yaml:"last_header"`
}

ClientState from Tendermint tracks the current validator set, latest height, and a possible frozen height.

func Initialize

func Initialize(
	id string, trustLevel tmmath.Fraction,
	trustingPeriod, ubdPeriod, maxClockDrift time.Duration,
	header Header,
) (ClientState, error)

Initialize creates a client state and validates its contents, checking that the provided consensus state is from the same client type.

func InitializeFromMsg

func InitializeFromMsg(msg MsgCreateClient) (ClientState, error)

InitializeFromMsg creates a tendermint client state from a CreateClientMsg

func NewClientState

func NewClientState(
	id string, trustLevel tmmath.Fraction,
	trustingPeriod, ubdPeriod, maxClockDrift time.Duration,
	header Header,
) ClientState

NewClientState creates a new ClientState instance

func (ClientState) ClientType

func (cs ClientState) ClientType() clientexported.ClientType

ClientType is tendermint.

func (ClientState) GetChainID

func (cs ClientState) GetChainID() string

GetChainID returns the chain-id from the last header

func (ClientState) GetID

func (cs ClientState) GetID() string

GetID returns the tendermint client state identifier.

func (ClientState) GetLatestHeight

func (cs ClientState) GetLatestHeight() uint64

GetLatestHeight returns latest block height.

func (ClientState) GetLatestTimestamp

func (cs ClientState) GetLatestTimestamp() time.Time

GetLatestTimestamp returns latest block time.

func (ClientState) IsFrozen

func (cs ClientState) IsFrozen() bool

IsFrozen returns true if the frozen height has been set.

func (ClientState) Validate

func (cs ClientState) Validate() error

Validate performs a basic validation of the client state fields.

func (ClientState) VerifyChannelState

func (cs ClientState) VerifyChannelState(
	_ sdk.KVStore,
	cdc codec.Marshaler,
	height uint64,
	prefix commitmentexported.Prefix,
	proof commitmentexported.Proof,
	portID,
	channelID string,
	channel channelexported.ChannelI,
	consensusState clientexported.ConsensusState,
) error

VerifyChannelState verifies a proof of the channel state of the specified channel end, under the specified port, stored on the target machine.

func (ClientState) VerifyClientConsensusState

func (cs ClientState) VerifyClientConsensusState(
	_ sdk.KVStore,
	cdc *codec.Codec,
	provingRoot commitmentexported.Root,
	height uint64,
	counterpartyClientIdentifier string,
	consensusHeight uint64,
	prefix commitmentexported.Prefix,
	proof commitmentexported.Proof,
	consensusState clientexported.ConsensusState,
) error

VerifyClientConsensusState verifies a proof of the consensus state of the Tendermint client stored on the target machine.

func (ClientState) VerifyConnectionState

func (cs ClientState) VerifyConnectionState(
	_ sdk.KVStore,
	cdc codec.Marshaler,
	height uint64,
	prefix commitmentexported.Prefix,
	proof commitmentexported.Proof,
	connectionID string,
	connectionEnd connectionexported.ConnectionI,
	consensusState clientexported.ConsensusState,
) error

VerifyConnectionState verifies a proof of the connection state of the specified connection end stored on the target machine.

func (ClientState) VerifyNextSequenceRecv

func (cs ClientState) VerifyNextSequenceRecv(
	_ sdk.KVStore,
	height uint64,
	prefix commitmentexported.Prefix,
	proof commitmentexported.Proof,
	portID,
	channelID string,
	nextSequenceRecv uint64,
	consensusState clientexported.ConsensusState,
) error

VerifyNextSequenceRecv verifies a proof of the next sequence number to be received of the specified channel at the specified port.

func (ClientState) VerifyPacketAcknowledgement

func (cs ClientState) VerifyPacketAcknowledgement(
	_ sdk.KVStore,
	height uint64,
	prefix commitmentexported.Prefix,
	proof commitmentexported.Proof,
	portID,
	channelID string,
	sequence uint64,
	acknowledgement []byte,
	consensusState clientexported.ConsensusState,
) error

VerifyPacketAcknowledgement verifies a proof of an incoming packet acknowledgement at the specified port, specified channel, and specified sequence.

func (ClientState) VerifyPacketAcknowledgementAbsence

func (cs ClientState) VerifyPacketAcknowledgementAbsence(
	_ sdk.KVStore,
	height uint64,
	prefix commitmentexported.Prefix,
	proof commitmentexported.Proof,
	portID,
	channelID string,
	sequence uint64,
	consensusState clientexported.ConsensusState,
) error

VerifyPacketAcknowledgementAbsence verifies a proof of the absence of an incoming packet acknowledgement at the specified port, specified channel, and specified sequence.

func (ClientState) VerifyPacketCommitment

func (cs ClientState) VerifyPacketCommitment(
	_ sdk.KVStore,
	height uint64,
	prefix commitmentexported.Prefix,
	proof commitmentexported.Proof,
	portID,
	channelID string,
	sequence uint64,
	commitmentBytes []byte,
	consensusState clientexported.ConsensusState,
) error

VerifyPacketCommitment verifies a proof of an outgoing packet commitment at the specified port, specified channel, and specified sequence.

type ConsensusState

type ConsensusState struct {
	Timestamp    time.Time               `json:"timestamp" yaml:"timestamp"`
	Root         commitmentexported.Root `json:"root" yaml:"root"`
	Height       uint64                  `json:"height" yaml:"height"`
	ValidatorSet *tmtypes.ValidatorSet   `json:"validator_set" yaml:"validator_set"`
}

ConsensusState defines a Tendermint consensus state

func NewConsensusState

func NewConsensusState(
	timestamp time.Time, root commitmentexported.Root, height uint64,
	valset *tmtypes.ValidatorSet,
) ConsensusState

NewConsensusState creates a new ConsensusState instance.

func (ConsensusState) ClientType

ClientType returns Tendermint

func (ConsensusState) GetHeight

func (cs ConsensusState) GetHeight() uint64

GetHeight returns the height for the specific consensus state

func (ConsensusState) GetRoot

func (cs ConsensusState) GetRoot() commitmentexported.Root

GetRoot returns the commitment Root for the specific

func (ConsensusState) GetTimestamp

func (cs ConsensusState) GetTimestamp() uint64

GetTimestamp returns block time in nanoseconds at which the consensus state was stored

func (ConsensusState) ValidateBasic

func (cs ConsensusState) ValidateBasic() error

ValidateBasic defines a basic validation for the tendermint consensus state.

type Evidence

type Evidence struct {
	ClientID string `json:"client_id" yaml:"client_id"`
	Header1  Header `json:"header1" yaml:"header1"`
	Header2  Header `json:"header2" yaml:"header2"`
	ChainID  string `json:"chain_id" yaml:"chain_id"`
}

Evidence is a wrapper over tendermint's DuplicateVoteEvidence that implements Evidence interface expected by ICS-02

func (Evidence) ClientType

func (ev Evidence) ClientType() clientexported.ClientType

ClientType is Tendermint light client

func (Evidence) GetClientID

func (ev Evidence) GetClientID() string

GetClientID returns the ID of the client that committed a misbehaviour.

func (Evidence) GetHeight

func (ev Evidence) GetHeight() int64

GetHeight returns the height at which misbehaviour occurred

NOTE: assumes that evidence headers have the same height

func (Evidence) Hash

func (ev Evidence) Hash() tmbytes.HexBytes

Hash implements Evidence interface

func (Evidence) Route

func (ev Evidence) Route() string

Route implements Evidence interface

func (Evidence) String

func (ev Evidence) String() string

String implements Evidence interface

func (Evidence) Type

func (ev Evidence) Type() string

Type implements Evidence interface

func (Evidence) ValidateBasic

func (ev Evidence) ValidateBasic() error

ValidateBasic implements Evidence interface

type Header struct {
	tmtypes.SignedHeader `json:"signed_header" yaml:"signed_header"` // contains the commitment root
	ValidatorSet         *tmtypes.ValidatorSet                       `json:"validator_set" yaml:"validator_set"`
}

Header defines the Tendermint consensus Header

func CreateTestHeader

func CreateTestHeader(chainID string, height int64, timestamp time.Time, valSet *tmtypes.ValidatorSet, signers []tmtypes.PrivValidator) Header

CreateTestHeader creates a mock header for testing only.

func (Header) ClientType

func (h Header) ClientType() clientexported.ClientType

ClientType defines that the Header is a Tendermint consensus algorithm

func (Header) ConsensusState

func (h Header) ConsensusState() ConsensusState

ConsensusState returns the consensus state associated with the header

func (Header) GetHeight

func (h Header) GetHeight() uint64

GetHeight returns the current height

NOTE: also referred as `sequence`

func (Header) ToABCIHeader

func (h Header) ToABCIHeader() abci.Header

ToABCIHeader parses the header to an ABCI header type. NOTE: only for testing use.

func (Header) ValidateBasic

func (h Header) ValidateBasic(chainID string) error

ValidateBasic calls the SignedHeader ValidateBasic function and checks that validatorsets are not nil

type MsgCreateClient

type MsgCreateClient struct {
	ClientID        string          `json:"client_id" yaml:"client_id"`
	Header          Header          `json:"header" yaml:"header"`
	TrustLevel      tmmath.Fraction `json:"trust_level" yaml:"trust_level"`
	TrustingPeriod  time.Duration   `json:"trusting_period" yaml:"trusting_period"`
	UnbondingPeriod time.Duration   `json:"unbonding_period" yaml:"unbonding_period"`
	MaxClockDrift   time.Duration   `json:"max_clock_drift" yaml:"max_clock_drift"`
	Signer          sdk.AccAddress  `json:"address" yaml:"address"`
}

MsgCreateClient defines a message to create an IBC client

func NewMsgCreateClient

func NewMsgCreateClient(
	id string, header Header, trustLevel tmmath.Fraction,
	trustingPeriod, unbondingPeriod, maxClockDrift time.Duration, signer sdk.AccAddress,
) MsgCreateClient

NewMsgCreateClient creates a new MsgCreateClient instance

func (MsgCreateClient) GetClientID

func (msg MsgCreateClient) GetClientID() string

GetClientID implements clientexported.MsgCreateClient

func (MsgCreateClient) GetClientType

func (msg MsgCreateClient) GetClientType() string

GetClientType implements clientexported.MsgCreateClient

func (MsgCreateClient) GetConsensusState

func (msg MsgCreateClient) GetConsensusState() clientexported.ConsensusState

GetConsensusState implements clientexported.MsgCreateClient

func (MsgCreateClient) GetSignBytes

func (msg MsgCreateClient) GetSignBytes() []byte

GetSignBytes implements sdk.Msg

func (MsgCreateClient) GetSigners

func (msg MsgCreateClient) GetSigners() []sdk.AccAddress

GetSigners implements sdk.Msg

func (MsgCreateClient) Route

func (msg MsgCreateClient) Route() string

Route implements sdk.Msg

func (MsgCreateClient) Type

func (msg MsgCreateClient) Type() string

Type implements sdk.Msg

func (MsgCreateClient) ValidateBasic

func (msg MsgCreateClient) ValidateBasic() error

ValidateBasic implements sdk.Msg

type MsgSubmitClientMisbehaviour

type MsgSubmitClientMisbehaviour struct {
	Evidence  evidenceexported.Evidence `json:"evidence" yaml:"evidence"`
	Submitter sdk.AccAddress            `json:"submitter" yaml:"submitter"`
}

MsgSubmitClientMisbehaviour defines an sdk.Msg type that supports submitting Evidence for client misbehaviour.

func NewMsgSubmitClientMisbehaviour

func NewMsgSubmitClientMisbehaviour(e evidenceexported.Evidence, s sdk.AccAddress) MsgSubmitClientMisbehaviour

NewMsgSubmitClientMisbehaviour creates a new MsgSubmitClientMisbehaviour instance.

func (MsgSubmitClientMisbehaviour) GetEvidence

func (MsgSubmitClientMisbehaviour) GetSignBytes

func (msg MsgSubmitClientMisbehaviour) GetSignBytes() []byte

GetSignBytes returns the raw bytes a signer is expected to sign when submitting a MsgSubmitClientMisbehaviour message.

func (MsgSubmitClientMisbehaviour) GetSigners

func (msg MsgSubmitClientMisbehaviour) GetSigners() []sdk.AccAddress

GetSigners returns the single expected signer for a MsgSubmitClientMisbehaviour.

func (MsgSubmitClientMisbehaviour) GetSubmitter

func (msg MsgSubmitClientMisbehaviour) GetSubmitter() sdk.AccAddress

func (MsgSubmitClientMisbehaviour) Route

func (msg MsgSubmitClientMisbehaviour) Route() string

Route returns the MsgSubmitClientMisbehaviour's route.

func (MsgSubmitClientMisbehaviour) Type

Type returns the MsgSubmitClientMisbehaviour's type.

func (MsgSubmitClientMisbehaviour) ValidateBasic

func (msg MsgSubmitClientMisbehaviour) ValidateBasic() error

ValidateBasic performs basic (non-state-dependant) validation on a MsgSubmitClientMisbehaviour.

type MsgUpdateClient

type MsgUpdateClient struct {
	ClientID string         `json:"client_id" yaml:"client_id"`
	Header   Header         `json:"header" yaml:"header"`
	Signer   sdk.AccAddress `json:"address" yaml:"address"`
}

MsgUpdateClient defines a message to update an IBC client

func NewMsgUpdateClient

func NewMsgUpdateClient(id string, header Header, signer sdk.AccAddress) MsgUpdateClient

NewMsgUpdateClient creates a new MsgUpdateClient instance

func (MsgUpdateClient) GetClientID

func (msg MsgUpdateClient) GetClientID() string

GetClientID implements clientexported.MsgUpdateClient

func (MsgUpdateClient) GetHeader

func (msg MsgUpdateClient) GetHeader() clientexported.Header

GetHeader implements clientexported.MsgUpdateClient

func (MsgUpdateClient) GetSignBytes

func (msg MsgUpdateClient) GetSignBytes() []byte

GetSignBytes implements sdk.Msg

func (MsgUpdateClient) GetSigners

func (msg MsgUpdateClient) GetSigners() []sdk.AccAddress

GetSigners implements sdk.Msg

func (MsgUpdateClient) Route

func (msg MsgUpdateClient) Route() string

Route implements sdk.Msg

func (MsgUpdateClient) Type

func (msg MsgUpdateClient) Type() string

Type implements sdk.Msg

func (MsgUpdateClient) ValidateBasic

func (msg MsgUpdateClient) ValidateBasic() error

ValidateBasic implements sdk.Msg

Jump to

Keyboard shortcuts

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