Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

tendermint source pure

Constants 3

const BlockProtocol, AddressSize, MaxSignatureSize

 1const (
 2	// BlockProtocol versions all block data structures and processing.
 3	// This includes validity of blocks and state updates.
 4	BlockProtocol uint64 = 11
 5	AddressSize          = 20
 6	// MaxSignatureSize is a maximum allowed signature size for the Proposal
 7	// and Vote.
 8	// XXX: secp256k1 does not have Size nor MaxSize defined.
 9	MaxSignatureSize = 64
10)
source

const MaxChainIDLen, SentinelRoot, ClientStateTypeURL, ConsensusStateTypeURL

 1const (
 2	// MaxChainIDLen is a maximum length of the chain ID.
 3	MaxChainIDLen = 50
 4	// SentinelRoot is used as a stand-in root value for the consensus state set at the upgrade height
 5	SentinelRoot = "sentinel_root"
 6	// ClientStateTypeURL is the proto Any type URL counterparties use when
 7	// storing the upgraded ClientState via cdc.MarshalInterface.
 8	ClientStateTypeURL = "/ibc.lightclients.tendermint.v1.ClientState"
 9	// ConsensusStateTypeURL is the proto Any type URL counterparties use
10	// when storing the upgraded ConsensusState via cdc.MarshalInterface.
11	ConsensusStateTypeURL = "/ibc.lightclients.tendermint.v1.ConsensusState"
12)
source

Variables 2

var DefaultTrustLevel

1var DefaultTrustLevel = NewFraction(1, 3)
source

DefaultTrustLevel is the tendermint light client default trust level

var FrozenHeight

1var FrozenHeight = types.NewHeight(0, 1)
source

FrozenHeight is same for all misbehaviour

Functions 7

func ValidateTrustLevel

1func ValidateTrustLevel(lvl Fraction) error
source

ValidateTrustLevel checks that trustLevel is within the allowed range [1/3, 1]. If not, it returns an error. 1/3 is the minimum amount of trust needed which does not break the security model.

func NewClientState

1func NewClientState(chainID string, trustLevel Fraction,
2	trustingPeriod, ubdPeriod, maxClockDrift time.Duration,
3	latestHeight types.Height, specs []*ics23.ProofSpec, upgradePath []string) *ClientState
source

Types 16

type BlockID

struct
1type BlockID struct {
2	Hash          []byte
3	PartSetHeader PartSetHeader
4}
source

BlockID

Methods on BlockID

func Equals

method on BlockID
1func (blockID BlockID) Equals(other BlockID) bool
source

Equals returns true if the BlockID matches the given BlockID

func IsZero

method on BlockID
1func (blockID BlockID) IsZero() bool
source

IsZero returns true if this is the BlockID of a nil block.

func ValidateBasic

method on BlockID
1func (blockID BlockID) ValidateBasic() error
source

ValidateBasic performs basic validation.

type BlockIDFlag

ident
1type BlockIDFlag byte
source

BlockIdFlag indicates which BlockID the signature is for

type ClientState

struct
 1type ClientState struct {
 2	ChainID    string
 3	TrustLevel Fraction
 4	// duration of the period since the LatestTimestamp during which the
 5	// submitted headers are valid for upgrade
 6	TrustingPeriod time.Duration
 7	// duration of the staking unbonding period
 8	UnbondingPeriod time.Duration
 9	// defines how much new (untrusted) header's Time can drift into the future.
10	MaxClockDrift time.Duration
11	// Block height when the client was frozen due to a misbehaviour
12	FrozenHeight types.Height
13	// Latest height the client was updated to
14	LatestHeight types.Height
15	// Proof specifications used in verifying counterparty state
16	ProofSpecs []*ics23.ProofSpec
17
18	// Path at which next upgraded client will be committed.
19	// Each element corresponds to the key for a single CommitmentProof in the
20	// chained proof. NOTE: ClientState must stored under
21	// `{upgradePath}/{upgradeHeight}/clientState` ConsensusState must be stored
22	// under `{upgradepath}/{upgradeHeight}/consensusState` For SDK chains using
23	// the default upgrade module, upgrade_path should be []string{"upgrade",
24	// "upgradedIBCState"}`
25	UpgradePath []string
26}
source

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

