hotstuff

package
v0.0.0-...-8ad0a2a Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSnapshot

func NewSnapshot(ids []hots.ID, pks []*bls.PublicKey) *snapshot

Types

type API

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

API is a user facing RPC API to send requests for replicas joining/removing to the Hotstuff network

func (*API) Add

func (api *API) Add(expire rpc.BlockNumber, id uint32, pkbytes hexutil.Bytes, sigbytes hexutil.Bytes) error

func (*API) Aggregate

func (api *API) Aggregate(mulSigbytes []hexutil.Bytes) (hexutil.Bytes, error)

func (*API) GetReplicaInfo

func (api *API) GetReplicaInfo(expire rpc.BlockNumber) ([]replica, error)

func (*API) ProposeAdd

func (api *API) ProposeAdd(expire rpc.BlockNumber, id uint32, pkbytes hexutil.Bytes) (hexutil.Bytes, error)

func (*API) ProposeRemove

func (api *API) ProposeRemove(expire rpc.BlockNumber, id uint32) (hexutil.Bytes, error)

func (*API) Remove

func (api *API) Remove(expire rpc.BlockNumber, id uint32, sigbytes hexutil.Bytes) error

type Config

type Config struct {
	Mine bool

	Id common.ID

	Key *bls.PrivateKey

	ServiceMaker func(consensus.ChainReader) *Service

	ChainReader consensus.ChainReader
}

The config to build the Hotstuff consensus engine(council)

type Council

type Council struct {
	*Legal
	// contains filtered or unexported fields
}

Council is the Hotstuff consensus engine.

func NewCouncil

func NewCouncil(lg *Legal, id hots.ID, key *bls.PrivateKey) *Council

func (*Council) APIs

func (c *Council) APIs(chain consensus.ChainReader) []rpc.API

APIs implements Hotstuff engine apis.

func (*Council) Close

func (c *Council) Close() error

func (*Council) MakeService

func (c *Council) MakeService(chain consensus.ChainReader) *Service

MakeService returns Hotstuff protocol handler service which implements node.Service. Note, the method should only be called once during the registration of an Ethereum node service.

func (*Council) Prepare

func (c *Council) Prepare(chain consensus.ChainReader, header *types.Header) error

Prepare implements consensus.Engine.Prepare, preparing all the consensus fields of the header for running the transactions on top. Furthermore, the consensus state of the Council will be updated and enter a new consensus round to generate quorum certificates more quickly if there are changes in the passed head header.

func (*Council) Prior

func (c *Council) Prior(block *types.Block) []enode.ID

Prior implements handler.priorBroadcastSelector to choose the prior peers for broadcasting the block.

func (*Council) Seal

func (c *Council) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error

Seal generates a new sealing request for the given input block and pushes the result into the given channel.

Note, the method returns immediately and will send the result async. More than one result may also be returned depending on the consensus algorithm.

func (*Council) Sign

func (c *Council) Sign(text []byte) (*bls.PartialSignature, error)

Sign signs the ciphertext using the local private key

func (*Council) Timeout

func (c *Council) Timeout(id hots.ID, view uint64) error

Timeout notifies the council of the remote timed out events.

func (*Council) VerifyAt

func (c *Council) VerifyAt(header *types.Header, sig *bls.PartialSignature, text []byte) error

Verify verifies the validity of a partial signature.

func (*Council) Vote

func (c *Council) Vote(id hots.ID, view uint64, block []byte, sig *bls.PartialSignature) error

Vote notifies the council of the remote voting events.

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

Legal tracks the valid Hotstuff relicas and records their public keys and IDs

func NewLegal

func NewLegal(db ethdb.Database) *Legal

func (*Legal) APIs

func (lg *Legal) APIs(chain consensus.ChainReader) []rpc.API

APIs implements consensus.Engine.APIs.

func (*Legal) Author

func (lg *Legal) Author(header *types.Header) (common.Address, error)

Author implements consensus.Engine.Author and retrieves the Ethereum address of the account that minted the given block.

func (*Legal) CalcDifficulty

func (lg *Legal) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int

CalcDifficulty implements consensus.Engine.CalcDifficulty.

func (*Legal) Close

func (lg *Legal) Close() error

Close implements consensus.Engine.Close.

func (*Legal) Finalize

func (lg *Legal) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction,
	uncles []*types.Header, receipts []*types.Receipt) error

Finalize implements consensus.Engine.Finalize.

func (*Legal) FinalizeAndAssemble

func (lg *Legal) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction,
	uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)

FinalizeAndAssemble implements consensus.Engine.FinalizeAndAssemble.

func (*Legal) Prepare

func (lg *Legal) Prepare(chain consensus.ChainReader, header *types.Header) error

Prepare implements consensus.Engine.Prepare and does nothing.

func (*Legal) Seal

func (lg *Legal) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error

Seal implements consensus.Engine.Seal and does nothing.

func (*Legal) SealHash

func (lg *Legal) SealHash(header *types.Header) (hash common.Hash)

SealHash implements consensus.Engine.SealHash, returns the hash of a block prior to it being sealed.

func (*Legal) VerifyHeader

func (lg *Legal) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error

VerifyHeader implements consensus.Engine.VerifyHeader and checks whether a header conforms to the consensus rules of the Hotstuff engine. Verifying the seal is done here.

func (*Legal) VerifyHeaders

func (lg *Legal) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)

VerifyHeaders implements consensus.Engine.VerifyHeaders, it is similar to VerifyHeader, but verifies a batch of headers concurrently. The method returns a quit channel to abort the operations and a results channel to retrieve the async verifications (the order is that of the input slice).

func (*Legal) VerifySeal

func (lg *Legal) VerifySeal(ChainReader consensus.ChainReader, header *types.Header) error

VerifySeal checks whether the crypto seal on a header is valid according to the consensus rules of the given engine.

func (*Legal) VerifyUncles

func (lg *Legal) VerifyUncles(ChainReader consensus.ChainReader, block *types.Block) error

VerifyUncles implements consensus.Engine.VerifyUncles and verifies that the given block's uncles conform to the consensus rules of Hotstuff engine.

type Service

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

func (*Service) APIs

func (s *Service) APIs() []rpc.API

func (*Service) Protocols

func (s *Service) Protocols() []p2p.Protocol

func (*Service) Start

func (s *Service) Start(server *p2p.Server) error

func (*Service) Stop

func (s *Service) Stop() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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