backend

package
v0.0.0-...-f5c8f65 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: GPL-3.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendValidatorsToGenesisBlock

func AppendValidatorsToGenesisBlock(genesis *core.Genesis, validators []istanbul.ValidatorData)

func New

New creates an Ethereum backend for Istanbul core engine.

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

func (api *API) AddProxy(url, externalUrl string) (bool, error)

AddProxy peers with a remote node that acts as a proxy, even if slots are full

func (*API) ForceRoundChange

func (api *API) ForceRoundChange() (bool, error)

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

func (api *API) GetProposer(sequence *rpc.BlockNumber, round *uint64) (common.Address, error)

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

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

GetValidators retrieves the list validators that must sign a given block.

func (*API) GetVersionCertificateTableInfo

func (api *API) GetVersionCertificateTableInfo() (map[string]*vet.VersionCertificateEntryInfo, error)

func (*API) RemoveProxy

func (api *API) RemoveProxy(url string) (bool, error)

RemoveProxy removes a node from acting as a proxy

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) Address

func (sb *Backend) Address() common.Address

Address implements istanbul.Backend.Address

func (*Backend) Author

func (sb *Backend) 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 (*Backend) AuthorForBlock

func (sb *Backend) AuthorForBlock(number uint64) common.Address

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

func (sb *Backend) BroadcastConsensusMsg(destAddresses []common.Address, payload []byte) error

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

func (sb *Backend) CheckSignature(data []byte, address common.Address, sig []byte) error

CheckSignature implements istanbul.Backend.CheckSignature

func (*Backend) Close

func (sb *Backend) Close() error

Close the backend

func (*Backend) Commit

func (sb *Backend) Commit(proposal istanbul.Proposal, aggregatedSeal types.IstanbulAggregatedSeal, aggregatedEpochValidatorSetSeal types.IstanbulEpochValidatorSetSeal) error

Commit implements istanbul.Backend.Commit

func (*Backend) EpochSize

func (sb *Backend) EpochSize() uint64

Returns the size of epochs in blocks.

func (*Backend) EventMux

func (sb *Backend) EventMux() *event.TypeMux

EventMux implements istanbul.Backend.EventMux

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

func (sb *Backend) GetCurrentHeadBlock() istanbul.Proposal

GetCurrentHeadBlock retrieves the last block

func (*Backend) GetCurrentHeadBlockAndAuthor

func (sb *Backend) GetCurrentHeadBlockAndAuthor() (istanbul.Proposal, common.Address)

GetCurrentHeadBlockAndAuthor retrieves the last block alongside the coinbase address for it

func (*Backend) GetValidators

func (sb *Backend) GetValidators(blockNumber *big.Int, headerHash common.Hash) []istanbul.Validator

func (*Backend) HandleMsg

func (sb *Backend) HandleMsg(addr common.Address, msg p2p.Msg, peer consensus.Peer) (bool, error)

HandleMsg implements consensus.Handler.HandleMsg

func (*Backend) Handshake

func (sb *Backend) Handshake(peer consensus.Peer) (bool, error)

Handshake allows the initiating peer to identify itself as a validator

func (*Backend) HasBlock

func (sb *Backend) HasBlock(hash common.Hash, number *big.Int) bool

HasBlock implements istanbul.Backend.HasBlock

func (*Backend) IsLastBlockOfEpoch

func (sb *Backend) IsLastBlockOfEpoch(header *types.Header) bool

Returns whether or not a particular header represents the last block in the epoch.

func (*Backend) IsProxiedValidator

func (sb *Backend) IsProxiedValidator() bool

func (*Backend) IsProxy

func (sb *Backend) IsProxy() bool

func (*Backend) LastSubject

func (sb *Backend) LastSubject() (istanbul.Subject, error)

func (*Backend) LookbackWindow

func (sb *Backend) LookbackWindow() uint64

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

func (sb *Backend) NewChainHead(newBlock *types.Block)

Actions triggered by a new block being added to the chain.

func (*Backend) NewWork

func (sb *Backend) NewWork() error

This function is called by miner/worker.go whenever it's mainLoop gets a newWork event.

func (*Backend) NextBlockValidators

func (sb *Backend) NextBlockValidators(proposal istanbul.Proposal) (istanbul.ValidatorSet, error)

func (*Backend) ParentBlockValidators

func (sb *Backend) ParentBlockValidators(proposal istanbul.Proposal) istanbul.ValidatorSet

ParentBlockValidators implements istanbul.Backend.ParentBlockValidators

func (*Backend) Prepare

func (sb *Backend) Prepare(chain consensus.ChainReader, header *types.Header) error

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

func (sb *Backend) RefreshValPeers() error

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 (sb *Backend) RegisterPeer(peer consensus.Peer, isProxiedPeer bool)

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) SealHash

func (sb *Backend) SealHash(header *types.Header) common.Hash

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

func (*Backend) SendDelegateSignMsgToProxiedValidator

func (sb *Backend) SendDelegateSignMsgToProxiedValidator(msg []byte) error

SendDelegateSignMsgToProxiedValidator sends an istanbulDelegateSign message to a proxied validator if one exists

func (*Backend) SendDelegateSignMsgToProxy

func (sb *Backend) SendDelegateSignMsgToProxy(msg []byte) error

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) SetChain

func (sb *Backend) SetChain(chain consensus.ChainReader, currentBlock func() *types.Block, stateAt func(common.Hash) (*state.StateDB, error))

func (*Backend) SetP2PServer

func (sb *Backend) SetP2PServer(p2pserver consensus.P2PServer)

SetP2PServer implements consensus.Handler.SetP2PServer

func (*Backend) Sign

func (sb *Backend) Sign(data []byte) ([]byte, error)

Sign implements istanbul.Backend.Sign

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

func (sb *Backend) StartAnnouncing() error

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

func (sb *Backend) StopAnnouncing() error

StopAnnouncing implements consensus.Istanbul.StopAnnouncing

func (*Backend) StopValidating

func (sb *Backend) StopValidating() error

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 (sb *Backend) UnregisterPeer(peer consensus.Peer, isProxiedPeer bool)

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 (sb *Backend) ValidatorAddress() common.Address

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) Verify

func (sb *Backend) Verify(proposal istanbul.Proposal) (time.Duration, error)

Verify implements istanbul.Backend.Verify

func (*Backend) VerifyHeader

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

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

func (sb *Backend) 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.

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

func (s *Snapshot) MarshalJSON() ([]byte, error)

MarshalJSON to a json byte array

func (*Snapshot) UnmarshalJSON

func (s *Snapshot) UnmarshalJSON(b []byte) error

UnmarshalJSON from a json byte array

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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