Methods on ClientState

func ClientType

method on ClientState
1func (ClientState) ClientType() string
source

Implements lightclient.ClientState

func ProtoMarshal

method on ClientState
1func (cs ClientState) ProtoMarshal() (bz []byte)
source

func ValidateBasic

method on ClientState
1func (cs ClientState) ValidateBasic() error
source

Implements lightclient.ClientState

func ZeroCustomFields

method on ClientState
1func (cs ClientState) ZeroCustomFields() ClientState
source

ZeroCustomFields returns a copy of the ClientState with all client-customizable fields zeroed. Only the chain-specified fields (ChainID, UnbondingPeriod, LatestHeight, ProofSpecs, UpgradePath) are preserved. The counterparty chain commits to this zeroed form when scheduling an upgrade, so verification on the upgrade proof must be performed against the same shape.

type Commit

struct
1type Commit struct {
2	Height     uint64
3	Round      int32
4	BlockID    BlockID
5	Signatures []CommitSig
6}
source

Commit contains the evidence that a block was committed by a set of validators.

Methods on Commit

func BytesToSign

method on Commit
1func (c *Commit) BytesToSign(chainID string, valIdx int) []byte
source

BytesToSign returns the bytes-to-sign for a validator's vote. These bytes are produced from a protobuf marshaled type [CanonicalVote]1. Since proto is not available in Gno, the function tries to generate these bytes manually, using the same logic as protobuf.

func ValidateBasic

method on Commit
1func (c *Commit) ValidateBasic() error
source

ValidateBasic performs basic validation that doesn't involve state data. Does not actually check the cryptographic signatures.

type CommitSig

struct
1type CommitSig struct {
2	BlockIDFlag      BlockIDFlag
3	ValidatorAddress []byte
4	Timestamp        time.Time
5	Signature        []byte
6}
source

CommitSig is a part of the Vote included in a Commit.

Methods on CommitSig

func ValidateBasic

method on CommitSig
1func (cs CommitSig) ValidateBasic() error
source

ValidateBasic performs basic validation.

type Consensus

struct
1type Consensus struct {
2	Block uint64
3	App   uint64
4}
source

Consensus captures the consensus rules for processing a block in the blockchain, including all blockchain data structures and the rules of the application's state transition machine.

Methods on Consensus

func ProtoMarshal

method on Consensus
1func (c Consensus) ProtoMarshal() (bz []byte)
source

type ConsensusState

struct
 1type ConsensusState struct {
 2	// timestamp that corresponds to the block height in which the ConsensusState
 3	// was stored.
 4	Timestamp time.Time
 5	// commitment root (i.e app hash)
 6	Root               MerkleRoot
 7	NextValidatorsHash []byte
 8
 9	processedTime   time.Time
10	processedHeight types.Height
11}
source

ConsensusState defines the consensus state from Tendermint.

Methods on ConsensusState

func ClientType

method on ConsensusState
1func (ConsensusState) ClientType() string
source

Implements lightclient.ConsensusState

func Equal

method on ConsensusState
1func (cs ConsensusState) Equal(other ConsensusState) bool
source

func ProtoMarshal

method on ConsensusState
1func (cs ConsensusState) ProtoMarshal() (bz []byte)
source

func ValidateBasic

method on ConsensusState
1func (cs ConsensusState) ValidateBasic() error
source

Implements lightclient.ConsensusState

type Fraction

struct
1type Fraction struct {
2	Numerator   uint64
3	Denominator uint64
4}
source

Methods on Fraction

func ProtoMarshal

method on Fraction
1func (f Fraction) ProtoMarshal() (bz []byte)
source

type Header

