istanbul

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2021 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
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)
)

Constants to match up protocol versions and messages

View Source
const (
	ConsensusMsg           = 0x11
	QueryEnodeMsg          = 0x12
	ValEnodesShareMsg      = 0x13
	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!

View Source
const (
	MsgPreprepare uint64 = iota
	MsgPrepare
	MsgCommit
	MsgRoundChange
)
View Source
const (
	//MinEpochSize represents the minimum permissible epoch size
	MinEpochSize = 3
)
View Source
const ProtocolName = "istanbul"

protocolName is the official short name of the protocol used during capability negotiation.

Variables

View Source
var (
	// ErrUnauthorizedAddress is returned when given address cannot be found in
	// 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")
)
View Source
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

View Source
var ProtocolLengths = map[uint]uint64{Celo64: 22, Celo65: 27, Celo66: 27}

protocolLengths are the number of implemented message corresponding to different protocol versions.

View Source
var ProtocolVersions = []uint{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 CheckValidatorSignature(valSet ValidatorSet, data []byte, sig []byte) (common.Address, error)

func CompareValidatorPublicKeySlices

func CompareValidatorPublicKeySlices(valSet1 []blscrypto.SerializedPublicKey, valSet2 []blscrypto.SerializedPublicKey) bool

func CompareValidatorSlices

func CompareValidatorSlices(valSet1 []common.Address, valSet2 []common.Address) bool

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

func GetEpochFirstBlockGivenBlockNumber(blockNumber uint64, epochSize uint64) (uint64, error)

GetEpochFirstBlockGivenBlockNumber retrieves first block of a given block's epoch Fails when try to obtain first block of epoch 0 (genesis)

func GetEpochFirstBlockNumber

func GetEpochFirstBlockNumber(epochNumber uint64, epochSize uint64) (uint64, error)

GetEpochFirstBlockNumber retrieves first block of epoch.

func GetEpochLastBlockNumber

func GetEpochLastBlockNumber(epochNumber uint64, epochSize uint64) uint64

GetEpochLastBlockNumber retrieves last block of epoch

func GetEpochNumber

func GetEpochNumber(number uint64, epochSize uint64) uint64

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 GetNodeID

func GetNodeID(enodeURL string) (*enode.ID, error)

func GetNumberWithinEpoch

func GetNumberWithinEpoch(number uint64, epochSize uint64) uint64

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

func GetSignatureAddress(data []byte, sig []byte) (common.Address, error)

GetSignatureAddress gets the signer address from the signature

func IsFirstBlockOfEpoch

func IsFirstBlockOfEpoch(number uint64, epochSize uint64) bool

IsFirstBlockOfEpoch indicates if block number is the first block of its epoch

func IsGossipedMsg

func IsGossipedMsg(msgCode uint64) bool

IsGossipedMsg specifies which messages should be gossiped throughout the network (as opposed to directly sent to a peer).

func IsIstanbulMsg

func IsIstanbulMsg(msg p2p.Msg) bool

func IsLastBlockOfEpoch

func IsLastBlockOfEpoch(number uint64, epochSize uint64) bool

IsLastBlockOfEpoch indicates if block number is the last block of its epoch

func MapMessagesToSenders

func MapMessagesToSenders(messages []Message) []common.Address

MapMessagesToSenders map a list of Messages to the list of the sender addresses

func MapValidatorsToAddresses

func MapValidatorsToAddresses(validators []Validator) []common.Address

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

func MustGetEpochFirstBlockGivenBlockNumber(blockNumber uint64, epochSize uint64) uint64

MustGetEpochFirstBlockGivenBlockNumber is a variant of GetEpochFirstBlockGivenBlockNumber that panics if called for epoch 0 (genesis)

func RLPHash

func RLPHash(v interface{}) (h common.Hash)

func RandomnessCommitmentDBLocation

func RandomnessCommitmentDBLocation(commitment common.Hash) []byte

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 CommittedSubject struct {
	Subject               *Subject
	CommittedSeal         []byte
	EpochValidatorSetSeal []byte
}

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

type DecryptFn func(accounts.Account, []byte, []byte, []byte) ([]byte, error)

Decrypt is a decrypt callback function to request an ECIES ciphertext to be decrypted

type EncryptedEnodeURL

type EncryptedEnodeURL struct {
	DestAddress       common.Address
	EncryptedEnodeURL []byte
}

func (*EncryptedEnodeURL) DecodeRLP

func (ee *EncryptedEnodeURL) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, and load the ar fields from a RLP stream.

func (*EncryptedEnodeURL) EncodeRLP

func (ee *EncryptedEnodeURL) EncodeRLP(w io.Writer) error

EncodeRLP serializes ar into the Ethereum RLP format.

func (*EncryptedEnodeURL) String

func (ee *EncryptedEnodeURL) String() string

type EnodeCertMsg

type EnodeCertMsg struct {
	Msg           *Message
	DestAddresses []common.Address
}

## EnodeCertMsg ######################################################################

type EnodeCertificate

type EnodeCertificate struct {
	EnodeURL string
	Version  uint
}

func (*EnodeCertificate) DecodeRLP

func (ec *EnodeCertificate) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, and load the ec fields from a RLP stream.

func (*EnodeCertificate) EncodeRLP

func (ec *EnodeCertificate) EncodeRLP(w io.Writer) error

EncodeRLP serializes ec into the Ethereum RLP format.

type FinalCommittedEvent

type FinalCommittedEvent struct {
}

FinalCommittedEvent is posted when a proposal is committed

type ForwardMessage

type ForwardMessage struct {
	Code          uint64
	Msg           []byte
	DestAddresses []common.Address
}

type HashSignerFn

type HashSignerFn func(accounts.Account, []byte) ([]byte, error)

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

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

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

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

func NewPrepareMessage(subject *Subject, sender common.Address) *Message

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

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

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

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

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

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

func (m *Message) Commit() *CommittedSubject

Commit returns the committed subject if this is a commit message.

func (*Message) Copy

func (m *Message) Copy() *Message

func (*Message) DecodeRLP

func (m *Message) DecodeRLP(stream *rlp.Stream) error

func (*Message) EnodeCertificate

func (m *Message) EnodeCertificate() *EnodeCertificate

EnodeCertificate returns the enode certificate if this is an enode certificate message

func (*Message) ForwardMessage

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

func (m *Message) Payload() ([]byte, error)

func (*Message) PayloadNoSig

func (m *Message) PayloadNoSig() ([]byte, error)

func (*Message) Prepare

func (m *Message) Prepare() *Subject

Prepare returns prepare if this is a prepare message.

func (*Message) Preprepare

func (m *Message) Preprepare() *Preprepare

Preprepare returns preprepare if this is a preprepare message.

func (*Message) QueryEnodeMsg

func (m *Message) QueryEnodeMsg() *QueryEnodeData

QueryEnode returns query enode data if this is a query enode message.

func (*Message) RoundChange

func (m *Message) RoundChange() *RoundChange

Prepare returns round change if this is a round change message.

func (*Message) Sign

func (m *Message) Sign(signingFn func(data []byte) ([]byte, error)) error

func (*Message) String

func (m *Message) String() string

func (*Message) ValEnodesShareData

func (m *Message) ValEnodesShareData() *ValEnodesShareData

ValEnodesShareData returns val enode share data if this is a val enodes share message.

func (*Message) VersionCertificates

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

type MessageWithPeerIDEvent struct {
	PeerID  enode.ID
	Payload []byte
}

MessageWithPeerIDEvent is a MessageEvent with the peerID that sent the message

type PreparedCertificate

type PreparedCertificate struct {
	Proposal                Proposal
	PrepareOrCommitMessages []Message
}

func EmptyPreparedCertificate

func EmptyPreparedCertificate() PreparedCertificate

func (*PreparedCertificate) AsData

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

type PreparedCertificateData

type PreparedCertificateData struct {
	Proposal                *types.Block
	PrepareOrCommitMessages []Message
}

type PreparedCertificateSummary

type PreparedCertificateSummary struct {
	ProposalHash   common.Hash      `json:"proposalHash"`
	PrepareSenders []common.Address `json:"prepareSenders"`
	CommitSenders  []common.Address `json:"commitSenders"`
}

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 PreprepareSummary struct {
	View                          *View            `json:"view"`
	ProposalHash                  common.Hash      `json:"proposalHash"`
	RoundChangeCertificateSenders []common.Address `json:"roundChangeCertificateSenders"`
}

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

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

func (qed *QueryEnodeData) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, and load the ad fields from a RLP stream.

func (*QueryEnodeData) EncodeRLP

func (qed *QueryEnodeData) EncodeRLP(w io.Writer) error

EncodeRLP serializes ad into the Ethereum RLP format.

func (*QueryEnodeData) String

func (qed *QueryEnodeData) String() string

type Request

type Request struct {
	Proposal Proposal
}

func (*Request) DecodeRLP

func (b *Request) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, and load the consensus fields from a RLP stream.

func (*Request) EncodeRLP

func (b *Request) EncodeRLP(w io.Writer) error

EncodeRLP serializes b into the Ethereum RLP format.

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

type SharedValidatorEnode struct {
	Address  common.Address
	EnodeURL string
	Version  uint
}

func (*SharedValidatorEnode) String

func (sve *SharedValidatorEnode) String() string

type SignerFn

type SignerFn func(accounts.Account, string, []byte) ([]byte, error)

SignerFn is a signer callback function to request a header to be signed by a backing account.

type Subject

type Subject struct {
	View   *View
	Digest common.Hash
}

func (*Subject) String

func (s *Subject) String() string

type ValEnodesShareData

type ValEnodesShareData struct {
	ValEnodes []SharedValidatorEnode
}

func (*ValEnodesShareData) DecodeRLP

func (sd *ValEnodesShareData) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, and load the sd fields from a RLP stream.

func (*ValEnodesShareData) EncodeRLP

func (sd *ValEnodesShareData) EncodeRLP(w io.Writer) error

EncodeRLP serializes sd into the Ethereum RLP format.

func (*ValEnodesShareData) String

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

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

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

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

func (vc *VersionCertificate) Address() common.Address

func (*VersionCertificate) DecodeRLP

func (vc *VersionCertificate) DecodeRLP(s *rlp.Stream) error

func (*VersionCertificate) PublicKey

func (vc *VersionCertificate) PublicKey() *ecdsa.PublicKey

func (*VersionCertificate) String

func (vc *VersionCertificate) String() string

type View

type View struct {
	Round    *big.Int
	Sequence *big.Int
}

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

func (v *View) Cmp(y *View) int

Cmp compares v and y and returns:

-1 if v <  y
 0 if v == y
+1 if v >  y

func (*View) String

func (v *View) String() string

Directories

Path Synopsis
random
Package random implements a language independent method of producing random validator orderings.
Package random implements a language independent method of producing random validator orderings.

Jump to

Keyboard shortcuts

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