Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyParamsChainConfigToConfig(chainConfig *params.ChainConfig, config *Config) error
- func CheckValidatorSignature(valSet ValidatorSet, data []byte, sig []byte) (common.Address, error)
- func CompareValidatorPublicKeySlices(valSet1 []blscrypto.SerializedPublicKey, ...) bool
- func CompareValidatorSlices(valSet1 []common.Address, valSet2 []common.Address) bool
- func ConvertPublicKeysToStringSlice(publicKeys []blscrypto.SerializedPublicKey) []string
- func GetEpochFirstBlockGivenBlockNumber(blockNumber uint64, epochSize uint64) (uint64, error)
- func GetEpochFirstBlockNumber(epochNumber uint64, epochSize uint64) (uint64, error)
- func GetEpochLastBlockNumber(epochNumber uint64, epochSize uint64) uint64
- func GetEpochNumber(number uint64, epochSize uint64) uint64
- func GetNodeID(enodeURL string) (*enode.ID, error)
- func GetNumberWithinEpoch(number uint64, epochSize uint64) uint64
- func GetSignatureAddress(data []byte, sig []byte) (common.Address, error)
- func IsFirstBlockOfEpoch(number uint64, epochSize uint64) bool
- func IsGossipedMsg(msgCode uint64) bool
- func IsIstanbulMsg(msg p2p.Msg) bool
- func IsLastBlockOfEpoch(number uint64, epochSize uint64) bool
- func MapMessagesToSenders(messages []Message) []common.Address
- func MapValidatorsToAddresses(validators []Validator) []common.Address
- func MapValidatorsToPublicKeys(validators []Validator) []blscrypto.SerializedPublicKey
- func MustGetEpochFirstBlockGivenBlockNumber(blockNumber uint64, epochSize uint64) uint64
- func RLPHash(v interface{}) (h common.Hash)
- func RandomnessCommitmentDBLocation(commitment common.Hash) []byte
- func SeparateValidatorDataIntoIstanbulExtra(validators []ValidatorData) ([]common.Address, []blscrypto.SerializedPublicKey)
- type AddressEntry
- type AddressEntryRLP
- type BLSSignerFn
- type CommittedSubject
- type Config
- type DecryptFn
- type EncryptedEnodeURL
- type EnodeCertMsg
- type EnodeCertificate
- type FinalCommittedEvent
- type ForwardMessage
- type HashSignerFn
- type Message
- func NewCommitMessage(commit *CommittedSubject, sender common.Address) *Message
- func NewEnodeCeritifcateMessage(enodeCertificate *EnodeCertificate, sender common.Address) *Message
- func NewForwardMessage(fowardMessage *ForwardMessage, sender common.Address) *Message
- func NewPrepareMessage(subject *Subject, sender common.Address) *Message
- func NewPreprepareMessage(prePrepare *Preprepare, sender common.Address) *Message
- func NewQueryEnodeMessage(queryEnode *QueryEnodeData, sender common.Address) *Message
- func NewRoundChangeMessage(roundChange *RoundChange, sender common.Address) *Message
- func NewValEnodesShareMessage(valEnodeShareData *ValEnodesShareData, sender common.Address) *Message
- func NewVersionCeritifcatesMessage(versionCertificates []*VersionCertificate, sender common.Address) *Message
- func (m *Message) Commit() *CommittedSubject
- func (m *Message) Copy() *Message
- func (m *Message) DecodeRLP(stream *rlp.Stream) error
- func (m *Message) EnodeCertificate() *EnodeCertificate
- func (m *Message) ForwardMessage() *ForwardMessage
- func (m *Message) FromPayload(b []byte, validateFn func([]byte, []byte) (common.Address, error)) error
- func (m *Message) Payload() ([]byte, error)
- func (m *Message) PayloadNoSig() ([]byte, error)
- func (m *Message) Prepare() *Subject
- func (m *Message) Preprepare() *Preprepare
- func (m *Message) QueryEnodeMsg() *QueryEnodeData
- func (m *Message) RoundChange() *RoundChange
- func (m *Message) Sign(signingFn func(data []byte) ([]byte, error)) error
- func (m *Message) String() string
- func (m *Message) ValEnodesShareData() *ValEnodesShareData
- func (m *Message) VersionCertificates() []*VersionCertificate
- type MessageEvent
- type MessageWithPeerIDEvent
- type PreparedCertificate
- func (pc *PreparedCertificate) AsData() *PreparedCertificateData
- func (pc *PreparedCertificate) DecodeRLP(s *rlp.Stream) error
- func (pc *PreparedCertificate) EncodeRLP(w io.Writer) error
- func (pc *PreparedCertificate) IsEmpty() bool
- func (pc *PreparedCertificate) Summary() *PreparedCertificateSummary
- type PreparedCertificateData
- type PreparedCertificateSummary
- type Preprepare
- type PreprepareData
- type PreprepareSummary
- type Proposal
- type ProposerPolicy
- type ProposerSelector
- type ProxyConfig
- type QueryEnodeData
- type Request
- type RequestEvent
- type RoundChange
- type RoundChangeCertificate
- type SharedValidatorEnode
- type SignerFn
- type Subject
- type ValEnodesShareData
- type Validator
- type ValidatorData
- type ValidatorDataWithBLSKeyCache
- type ValidatorSet
- type ValidatorSetData
- type ValidatorSetDataWithBLSKeyCache
- type ValidatorsDataByAddress
- type VersionCertificate
- type View
Constants ¶
const ( // No longer supported, can be removed. // The corresponding version upstream (eth/65) is removed in upstream PR #22636. Celo64 = 64 // eth/63 + the istanbul messages Celo65 = 65 // incorporates changes from eth/64 (EIP) // Supported versions Celo66 = 66 // incorporates changes from eth/65 (EIP-2464) Celo67 = 67 // incorporates changes from eth/66 (EIP-2481) )
Constants to match up protocol versions and messages
const ( ConsensusMsg = 0x11 QueryEnodeMsg = 0x12 FwdMsg = 0x14 DelegateSignMsg = 0x15 VersionCertificatesMsg = 0x16 EnodeCertificateMsg = 0x17 ValidatorHandshakeMsg = 0x18 )
Message codes for istanbul related messages If you want to add a code, you need to increment the protocolLengths Array size and update the IsIstanbulMsg function below!
const ( MsgPreprepare uint64 = iota MsgPrepare MsgCommit MsgRoundChange )
const (
//MinEpochSize represents the minimum permissible epoch size
MinEpochSize = 3
)
const ProtocolName = "istanbul"
protocolName is the official short name of the protocol used during capability negotiation.
Variables ¶
var ( // current validator set. ErrUnauthorizedAddress = errors.New("not an elected validator") // ErrInvalidSigner is returned if a message's signature does not correspond to the address in msg.Address ErrInvalidSigner = errors.New("signed by incorrect validator") // 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") // ErrStoppedAnnounce is returned if announce is stopped ErrStoppedAnnounce = errors.New("stopped announce") // ErrStartedAnnounce is returned if announce is already started ErrStartedAnnounce = errors.New("started announce") // ErrStoppedProxiedValidatorEngine is returned if proxied validator engine is stopped ErrStoppedProxiedValidatorEngine = errors.New("stopped proxied validator engine") // ErrStartedProxiedValidatorEngine is returned if proxied validator engine is already started ErrStartedProxiedValidatorEngine = errors.New("started proxied validator engine") // ErrStoppedVPHThread is returned if validator peer handler thread is stopped ErrStoppedVPHThread = errors.New("stopped validator peer handler thread") // ErrStartedVPHThread is returned if validator peer handler thread is already started ErrStartedVPHThread = errors.New("started validator peer handler thread") // ErrValidatorNotProxied is returned if the validator is not configured to be proxied ErrValidatorNotProxied = errors.New("validator not proxied") // ErrInvalidEnodeCertMsgMapOldVersion is returned if a validator sends old enode certificate message ErrInvalidEnodeCertMsgMapOldVersion = errors.New("invalid enode certificate message map because of old version") )
var DefaultConfig = &Config{ RequestTimeout: 3000, TimeoutBackoffFactor: 1000, MinResendRoundChangeTimeout: 15 * 1000, MaxResendRoundChangeTimeout: 2 * 60 * 1000, BlockPeriod: 5, ProposerPolicy: ShuffledRoundRobin, Epoch: 30000, DefaultLookbackWindow: 12, ReplicaStateDBPath: "replicastate", ValidatorEnodeDBPath: "validatorenodes", VersionCertificateDBPath: "versioncertificates", RoundStateDBPath: "roundstates", Validator: false, Replica: false, Proxy: false, Proxied: false, AnnounceQueryEnodeGossipPeriod: 300, AnnounceAggressiveQueryEnodeGossipOnEnablement: true, AnnounceAdditionalValidatorsToGossip: 10, LoadTestCSVFile: "", }
DefaultConfig for istanbul consensus engine
protocolLengths are the number of implemented message corresponding to different protocol versions.
var ProtocolVersions = []uint{Celo67, Celo66}
ProtocolVersions are the supported versions of the istanbul protocol (first is primary). (First is primary in the sense that it's the most current one supported)
Functions ¶
func ApplyParamsChainConfigToConfig ¶
func ApplyParamsChainConfigToConfig(chainConfig *params.ChainConfig, config *Config) error
ApplyParamsChainConfigToConfig applies the istanbul config values from params.chainConfig to the istanbul.Config config
func CheckValidatorSignature ¶
func CompareValidatorPublicKeySlices ¶
func CompareValidatorPublicKeySlices(valSet1 []blscrypto.SerializedPublicKey, valSet2 []blscrypto.SerializedPublicKey) bool
func CompareValidatorSlices ¶
CompareValidatorSlices compares 2 validator slices and indicate if they are equal. Equality is defined as: valseSet1[i] must be equal to valSet2[i] for every i. (aka. order matters)
func ConvertPublicKeysToStringSlice ¶
func ConvertPublicKeysToStringSlice(publicKeys []blscrypto.SerializedPublicKey) []string
func GetEpochFirstBlockGivenBlockNumber ¶
GetEpochFirstBlockGivenBlockNumber retrieves first block of a given block's epoch Fails when try to obtain first block of epoch 0 (genesis)
func GetEpochFirstBlockNumber ¶
GetEpochFirstBlockNumber retrieves first block of epoch.
func GetEpochLastBlockNumber ¶
GetEpochLastBlockNumber retrieves last block of epoch
func GetEpochNumber ¶
GetEpochNumber retrieves the epoch number given the block number. Epoch 0 is a special block that only contains the genesis block (block 0), epoch 1 starts at block 1
func GetNumberWithinEpoch ¶
GetNumberWithinEpoch retrieves the block number within an epoch. The return value will be 1-based; thus first block of epoch is 1, and last block of epoch is `epochSize` There is a special case if the number == 0. It is basically the last block of the 0th epoch, and should have a value of epochSize
func GetSignatureAddress ¶
GetSignatureAddress gets the signer address from the signature
func IsFirstBlockOfEpoch ¶
IsFirstBlockOfEpoch indicates if block number is the first block of its epoch
func IsGossipedMsg ¶
IsGossipedMsg specifies which messages should be gossiped throughout the network (as opposed to directly sent to a peer).
func IsIstanbulMsg ¶
func IsLastBlockOfEpoch ¶
IsLastBlockOfEpoch indicates if block number is the last block of its epoch
func MapMessagesToSenders ¶
MapMessagesToSenders map a list of Messages to the list of the sender addresses
func MapValidatorsToAddresses ¶
MapValidatorsToAddresses maps a slice of validator to a slice of addresses
func MapValidatorsToPublicKeys ¶
func MapValidatorsToPublicKeys(validators []Validator) []blscrypto.SerializedPublicKey
MapValidatorsToPublicKeys maps a slice of validator to a slice of public keys
func MustGetEpochFirstBlockGivenBlockNumber ¶
MustGetEpochFirstBlockGivenBlockNumber is a variant of GetEpochFirstBlockGivenBlockNumber that panics if called for epoch 0 (genesis)
func RandomnessCommitmentDBLocation ¶
RandomnessCommitmentDBLocation will return the key for where the given commitment's cached key-value entry
func SeparateValidatorDataIntoIstanbulExtra ¶
func SeparateValidatorDataIntoIstanbulExtra(validators []ValidatorData) ([]common.Address, []blscrypto.SerializedPublicKey)
Types ¶
type AddressEntry ¶
type AddressEntry struct { Address common.Address PublicKey *ecdsa.PublicKey Node *enode.Node Version uint HighestKnownVersion uint NumQueryAttemptsForHKVersion uint LastQueryTimestamp *time.Time }
## AddressEntry ###################################################################### AddressEntry is an entry for the valEnodeTable.
func (*AddressEntry) DecodeRLP ¶
func (ae *AddressEntry) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder, and load the AddressEntry fields from a RLP stream.
func (*AddressEntry) EncodeRLP ¶
func (ae *AddressEntry) EncodeRLP(w io.Writer) error
EncodeRLP serializes AddressEntry into the Ethereum RLP format.
func (*AddressEntry) GetAddress ¶
func (ae *AddressEntry) GetAddress() common.Address
GetAddess returns the addess entry's address
func (*AddressEntry) GetNode ¶
func (ae *AddressEntry) GetNode() *enode.Node
GetNode returns the address entry's node
func (*AddressEntry) GetVersion ¶
func (ae *AddressEntry) GetVersion() uint
GetVersion returns the addess entry's version
func (*AddressEntry) String ¶
func (ae *AddressEntry) String() string
type AddressEntryRLP ¶
type AddressEntryRLP struct { Address common.Address CompressedPublicKey []byte EnodeURL string Version uint HighestKnownVersion uint NumQueryAttemptsForHKVersion uint LastQueryTimestamp []byte }
Implement RLP Encode/Decode interface
type BLSSignerFn ¶
type BLSSignerFn func(accounts.Account, []byte, []byte, bool, bool) (blscrypto.SerializedSignature, error)
BLSSignerFn is a signer callback function to request a message and extra data to be signed by a backing account using BLS with a direct or composite hasher
type CommittedSubject ¶
type Config ¶
type Config struct { RequestTimeout uint64 `toml:",omitempty"` // The timeout for each Istanbul round in milliseconds. TimeoutBackoffFactor uint64 `toml:",omitempty"` // Timeout at subsequent rounds is: RequestTimeout + 2**round * TimeoutBackoffFactor (in milliseconds) MinResendRoundChangeTimeout uint64 `toml:",omitempty"` // Minimum interval with which to resend RoundChange messages for same round MaxResendRoundChangeTimeout uint64 `toml:",omitempty"` // Maximum interval with which to resend RoundChange messages for same round 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 DefaultLookbackWindow uint64 `toml:",omitempty"` // The default value for how many blocks in a row a validator must miss to be considered "down" ReplicaStateDBPath string `toml:",omitempty"` // The location for the validator replica state DB ValidatorEnodeDBPath string `toml:",omitempty"` // The location for the validator enodes DB VersionCertificateDBPath string `toml:",omitempty"` // The location for the signed announce version DB RoundStateDBPath string `toml:",omitempty"` // The location for the round states DB Validator bool `toml:",omitempty"` // Specified if this node is configured to validate (specifically if --mine command line is set) Replica bool `toml:",omitempty"` // Specified if this node is configured to be a replica // Proxy Configs Proxy bool `toml:",omitempty"` // Specifies if this node is a proxy ProxiedValidatorAddress common.Address `toml:",omitempty"` // The address of the proxied validator // Proxied Validator Configs Proxied bool `toml:",omitempty"` // Specifies if this node is proxied ProxyConfigs []*ProxyConfig `toml:",omitempty"` // The set of proxy configs for this proxied validator at startup // Announce Configs AnnounceQueryEnodeGossipPeriod uint64 `toml:",omitempty"` // Time duration (in seconds) between gossiped query enode messages AnnounceAggressiveQueryEnodeGossipOnEnablement bool `toml:",omitempty"` // Specifies if this node should aggressively query enodes on announce enablement AnnounceAdditionalValidatorsToGossip int64 `toml:",omitempty"` // Specifies the number of additional non-elected validators to gossip an announce // Load test config LoadTestCSVFile string `toml:",omitempty"` // If non-empty, specifies the file to write out csv metrics about the block production cycle to. }
Config represents the istanbul consensus engine
type DecryptFn ¶
Decrypt is a decrypt callback function to request an ECIES ciphertext to be decrypted
type EncryptedEnodeURL ¶ added in v1.4.0
func (*EncryptedEnodeURL) DecodeRLP ¶ added in v1.4.0
func (ee *EncryptedEnodeURL) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder, and load the ar fields from a RLP stream.
func (*EncryptedEnodeURL) EncodeRLP ¶ added in v1.4.0
func (ee *EncryptedEnodeURL) EncodeRLP(w io.Writer) error
EncodeRLP serializes ar into the Ethereum RLP format.
func (*EncryptedEnodeURL) String ¶ added in v1.4.0
func (ee *EncryptedEnodeURL) String() string
type EnodeCertMsg ¶
## EnodeCertMsg ######################################################################
type EnodeCertificate ¶
type FinalCommittedEvent ¶
type FinalCommittedEvent struct { }
FinalCommittedEvent is posted when a proposal is committed
type ForwardMessage ¶
type HashSignerFn ¶
HashSignerFn is a signer callback function to request a hash to be signed by a backing account.
type Message ¶
type Message struct { Code uint64 Msg []byte // The serialised bytes of the innner message. Address common.Address // The sender address Signature []byte // Signature of the Message using the private key associated with the "Address" field // contains filtered or unexported fields }
Message is a wrapper used for all istanbul communication. It encapsulates the sender's address, a code that indicates the type of the wrapped message and a signature. Message instances also hold a deserialised instance of the inner message which can be retrieved by calling the corresponding function (Commit(), Preprepare() ... etc).
Messages should be initialised either through the use of one of the NewXXXMessage constructors or by calling FromPayload on an empty Message instance, these mechanisms ensure that the produced Message instances will contain the deserialised inner message instance and the serialised bytes of the inner message.
func NewCommitMessage ¶ added in v1.4.0
func NewCommitMessage(commit *CommittedSubject, sender common.Address) *Message
NewCommitMessage constructs a Message instance with the given sender and commit. Both the commit instance and the serialized bytes of commit are part of the returned Message.
func NewEnodeCeritifcateMessage ¶ added in v1.4.0
func NewEnodeCeritifcateMessage(enodeCertificate *EnodeCertificate, sender common.Address) *Message
NewValEnodesShareMessage constructs a Message instance with the given sender and enodeCertificate. Both the enodeCertificate instance and the serialized bytes of enodeCertificate are part of the returned Message.
func NewForwardMessage ¶ added in v1.4.0
func NewForwardMessage(fowardMessage *ForwardMessage, sender common.Address) *Message
NewForwardMessage constructs a Message instance with the given sender and forwardMessage. Both the forwardMessage instance and the serialized bytes of fowardMessage are part of the returned Message.
func NewPrepareMessage ¶ added in v1.4.0
NewPrepareMessage constructs a Message instance with the given sender and subject. Both the subject instance and the serialized bytes of subject are part of the returned Message.
func NewPreprepareMessage ¶ added in v1.4.0
func NewPreprepareMessage(prePrepare *Preprepare, sender common.Address) *Message
NewPreprepareMessage constructs a Message instance with the given sender and prePrepare. Both the prePrepare instance and the serialized bytes of prePrepare are part of the returned Message.
func NewQueryEnodeMessage ¶ added in v1.4.0
func NewQueryEnodeMessage(queryEnode *QueryEnodeData, sender common.Address) *Message
NewQueryEnodeMessage constructs a Message instance with the given sender and queryEnode. Both the queryEnode instance and the serialized bytes of queryEnode are part of the returned Message.
func NewRoundChangeMessage ¶ added in v1.4.0
func NewRoundChangeMessage(roundChange *RoundChange, sender common.Address) *Message
NewRoundChangeMessage constructs a Message instance with the given sender and roundChange. Both the roundChange instance and the serialized bytes of roundChange are part of the returned Message.
func NewValEnodesShareMessage ¶ added in v1.4.0
func NewValEnodesShareMessage(valEnodeShareData *ValEnodesShareData, sender common.Address) *Message
NewValEnodesShareMessage constructs a Message instance with the given sender and valEnodeShareData. Both the valEnodeShareData instance and the serialized bytes of valEnodeShareData are part of the returned Message.
func NewVersionCeritifcatesMessage ¶ added in v1.4.0
func NewVersionCeritifcatesMessage(versionCertificates []*VersionCertificate, sender common.Address) *Message
NewVersionCeritifcatesMessage constructs a Message instance with the given sender and versionCertificates. Both the versionCertificates instance and the serialized bytes of versionCertificates are part of the returned Message.
func (*Message) Commit ¶ added in v1.4.0
func (m *Message) Commit() *CommittedSubject
Commit returns the committed subject if this is a commit message.
func (*Message) EnodeCertificate ¶ added in v1.4.0
func (m *Message) EnodeCertificate() *EnodeCertificate
EnodeCertificate returns the enode certificate if this is an enode certificate message
func (*Message) ForwardMessage ¶ added in v1.4.0
func (m *Message) ForwardMessage() *ForwardMessage
ForwardMessage returns forward message if this is a forward message.
func (*Message) FromPayload ¶
func (m *Message) FromPayload(b []byte, validateFn func([]byte, []byte) (common.Address, error)) error
FromPayload decodes b into a Message instance it will set one of the private fields committedSubject, prePrepare, prepare or roundChange depending on the type of the message.
func (*Message) PayloadNoSig ¶
func (*Message) Preprepare ¶ added in v1.4.0
func (m *Message) Preprepare() *Preprepare
Preprepare returns preprepare if this is a preprepare message.
func (*Message) QueryEnodeMsg ¶ added in v1.4.0
func (m *Message) QueryEnodeMsg() *QueryEnodeData
QueryEnode returns query enode data if this is a query enode message.
func (*Message) RoundChange ¶ added in v1.4.0
func (m *Message) RoundChange() *RoundChange
Prepare returns round change if this is a round change message.
func (*Message) ValEnodesShareData ¶ added in v1.4.0
func (m *Message) ValEnodesShareData() *ValEnodesShareData
ValEnodesShareData returns val enode share data if this is a val enodes share message.
func (*Message) VersionCertificates ¶ added in v1.4.0
func (m *Message) VersionCertificates() []*VersionCertificate
VersionCertificates returns the version certificate entries if this is a version certificates message.
type MessageEvent ¶
type MessageEvent struct {
Payload []byte
}
MessageEvent is posted for Istanbul engine communication
type MessageWithPeerIDEvent ¶
MessageWithPeerIDEvent is a MessageEvent with the peerID that sent the message
type PreparedCertificate ¶
func EmptyPreparedCertificate ¶
func EmptyPreparedCertificate() PreparedCertificate
func (*PreparedCertificate) AsData ¶
func (pc *PreparedCertificate) AsData() *PreparedCertificateData
func (*PreparedCertificate) DecodeRLP ¶
func (pc *PreparedCertificate) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder, and load the consensus fields from a RLP stream.
func (*PreparedCertificate) EncodeRLP ¶
func (pc *PreparedCertificate) EncodeRLP(w io.Writer) error
EncodeRLP serializes b into the Ethereum RLP format.
func (*PreparedCertificate) IsEmpty ¶
func (pc *PreparedCertificate) IsEmpty() bool
func (*PreparedCertificate) Summary ¶
func (pc *PreparedCertificate) Summary() *PreparedCertificateSummary
type PreparedCertificateData ¶
type Preprepare ¶
type Preprepare struct { View *View Proposal Proposal RoundChangeCertificate RoundChangeCertificate }
func (*Preprepare) AsData ¶
func (pp *Preprepare) AsData() *PreprepareData
func (*Preprepare) DecodeRLP ¶
func (pp *Preprepare) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder, and load the consensus fields from a RLP stream.
func (*Preprepare) EncodeRLP ¶
func (pp *Preprepare) EncodeRLP(w io.Writer) error
EncodeRLP serializes b into the Ethereum RLP format.
func (*Preprepare) HasRoundChangeCertificate ¶
func (pp *Preprepare) HasRoundChangeCertificate() bool
func (*Preprepare) Summary ¶
func (pp *Preprepare) Summary() *PreprepareSummary
type PreprepareData ¶
type PreprepareData struct { View *View Proposal *types.Block RoundChangeCertificate RoundChangeCertificate }
type PreprepareSummary ¶
type Proposal ¶
type Proposal interface { // Number retrieves the sequence number of this proposal. Number() *big.Int Header() *types.Header // Hash retrieves the hash of this block Hash() common.Hash // ParentHash retrieves the hash of this block's parent ParentHash() common.Hash EncodeRLP(w io.Writer) error DecodeRLP(s *rlp.Stream) error }
Proposal supports retrieving height and serialized block to be used during Istanbul consensus.
type ProposerPolicy ¶
type ProposerPolicy uint64
ProposerPolicy represents the policy used to order elected validators within an epoch
const ( RoundRobin ProposerPolicy = iota Sticky ShuffledRoundRobin )
type ProposerSelector ¶
type ProposerSelector func(validatorSet ValidatorSet, lastBlockProposer common.Address, currentRound uint64) Validator
ProposerSelector returns the block proposer for a round given the last proposer, round number, and randomness.
type ProxyConfig ¶
type ProxyConfig struct { InternalNode *enode.Node `toml:",omitempty"` // The internal facing node of the proxy that this proxied validator will peer with ExternalNode *enode.Node `toml:",omitempty"` // The external facing node of the proxy that the proxied validator will broadcast via the announce message }
ProxyConfig represents the configuration for validator's proxies
type QueryEnodeData ¶ added in v1.4.0
type QueryEnodeData struct { EncryptedEnodeURLs []*EncryptedEnodeURL Version uint // The timestamp of the node when the message is generated. // This results in a new hash for a newly generated message so it gets regossiped by other nodes Timestamp uint }
func (*QueryEnodeData) DecodeRLP ¶ added in v1.4.0
func (qed *QueryEnodeData) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder, and load the ad fields from a RLP stream.
func (*QueryEnodeData) EncodeRLP ¶ added in v1.4.0
func (qed *QueryEnodeData) EncodeRLP(w io.Writer) error
EncodeRLP serializes ad into the Ethereum RLP format.
func (*QueryEnodeData) String ¶ added in v1.4.0
func (qed *QueryEnodeData) String() string
type Request ¶
type Request struct {
Proposal Proposal
}
type RequestEvent ¶
type RequestEvent struct {
Proposal Proposal
}
RequestEvent is posted to propose a proposal
type RoundChange ¶
type RoundChange struct { View *View PreparedCertificate PreparedCertificate }
func (*RoundChange) DecodeRLP ¶
func (b *RoundChange) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder, and load the consensus fields from a RLP stream.
func (*RoundChange) EncodeRLP ¶
func (b *RoundChange) EncodeRLP(w io.Writer) error
EncodeRLP serializes b into the Ethereum RLP format.
func (*RoundChange) HasPreparedCertificate ¶
func (b *RoundChange) HasPreparedCertificate() bool
type RoundChangeCertificate ¶
type RoundChangeCertificate struct {
RoundChangeMessages []Message
}
func (*RoundChangeCertificate) IsEmpty ¶
func (b *RoundChangeCertificate) IsEmpty() bool
type SharedValidatorEnode ¶ added in v1.4.0
type SharedValidatorEnode struct {}
func (*SharedValidatorEnode) String ¶ added in v1.4.0
func (sve *SharedValidatorEnode) String() string
type SignerFn ¶
SignerFn is a signer callback function to request a header to be signed by a backing account.
type ValEnodesShareData ¶ added in v1.4.0
type ValEnodesShareData struct {
}func (*ValEnodesShareData) DecodeRLP ¶ added in v1.4.0
func (sd *ValEnodesShareData) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder, and load the sd fields from a RLP stream.
func (*ValEnodesShareData) EncodeRLP ¶ added in v1.4.0
func (sd *ValEnodesShareData) EncodeRLP(w io.Writer) error
EncodeRLP serializes sd into the Ethereum RLP format.
func (*ValEnodesShareData) String ¶ added in v1.4.0
func (sd *ValEnodesShareData) String() string
type Validator ¶
type Validator interface { fmt.Stringer // Address returns address Address() common.Address // BLSPublicKey returns the BLS public key (compressed format) BLSPublicKey() blscrypto.SerializedPublicKey // BLSPublicKeyUncompressed returns the BLS public key (uncompressed format) BLSPublicKeyUncompressed() []byte // Serialize returns binary reprenstation of the Validator // can be use used to instantiate a validator with DeserializeValidator() Serialize() ([]byte, error) // AsData returns Validator representation as ValidatorData AsData() *ValidatorData // AsData returns Validator representation as ValidatorData AsDataWithBLSKeyCache() *ValidatorDataWithBLSKeyCache // CacheUncompressedBLSKey stores the uncompressed BLS public key to cache CacheUncompressedBLSKey() // Copy validator Copy() Validator }
type ValidatorData ¶
type ValidatorData struct { Address common.Address BLSPublicKey blscrypto.SerializedPublicKey }
func CombineIstanbulExtraToValidatorData ¶
func CombineIstanbulExtraToValidatorData(addrs []common.Address, blsPublicKeys []blscrypto.SerializedPublicKey) ([]ValidatorData, error)
func ValidatorSetDiff ¶
func ValidatorSetDiff(oldValSet []ValidatorData, newValSet []ValidatorData) ([]ValidatorData, *big.Int)
type ValidatorDataWithBLSKeyCache ¶
type ValidatorDataWithBLSKeyCache struct { Address common.Address BLSPublicKey blscrypto.SerializedPublicKey UncompressedBLSPublicKey []byte }
type ValidatorSet ¶
type ValidatorSet interface { fmt.Stringer // Sets the randomness for use in the proposer policy. // This is injected into the ValidatorSet when we call `getOrderedValidators` SetRandomness(seed common.Hash) // Sets the randomness for use in the proposer policy GetRandomness() common.Hash // Return the validator size Size() int // Get the maximum number of faulty nodes F() int // Get the minimum quorum size MinQuorumSize() int // List returns all the validators List() []Validator // Return the validator index GetIndex(addr common.Address) int // Get validator by index GetByIndex(i uint64) Validator // Get validator by given address GetByAddress(addr common.Address) (int, Validator) // CointainByAddress indicates if a validator with the given address is present ContainsByAddress(add common.Address) bool // Add validators AddValidators(validators []ValidatorData) bool // Remove validators RemoveValidators(removedValidators *big.Int) bool // Copy validator set Copy() ValidatorSet // CacheUncompressedBLSKey stores the uncompressed BLS public key to cache for each validator in the valset CacheUncompressedBLSKey() // HasBLSKeyCache tests that all uncompressed BLS public keys are in the cache, otherwise returns false HasBLSKeyCache() bool // Serialize returns binary reprentation of the ValidatorSet // can be use used to instantiate a validator with DeserializeValidatorSet() Serialize() ([]byte, error) }
type ValidatorSetData ¶
type ValidatorSetData struct { Validators []ValidatorData Randomness common.Hash }
type ValidatorSetDataWithBLSKeyCache ¶
type ValidatorSetDataWithBLSKeyCache struct { Validators []ValidatorDataWithBLSKeyCache Randomness common.Hash }
type ValidatorsDataByAddress ¶
type ValidatorsDataByAddress []ValidatorData
func (ValidatorsDataByAddress) Len ¶
func (a ValidatorsDataByAddress) Len() int
func (ValidatorsDataByAddress) Less ¶
func (a ValidatorsDataByAddress) Less(i, j int) bool
func (ValidatorsDataByAddress) Swap ¶
func (a ValidatorsDataByAddress) Swap(i, j int)
type VersionCertificate ¶ added in v1.4.0
type VersionCertificate struct { Version uint Signature []byte // contains filtered or unexported fields }
VersionCertificate is an entry in the VersionCertificateDB. It's a signed message from a registered or active validator indicating the most recent version of its enode.
func NewVersionCertificate ¶ added in v1.4.0
func NewVersionCertificate(version uint, signingFn func([]byte) ([]byte, error)) (*VersionCertificate, error)
NewVersionCeritifcate constructs a VersionCertificate instance with the given version. It uses the signingFn to generate a version signature and then builds a version certificate from the version and its signature.
func NewVersionCertificateFromFields ¶ added in v1.4.0
func NewVersionCertificateFromFields(version uint, signature []byte, address common.Address, key *ecdsa.PublicKey) *VersionCertificate
NewVersionCeritifcateFrom fields constructs a VersionCertificate instance with the given fields, using them to build a VersionCertificate instance. No validation is done on the provided fields. It is assumed that the fields are valid, meaning that the signature was generated using the given version and the private part of the given public key, and also that the address corresponds to the given public key.
func (*VersionCertificate) Address ¶ added in v1.4.0
func (vc *VersionCertificate) Address() common.Address
func (*VersionCertificate) DecodeRLP ¶ added in v1.4.0
func (vc *VersionCertificate) DecodeRLP(s *rlp.Stream) error
func (*VersionCertificate) PublicKey ¶ added in v1.4.0
func (vc *VersionCertificate) PublicKey() *ecdsa.PublicKey
func (*VersionCertificate) String ¶ added in v1.4.0
func (vc *VersionCertificate) String() string
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.