struct
 1type Header struct {
 2	// basic block info
 3	Version Consensus
 4	ChainID string
 5	Height  uint64
 6	Time    time.Time
 7
 8	// prev block info
 9	LastBlockID BlockID
10
11	// hashes of block data
12	// commit info from validators from the last block
13	LastCommitHash []byte
14	// transactions
15	DataHash []byte
16
17	// hashes from the app output form the preb block
18	// validators for the current block
19	ValidatorsHash []byte
20	// validators for the next block
21	NextValidatorsHash []byte
22	// consensus params for the current block
23	ConsensusHash []byte
24	// state afterx txs from the previous block
25	AppHash []byte
26	// root hash of all results from the txs from the previous block
27	LastResultsHash []byte
28
29	// consensus info
30	// evidence included in the block
31	EvidenceHash []byte
32	//original proposer of the block
33	ProposerAddress []byte
34}
source

Header defines the structure of a block header.

Methods on Header

func Expired

method on Header
1func (h Header) Expired(trustingPeriod time.Duration) error
source

func Hash

method on Header
1func (h *Header) Hash() []byte
source

func ValidateBasic

method on Header
1func (h Header) ValidateBasic() error
source

ValidateBasic performs stateless validation on a Header returning an error if any validation fails.

NOTE: Timestamp validation is subtle and handled elsewhere.

type MerkleRoot

struct
1type MerkleRoot struct {
2	Hash []byte
3}
source

Methods on MerkleRoot

func Empty

method on MerkleRoot
1func (mr MerkleRoot) Empty() bool
source

Empty returns true if the root is empty

func ProtoMarshal

method on MerkleRoot
1func (mr MerkleRoot) ProtoMarshal() (bz []byte)
source

type Misbehaviour

struct
1type Misbehaviour struct {
2	Header1 *MsgHeader
3	Header2 *MsgHeader
4}
source

Misbehaviour is a wrapper over two conflicting Headers that implements Misbehaviour interface expected by ICS-02

Methods on Misbehaviour

func ClientType

method on Misbehaviour
1func (Misbehaviour) ClientType() string
source

Implements lightclient.ClientMessage

func ValidateBasic

method on Misbehaviour
1func (m Misbehaviour) ValidateBasic() error
source

Implements lightclient.ClientMessage

type MsgHeader

struct
1type MsgHeader struct {
2	Header            *Header
3	Commit            *Commit
4	ValidatorSet      *ValidatorSet
5	TrustedHeight     types.Height
6	TrustedValidators *ValidatorSet
7}
source

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

Methods on MsgHeader

func ClientType

method on MsgHeader
1func (*MsgHeader) ClientType() string
source

Implements lightclient.ClientMessage

func ConsensusState

method on MsgHeader
1func (h MsgHeader) ConsensusState() ConsensusState
source

ConsensusState returns the updated consensus state associated with the header

func GetHeight

method on MsgHeader
1func (h MsgHeader) GetHeight() types.Height
source

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 ValidateBasic

method on MsgHeader
1func (h *MsgHeader) ValidateBasic() error
source

Implements lightclient.ClientMessage NOTE: TrustedHeight and TrustedValidators may be empty when creating client with MsgCreateClient

type PartSetHeader

struct
1type PartSetHeader struct {
2	Total uint32
3	Hash  []byte
4}
source

PartsetHeader

Methods on PartSetHeader

func Equals

method on PartSetHeader
1func (psh PartSetHeader) Equals(other PartSetHeader) bool
source

func IsZero

method on PartSetHeader
1func (psh PartSetHeader) IsZero() bool
source

func ProtoMarshal

method on PartSetHeader
1func (psh PartSetHeader) ProtoMarshal() (bz []byte)
source

func ValidateBasic

method on PartSetHeader
1func (psh PartSetHeader) ValidateBasic() error
source

ValidateBasic performs basic validation.

type TMLightClient

struct
1type TMLightClient struct {
2	ClientState            *ClientState
3	ConsensusStateByHeight *bptree.BPTree // height:*ConsensusState
4}
source

Methods on TMLightClient

func CheckForMisbehaviour

method on TMLightClient
1func (tm *TMLightClient) CheckForMisbehaviour(clientMsg lightclient.ClientMessage) bool
source

Implements lightclient.Interface

func GetConsensusState

method on TMLightClient
1func (tm *TMLightClient) GetConsensusState(height types.Height) (*ConsensusState, bool)
source

GetConsensusState returns the consensus state mapped at height, if any.

func GetNextConsensusState

