types

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddressPrefixCelestia = "celestia"
	AddressPrefixValoper  = "celestiavaloper"
	AddressPrefixValCons  = "celestiavalcons"
)

celestia prefixes

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address string

func NewAddressFromBytes added in v1.3.1

func NewAddressFromBytes(data []byte) (Address, error)

func (Address) Decimal

func (a Address) Decimal() (decimal.Decimal, error)

func (Address) Decode

func (a Address) Decode() (string, []byte, error)

Decode decodes address, returning the human-readable part and the data part excluding the checksum.

func (Address) String

func (a Address) String() string

type Block

type Block struct {
	Header `json:"header"`
	Data   `json:"data"`
	// Evidence   types.EvidenceData `json:"evidence"`
	LastCommit *Commit `json:"last_commit"`
}

Block defines the atomic unit of a CometBFT blockchain.

type BlockData

type BlockData struct {
	ResultBlock
	ResultBlockResults
}

type BlockId

type BlockId struct {
	Hash Hex `json:"hash"`
}

type BlockParams

type BlockParams struct {
	// Note: must be greater than 0
	MaxBytes int64 `json:"max_bytes,omitempty,string" protobuf:"varint,1,opt,name=max_bytes,json=maxBytes,proto3"`
	// Note: must be greater or equal to -1
	MaxGas int64 `json:"max_gas,omitempty,string" protobuf:"varint,2,opt,name=max_gas,json=maxGas,proto3"`
}

BlockParams contains limits on the block size.

type Commit added in v1.4.0

type Commit struct {
	Height     int64             `json:"height,string"`
	Round      int32             `json:"round"`
	BlockID    BlockId           `json:"block_id"`
	Signatures []types.CommitSig `json:"signatures"`
}

type Consensus

type Consensus struct {
	Block uint64 `json:"block,omitempty,string" protobuf:"varint,1,opt,name=block,proto3"`
	App   uint64 `json:"app,omitempty,string"   protobuf:"varint,2,opt,name=app,proto3"`
}

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.

type ConsensusParams

type ConsensusParams struct {
	Block     *BlockParams     `json:"block"     protobuf:"bytes,1,opt,name=block,proto3"`
	Evidence  *EvidenceParams  `json:"evidence"  protobuf:"bytes,2,opt,name=evidence,proto3"`
	Validator *ValidatorParams `json:"validator" protobuf:"bytes,3,opt,name=validator,proto3"`
	Version   *VersionParams   `json:"version"   protobuf:"bytes,4,opt,name=version,proto3"`
}

ConsensusParams contains all consensus-relevant parameters that can be adjusted by the abci app

type Data

type Data struct {
	// Txs that will be applied by state @ block.Height+1.
	// NOTE: not all txs here are valid.  We're just agreeing on the order first.
	// This means that block.AppHash does not include these txs.
	Txs types.Txs `json:"txs"`

	// SquareSize is the size of the square after splitting all the block data
	// into shares. The erasure data is discarded after generation, and keeping this
	// value avoids unnecessarily regenerating all the shares when returning
	// proofs that some element was included in the block
	SquareSize uint64 `json:"square_size,string"`
}

Data contains all the available Data of the block. Data with reserved namespaces (Txs, IntermediateStateRoots, Evidence) and Celestia application-specific Blobs.

type Event

type Event struct {
	Type       string           `json:"type,omitempty"       protobuf:"bytes,1,opt,name=type,proto3"`
	Attributes []EventAttribute `json:"attributes,omitempty" protobuf:"bytes,2,rep,name=attributes,proto3"`
}

Event allows application developers to attach additional information to ResponseBeginBlock, ResponseEndBlock, ResponseCheckTx and ResponseDeliverTx. Later transactions may be queried using these events.

type EventAttribute

type EventAttribute struct {
	Key   []byte `json:"key,omitempty"   protobuf:"bytes,1,opt,name=key,proto3"`
	Value []byte `json:"value,omitempty" protobuf:"bytes,2,opt,name=value,proto3"`
	Index bool   `json:"index,omitempty" protobuf:"varint,3,opt,name=index,proto3"`
}

EventAttribute is a single key-value pair, associated with an event.

type EvidenceParams

type EvidenceParams struct {
	// Max age of evidence, in blocks.
	//
	// The basic formula for calculating this is: MaxAgeDuration / {average block
	// time}.
	MaxAgeNumBlocks int64 `json:"max_age_num_blocks,omitempty,string" protobuf:"varint,1,opt,name=max_age_num_blocks,json=maxAgeNumBlocks,proto3"`
	// Max age of evidence, in time.
	//
	// It should correspond with an app's "unbonding period" or other similar
	// mechanism for handling [Nothing-At-Stake
	// attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed).
	MaxAgeDuration time.Duration `json:"max_age_duration,string" protobuf:"bytes,2,opt,name=max_age_duration,json=maxAgeDuration,proto3,stdduration"`
	// This sets the maximum size of total evidence in bytes that can be committed in a single block.
	// And should fall comfortably under the max block bytes.
	// Default is 1048576 or 1MB
	MaxBytes int64 `json:"max_bytes,omitempty,string" protobuf:"varint,3,opt,name=max_bytes,json=maxBytes,proto3"`
}

