backend

package
v0.0.0-...-e667f6b Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2020 License: GPL-3.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HighFreqTickerDuration = 1 * time.Minute
	LowFreqTickerDuration  = 10 * time.Minute
)

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

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

RemoveProxy removes a node from acting as a proxy

type AnnounceFrequencyState

type AnnounceFrequencyState int
const (
	// In this state, send out an announce message every 1 minute until the first peer is established
	HighFreqBeforeFirstPeerState AnnounceFrequencyState = iota

	// In this state, send out an announce message every 1 minute for the first 10 announce 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

	// In this state, send out an announce message every 10 minutes
	LowFreqState
)

type AnnounceGossipTimestamp

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

Entries for the recent announce messages

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, signFn istanbul.SignerFn, signHashBLSFn istanbul.BLSSignerFn, signMessageBLSFn istanbul.MessageSignerFn)

Authorize implements istanbul.Backend.Authorize

func (*Backend) BroadcastConsensusMsg

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

Broadcast implements istanbul.Backend.BroadcastConsensusMsg

func (*Backend) CalcDifficulty

func (sb *Backend) 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 based on the previous blocks in the chain and the current signer.

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

func (sb *Backend) ConnectToVals()

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, uncles []*types.Header, receipts []*types.Receipt, randomness *types.Randomness) (*types.Block, error)

Finalize 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) Gossip

func (sb *Backend) Gossip(destAddresses []common.Address, payload []byte, ethMsgCode uint64, ignoreCache bool) error

Gossip implements istanbul.Backend.Gossip

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

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

This function is called by all nodes. At the end of each epoch, this function will

  1. Output if it is or isn't an elected validator if it has mining turned on.
  2. Refresh the validator connections if it's a proxy or non proxied validator

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

func (sb *Backend) Protocol() consensus.Protocol

Protocol implements consensus.Engine.Protocol

func (*Backend) RefreshValPeers

func (sb *Backend) RefreshValPeers(valset istanbul.ValidatorSet)

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)

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

func (sb *Backend) Start(hasBadBlock func(common.Hash) bool,
	stateAt func(common.Hash) (*state.StateDB, error), processBlock func(*types.Block, *state.StateDB) (types.Receipts, []*types.Log, uint64, error),
	validateState func(*types.Block, *state.StateDB, types.Receipts, uint64) error) error

Start implements consensus.Istanbul.Start

func (*Backend) Stop

func (sb *Backend) Stop() error

Stop implements consensus.Istanbul.Stop

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

func (*Backend) VerifyUncles

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