method on TMLightClient
1func (tm *TMLightClient) GetNextConsensusState(height types.Height) (*ConsensusState, bool)
source

GetNextConsensusState returns the lowest consensus state that is larger than the given height.

func GetPreviousConsensusState

method on TMLightClient
1func (tm *TMLightClient) GetPreviousConsensusState(height types.Height) (*ConsensusState, bool)
source

GetPreviousConsensusState returns the highest consensus state that is lower than the given height.

func HasConsensusState

method on TMLightClient
1func (tm *TMLightClient) HasConsensusState(height types.Height) bool
source

func Initialize

method on TMLightClient
1func (tm *TMLightClient) Initialize(clientState lightclient.ClientState, consensusState lightclient.ConsensusState) error
source

Implements lightclient.Interface

func IsExpired

method on TMLightClient
1func (tm *TMLightClient) IsExpired(latestTimestamp, now time.Time) bool
source

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 LatestHeight

method on TMLightClient
1func (tm *TMLightClient) LatestHeight() types.Height
source

Implements lightclient.Interface

func RecoverClient

method on TMLightClient
1func (tm *TMLightClient) RecoverClient(substitute lightclient.Interface) error
source

Implements lightclient.Interface.

RecoverClient copies the substitute's consensus state at its latest height into the subject (tm), updates the subject's ChainID, LatestHeight and TrustingPeriod to match the substitute, and un-freezes the subject by resetting FrozenHeight. The substitute and subject client states must match in TrustLevel, UnbondingPeriod, MaxClockDrift, ProofSpecs and UpgradePath.

func SetConsensusState

method on TMLightClient
1func (tm *TMLightClient) SetConsensusState(height types.Height, consState *ConsensusState)
source

func Status

method on TMLightClient
1func (tm *TMLightClient) Status() lightclient.Status
source

Implements lightclient.Interface

func TimestampAtHeight

method on TMLightClient
1func (tm *TMLightClient) TimestampAtHeight(height types.Height) (uint64, error)
source

Implements lightclient.Interface

func UpdateState

method on TMLightClient
1func (tm *TMLightClient) UpdateState(clientMsg lightclient.ClientMessage) []types.Height
source

Implements lightclient.Interface

func UpdateStateOnMisbehaviour

method on TMLightClient
1func (tm *TMLightClient) UpdateStateOnMisbehaviour(clientMsg lightclient.ClientMessage)
source

Implements lightclient.Interface

func VerifyClientMessage

method on TMLightClient
1func (tm *TMLightClient) VerifyClientMessage(clientMsg lightclient.ClientMessage) error
source

Implements lightclient.Interface

func VerifyMembership

method on TMLightClient
1func (tm *TMLightClient) VerifyMembership(height types.Height,
2	proofs []ics23.CommitmentProof, path types.MerklePath,
3	value []byte) error
source

Implements lightclient.Interface

func VerifyNonMembership

method on TMLightClient
1func (tm *TMLightClient) VerifyNonMembership(height types.Height,
2	proofs []ics23.CommitmentProof, path types.MerklePath) error
source

Implements lightclient.Interface

func VerifyUpgradeAndUpdateState

method on TMLightClient
1func (tm *TMLightClient) VerifyUpgradeAndUpdateState(newClient, newConsState,
2	upgradeClientProof, upgradeConsensusStateProof any) error
source

Implements lightclient.Interface

type Validator

struct
1type Validator struct {
2	Address          []byte
3	PubKey           []byte
4	VotingPower      int64
5	ProposerPriority int64
6}
source

Methods on Validator

type ValidatorSet

struct
1type ValidatorSet struct {
2	Validators       []*Validator
3	Proposer         *Validator
4	TotalVotingPower int64
5}
source

Methods on ValidatorSet

func GetByAddress

method on ValidatorSet
1func (vals *ValidatorSet) GetByAddress(address []byte) (index int32, val *Validator)
source

GetByAddress returns an index of the validator with address and validator itself (copy) if found. Otherwise, -1 and nil are returned.

func Hash

method on ValidatorSet
1func (vals ValidatorSet) Hash() []byte
source

Imports 16

Source Files 13