Documentation ¶
Index ¶
- Constants
- Variables
- func PrintPanicStack()
- func PubKeyToIdentity(pubkey *ecdsa.PublicKey) (ret bdls.Identity)
- type API
- func (api *API) GetAccountGasFeeRewards(account common.Address) (total *big.Int, err error)
- func (api *API) GetAccountProposerRewards(account common.Address) (total *big.Int, err error)
- func (api *API) GetAccountValidatorRewards(account common.Address) (total *big.Int, err error)
- func (api *API) GetStaker(account common.Address) (stakers *committee.Staker, err error)
- func (api *API) GetStakers() (stakers []*committee.Staker, err error)
- func (api *API) GetTotalGasFeeRewards() (total *big.Int, err error)
- func (api *API) GetTotalProposerRewards() (total *big.Int, err error)
- func (api *API) GetTotalStaked() (total *big.Int, err error)
- func (api *API) GetTotalStakingOperations() (count uint64, err error)
- func (api *API) GetTotalValidatorRewards() (total *big.Int, err error)
- func (api *API) GetValidators(number *rpc.BlockNumber) ([]common.Address, error)
- func (api *API) GetValidatorsAtHash(hash common.Hash) ([]common.Address, error)
- func (api *API) Version() string
- type BDLSEngine
- func (e *BDLSEngine) APIs(chain consensus.ChainReader) []rpc.API
- func (e *BDLSEngine) Author(header *types.Header) (common.Address, error)
- func (e *BDLSEngine) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
- func (e *BDLSEngine) Close() error
- func (e *BDLSEngine) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...)
- func (e *BDLSEngine) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (e *BDLSEngine) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (e *BDLSEngine) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, ...) error
- func (e *BDLSEngine) SealHash(header *types.Header) (hash common.Hash)
- func (e *BDLSEngine) SetBlockValidator(hasBadBlock func(common.Hash) bool, ...)
- func (e *BDLSEngine) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
- func (e *BDLSEngine) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (e *BDLSEngine) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (e *BDLSEngine) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- type EngineMessage
- func (*EngineMessage) Descriptor() ([]byte, []int)
- func (m *EngineMessage) GetMessage() []byte
- func (m *EngineMessage) GetNonce() uint32
- func (m *EngineMessage) GetType() EngineMessageType
- func (m *EngineMessage) Marshal() (dAtA []byte, err error)
- func (m *EngineMessage) MarshalTo(dAtA []byte) (int, error)
- func (m *EngineMessage) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*EngineMessage) ProtoMessage()
- func (m *EngineMessage) Reset()
- func (m *EngineMessage) Size() (n int)
- func (m *EngineMessage) String() string
- func (m *EngineMessage) Unmarshal(dAtA []byte) error
- func (m *EngineMessage) XXX_DiscardUnknown()
- func (m *EngineMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *EngineMessage) XXX_Merge(src proto.Message)
- func (m *EngineMessage) XXX_Size() int
- func (m *EngineMessage) XXX_Unmarshal(b []byte) error
- type EngineMessageType
- type MessageInput
- type MessageOutput
Constants ¶
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 ¶
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) )
var ( ErrInvalidLengthEngine = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowEngine = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupEngine = fmt.Errorf("proto: unexpected end of group") )
var EngineMessageType_name = map[int32]string{
0: "Proposal",
1: "Consensus",
}
var EngineMessageType_value = map[string]int32{
"Proposal": 0,
"Consensus": 1,
}
Functions ¶
func PrintPanicStack ¶
func PrintPanicStack()
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 ¶
GetAccountGasFeeRewards returns the total staked value
func (*API) GetAccountProposerRewards ¶
GetAccountProposerRewards returns the total staked value
func (*API) GetAccountValidatorRewards ¶
GetAccountValidatorRewards returns the total staked value
func (*API) GetStakers ¶
GetStakers returns a map for all stakers and it's value
func (*API) GetTotalGasFeeRewards ¶
GetTotalGasFeeRewards returns the total staked value
func (*API) GetTotalProposerRewards ¶
GetTotalProposerRewards returns the total staked value
func (*API) GetTotalStaked ¶
GetTotalStake returns the total staked value
func (*API) GetTotalStakingOperations ¶
GetTotalStakingOperations returns the total staking operations performed
func (*API) GetTotalValidatorRewards ¶
GetTotalValidatorRewards returns the total staked value
func (*API) GetValidators ¶
GetValidators returns the validator addresses at specific block height
func (*API) GetValidatorsAtHash ¶
GetValidatorsAtHash returns the validator addresses at specific block hash
type BDLSEngine ¶
type BDLSEngine struct {
// contains filtered or unexported fields
}
BDLSEngine implements BDLS-based blockchain consensus engine
func New ¶
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 ¶
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) 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