ecpon

package
v0.0.0-...-10c1c44 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

implements consensus interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadExtra

func ReadExtra(h *types.Header) (*ConsensusGroup, *BlockProof, error)

read a block to get Next Committe info and the correctness proof of the block

func SealHash

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

SealHash returns the hash of a block prior to it being sealed. need to implement

func VerifyExtraData

func VerifyExtraData(nextcommittee *ConsensusGroup, blkproof *BlockProof) error

Types

type API

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

API is a user facing RPC API to allow controlling PON/BADA consensus

func (*API) Name

func (api *API) Name() string

let's implement dummy API

type BlockProof

type BlockProof struct {
	PubKeys  []byte `json:"publickeys"`
	Checksum []byte `json:"checksum"`
	R        []byte `json:"rValue"` // R value of multi signature
	S        []byte `json:"sValue"` /// S value of multi signature
}

func NewBlockProof

func NewBlockProof(sValidators []string, pubkeys []byte, checksum []byte, r []byte, s []byte) *BlockProof

type ConsensusGroup

type ConsensusGroup struct {
	BlockNo uint64 //Block number which this committee works for
	//Validators []enode.ID //validater list, the first one is the leader
	Validators []string // this time, string id used, later I'll use enode.ID

}

func NewConsensusGroup

func NewConsensusGroup(num uint64, validators []string) *ConsensusGroup

type EcPonBada

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

func New

New creates a EcPonBada consensus engine

func (*EcPonBada) APIs

func (c *EcPonBada) APIs(chain consensus.ChainHeaderReader) []rpc.API

APIs implements consensus.Engine, returning the user facing RPC API to allow controlling the signer voting.

func (*EcPonBada) Author

func (c *EcPonBada) Author(header *types.Header) (common.Address, error)

Author implements consensus.Engine, returning the Ethereum address recovered

func (*EcPonBada) CalcDifficulty

func (c *EcPonBada) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *types.Header) *big.Int

let's just return notUsedDifficulty later, we need to implement it.

func (*EcPonBada) Close

func (c *EcPonBada) Close() error

Close implements consensus.Engine. It's a noop for clique as there are no background threads.

func (*EcPonBada) Finalize

func (c *EcPonBada) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header)

Finalize implements consensus.Engine, ensuring no uncles are set, nor block rewards given.

func (*EcPonBada) FinalizeAndAssemble

func (c *EcPonBada) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)

FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set, nor block rewards given, and returns the final block.

func (*EcPonBada) Prepare

func (c *EcPonBada) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error

Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.

func (*EcPonBada) Seal

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

Seal implements consensus.Engine, attempting to create a sealed block using multi signature it is not used, instead, below API is used

func (*EcPonBada) SealEcPonBada

func (c *EcPonBada) SealEcPonBada(chain consensus.ChainHeaderReader, block *types.Block, blockProof *BlockProof, nextcommittee *ConsensusGroup) (*types.Block, error)

Seal implements consensus.Engine, attempting to create a sealed block using multi signature this API is not defined in Consensus Interface EcPonBada, we can seal immediately, we don't need channel we put signature data and next committee information in the extradata field of header

func (*EcPonBada) SealHash

func (c *EcPonBada) SealHash(header *types.Header) common.Hash

SealHash returns the hash of a block prior to it being sealed.

func (*EcPonBada) SetEcRpcHandler

func (c *EcPonBada) SetEcRpcHandler(handler EcRpcCall)

this is the api only supported in EcPonBada consensus api register ecrpchandler

func (*EcPonBada) VerifyHeader

func (c *EcPonBada) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error

VerifyHeader checks whether a header conforms to the consensus rules.

func (*EcPonBada) VerifyHeaders

func (c *EcPonBada) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)

VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers. 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 (*EcPonBada) VerifyUncles

func (c *EcPonBada) VerifyUncles(chain consensus.ChainReader, block *types.Block) error

VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.

type EcRpcCall

type EcRpcCall interface {
	SendVerifySeal(blockno uint64, bhash common.Hash, bproof *BlockProof) error
}

type ExtraData

type ExtraData struct {
	//in fact both the value must not be nil, for easy testing, nil allowed temporarilly
	NextCommittee *ConsensusGroup `rlp:"nil"`
	BlkProof      *BlockProof     `rlp:"nil"`
}

extradata is inserted in block header nextcommittee includes information on next committee members who are reponsible for singing next block blkproof includes mainly signagtures of committee members who validated the block

type ValidatorProof

type ValidatorProof interface{}

ValidatorProof includes the information for convincing the validators are legitimate at the moment, i'll use the empty interface, later, need to define concrete structure

Jump to

Keyboard shortcuts

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