types

package
v0.1.1-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: Apache-2.0 Imports: 16 Imported by: 38

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InitStateVersion = tmstate.Version{
	Consensus: tmversion.Consensus{
		Block: version.BlockProtocol,
		App:   0,
	},
	Software: version.TMCoreSemVer,
}

InitStateVersion sets the Consensus.Block and Software versions, but leaves the Consensus.App version blank. The Consensus.App version will be set during the Handshake, once we hear from the app what protocol version it is running.

Functions

This section is empty.

Types

type Batch

type Batch struct {
	StartHeight uint64
	EndHeight   uint64
	Blocks      []*Block
	Commits     []*Commit
}

Batch defines a struct for block aggregation for support of batching. TODO: maybe change to BlockBatch

func (*Batch) FromProto

func (b *Batch) FromProto(other *pb.Batch) error

FromProto fills Batch with data from its protobuf representation.

func (*Batch) MarshalBinary

func (b *Batch) MarshalBinary() ([]byte, error)

MarshalBinary encodes Batch into binary form and returns it.

func (*Batch) ToProto

func (b *Batch) ToProto() *pb.Batch

ToProto converts Batch into protobuf representation and returns it.

func (*Batch) UnmarshalBinary

func (b *Batch) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes binary form of Batch into object.

type Block

type Block struct {
	Header     Header
	Data       Data
	LastCommit Commit
}

Block defines the structure of Dymint block.

func (*Block) FromProto

func (b *Block) FromProto(other *pb.Block) error

FromProto fills Block with data from its protobuf representation.

func (*Block) Hash

func (b *Block) Hash() [32]byte

Hash returns ABCI-compatible hash of a block.

func (*Block) MarshalBinary

func (b *Block) MarshalBinary() ([]byte, error)

MarshalBinary encodes Block into binary form and returns it.

func (*Block) ToProto

func (b *Block) ToProto() *pb.Block

ToProto converts Block into protobuf representation and returns it.

func (*Block) UnmarshalBinary

func (b *Block) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes binary form of Block into object.

func (*Block) ValidateBasic

func (b *Block) ValidateBasic() error

ValidateBasic performs basic validation of a block.

type Commit

type Commit struct {
	Height     uint64
	HeaderHash [32]byte
	Signatures []Signature // most of the time this is a single signature
}

Commit cointains evidence of block creation.

func (*Commit) FromProto

func (c *Commit) FromProto(other *pb.Commit) error

FromProto fills Commit with data from its protobuf representation.

func (*Commit) MarshalBinary

func (c *Commit) MarshalBinary() ([]byte, error)

MarshalBinary encodes Commit into binary form and returns it.

func (*Commit) ToProto

func (c *Commit) ToProto() *pb.Commit

ToProto converts Commit into protobuf representation and returns it.

func (*Commit) UnmarshalBinary

func (c *Commit) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes binary form of Commit into object.

func (*Commit) ValidateBasic

func (c *Commit) ValidateBasic() error

ValidateBasic performs basic validation of a commit.

type Data

type Data struct {
	Txs                    Txs
	IntermediateStateRoots IntermediateStateRoots
	Evidence               EvidenceData
}

Data defines Dymint block data.

func (*Data) MarshalBinary

func (d *Data) MarshalBinary() ([]byte, error)

MarshalBinary encodes Data into binary form and returns it.

func (*Data) ToProto

func (d *Data) ToProto() *pb.Data

ToProto converts Data into protobuf representation and returns it.

func (*Data) ValidateBasic

func (d *Data) ValidateBasic() error

ValidateBasic performs basic validation of block data. Actually it's a placeholder, because nothing is checked.

type Evidence

type Evidence interface {
	ABCI() []abci.Evidence // forms individual evidence to be sent to the application
	Bytes() []byte         // bytes which comprise the evidence
	Hash() []byte          // hash of the evidence
	Height() int64         // height of the infraction
	String() string        // string format of the evidence
	Time() time.Time       // time of the infraction
	ValidateBasic() error  // basic consistency check
}

Evidence represents any provable malicious activity by a validator. Verification logic for each evidence is part of the evidence module.

type EvidenceData

type EvidenceData struct {
	Evidence []Evidence
}

EvidenceData defines how evidence is stored in block.

