Documentation ¶
Index ¶
- func AppendValidatorsToGenesisBlock(genesis *core.Genesis, validators []istanbul.ValidatorData)
- func New(config *istanbul.Config, db ethdb.Database) consensus.Istanbul
- type API
- func (api *API) AddProxy(url, externalUrl string) (bool, error)
- func (api *API) ForceRoundChange() (bool, error)
- func (api *API) GetCurrentRoundState() (*core.RoundStateSummary, error)
- func (api *API) GetProposer(sequence *rpc.BlockNumber, round *uint64) (common.Address, error)
- func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error)
- func (api *API) GetValEnodeTable() (map[string]*vet.ValEnodeEntryInfo, error)
- func (api *API) GetValidators(number *rpc.BlockNumber) ([]common.Address, error)
- func (api *API) GetVersionCertificateTableInfo() (map[string]*vet.VersionCertificateEntryInfo, error)
- func (api *API) RemoveProxy(url string) (bool, error)
- type Backend
- func (sb *Backend) APIs(chain consensus.ChainReader) []rpc.API
- func (sb *Backend) Address() common.Address
- func (sb *Backend) Author(header *types.Header) (common.Address, error)
- func (sb *Backend) AuthorForBlock(number uint64) common.Address
- func (sb *Backend) Authorize(address common.Address, publicKey *ecdsa.PublicKey, ...)
- func (sb *Backend) BroadcastConsensusMsg(destAddresses []common.Address, payload []byte) error
- func (sb *Backend) CheckSignature(data []byte, address common.Address, sig []byte) error
- func (sb *Backend) Close() error
- func (sb *Backend) Commit(proposal istanbul.Proposal, aggregatedSeal types.IstanbulAggregatedSeal, ...) error
- func (sb *Backend) EpochSize() uint64
- func (sb *Backend) EventMux() *event.TypeMux
- func (sb *Backend) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...)
- func (sb *Backend) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (sb *Backend) GetCurrentHeadBlock() istanbul.Proposal
- func (sb *Backend) GetCurrentHeadBlockAndAuthor() (istanbul.Proposal, common.Address)
- func (sb *Backend) GetValidators(blockNumber *big.Int, headerHash common.Hash) []istanbul.Validator
- func (sb *Backend) HandleMsg(addr common.Address, msg p2p.Msg, peer consensus.Peer) (bool, error)
- func (sb *Backend) Handshake(peer consensus.Peer) (bool, error)
- func (sb *Backend) HasBlock(hash common.Hash, number *big.Int) bool
- func (sb *Backend) IsLastBlockOfEpoch(header *types.Header) bool
- func (sb *Backend) IsProxiedValidator() bool
- func (sb *Backend) IsProxy() bool
- func (sb *Backend) LastSubject() (istanbul.Subject, error)
- func (sb *Backend) LookbackWindow() uint64
- func (sb *Backend) Multicast(destAddresses []common.Address, payload []byte, ethMsgCode uint64) error
- func (sb *Backend) NewChainHead(newBlock *types.Block)
- func (sb *Backend) NewWork() error
- func (sb *Backend) NextBlockValidators(proposal istanbul.Proposal) (istanbul.ValidatorSet, error)
- func (sb *Backend) ParentBlockValidators(proposal istanbul.Proposal) istanbul.ValidatorSet
- func (sb *Backend) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (sb *Backend) RefreshValPeers() error
- func (sb *Backend) RegisterPeer(peer consensus.Peer, isProxiedPeer bool)
- func (sb *Backend) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, ...) error
- func (sb *Backend) SealHash(header *types.Header) common.Hash
- func (sb *Backend) SendDelegateSignMsgToProxiedValidator(msg []byte) error
- func (sb *Backend) SendDelegateSignMsgToProxy(msg []byte) error
- func (sb *Backend) SetBroadcaster(broadcaster consensus.Broadcaster)
- func (sb *Backend) SetChain(chain consensus.ChainReader, currentBlock func() *types.Block, ...)
- func (sb *Backend) SetP2PServer(p2pserver consensus.P2PServer)
- func (sb *Backend) Sign(data []byte) ([]byte, error)
- func (sb *Backend) SignBLSWithCompositeHash(data []byte) (blscrypto.SerializedSignature, error)
- func (sb *Backend) SignBlockHeader(data []byte) (blscrypto.SerializedSignature, error)
- func (sb *Backend) StartAnnouncing() error
- func (sb *Backend) StartValidating(hasBadBlock func(common.Hash) bool, ...) error
- func (sb *Backend) StopAnnouncing() error
- func (sb *Backend) StopValidating() error
- func (sb *Backend) SubscribeNewDelegateSignEvent(ch chan<- istanbul.MessageEvent) event.Subscription
- func (sb *Backend) UnregisterPeer(peer consensus.Peer, isProxiedPeer bool)
- func (sb *Backend) UpdateValSetDiff(chain consensus.ChainReader, header *types.Header, state *state.StateDB) error
- func (sb *Backend) ValidatorAddress() common.Address
- func (sb *Backend) ValidatorElectedAndSignedParentBlock(child *types.Block) (elected bool, inParentSeal bool, countInParentSeal int, missedRounds int64)
- func (sb *Backend) Validators(proposal istanbul.Proposal) istanbul.ValidatorSet
- func (sb *Backend) Verify(proposal istanbul.Proposal) (time.Duration, error)
- func (sb *Backend) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
- func (sb *Backend) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (sb *Backend) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- type QueryEnodeGossipFrequencyState
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendValidatorsToGenesisBlock ¶
func AppendValidatorsToGenesisBlock(genesis *core.Genesis, validators []istanbul.ValidatorData)
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is a user facing RPC API to dump Istanbul state
func (*API) AddProxy ¶
AddProxy peers with a remote node that acts as a proxy, even if slots are full
func (*API) ForceRoundChange ¶
GetCurrentRoundState retrieves the current IBFT RoundState
func (*API) GetCurrentRoundState ¶
func (api *API) GetCurrentRoundState() (*core.RoundStateSummary, error)
GetCurrentRoundState retrieves the current IBFT RoundState
func (*API) GetProposer ¶
GetProposer retrieves the proposer for a given block number (i.e. sequence) and round.
func (*API) GetSnapshot ¶
func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error)
GetSnapshot retrieves the state snapshot at a given block.
func (*API) GetValEnodeTable ¶
func (api *API) GetValEnodeTable() (map[string]*vet.ValEnodeEntryInfo, error)
Retrieve the Validator Enode Table
func (*API) GetValidators ¶
GetValidators retrieves the list validators that must sign a given block.
func (*API) GetVersionCertificateTableInfo ¶
func (api *API) GetVersionCertificateTableInfo() (map[string]*vet.VersionCertificateEntryInfo, error)
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
func (*Backend) APIs ¶
func (sb *Backend) APIs(chain consensus.ChainReader) []rpc.API
APIs returns the RPC APIs this consensus engine provides.
func (*Backend) 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 (*Backend) AuthorForBlock ¶
AuthorForBlock implements istanbul.Backend.AuthorForBlock
func (*Backend) Authorize ¶
func (sb *Backend) Authorize(address common.Address, publicKey *ecdsa.PublicKey, decryptFn istanbul.DecryptFn, signFn istanbul.SignerFn, signHashBLSFn istanbul.BLSSignerFn, signMessageBLSFn istanbul.BLSMessageSignerFn)
Authorize implements istanbul.Backend.Authorize
func (*Backend) BroadcastConsensusMsg ¶
BroadcastConsensusMsg implements istanbul.Backend.BroadcastConsensusMsg This function will wrap the consensus message in a fwdMessage if it's a proxied validator. It will then multicast the msg (the wrapped or original version) to the other validators and send it to itself.
func (*Backend) CheckSignature ¶
CheckSignature implements istanbul.Backend.CheckSignature
func (*Backend) Commit ¶
func (sb *Backend) Commit(proposal istanbul.Proposal, aggregatedSeal types.IstanbulAggregatedSeal, aggregatedEpochValidatorSetSeal types.IstanbulEpochValidatorSetSeal) error
Commit implements istanbul.Backend.Commit
func (*Backend) Finalize ¶
func (sb *Backend) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction)
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 (*Backend) FinalizeAndAssemble ¶
func (sb *Backend) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, receipts []*types.Receipt, randomness *types.Randomness) (*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 (*Backend) GetCurrentHeadBlock ¶
GetCurrentHeadBlock retrieves the last block
func (*Backend) GetCurrentHeadBlockAndAuthor ¶
GetCurrentHeadBlockAndAuthor retrieves the last block alongside the coinbase address for it
func (*Backend) GetValidators ¶
func (*Backend) IsLastBlockOfEpoch ¶
Returns whether or not a particular header represents the last block in the epoch.
func (*Backend) IsProxiedValidator ¶
func (*Backend) LookbackWindow ¶
Returns the size of the lookback window for calculating uptime (in blocks)
func (*Backend) Multicast ¶
func (sb *Backend) Multicast(destAddresses []common.Address, payload []byte, ethMsgCode uint64) error
Multicast implements istanbul.Backend.Multicast Multicast will send the eth message (with the message's payload and msgCode field set to the params payload and ethMsgCode respectively) to the nodes with the signing address in the destAddresses param. If this node is proxied and destAddresses is not nil, the message will be wrapped in an istanbul.ForwardMessage to ensure the proxy sends it to the correct destAddresses. If the destAddresses param is set to nil, then this function will send the message to all connected peers.
func (*Backend) NewChainHead ¶
Actions triggered by a new block being added to the chain.
func (*Backend) NewWork ¶
This function is called by miner/worker.go whenever it's mainLoop gets a newWork event.
func (*Backend) NextBlockValidators ¶
func (*Backend) ParentBlockValidators ¶
func (sb *Backend) ParentBlockValidators(proposal istanbul.Proposal) istanbul.ValidatorSet
ParentBlockValidators implements istanbul.Backend.ParentBlockValidators
func (*Backend) Prepare ¶
Prepare initializes the consensus fields of a block header according to the rules of a particular engine. The changes are executed inline.
func (*Backend) RefreshValPeers ¶
RefreshValPeers will create 'validator' type peers to all the valset validators, and disconnect from the peers that are not part of the valset. It will also disconnect all validator connections if this node is not a validator. Note that adding and removing validators are idempotent operations. If the validator being added or removed is already added or removed, then a no-op will be done.
func (*Backend) RegisterPeer ¶
func (*Backend) Seal ¶
func (sb *Backend) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error
Seal generates a new block for the given input block with the local miner's seal place on top.
func (*Backend) SendDelegateSignMsgToProxiedValidator ¶
SendDelegateSignMsgToProxiedValidator sends an istanbulDelegateSign message to a proxied validator if one exists
func (*Backend) SendDelegateSignMsgToProxy ¶
SendDelegateSignMsgToProxy sends an istanbulDelegateSign message to a proxy if one exists
func (*Backend) SetBroadcaster ¶
func (sb *Backend) SetBroadcaster(broadcaster consensus.Broadcaster)
SetBroadcaster implements consensus.Handler.SetBroadcaster
func (*Backend) SetP2PServer ¶
SetP2PServer implements consensus.Handler.SetP2PServer
func (*Backend) SignBLSWithCompositeHash ¶
func (sb *Backend) SignBLSWithCompositeHash(data []byte) (blscrypto.SerializedSignature, error)
func (*Backend) SignBlockHeader ¶
func (sb *Backend) SignBlockHeader(data []byte) (blscrypto.SerializedSignature, error)
func (*Backend) StartAnnouncing ¶
StartAnnouncing implements consensus.Istanbul.StartAnnouncing
func (*Backend) StartValidating ¶
func (sb *Backend) StartValidating(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) error
StartValidating implements consensus.Istanbul.StartValidating
func (*Backend) StopAnnouncing ¶
StopAnnouncing implements consensus.Istanbul.StopAnnouncing
func (*Backend) StopValidating ¶
StopValidating implements consensus.Istanbul.StopValidating
func (*Backend) SubscribeNewDelegateSignEvent ¶
func (sb *Backend) SubscribeNewDelegateSignEvent(ch chan<- istanbul.MessageEvent) event.Subscription
SubscribeNewDelegateSignEvent subscribes a channel to any new delegate sign messages
func (*Backend) UnregisterPeer ¶
func (*Backend) UpdateValSetDiff ¶
func (sb *Backend) UpdateValSetDiff(chain consensus.ChainReader, header *types.Header, state *state.StateDB) error
UpdateValSetDiff will update the validator set diff in the header, if the mined header is the last block of the epoch
func (*Backend) ValidatorAddress ¶
func (*Backend) ValidatorElectedAndSignedParentBlock ¶
func (sb *Backend) ValidatorElectedAndSignedParentBlock(child *types.Block) (elected bool, inParentSeal bool, countInParentSeal int, missedRounds int64)
Determine if this validator signed the parent of the supplied block: First check the grandparent's validator set. If not elected, it didn't. Then, check the parent seal on the supplied block. We cannot determine any specific info from the validators in the seal of the parent block, because different nodes circulate different versions. It only becomes canonical when the child block is proposed.
func (*Backend) Validators ¶
func (sb *Backend) Validators(proposal istanbul.Proposal) istanbul.ValidatorSet
Validators implements istanbul.Backend.Validators
func (*Backend) VerifyHeader ¶
VerifyHeader checks whether a header conforms to the consensus rules of a given engine. Verifies the seal regardless of given "seal" argument.
func (*Backend) VerifyHeaders ¶
func (sb *Backend) 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 (*Backend) VerifySeal ¶
VerifySeal checks whether the crypto seal on a header is valid according to the consensus rules of the given engine.
type QueryEnodeGossipFrequencyState ¶
type QueryEnodeGossipFrequencyState int
QueryEnodeGossipFrequencyState specifies how frequently to gossip query enode messages
const ( // HighFreqBeforeFirstPeerState will send out a query enode message every 1 minute until the first peer is established HighFreqBeforeFirstPeerState QueryEnodeGossipFrequencyState = iota // HighFreqAfterFirstPeerState will send out an query enode message every 1 minute for the first 10 query enode messages after the first peer is established. // This is on the assumption that when this node first establishes a peer, the p2p network that this node is in may // be partitioned with the broader p2p network. We want to give that p2p network some time to connect to the broader p2p network. HighFreqAfterFirstPeerState // LowFreqState will send out an query every config.AnnounceQueryEnodeGossipPeriod seconds LowFreqState )
type Snapshot ¶
type Snapshot struct { Epoch uint64 // The number of blocks for each epoch Number uint64 // Block number where the snapshot was created Hash common.Hash // Block hash where the snapshot was created ValSet istanbul.ValidatorSet // Set of authorized validators at this moment }
Snapshot is the state of the authorization voting at a given point in time.
func (*Snapshot) MarshalJSON ¶
MarshalJSON to a json byte array
func (*Snapshot) UnmarshalJSON ¶
UnmarshalJSON from a json byte array