casper

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Casper

type Casper struct {
	// contains filtered or unexported fields
}

Casper is BFT based proof of stack consensus algorithm, it provides safety and liveness in theory, it's design mainly refers to https://github.com/ethereum/research/blob/master/papers/casper-basics/casper_basics.pdf

func NewCasper

func NewCasper(store state.Store, queue msgQueue, checkpoints []*state.Checkpoint) *Casper

NewCasper create a new instance of Casper argument checkpoints load the checkpoints from leveldb the first element of checkpoints must genesis checkpoint or the last finalized checkpoint in order to reduce memory space the others must be successors of first one

func (*Casper) ApplyBlock

func (c *Casper) ApplyBlock(block *types.Block) (bc.Hash, error)

ApplyBlock used to receive a new block from upper layer, it provides idempotence and parse the vote and mortgage from the transactions, then save to the checkpoint the tree of checkpoint will grow with the arrival of new blocks it will return verification when an epoch is reached and the current node is the validator, otherwise return nil the chain module must broadcast the verification

func (*Casper) AuthVerification

func (c *Casper) AuthVerification(msg *ValidCasperSignMsg) error

AuthVerification verify whether the Verification is legal. the status of source checkpoint must justified, and an individual validator ν must not publish two distinct Verification ⟨ν,s1,t1,h(s1),h(t1)⟩ and ⟨ν,s2,t2,h(s2),h(t2)⟩, such that either: h(t1) = h(t2) OR h(s1) < h(s2) < h(t2) < h(t1)

func (*Casper) BestChain

func (c *Casper) BestChain() bc.Hash

func (*Casper) LastFinalized

func (c *Casper) LastFinalized() (uint64, bc.Hash)

LastFinalized return the block height and block hash which is finalized at last

func (*Casper) LastJustified

func (c *Casper) LastJustified() (uint64, bc.Hash)

LastJustified return the block height and block hash which is justified at last

func (*Casper) ParentCheckpoint

func (c *Casper) ParentCheckpoint(blockHash *bc.Hash) (*state.Checkpoint, error)

func (*Casper) ParentCheckpointByPrevHash

func (c *Casper) ParentCheckpointByPrevHash(prevBlockHash *bc.Hash) (*state.Checkpoint, error)

func (*Casper) RollbackCh

func (c *Casper) RollbackCh() <-chan *RollbackMsg

type RollbackMsg

type RollbackMsg struct {
	BestHash bc.Hash
	Reply    chan error
}

RollbackMsg sent the rollback msg to chain core

type ValidCasperSignMsg

type ValidCasperSignMsg struct {
	SourceHash bc.Hash
	TargetHash bc.Hash
	Signature  []byte
	PubKey     string
}

Jump to

Keyboard shortcuts

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