bdls_engine

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2020 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// statistics stored in account storage trie of GasFeeAddress
	// global
	KeyTotalGasFeeRewards    = "/v1/stats/totalGasFeeRewards"
	KeyTotalValidatorRewards = "/v1/stats/totalValidatorRewards"
	KeyTotalProposerRewards  = "/v1/stats/totalProposerRewards"

	// account
	KeyAccountGasFeeRewards    = "/v1/stats/%s/totalGasFeeRewards"
	KeyAccountValidatorRewards = "/v1/stats/%s/totalValidatorRewards"
	KeyAccountProposerRewards  = "/v1/stats/%s/totalProposerRewards"
)

Variables

View Source
var (
	// Proposer's SPA reward
	ProposerReward       = new(big.Int).Mul(big.NewInt(1000), big.NewInt(params.Ether))
	TotalValidatorReward = new(big.Int).Mul(big.NewInt(3000), big.NewInt(params.Ether))
	// Account to deposit gas fee
	GasFeeAddress = common.HexToAddress("0xdddddddddddddddddddddddddddddddddddddddd")
	Multiplier    = big.NewInt(1e18)
)
View Source
var (
	ErrInvalidLengthEngine        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowEngine          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupEngine = fmt.Errorf("proto: unexpected end of group")
)
View Source
var EngineMessageType_name = map[int32]string{
	0: "Proposal",
	1: "Consensus",
}
View Source
var EngineMessageType_value = map[string]int32{
	"Proposal":  0,
	"Consensus": 1,
}

Functions

func PrintPanicStack

func PrintPanicStack()

func PubKeyToIdentity

func PubKeyToIdentity(pubkey *ecdsa.PublicKey) (ret bdls.Identity)

PublicKey to Identity conversion, for use in BDLS

Types

type API

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

API is a user facing RPC API to dump BDLS state

func (*API) GetAccountGasFeeRewards

func (api *API) GetAccountGasFeeRewards(account common.Address) (total *big.Int, err error)

GetAccountGasFeeRewards returns the total staked value

func (*API) GetAccountProposerRewards

func (api *API) GetAccountProposerRewards(account common.Address) (total *big.Int, err error)

GetAccountProposerRewards returns the total staked value

func (*API) GetAccountValidatorRewards

func (api *API) GetAccountValidatorRewards(account common.Address) (total *big.Int, err error)

GetAccountValidatorRewards returns the total staked value

func (*API) GetStaker

func (api *API) GetStaker(account common.Address) (stakers *committee.Staker, err error)

GetStaker returns a staker's information

func (*API) GetStakers

func (api *API) GetStakers() (stakers []*committee.Staker, err error)

GetStakers returns a map for all stakers and it's value

func (*API) GetTotalGasFeeRewards

func (api *API) GetTotalGasFeeRewards() (total *big.Int, err error)

GetTotalGasFeeRewards returns the total staked value

func (*API) GetTotalProposerRewards

func (api *API) GetTotalProposerRewards() (total *big.Int, err error)

GetTotalProposerRewards returns the total staked value

func (*API) GetTotalStaked

func (api *API) GetTotalStaked() (total *big.Int, err error)

GetTotalStake returns the total staked value

func (*API) GetTotalStakingOperations

func (api *API) GetTotalStakingOperations() (count uint64, err error)

GetTotalStakingOperations returns the total staking operations performed

func (*API) GetTotalValidatorRewards

func (api *API) GetTotalValidatorRewards() (total *big.Int, err error)

GetTotalValidatorRewards returns the total staked value

func (*API) GetValidators

func (api *API) GetValidators(number *rpc.BlockNumber) ([]common.Address, error)

GetValidators returns the validator addresses at specific block height

func (*API) GetValidatorsAtHash

func (api *API) GetValidatorsAtHash(hash common.Hash) ([]common.Address, error)

GetValidatorsAtHash returns the validator addresses at specific block hash

func (*API) Version

func (api *API) Version() string

type BDLSEngine

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

BDLSEngine implements BDLS-based blockchain consensus engine

func New

func New(accountManager *accounts.Manager, mux *event.TypeMux, db ethdb.Database) *BDLSEngine

New creates a ethereum compatible BDLS engine with account manager for signing and mux for message exchanging

func (*BDLSEngine) APIs

func (e *BDLSEngine) APIs(chain consensus.ChainReader) []rpc.API

APIs returns the RPC APIs this consensus engine provides.

func (*BDLSEngine) Author

func (e *BDLSEngine) Author(header *types.Header) (common.Address, error)

Author retrieves the Ethereum address of the account that minted the given block, which may be different from the header's coinbase if a consensus engine is based on signatures.

func (*BDLSEngine) CalcDifficulty

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

CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have.

func (*BDLSEngine) Close

func (e *BDLSEngine) Close() error

Close terminates any background threads maintained by the consensus engine.

