Documentation ¶
Overview ¶
Package tendermint implements a concrete LightClientModule, ClientState, ConsensusState, Header, Misbehaviour and types for the Tendermint consensus light client. This implementation is based off the ICS 07 specification (https://github.com/cosmos/ibc/tree/main/spec/client/ics-007-tendermint-client)
Note that client identifiers are expected to be in the form: 07-tendermint-{N}. Client identifiers are generated and validated by core IBC, unexpected client identifiers will result in errors.
Index ¶
- Constants
- Variables
- func GetHeightFromIterationKey(iterKey []byte) exported.Height
- func GetIterationKey(clientStore storetypes.KVStore, height exported.Height) []byte
- func GetProcessedHeight(clientStore storetypes.KVStore, height exported.Height) (exported.Height, bool)
- func GetProcessedTime(clientStore storetypes.KVStore, height exported.Height) (uint64, bool)
- func IsMatchingClientState(subject, substitute ClientState) bool
- func IterateConsensusStateAscending(clientStore storetypes.KVStore, cb func(height exported.Height) (stop bool))
- func IterationKey(height exported.Height) []byte
- func ProcessedHeightKey(height exported.Height) []byte
- func ProcessedTimeKey(height exported.Height) []byte
- func PruneAllExpiredConsensusStates(ctx sdk.Context, clientStore storetypes.KVStore, cdc codec.BinaryCodec, ...) int
- func RegisterInterfaces(registry codectypes.InterfaceRegistry)
- func SetIterationKey(clientStore storetypes.KVStore, height exported.Height)
- func SetProcessedHeight(clientStore storetypes.KVStore, consHeight, processedHeight exported.Height)
- func SetProcessedTime(clientStore storetypes.KVStore, height exported.Height, timeNs uint64)
- type AppModule
- type AppModuleBasic
- func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage
- func (AppModuleBasic) GetQueryCmd() *cobra.Command
- func (AppModuleBasic) GetTxCmd() *cobra.Command
- func (AppModuleBasic) IsAppModule()
- func (AppModuleBasic) IsOnePerModuleType()
- func (AppModuleBasic) Name() string
- func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux)
- func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)
- func (AppModuleBasic) RegisterLegacyAminoCodec(*codec.LegacyAmino)
- func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error
- type ClientState
- func (ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, ...) bool
- func (cs ClientState) CheckSubstituteAndUpdateState(ctx sdk.Context, cdc codec.BinaryCodec, ...) error
- func (ClientState) ClientType() string
- func (*ClientState) Descriptor() ([]byte, []int)
- func (cs ClientState) GetChainID() string
- func (cs ClientState) IsExpired(latestTimestamp, now time.Time) bool
- func (m *ClientState) Marshal() (dAtA []byte, err error)
- func (m *ClientState) MarshalTo(dAtA []byte) (int, error)
- func (m *ClientState) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*ClientState) ProtoMessage()
- func (m *ClientState) Reset()
- func (m *ClientState) Size() (n int)
- func (m *ClientState) String() string
- func (m *ClientState) Unmarshal(dAtA []byte) error
- func (cs ClientState) UpdateState(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, ...) []exported.Height
- func (cs ClientState) UpdateStateOnMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, ...)
- func (cs ClientState) Validate() error
- func (cs *ClientState) VerifyClientMessage(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, ...) error
- func (cs ClientState) VerifyUpgradeAndUpdateState(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, ...) error
- func (m *ClientState) XXX_DiscardUnknown()
- func (m *ClientState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *ClientState) XXX_Merge(src proto.Message)
- func (m *ClientState) XXX_Size() int
- func (m *ClientState) XXX_Unmarshal(b []byte) error
- func (cs ClientState) ZeroCustomFields() *ClientState
- type ConsensusState
- func GetConsensusState(store storetypes.KVStore, cdc codec.BinaryCodec, height exported.Height) (*ConsensusState, bool)
- func GetNextConsensusState(clientStore storetypes.KVStore, cdc codec.BinaryCodec, height exported.Height) (*ConsensusState, bool)
- func GetPreviousConsensusState(clientStore storetypes.KVStore, cdc codec.BinaryCodec, height exported.Height) (*ConsensusState, bool)
- func NewConsensusState(timestamp time.Time, root commitmenttypes.MerkleRoot, ...) *ConsensusState
- func (ConsensusState) ClientType() string
- func (*ConsensusState) Descriptor() ([]byte, []int)
- func (cs ConsensusState) GetRoot() exported.Root
- func (cs ConsensusState) GetTimestamp() uint64
- func (m *ConsensusState) Marshal() (dAtA []byte, err error)
- func (m *ConsensusState) MarshalTo(dAtA []byte) (int, error)
- func (m *ConsensusState) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*ConsensusState) ProtoMessage()
- func (m *ConsensusState) Reset()
- func (m *ConsensusState) Size() (n int)
- func (m *ConsensusState) String() string
- func (m *ConsensusState) Unmarshal(dAtA []byte) error
- func (cs ConsensusState) ValidateBasic() error
- func (m *ConsensusState) XXX_DiscardUnknown()
- func (m *ConsensusState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *ConsensusState) XXX_Merge(src proto.Message)
- func (m *ConsensusState) XXX_Size() int
- func (m *ConsensusState) XXX_Unmarshal(b []byte) error
- type Fraction
- func (*Fraction) Descriptor() ([]byte, []int)
- func (m *Fraction) GetDenominator() uint64
- func (m *Fraction) GetNumerator() uint64
- func (m *Fraction) Marshal() (dAtA []byte, err error)
- func (m *Fraction) MarshalTo(dAtA []byte) (int, error)
- func (m *Fraction) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Fraction) ProtoMessage()
- func (m *Fraction) Reset()
- func (m *Fraction) Size() (n int)
- func (m *Fraction) String() string
- func (f Fraction) ToTendermint() cmtmath.Fraction
- func (m *Fraction) Unmarshal(dAtA []byte) error
- func (m *Fraction) XXX_DiscardUnknown()
- func (m *Fraction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Fraction) XXX_Merge(src proto.Message)
- func (m *Fraction) XXX_Size() int
- func (m *Fraction) XXX_Unmarshal(b []byte) error
- type Header
- func (Header) ClientType() string
- func (h Header) ConsensusState() *ConsensusState
- func (*Header) Descriptor() ([]byte, []int)
- func (h Header) GetHeight() exported.Height
- func (h Header) GetTime() time.Time
- func (m *Header) GetTrustedHeight() types.Height
- func (m *Header) GetTrustedValidators() *types2.ValidatorSet
- func (m *Header) GetValidatorSet() *types2.ValidatorSet
- func (m *Header) Marshal() (dAtA []byte, err error)
- func (m *Header) MarshalTo(dAtA []byte) (int, error)
- func (m *Header) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Header) ProtoMessage()
- func (m *Header) Reset()
- func (m *Header) Size() (n int)
- func (m *Header) String() string
- func (m *Header) Unmarshal(dAtA []byte) error
- func (h Header) ValidateBasic() error
- func (m *Header) XXX_DiscardUnknown()
- func (m *Header) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Header) XXX_Merge(src proto.Message)
- func (m *Header) XXX_Size() int
- func (m *Header) XXX_Unmarshal(b []byte) error
- type LightClientModule
- func (l LightClientModule) CheckForMisbehaviour(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) bool
- func (l LightClientModule) Initialize(ctx sdk.Context, clientID string, clientStateBz, consensusStateBz []byte) error
- func (l LightClientModule) LatestHeight(ctx sdk.Context, clientID string) exported.Height
- func (l LightClientModule) RecoverClient(ctx sdk.Context, clientID, substituteClientID string) error
- func (l LightClientModule) Status(ctx sdk.Context, clientID string) exported.Status
- func (l LightClientModule) TimestampAtHeight(ctx sdk.Context, clientID string, height exported.Height) (uint64, error)
- func (l LightClientModule) UpdateState(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) []exported.Height
- func (l LightClientModule) UpdateStateOnMisbehaviour(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage)
- func (l LightClientModule) VerifyClientMessage(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) error
- func (l LightClientModule) VerifyMembership(ctx sdk.Context, clientID string, height exported.Height, ...) error
- func (l LightClientModule) VerifyNonMembership(ctx sdk.Context, clientID string, height exported.Height, ...) error
- func (l LightClientModule) VerifyUpgradeAndUpdateState(ctx sdk.Context, clientID string, newClient []byte, newConsState []byte, ...) error
- type Misbehaviour
- func (Misbehaviour) ClientType() string
- func (*Misbehaviour) Descriptor() ([]byte, []int)
- func (misbehaviour Misbehaviour) GetTime() time.Time
- func (m *Misbehaviour) Marshal() (dAtA []byte, err error)
- func (m *Misbehaviour) MarshalTo(dAtA []byte) (int, error)
- func (m *Misbehaviour) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Misbehaviour) ProtoMessage()
- func (m *Misbehaviour) Reset()
- func (m *Misbehaviour) Size() (n int)
- func (m *Misbehaviour) String() string
- func (m *Misbehaviour) Unmarshal(dAtA []byte) error
- func (misbehaviour Misbehaviour) ValidateBasic() error
- func (m *Misbehaviour) XXX_DiscardUnknown()
- func (m *Misbehaviour) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Misbehaviour) XXX_Merge(src proto.Message)
- func (m *Misbehaviour) XXX_Size() int
- func (m *Misbehaviour) XXX_Unmarshal(b []byte) error
Constants ¶
const KeyIterateConsensusStatePrefix = "iterateConsensusStates"
const (
ModuleName = "07-tendermint"
)
const SentinelRoot = "sentinel_root"
SentinelRoot is used as a stand-in root value for the consensus state set at the upgrade height
Variables ¶
var ( ErrInvalidChainID = errorsmod.Register(ModuleName, 2, "invalid chain-id") ErrInvalidTrustingPeriod = errorsmod.Register(ModuleName, 3, "invalid trusting period") ErrInvalidUnbondingPeriod = errorsmod.Register(ModuleName, 4, "invalid unbonding period") ErrInvalidHeaderHeight = errorsmod.Register(ModuleName, 5, "invalid header height") ErrInvalidHeader = errorsmod.Register(ModuleName, 6, "invalid header") ErrInvalidMaxClockDrift = errorsmod.Register(ModuleName, 7, "invalid max clock drift") ErrProcessedTimeNotFound = errorsmod.Register(ModuleName, 8, "processed time not found") ErrProcessedHeightNotFound = errorsmod.Register(ModuleName, 9, "processed height not found") ErrDelayPeriodNotPassed = errorsmod.Register(ModuleName, 10, "packet-specified delay period has not been reached") ErrTrustingPeriodExpired = errorsmod.Register(ModuleName, 11, "time since latest trusted state has passed the trusting period") ErrUnbondingPeriodExpired = errorsmod.Register(ModuleName, 12, "time since latest trusted state has passed the unbonding period") ErrInvalidProofSpecs = errorsmod.Register(ModuleName, 13, "invalid proof specs") ErrInvalidValidatorSet = errorsmod.Register(ModuleName, 14, "invalid validator set") ErrInvalidTrustLevel = errorsmod.Register(ModuleName, 15, "invalid trust level") )
IBC tendermint client sentinel errors
var ( // KeyProcessedTime is appended to consensus state key to store the processed time KeyProcessedTime = []byte("/processedTime") // KeyProcessedHeight is appended to consensus state key to store the processed height KeyProcessedHeight = []byte("/processedHeight") // KeyIteration stores the key mapping to consensus state key for efficient iteration KeyIteration = []byte("/iterationKey") )
var ( ErrInvalidLengthTendermint = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowTendermint = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupTendermint = fmt.Errorf("proto: unexpected end of group") )
var DefaultTrustLevel = NewFractionFromTm(light.DefaultTrustLevel)
DefaultTrustLevel is the tendermint light client default trust level
var FrozenHeight = clienttypes.NewHeight(0, 1)
FrozenHeight is same for all misbehaviour
Functions ¶
func GetHeightFromIterationKey ¶
GetHeightFromIterationKey takes an iteration key and returns the height that it references
func GetIterationKey ¶
func GetIterationKey(clientStore storetypes.KVStore, height exported.Height) []byte
GetIterationKey returns the consensus state key stored under the efficient iteration key. NOTE: This function is currently only used for testing purposes
func GetProcessedHeight ¶
func GetProcessedHeight(clientStore storetypes.KVStore, height exported.Height) (exported.Height, bool)
GetProcessedHeight gets the height at which this chain received and processed a tendermint header. This is used to validate that a received packet has passed the block delay period.
func GetProcessedTime ¶
GetProcessedTime gets the time (in nanoseconds) at which this chain received and processed a tendermint header. This is used to validate that a received packet has passed the time delay period.
func IsMatchingClientState ¶
func IsMatchingClientState(subject, substitute ClientState) bool
IsMatchingClientState returns true if all the client state parameters match except for frozen height, latest height, trusting period, chain-id.
func IterateConsensusStateAscending ¶
func IterateConsensusStateAscending(clientStore storetypes.KVStore, cb func(height exported.Height) (stop bool))
IterateConsensusStateAscending iterates through the consensus states in ascending order. It calls the provided callback on each height, until stop=true is returned.
func IterationKey ¶
IterationKey returns the key under which the consensus state key will be stored. The iteration key is a BigEndian representation of the consensus state key to support efficient iteration.
func ProcessedHeightKey ¶
ProcessedHeightKey returns the key under which the processed height will be stored in the client store.
func ProcessedTimeKey ¶
ProcessedTimeKey returns the key under which the processed time will be stored in the client store.
func PruneAllExpiredConsensusStates ¶
func PruneAllExpiredConsensusStates( ctx sdk.Context, clientStore storetypes.KVStore, cdc codec.BinaryCodec, clientState *ClientState, ) int
PruneAllExpiredConsensusStates iterates over all consensus states for a given client store. If a consensus state is expired, it is deleted and its metadata is deleted. The number of consensus states pruned is returned.
func RegisterInterfaces ¶
func RegisterInterfaces(registry codectypes.InterfaceRegistry)
RegisterInterfaces registers the tendermint concrete client-related implementations and interfaces.
func SetIterationKey ¶
func SetIterationKey(clientStore storetypes.KVStore, height exported.Height)
SetIterationKey stores the consensus state key under a key that is more efficient for ordered iteration
func SetProcessedHeight ¶
func SetProcessedHeight(clientStore storetypes.KVStore, consHeight, processedHeight exported.Height)
SetProcessedHeight stores the height at which a header was processed and the corresponding consensus state was created. This is useful when validating whether a packet has reached the specified block delay period in the tendermint client's verification functions
func SetProcessedTime ¶
func SetProcessedTime(clientStore storetypes.KVStore, height exported.Height, timeNs uint64)
SetProcessedTime stores the time at which a header was processed and the corresponding consensus state was created. This is useful when validating whether a packet has reached the time specified delay period in the tendermint client's verification functions
Types ¶
type AppModule ¶
type AppModule struct { AppModuleBasic // contains filtered or unexported fields }
AppModule is the application module for the Tendermint client module
func NewAppModule ¶
func NewAppModule(lightClientModule LightClientModule) AppModule
NewAppModule creates a new Tendermint client module
func (AppModule) IsAppModule ¶
func (AppModule) IsAppModule()
IsAppModule implements the appmodule.AppModule interface.
func (AppModule) IsOnePerModuleType ¶
func (AppModule) IsOnePerModuleType()
IsOnePerModuleType implements the depinject.OnePerModuleType interface.
type AppModuleBasic ¶
type AppModuleBasic struct{}
AppModuleBasic defines the basic application module used by the tendermint light client. Only the RegisterInterfaces function needs to be implemented. All other function perform a no-op.
func (AppModuleBasic) DefaultGenesis ¶
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage
DefaultGenesis performs a no-op. Genesis is not supported for the tendermint light client.
func (AppModuleBasic) GetQueryCmd ¶
func (AppModuleBasic) GetQueryCmd() *cobra.Command
GetQueryCmd performs a no-op. Please see the 02-client cli commands.
func (AppModuleBasic) GetTxCmd ¶
func (AppModuleBasic) GetTxCmd() *cobra.Command
GetTxCmd performs a no-op. Please see the 02-client cli commands.
func (AppModuleBasic) IsAppModule ¶
func (AppModuleBasic) IsAppModule()
IsAppModule implements the appmodule.AppModule interface.
func (AppModuleBasic) IsOnePerModuleType ¶
func (AppModuleBasic) IsOnePerModuleType()
IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (AppModuleBasic) Name ¶
func (AppModuleBasic) Name() string
Name returns the tendermint module name.
func (AppModuleBasic) RegisterGRPCGatewayRoutes ¶
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux)
RegisterGRPCGatewayRoutes performs a no-op.
func (AppModuleBasic) RegisterInterfaces ¶
func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)
RegisterInterfaces registers module concrete types into protobuf Any. This allows core IBC to unmarshal tendermint light client types.
func (AppModuleBasic) RegisterLegacyAminoCodec ¶
func (AppModuleBasic) RegisterLegacyAminoCodec(*codec.LegacyAmino)
RegisterLegacyAminoCodec performs a no-op. The Tendermint client does not support amino.
func (AppModuleBasic) ValidateGenesis ¶
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error
ValidateGenesis performs a no-op. Genesis is not supported for the tendermint light client.
type ClientState ¶
type ClientState struct { ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` TrustLevel Fraction `protobuf:"bytes,2,opt,name=trust_level,json=trustLevel,proto3" json:"trust_level"` // duration of the period since the LatestTimestamp during which the // submitted headers are valid for upgrade TrustingPeriod time.Duration `protobuf:"bytes,3,opt,name=trusting_period,json=trustingPeriod,proto3,stdduration" json:"trusting_period"` // duration of the staking unbonding period UnbondingPeriod time.Duration `protobuf:"bytes,4,opt,name=unbonding_period,json=unbondingPeriod,proto3,stdduration" json:"unbonding_period"` // defines how much new (untrusted) header's Time can drift into the future. MaxClockDrift time.Duration `protobuf:"bytes,5,opt,name=max_clock_drift,json=maxClockDrift,proto3,stdduration" json:"max_clock_drift"` // Block height when the client was frozen due to a misbehaviour FrozenHeight types.Height `protobuf:"bytes,6,opt,name=frozen_height,json=frozenHeight,proto3" json:"frozen_height"` // Latest height the client was updated to LatestHeight types.Height `protobuf:"bytes,7,opt,name=latest_height,json=latestHeight,proto3" json:"latest_height"` // Proof specifications used in verifying counterparty state ProofSpecs []*_go.ProofSpec `protobuf:"bytes,8,rep,name=proof_specs,json=proofSpecs,proto3" json:"proof_specs,omitempty"` // Path at which next upgraded client will be committed. // Each element corresponds to the key for a single CommitmentProof in the // chained proof. NOTE: ClientState must stored under // `{upgradePath}/{upgradeHeight}/clientState` ConsensusState must be stored // under `{upgradepath}/{upgradeHeight}/consensusState` For SDK chains using // the default upgrade module, upgrade_path should be []string{"upgrade", // "upgradedIBCState"}` UpgradePath []string `protobuf:"bytes,9,rep,name=upgrade_path,json=upgradePath,proto3" json:"upgrade_path,omitempty"` // allow_update_after_expiry is deprecated AllowUpdateAfterExpiry bool `` // Deprecated: Do not use. /* 133-byte string literal not displayed */ // allow_update_after_misbehaviour is deprecated AllowUpdateAfterMisbehaviour bool `` // Deprecated: Do not use. /* 151-byte string literal not displayed */ }
ClientState from Tendermint tracks the current validator set, latest height, and a possible frozen height.
func NewClientState ¶
func NewClientState( chainID string, trustLevel Fraction, trustingPeriod, ubdPeriod, maxClockDrift time.Duration, latestHeight clienttypes.Height, specs []*ics23.ProofSpec, upgradePath []string, ) *ClientState
NewClientState creates a new ClientState instance
func (ClientState) CheckForMisbehaviour ¶
func (ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, msg exported.ClientMessage) bool
CheckForMisbehaviour detects duplicate height misbehaviour and BFT time violation misbehaviour in a submitted Header message and verifies the correctness of a submitted Misbehaviour ClientMessage
func (ClientState) CheckSubstituteAndUpdateState ¶
func (cs ClientState) CheckSubstituteAndUpdateState( ctx sdk.Context, cdc codec.BinaryCodec, subjectClientStore, substituteClientStore storetypes.KVStore, substituteClient exported.ClientState, ) error
CheckSubstituteAndUpdateState will try to update the client with the state of the substitute.
AllowUpdateAfterMisbehaviour and AllowUpdateAfterExpiry have been deprecated. Please see ADR 026 for more information.
The following must always be true:
- The substitute client is the same type as the subject client
- The subject and substitute client states match in all parameters (expect frozen height, latest height, and chain-id)
In case 1) before updating the client, the client will be unfrozen by resetting the FrozenHeight to the zero Height.
func (*ClientState) Descriptor ¶
func (*ClientState) Descriptor() ([]byte, []int)
func (ClientState) GetChainID ¶
func (cs ClientState) GetChainID() string
GetChainID returns the chain-id
func (ClientState) IsExpired ¶
func (cs ClientState) IsExpired(latestTimestamp, now time.Time) bool
IsExpired returns whether or not the client has passed the trusting period since the last update (in which case no headers are considered valid).
func (*ClientState) Marshal ¶
func (m *ClientState) Marshal() (dAtA []byte, err error)
func (*ClientState) MarshalToSizedBuffer ¶
func (m *ClientState) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*ClientState) ProtoMessage ¶
func (*ClientState) ProtoMessage()
func (*ClientState) Reset ¶
func (m *ClientState) Reset()
func (*ClientState) Size ¶
func (m *ClientState) Size() (n int)
func (*ClientState) String ¶
func (m *ClientState) String() string
func (*ClientState) Unmarshal ¶
func (m *ClientState) Unmarshal(dAtA []byte) error
func (ClientState) UpdateState ¶
func (cs ClientState) UpdateState(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, clientMsg exported.ClientMessage) []exported.Height
UpdateState may be used to either create a consensus state for: - a future height greater than the latest client state height - a past height that was skipped during bisection If we are updating to a past height, a consensus state is created for that height to be persisted in client store If we are updating to a future height, the consensus state is created and the client state is updated to reflect the new latest height A list containing the updated consensus height is returned. UpdateState must only be used to update within a single revision, thus header revision number and trusted height's revision number must be the same. To update to a new revision, use a separate upgrade path UpdateState will prune the oldest consensus state if it is expired. If the provided clientMsg is not of type of Header then the handler will noop and empty slice is returned.
func (ClientState) UpdateStateOnMisbehaviour ¶
func (cs ClientState) UpdateStateOnMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, _ exported.ClientMessage)
UpdateStateOnMisbehaviour updates state upon misbehaviour, freezing the ClientState. This method should only be called when misbehaviour is detected as it does not perform any misbehaviour checks.
func (ClientState) Validate ¶
func (cs ClientState) Validate() error
Validate performs a basic validation of the client state fields.
func (*ClientState) VerifyClientMessage ¶
func (cs *ClientState) VerifyClientMessage( ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, clientMsg exported.ClientMessage, ) error
VerifyClientMessage checks if the clientMessage is of type Header or Misbehaviour and verifies the message
func (ClientState) VerifyUpgradeAndUpdateState ¶
func (cs ClientState) VerifyUpgradeAndUpdateState( ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, upgradedClient exported.ClientState, upgradedConsState exported.ConsensusState, upgradeClientProof, upgradeConsStateProof []byte, ) error
VerifyUpgradeAndUpdateState checks if the upgraded client has been committed by the current client It will zero out all client-specific fields (e.g. TrustingPeriod) and verify all data in client state that must be the same across all valid Tendermint clients for the new chain. VerifyUpgrade will return an error if: - the upgradedClient is not a Tendermint ClientState - the latest height of the client state does not have the same revision number or has a greater height than the committed client.
- the height of upgraded client is not greater than that of current client
- the latest height of the new client does not match or is greater than the height in committed client
- any Tendermint chain specified parameter in upgraded client such as ChainID, UnbondingPeriod, and ProofSpecs do not match parameters set by committed client
func (*ClientState) XXX_DiscardUnknown ¶
func (m *ClientState) XXX_DiscardUnknown()
func (*ClientState) XXX_Marshal ¶
func (m *ClientState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*ClientState) XXX_Merge ¶
func (m *ClientState) XXX_Merge(src proto.Message)
func (*ClientState) XXX_Size ¶
func (m *ClientState) XXX_Size() int
func (*ClientState) XXX_Unmarshal ¶
func (m *ClientState) XXX_Unmarshal(b []byte) error
func (ClientState) ZeroCustomFields ¶
func (cs ClientState) ZeroCustomFields() *ClientState
ZeroCustomFields returns a ClientState that is a copy of the current ClientState with all client customizable fields zeroed out. All chain specific fields must remain unchanged. This client state will be used to verify chain upgrades when a chain breaks a light client verification parameter such as chainID.
type ConsensusState ¶
type ConsensusState struct { // timestamp that corresponds to the block height in which the ConsensusState // was stored. Timestamp time.Time `protobuf:"bytes,1,opt,name=timestamp,proto3,stdtime" json:"timestamp"` // commitment root (i.e app hash) Root types1.MerkleRoot `protobuf:"bytes,2,opt,name=root,proto3" json:"root"` NextValidatorsHash github_com_cometbft_cometbft_libs_bytes.HexBytes `` /* 175-byte string literal not displayed */ }
ConsensusState defines the consensus state from Tendermint.
func GetConsensusState ¶
func GetConsensusState(store storetypes.KVStore, cdc codec.BinaryCodec, height exported.Height) (*ConsensusState, bool)
GetConsensusState retrieves the consensus state from the client prefixed store. If the ConsensusState does not exist in state for the provided height a nil value and false boolean flag is returned
func GetNextConsensusState ¶
func GetNextConsensusState(clientStore storetypes.KVStore, cdc codec.BinaryCodec, height exported.Height) (*ConsensusState, bool)
GetNextConsensusState returns the lowest consensus state that is larger than the given height. The Iterator returns a storetypes.Iterator which iterates from start (inclusive) to end (exclusive). If the starting height exists in store, we need to call iterator.Next() to get the next consenus state. Otherwise, the iterator is already at the next consensus state so we can call iterator.Value() immediately.
func GetPreviousConsensusState ¶
func GetPreviousConsensusState(clientStore storetypes.KVStore, cdc codec.BinaryCodec, height exported.Height) (*ConsensusState, bool)
GetPreviousConsensusState returns the highest consensus state that is lower than the given height. The Iterator returns a storetypes.Iterator which iterates from the end (exclusive) to start (inclusive). Thus to get previous consensus state we call iterator.Value() immediately.
func NewConsensusState ¶
func NewConsensusState( timestamp time.Time, root commitmenttypes.MerkleRoot, nextValsHash cmtbytes.HexBytes, ) *ConsensusState
NewConsensusState creates a new ConsensusState instance.
func (ConsensusState) ClientType ¶
func (ConsensusState) ClientType() string
ClientType returns Tendermint
func (*ConsensusState) Descriptor ¶
func (*ConsensusState) Descriptor() ([]byte, []int)
func (ConsensusState) GetRoot ¶
func (cs ConsensusState) GetRoot() exported.Root
GetRoot returns the commitment Root for the specific
func (ConsensusState) GetTimestamp ¶
func (cs ConsensusState) GetTimestamp() uint64
GetTimestamp returns block time in nanoseconds of the header that created consensus state
func (*ConsensusState) Marshal ¶
func (m *ConsensusState) Marshal() (dAtA []byte, err error)
func (*ConsensusState) MarshalToSizedBuffer ¶
func (m *ConsensusState) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*ConsensusState) ProtoMessage ¶
func (*ConsensusState) ProtoMessage()
func (*ConsensusState) Reset ¶
func (m *ConsensusState) Reset()
func (*ConsensusState) Size ¶
func (m *ConsensusState) Size() (n int)
func (*ConsensusState) String ¶
func (m *ConsensusState) String() string
func (*ConsensusState) Unmarshal ¶
func (m *ConsensusState) Unmarshal(dAtA []byte) error
func (ConsensusState) ValidateBasic ¶
func (cs ConsensusState) ValidateBasic() error
ValidateBasic defines a basic validation for the tendermint consensus state. NOTE: ProcessedTimestamp may be zero if this is an initial consensus state passed in by relayer as opposed to a consensus state constructed by the chain.
func (*ConsensusState) XXX_DiscardUnknown ¶
func (m *ConsensusState) XXX_DiscardUnknown()
func (*ConsensusState) XXX_Marshal ¶
func (m *ConsensusState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*ConsensusState) XXX_Merge ¶
func (m *ConsensusState) XXX_Merge(src proto.Message)
func (*ConsensusState) XXX_Size ¶
func (m *ConsensusState) XXX_Size() int
func (*ConsensusState) XXX_Unmarshal ¶
func (m *ConsensusState) XXX_Unmarshal(b []byte) error
type Fraction ¶
type Fraction struct { Numerator uint64 `protobuf:"varint,1,opt,name=numerator,proto3" json:"numerator,omitempty"` Denominator uint64 `protobuf:"varint,2,opt,name=denominator,proto3" json:"denominator,omitempty"` }
Fraction defines the protobuf message type for tmmath.Fraction that only supports positive values.
func NewFractionFromTm ¶
NewFractionFromTm returns a new Fraction instance from a tmmath.Fraction
func (*Fraction) Descriptor ¶
func (*Fraction) GetDenominator ¶
func (*Fraction) GetNumerator ¶
func (*Fraction) MarshalToSizedBuffer ¶
func (*Fraction) ProtoMessage ¶
func (*Fraction) ProtoMessage()
func (Fraction) ToTendermint ¶
ToTendermint converts Fraction to tmmath.Fraction
func (*Fraction) XXX_DiscardUnknown ¶
func (m *Fraction) XXX_DiscardUnknown()
func (*Fraction) XXX_Marshal ¶
func (*Fraction) XXX_Unmarshal ¶
type Header ¶
type Header struct { *types2.SignedHeader `protobuf:"bytes,1,opt,name=signed_header,json=signedHeader,proto3,embedded=signed_header" json:"signed_header,omitempty"` ValidatorSet *types2.ValidatorSet `protobuf:"bytes,2,opt,name=validator_set,json=validatorSet,proto3" json:"validator_set,omitempty"` TrustedHeight types.Height `protobuf:"bytes,3,opt,name=trusted_height,json=trustedHeight,proto3" json:"trusted_height"` TrustedValidators *types2.ValidatorSet `protobuf:"bytes,4,opt,name=trusted_validators,json=trustedValidators,proto3" json:"trusted_validators,omitempty"` }
Header defines the Tendermint client consensus Header. It encapsulates all the information necessary to update from a trusted Tendermint ConsensusState. The inclusion of TrustedHeight and TrustedValidators allows this update to process correctly, so long as the ConsensusState for the TrustedHeight exists, this removes race conditions among relayers The SignedHeader and ValidatorSet are the new untrusted update fields for the client. The TrustedHeight is the height of a stored ConsensusState on the client that will be used to verify the new untrusted header. The Trusted ConsensusState must be within the unbonding period of current time in order to correctly verify, and the TrustedValidators must hash to TrustedConsensusState.NextValidatorsHash since that is the last trusted validator set at the TrustedHeight.
func (Header) ClientType ¶
ClientType defines that the Header is a Tendermint consensus algorithm
func (Header) ConsensusState ¶
func (h Header) ConsensusState() *ConsensusState
ConsensusState returns the updated consensus state associated with the header
func (*Header) Descriptor ¶
func (Header) GetHeight ¶
GetHeight returns the current height. It returns 0 if the tendermint header is nil. NOTE: the header.Header is checked to be non nil in ValidateBasic.
func (Header) GetTime ¶
GetTime returns the current block timestamp. It returns a zero time if the tendermint header is nil. NOTE: the header.Header is checked to be non nil in ValidateBasic.
func (*Header) GetTrustedHeight ¶
func (*Header) GetTrustedValidators ¶
func (m *Header) GetTrustedValidators() *types2.ValidatorSet
func (*Header) GetValidatorSet ¶
func (m *Header) GetValidatorSet() *types2.ValidatorSet
func (*Header) MarshalToSizedBuffer ¶
func (*Header) ProtoMessage ¶
func (*Header) ProtoMessage()
func (Header) ValidateBasic ¶
ValidateBasic calls the SignedHeader ValidateBasic function and checks that validatorsets are not nil. NOTE: TrustedHeight and TrustedValidators may be empty when creating client with MsgCreateClient
func (*Header) XXX_DiscardUnknown ¶
func (m *Header) XXX_DiscardUnknown()
func (*Header) XXX_Marshal ¶
func (*Header) XXX_Unmarshal ¶
type LightClientModule ¶
type LightClientModule struct {
// contains filtered or unexported fields
}
LightClientModule implements the core IBC api.LightClientModule interface.
func NewLightClientModule ¶
func NewLightClientModule(cdc codec.BinaryCodec, storeProvider clienttypes.StoreProvider) LightClientModule
NewLightClientModule creates and returns a new 07-tendermint LightClientModule.
func (LightClientModule) CheckForMisbehaviour ¶
func (l LightClientModule) CheckForMisbehaviour(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) bool
CheckForMisbehaviour obtains the client state associated with the client identifier and calls into the clientState.CheckForMisbehaviour method.
func (LightClientModule) Initialize ¶
func (l LightClientModule) Initialize(ctx sdk.Context, clientID string, clientStateBz, consensusStateBz []byte) error
Initialize unmarshals the provided client and consensus states and performs basic validation. It calls into the clientState.initialize method.
func (LightClientModule) LatestHeight ¶
LatestHeight returns the latest height for the client state for the given client identifier. If no client is present for the provided client identifier a zero value height is returned.
func (LightClientModule) RecoverClient ¶
func (l LightClientModule) RecoverClient(ctx sdk.Context, clientID, substituteClientID string) error
RecoverClient asserts that the substitute client is a tendermint client. It obtains the client state associated with the subject client and calls into the subjectClientState.CheckSubstituteAndUpdateState method.
func (LightClientModule) Status ¶
Status obtains the client state associated with the client identifier and calls into the clientState.status method.
func (LightClientModule) TimestampAtHeight ¶
func (l LightClientModule) TimestampAtHeight( ctx sdk.Context, clientID string, height exported.Height, ) (uint64, error)
TimestampAtHeight obtains the client state associated with the client identifier and calls into the clientState.getTimestampAtHeight method.
func (LightClientModule) UpdateState ¶
func (l LightClientModule) UpdateState(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) []exported.Height
UpdateState obtains the client state associated with the client identifier and calls into the clientState.UpdateState method.
func (LightClientModule) UpdateStateOnMisbehaviour ¶
func (l LightClientModule) UpdateStateOnMisbehaviour(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage)
UpdateStateOnMisbehaviour obtains the client state associated with the client identifier and calls into the clientState.UpdateStateOnMisbehaviour method.
func (LightClientModule) VerifyClientMessage ¶
func (l LightClientModule) VerifyClientMessage(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) error
VerifyClientMessage obtains the client state associated with the client identifier and calls into the clientState.VerifyClientMessage method.
func (LightClientModule) VerifyMembership ¶
func (l LightClientModule) VerifyMembership( ctx sdk.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path, value []byte, ) error
VerifyMembership obtains the client state associated with the client identifier and calls into the clientState.verifyMembership method.
func (LightClientModule) VerifyNonMembership ¶
func (l LightClientModule) VerifyNonMembership( ctx sdk.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path, ) error
VerifyNonMembership obtains the client state associated with the client identifier and calls into the clientState.verifyNonMembership method.
func (LightClientModule) VerifyUpgradeAndUpdateState ¶
func (l LightClientModule) VerifyUpgradeAndUpdateState( ctx sdk.Context, clientID string, newClient []byte, newConsState []byte, upgradeClientProof, upgradeConsensusStateProof []byte, ) error
VerifyUpgradeAndUpdateState obtains the client state associated with the client identifier and calls into the clientState.VerifyUpgradeAndUpdateState method. The new client and consensus states will be unmarshaled and an error is returned if the new client state is not at a height greater than the existing client.
type Misbehaviour ¶
type Misbehaviour struct { // ClientID is deprecated ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` // Deprecated: Do not use. Header1 *Header `protobuf:"bytes,2,opt,name=header_1,json=header1,proto3" json:"header_1,omitempty"` Header2 *Header `protobuf:"bytes,3,opt,name=header_2,json=header2,proto3" json:"header_2,omitempty"` }
Misbehaviour is a wrapper over two conflicting Headers that implements Misbehaviour interface expected by ICS-02
func NewMisbehaviour ¶
func NewMisbehaviour(clientID string, header1, header2 *Header) *Misbehaviour
NewMisbehaviour creates a new Misbehaviour instance.
func (Misbehaviour) ClientType ¶
func (Misbehaviour) ClientType() string
ClientType is Tendermint light client
func (*Misbehaviour) Descriptor ¶
func (*Misbehaviour) Descriptor() ([]byte, []int)
func (Misbehaviour) GetTime ¶
func (misbehaviour Misbehaviour) GetTime() time.Time
GetTime returns the timestamp at which misbehaviour occurred. It uses the maximum value from both headers to prevent producing an invalid header outside of the misbehaviour age range.
func (*Misbehaviour) Marshal ¶
func (m *Misbehaviour) Marshal() (dAtA []byte, err error)
func (*Misbehaviour) MarshalToSizedBuffer ¶
func (m *Misbehaviour) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*Misbehaviour) ProtoMessage ¶
func (*Misbehaviour) ProtoMessage()
func (*Misbehaviour) Reset ¶
func (m *Misbehaviour) Reset()
func (*Misbehaviour) Size ¶
func (m *Misbehaviour) Size() (n int)
func (*Misbehaviour) String ¶
func (m *Misbehaviour) String() string
func (*Misbehaviour) Unmarshal ¶
func (m *Misbehaviour) Unmarshal(dAtA []byte) error
func (Misbehaviour) ValidateBasic ¶
func (misbehaviour Misbehaviour) ValidateBasic() error
ValidateBasic implements Misbehaviour interface
func (*Misbehaviour) XXX_DiscardUnknown ¶
func (m *Misbehaviour) XXX_DiscardUnknown()
func (*Misbehaviour) XXX_Marshal ¶
func (m *Misbehaviour) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*Misbehaviour) XXX_Merge ¶
func (m *Misbehaviour) XXX_Merge(src proto.Message)
func (*Misbehaviour) XXX_Size ¶
func (m *Misbehaviour) XXX_Size() int
func (*Misbehaviour) XXX_Unmarshal ¶
func (m *Misbehaviour) XXX_Unmarshal(b []byte) error