EvidenceParams determine how we handle evidence of malfeasance.

type Header struct {
	// basic block info
	Version Consensus `json:"version"`
	ChainID string    `json:"chain_id"`
	Height  int64     `json:"height,string"`
	Time    time.Time `json:"time"`

	// prev block info
	LastBlockID BlockId `json:"last_block_id"`

	// hashes of block data
	LastCommitHash Hex `json:"last_commit_hash"` // commit from validators from the last block
	DataHash       Hex `json:"data_hash"`        // transactions

	// hashes from the app output from the prev block
	ValidatorsHash     Hex `json:"validators_hash"`      // validators for the current block
	NextValidatorsHash Hex `json:"next_validators_hash"` // validators for the next block
	ConsensusHash      Hex `json:"consensus_hash"`       // consensus params for current block
	AppHash            Hex `json:"app_hash"`             // state after txs from the previous block
	// root hash of all results from the txs from the previous block
	// see `deterministicResponseDeliverTx` to understand which parts of a tx are hashed into here
	LastResultsHash Hex `json:"last_results_hash"`

	// consensus info
	EvidenceHash    Hex `json:"evidence_hash"`    // evidence included in the block
	ProposerAddress Hex `json:"proposer_address"` // original proposer of the block
}

Header defines the structure of a CometBFT block header.

type Hex

type Hex []byte

func HexFromString

func HexFromString(s string) (Hex, error)

func (Hex) Bytes

func (h Hex) Bytes() []byte

func (Hex) MarshalJSON

func (h Hex) MarshalJSON() ([]byte, error)

func (*Hex) Scan

func (h *Hex) Scan(src interface{}) (err error)

func (Hex) String

func (h Hex) String() string

func (*Hex) UnmarshalJSON

func (h *Hex) UnmarshalJSON(data []byte) error

func (Hex) Value

func (h Hex) Value() (driver.Value, error)

type Level

type Level int64

func (Level) String

func (l Level) String() string

type ResponseDeliverTx

type ResponseDeliverTx struct {
	Code      uint32          `json:"code,omitempty"              protobuf:"varint,1,opt,name=code,proto3"`
	Data      json.RawMessage `json:"data,omitempty"              protobuf:"bytes,2,opt,name=data,proto3"`
	Log       string          `json:"log,omitempty"               protobuf:"bytes,3,opt,name=log,proto3"`
	Info      string          `json:"info,omitempty"              protobuf:"bytes,4,opt,name=info,proto3"`
	GasWanted int64           `json:"gas_wanted,omitempty,string" protobuf:"varint,5,opt,name=gas_wanted,proto3"`
	GasUsed   int64           `json:"gas_used,omitempty,string"   protobuf:"varint,6,opt,name=gas_used,proto3"`
	Events    []Event         `json:"events,omitempty"            protobuf:"bytes,7,rep,name=events,proto3"`
	Codespace string          `json:"codespace,omitempty"         protobuf:"bytes,8,opt,name=codespace,proto3"`
}

func (*ResponseDeliverTx) IsFailed

func (tx *ResponseDeliverTx) IsFailed() bool

type ResultBlock

type ResultBlock struct {
	BlockID BlockId `json:"block_id"`
	Block   *Block  `json:"block"`
}

ResultBlock is a single block (with meta)

type ResultBlockResults

type ResultBlockResults struct {
	Height                Level                `json:"height,string"`
	TxsResults            []*ResponseDeliverTx `json:"txs_results"`
	BeginBlockEvents      []Event              `json:"begin_block_events"`
	EndBlockEvents        []Event              `json:"end_block_events"`
	ValidatorUpdates      []ValidatorUpdate    `json:"validator_updates"`
	ConsensusParamUpdates *ConsensusParams     `json:"consensus_param_updates"`
}

ResultBlockResults is an ABCI results from a block origin: github.com/celestiaorg/celestia-core@v1.26.2-tm-v0.34.28/rpc/core/types/responses.go

type ValidatorParams

type ValidatorParams struct {
	PubKeyTypes []string `json:"pub_key_types,omitempty" protobuf:"bytes,1,rep,name=pub_key_types,json=pubKeyTypes,proto3"`
}

ValidatorParams restrict the public key types validators can use. NOTE: uses ABCI pubkey naming, not Amino names.

type ValidatorUpdate

type ValidatorUpdate struct {
	// PubKey any   `json:"pub_key"                protobuf:"bytes,1,opt,name=pub_key,json=pubKey,proto3"` // crypto.PublicKey
	Power int64 `json:"power,omitempty,string" protobuf:"varint,2,opt,name=power,proto3"`
}

ValidatorUpdate

type VersionParams

type VersionParams struct {
	AppVersion uint64 `json:"app_version,omitempty,string" protobuf:"varint,1,opt,name=app_version,json=appVersion,proto3"`
}

VersionParams contains the ABCI application version.

Jump to

Keyboard shortcuts

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