func (*BDLSEngine) Finalize

func (e *BDLSEngine) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header)

Finalize runs any post-transaction state modifications (e.g. block rewards) but does not assemble the block.

Note: The block header and state database might be updated to reflect any consensus rules that happen at finalization (e.g. block rewards).

func (*BDLSEngine) FinalizeAndAssemble

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

FinalizeAndAssemble runs any post-transaction state modifications (e.g. block rewards) and assembles the final block.

Note: The block header and state database might be updated to reflect any consensus rules that happen at finalization (e.g. block rewards).

func (*BDLSEngine) Prepare

func (e *BDLSEngine) Prepare(chain consensus.ChainReader, header *types.Header) error

Prepare initializes the fields of a block header according to the rules of a particular engine. The changes are executed inline.

func (*BDLSEngine) Seal

func (e *BDLSEngine) 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 (*BDLSEngine) SealHash

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

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

func (*BDLSEngine) SetBlockValidator

func (e *BDLSEngine) SetBlockValidator(hasBadBlock func(common.Hash) bool,
	processBlock func(*types.Block, *state.StateDB) (types.Receipts, []*types.Log, uint64, error),
	validateState func(*types.Block, *state.StateDB, types.Receipts, uint64) error,
	stateAt func(hash common.Hash) (*state.StateDB, error))

SetBlockValidator starts the validating engine, this will be set by miner while starting.

func (*BDLSEngine) VerifyHeader

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

VerifyHeader checks whether a header conforms to the consensus rules of a given engine. Verifying the seal may be done optionally here, or explicitly via the VerifySeal method.

func (*BDLSEngine) VerifyHeaders

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

VerifyHeaders 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 (*BDLSEngine) VerifySeal

func (e *BDLSEngine) VerifySeal(chain 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. Fields to verify:

  • Signature
  • Decision
  • R

func (*BDLSEngine) VerifyUncles

func (e *BDLSEngine) VerifyUncles(chain consensus.ChainReader, block *types.Block) error

VerifyUncles verifies that the given block's uncles conform to the consensus rules of a given engine.

type EngineMessage

type EngineMessage struct {
	// Type of this message
	Type EngineMessageType `protobuf:"varint,1,opt,name=Type,proto3,enum=bdls_engine.EngineMessageType" json:"Type,omitempty"`
	// the Message in bytes
	Message              []byte   `protobuf:"bytes,2,opt,name=Message,proto3" json:"Message,omitempty"`
	Nonce                uint32   `protobuf:"varint,3,opt,name=Nonce,proto3" json:"Nonce,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Message defines a engine encapsulate message

func (*EngineMessage) Descriptor

func (*EngineMessage) Descriptor() ([]byte, []int)

func (*EngineMessage) GetMessage

func (m *EngineMessage) GetMessage() []byte

func (*EngineMessage) GetNonce

func (m *EngineMessage) GetNonce() uint32

func (*EngineMessage) GetType

func (m *EngineMessage) GetType() EngineMessageType

func (*EngineMessage) Marshal

func (m *EngineMessage) Marshal() (dAtA []byte, err error)

func (*EngineMessage) MarshalTo

func (m *EngineMessage) MarshalTo(dAtA []byte) (int, error)

func (*EngineMessage) MarshalToSizedBuffer

func (m *EngineMessage) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*EngineMessage) ProtoMessage

func (*EngineMessage) ProtoMessage()

func (*EngineMessage) Reset

func (m *EngineMessage) Reset()

func (*EngineMessage) Size

func (m *EngineMessage) Size() (n int)

func (*EngineMessage) String

func (m *EngineMessage) String() string

func (*EngineMessage) Unmarshal

func (m *EngineMessage) Unmarshal(dAtA []byte) error

func (*EngineMessage) XXX_DiscardUnknown

func (m *EngineMessage) XXX_DiscardUnknown()

func (*EngineMessage) XXX_Marshal

func (m *EngineMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*EngineMessage) XXX_Merge

func (m *EngineMessage) XXX_Merge(src proto.Message)

func (*EngineMessage) XXX_Size

func (m *EngineMessage) XXX_Size() int

func (*EngineMessage) XXX_Unmarshal

func (m *EngineMessage) XXX_Unmarshal(b []byte) error

type EngineMessageType

type EngineMessageType int32

MessageType defines supported message types

const (
	// Proposal message
	EngineMessageType_Proposal EngineMessageType = 0
	// Consensus message
	EngineMessageType_Consensus EngineMessageType = 1
)

func (EngineMessageType) EnumDescriptor

func (EngineMessageType) EnumDescriptor() ([]byte, []int)

func (EngineMessageType) String

func (x EngineMessageType) String() string

type MessageInput

type MessageInput []byte

protocol manager will deliver the incoming consensus message via this type to this engine

type MessageOutput

type MessageOutput []byte

protocol manager will subscribe and broadcast this type of message

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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