type Header struct {
	// Block and App version
	Version Version
	// NamespaceID identifies this chain e.g. when connected to other rollups via IBC.
	// TODO(ismail): figure out if we want to use namespace.ID here instead (downside is that it isn't fixed size)
	// at least extract the used constants (32, 8) as package variables though.
	NamespaceID [8]byte

	Height uint64
	Time   uint64 // time in tai64 format

	// prev block info
	LastHeaderHash [32]byte

	// hashes of block data
	LastCommitHash [32]byte // commit from aggregator(s) from the last block
	DataHash       [32]byte // Block.Data root aka Transactions
	ConsensusHash  [32]byte // consensus params for current block
	AppHash        [32]byte // state after applying txs from the current block

	// Root hash of all results from the txs from the previous block.
	// This is ABCI specific but smart-contract chains require some way of committing
	// to transaction receipts/results.
	LastResultsHash [32]byte

	// Note that the address can be derived from the pubkey which can be derived
	// from the signature when using secp256k.
	// We keep this in case users choose another signature format where the
	// pubkey can't be recovered by the signature (e.g. ed25519).
	ProposerAddress []byte // original proposer of the block

	// Hash of block aggregator set, at a time of block creation
	AggregatorsHash [32]byte
}

Header defines the structure of Dymint block header.

func (*Header) FromProto

func (h *Header) FromProto(other *pb.Header) error

FromProto fills Header with data from its protobuf representation.

func (*Header) Hash

func (h *Header) Hash() [32]byte

Hash returns ABCI-compatible hash of a header.

func (*Header) MarshalBinary

func (h *Header) MarshalBinary() ([]byte, error)

MarshalBinary encodes Header into binary form and returns it.

func (*Header) ToProto

func (h *Header) ToProto() *pb.Header

ToProto converts Header into protobuf representation and returns it.

func (*Header) UnmarshalBinary

func (h *Header) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes binary form of Header into object.

func (*Header) ValidateBasic

func (h *Header) ValidateBasic() error

ValidateBasic performs basic validation of a header.

type IntermediateStateRoots

type IntermediateStateRoots struct {
	RawRootsList [][]byte
}

IntermediateStateRoots describes the state between transactions. They are required for fraud proofs.

type Signature

type Signature []byte

Signature represents signature of block creator.

type State

type State struct {
	Version tmstate.Version

	// immutable
	ChainID       string
	InitialHeight int64 // should be 1, not 0, when starting from height 1

	// LastBlockHeight=0 at genesis (ie. block(H=0) does not exist)
	LastBlockHeight int64
	LastBlockID     types.BlockID
	LastBlockTime   time.Time

	// SLStateIndex identifies the Settlement Layer state index we're synced with
	SLStateIndex uint64

	// In the MVP implementation, there will be only one Validator
	NextValidators              *types.ValidatorSet
	Validators                  *types.ValidatorSet
	LastValidators              *types.ValidatorSet
	LastHeightValidatorsChanged int64

	// Consensus parameters used for validating blocks.
	// Changes returned by EndBlock and updated after Commit.
	ConsensusParams                  tmproto.ConsensusParams
	LastHeightConsensusParamsChanged int64

	// Merkle root of the results from executing prev block
	LastResultsHash [32]byte

	// the latest AppHash we've received from calling abci.Commit()
	AppHash [32]byte
}

State contains information about current state of the blockchain.

func NewFromGenesisDoc

func NewFromGenesisDoc(genDoc *types.GenesisDoc) (State, error)

NewFromGenesisDoc reads blockchain State from genesis.

func (*State) FromProto

func (s *State) FromProto(other *pb.State) error

FromProto fills State with data from its protobuf representation.

func (*State) ToProto

func (s *State) ToProto() (*pb.State, error)

ToProto converts State into protobuf representation and returns it.

type Tx

type Tx []byte

Tx represents transactoin.

func (Tx) Hash

func (tx Tx) Hash() []byte

Hash computes the TMHASH hash of the wire encoded transaction.

type TxProof

type TxProof struct {
	RootHash tmbytes.HexBytes `json:"root_hash"`
	Data     Tx               `json:"data"`
	Proof    merkle.Proof     `json:"proof"`
}

TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree.

type Txs

type Txs []Tx

Txs represents a slice of transactions.

func (Txs) Proof

func (txs Txs) Proof(i int) TxProof

Proof returns a simple merkle proof for this node. Panics if i < 0 or i >= len(txs) TODO: optimize this!

type Version

type Version struct {
	Block uint64
	App   uint64
}

Version 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. This is equivalent to the tmversion.Consensus type in Tendermint.

Directories

Path Synopsis
pb

Jump to

Keyboard shortcuts

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