Documentation ¶
Index ¶
- Variables
- func BytesToG1Jac(ipoints [][48]byte) []bls381.G1Jac
- func BytesToG2Jac(ipoints [][96]byte) []bls381.G2Jac
- func CheckValidatorSignature(valSet ValidatorSet, data []byte, sig []byte) (common.Address, error)
- func G1JacToBytes(points []bls381.G1Jac) [][48]byte
- func G2JacToBytes(points []bls381.G2Jac) [][96]byte
- func GetSignatureAddress(data []byte, sig []byte) (common.Address, error)
- func NodeDataDecode(nData NodeData) crypto.NodeData
- func RLPHash(v interface{}) (h common.Hash)
- func RecDataDecode(recData RecData) crypto.RecData
- func RoundDataDecode(rData RoundData) crypto.RoundData
- type Backend
- type Beacon
- type Commit
- type Commitment
- type Config
- type Decide
- type FinalCommittedEvent
- type MessageEvent
- type NizkProof
- type NizkProofMixed
- type NodeData
- type Prepare
- type Preprepare
- type PrivateData
- type Proposal
- type ProposalSelector
- type ProposerPolicy
- type RecData
- type Reconstruct
- type Request
- type RequestEvent
- type RoundData
- type Subject
- type Validator
- type ValidatorSet
- type Validators
- type View
Constants ¶
This section is empty.
Variables ¶
var ( // current validator set. ErrUnauthorizedAddress = errors.New("unauthorized address") // ErrStoppedEngine is returned if the engine is stopped ErrStoppedEngine = errors.New("stopped engine") // ErrStartedEngine is returned if the engine is already started ErrStartedEngine = errors.New("started engine") )
var DefaultConfig = &Config{ RequestTimeout: 10000, BlockPeriod: 1, ProposerPolicy: RoundRobin, Epoch: 30000, Ceil2Nby3Block: big.NewInt(0), AllowedFutureBlockTime: 0, StartSeq: 10, ForwardSeq: 0, NodeIndex: 0, Local: false, }
Functions ¶
func BytesToG1Jac ¶
func BytesToG2Jac ¶
func CheckValidatorSignature ¶
func G1JacToBytes ¶
func G2JacToBytes ¶
func GetSignatureAddress ¶
GetSignatureAddress gets the signer address from the signature
func NodeDataDecode ¶
func RecDataDecode ¶
func RoundDataDecode ¶
Types ¶
type Backend ¶
type Backend interface { // Address returns the owner's address Address() common.Address // Validators returns the validator set Validators(proposal Proposal) ValidatorSet // EventMux returns the event mux in backend EventMux() *event.TypeMux // Broadcast sends a message to all validators (include self) Broadcast(valSet ValidatorSet, payload []byte) error // SendToNode sends a message to the recipient with the given address SendToNode(addr common.Address, payload []byte) error // Gossip sends a message to all validators (exclude self) Gossip(valSet ValidatorSet, payload []byte) error // Commit delivers an approved proposal to backend. // The delivered proposal will be put into blockchain. Commit(proposal Proposal, seals [][]byte) error // Verify verifies the proposal. If a consensus.ErrFutureBlock error is returned, // the time difference of the proposal and current time is also returned. Verify(Proposal) (time.Duration, error) // Sign signs input data with the backend's private key Sign([]byte) ([]byte, error) // CheckSignature verifies the signature by checking if it's signed by // the given validator CheckSignature(data []byte, addr common.Address, sig []byte) error // LastProposal retrieves latest committed proposal and the address of proposer LastProposal() (Proposal, common.Address) // HasPropsal checks if the combination of the given hash and height matches any existing blocks HasPropsal(hash common.Hash, number *big.Int) bool // GetProposer returns the proposer of the given block height GetProposer(number uint64) common.Address // ParentValidators returns the validator set of the given proposal's parent block ParentValidators(proposal Proposal) ValidatorSet // HasBadBlock returns whether the block with the hash is a bad block HasBadProposal(hash common.Hash) bool Close() error }
Backend provides application specific functions for Istanbul core
type Commitment ¶
type Commitment struct {
NData NodeData
}
Commitment is sent during the commitment phase
type Config ¶
type Config struct { RequestTimeout uint64 `toml:",omitempty"` // The timeout for each Istanbul round in milliseconds. BlockPeriod uint64 `toml:",omitempty"` // Default minimum difference between two consecutive block's timestamps in second ProposerPolicy ProposerPolicy `toml:",omitempty"` // The policy for proposer selection Epoch uint64 `toml:",omitempty"` // The number of blocks after which to checkpoint and reset the pending votes Ceil2Nby3Block *big.Int `toml:",omitempty"` // Number of confirmations required to move from one state to next [2F + 1 to Ceil(2N/3)] AllowedFutureBlockTime uint64 `toml:",omitempty"` // Max time (in seconds) from current time allowed for blocks, before they're considered future blocks StartSeq uint64 ForwardSeq uint64 NodeIndex int Local bool }
type FinalCommittedEvent ¶
type FinalCommittedEvent struct { }
FinalCommittedEvent is posted when a proposal is committed
type MessageEvent ¶
type MessageEvent struct {
Payload []byte
}
MessageEvent is posted for Istanbul engine communication
type NizkProofMixed ¶
type NodeData ¶
type NodeData struct { Round uint64 Root common.Hash // Nil root indicates commitment phase poly. commitment Points [][96]byte EncEvals [][48]byte Proofs []NizkProofMixed IndexSet []uint64 }
func NodeDataEncode ¶
type Preprepare ¶
type PrivateData ¶
type PrivateData struct {
RData RoundData
}
PrivateData has the data a leader privately sends to a node
type Proposal ¶
type Proposal interface { // Number retrieves the sequence number of this proposal. Number() *big.Int // Hash retrieves the hash of this proposal. Hash() common.Hash RBRoot() common.Hash Commitments() [][96]byte IndexSet() []uint64 EncEvals() [][48]byte UpdateDRB([]uint64, [][96]byte, [][48]byte, common.Hash) EncodeRLP(w io.Writer) error DecodeRLP(s *rlp.Stream) error String() string }
Proposal supports retrieving height and serialized block to be used during Istanbul consensus.
type ProposalSelector ¶
type ProposalSelector func(ValidatorSet, common.Address, uint64) Validator
type Reconstruct ¶
Reconstruct for the reconstruction phase
type RequestEvent ¶
type RequestEvent struct {
Proposal Proposal
}
RequestEvent is posted to propose a proposal
type RoundData ¶
type RoundData struct { Round uint64 Root common.Hash IndexSet []common.Address Proofs []NizkProofMixed }
func RoundDataEncode ¶
type Subject ¶
func (*Subject) DecodeRLP ¶
DecodeRLP implements rlp.Decoder, and load the consensus fields from a RLP stream.
type ValidatorSet ¶
type ValidatorSet interface { // Calculate the proposer CalcProposer(lastProposer common.Address, round uint64) // Returns the future proposer GetFutProposer(common.Address, uint64, uint64) common.Address // Return the validator size Size() int // Return the validator array List() []Validator // Get validator by index GetByIndex(i uint64) Validator // Get validator by given address GetByAddress(addr common.Address) (int, Validator) // Get current proposer GetProposer() Validator // Check whether the validator with given address is a proposer IsProposer(address common.Address) bool // Add validator AddValidator(address common.Address) bool // Remove validator RemoveValidator(address common.Address) bool // Copy validator set Copy() ValidatorSet // Get the maximum number of faulty nodes F() int // Get proposer policy Policy() ProposerPolicy }
type Validators ¶
type Validators []Validator
func (Validators) Len ¶
func (slice Validators) Len() int
func (Validators) Less ¶
func (slice Validators) Less(i, j int) bool
func (Validators) Swap ¶
func (slice Validators) Swap(i, j int)
type View ¶
View includes a round number and a sequence number. Sequence is the block number we'd like to commit. Each round has a number and is composed by 3 steps: preprepare, prepare and commit.
If the given block is not accepted by validators, a round change will occur and the validators start a new round with round+1.
func (*View) DecodeRLP ¶
DecodeRLP implements rlp.Decoder, and load the consensus fields from a RLP stream.