common

package
v1.7.12-rc.4 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: BSD-3-Clause Imports: 20 Imported by: 224

Documentation

Overview

Package common is a generated GoMock package.

Index

Constants

View Source
const (
	// StatusUpdateFrequency is how many containers should be processed between
	// logs
	StatusUpdateFrequency = 5000

	// MaxOutstandingGetAncestorsRequests is the maximum number of GetAncestors
	// sent but not responded to/failed
	MaxOutstandingGetAncestorsRequests = 10

	// MaxOutstandingBroadcastRequests is the maximum number of requests to have
	// outstanding when broadcasting.
	MaxOutstandingBroadcastRequests = 50
)
View Source
const (
	WriteLock = iota
	ReadLock
	NoLock
)

List of all allowed options

Variables

This section is empty.

Functions

func SendMixedQuery added in v1.7.11

func SendMixedQuery(
	sender Sender,
	vdrs []ids.NodeID,
	numPushTo int,
	reqID uint32,
	containerID ids.ID,
	container []byte,
)

Send a query composed partially of push queries and partially of pull queries. The validators in [vdrs] will be queried. This function sends at most [numPushTo] push queries. The rest are pull queries. If [numPushTo] > len(vdrs), len(vdrs) push queries are sent. [containerID] and [container] are the ID and body of the container being queried. [sender] is used to actually send the queries.

Types

type AcceptedFrontierHandler added in v1.7.4

type AcceptedFrontierHandler interface {
	// Notify this engine of an accepted frontier.
	//
	// This function can be called by any validator. It is not safe to assume
	// this message is in response to a GetAcceptedFrontier message, is
	// utilizing a unique requestID, or that the containerIDs from a valid
	// frontier.
	AcceptedFrontier(
		validatorID ids.NodeID,
		requestID uint32,
		containerIDs []ids.ID,
	) error

	// Notify this engine that a get accepted frontier request it issued has
	// failed.
	//
	// This function will be called if the engine sent a GetAcceptedFrontier
	// message that is not anticipated to be responded to. This could be because
	// the recipient of the message is unknown or if the message request has
	// timed out.
	//
	// The validatorID, and requestID, are assumed to be the same as those sent
	// in the GetAcceptedFrontier message.
	GetAcceptedFrontierFailed(validatorID ids.NodeID, requestID uint32) error
}

AcceptedFrontierHandler defines how a consensus engine reacts to accepted frontier messages from other validators. Functions only return fatal errors.

func NewNoOpAcceptedFrontierHandler added in v1.7.4

func NewNoOpAcceptedFrontierHandler(log logging.Logger) AcceptedFrontierHandler

type AcceptedHandler

type AcceptedHandler interface {
	// Notify this engine of a set of accepted vertices.
	//
	// This function can be called by any validator. It is not safe to assume
	// this message is in response to a GetAccepted message, is utilizing a
	// unique requestID, or that the containerIDs are a subset of the
	// containerIDs from a GetAccepted message.
	Accepted(
		validatorID ids.NodeID,
		requestID uint32,
		containerIDs []ids.ID,
	) error

	// Notify this engine that a get accepted request it issued has failed.
	//
	// This function will be called if the engine sent a GetAccepted message
	// that is not anticipated to be responded to. This could be because the
	// recipient of the message is unknown or if the message request has timed
	// out.
	//
	// The validatorID, and requestID, are assumed to be the same as those sent
	// in the GetAccepted message.
	GetAcceptedFailed(validatorID ids.NodeID, requestID uint32) error
}

AcceptedHandler defines how a consensus engine reacts to accepted messages from other validators. Functions only return fatal errors.

func NewNoOpAcceptedHandler added in v1.7.4

func NewNoOpAcceptedHandler(log logging.Logger) AcceptedHandler

type AcceptedSender

type AcceptedSender interface {
	// SendGetAccepted requests that every node in [nodeIDs] sends an Accepted
	// message with all the IDs in [containerIDs] that the node thinks are
	// accepted.
	SendGetAccepted(
		nodeIDs ids.NodeIDSet,
		requestID uint32,
		containerIDs []ids.ID,
	)

	// SendAccepted responds to a GetAccepted message with a set of IDs of
	// containers that are accepted.
	SendAccepted(nodeID ids.NodeID, requestID uint32, containerIDs []ids.ID)
}

AcceptedSender defines how a consensus engine sends messages pertaining to accepted containers

type AcceptedStateSummaryHandler added in v1.7.11

type AcceptedStateSummaryHandler interface {
	// Notify this engine of a set of state summaries.
	//
	// This function can be called by any validator. It is not safe to assume
	// this message is in response to a GetAcceptedStateSummary message,
	// is utilizing a unique requestID, or that the summaryIDs are a subset of the
	// state summaries requested by key from a GetAcceptedStateSummary message.
	AcceptedStateSummary(validatorID ids.NodeID, requestID uint32, summaryIDs []ids.ID) error

	// Notify this engine that a get accepted state summary request it issued has
	// failed.
	//
	// This function will be called if the engine sent a GetAcceptedStateSummary
	// message that is not anticipated to be responded to. This could be because
	// the recipient of the message is unknown or if the message request has
	// timed out.
	//
	// The validatorID, and requestID, are assumed to be the same as those sent
	// in the GetAcceptedStateSummary message.
	GetAcceptedStateSummaryFailed(validatorID ids.NodeID, requestID uint32) error
}

AcceptedStateSummaryHandler defines how a consensus engine reacts to an accepted state summary message from another validator. Functions only return fatal errors.

func NewNoOpAcceptedStateSummaryHandler added in v1.7.11

func NewNoOpAcceptedStateSummaryHandler(log logging.Logger) AcceptedStateSummaryHandler

type AcceptedStateSummarySender added in v1.7.11

type AcceptedStateSummarySender interface {
	// SendGetAcceptedStateSummary requests that every node in [nodeIDs] sends an
	// AcceptedStateSummary message with all the state summary IDs referenced by [heights]
	// that the node thinks are accepted.
	SendGetAcceptedStateSummary(nodeIDs ids.NodeIDSet, requestID uint32, heights []uint64)

	// SendAcceptedStateSummary responds to a AcceptedStateSummary message with a
	// set of summary ids that are accepted.
	SendAcceptedStateSummary(nodeID ids.NodeID, requestID uint32, summaryIDs []ids.ID)
}

type AncestorsHandler added in v1.7.4

type AncestorsHandler interface {
	// Notify this engine of multiple containers.
	//
	// Each element of [containers] is the byte representation of a container.
	//
	// This should only be called during bootstrapping, in response to a
	// GetAncestors message to [validatorID] with request ID [requestID].
	//
	// This call should contain the container requested in that message, along
	// with ancestors. The containers should be in BFS order (ie the first
	// container must be the container requested in the GetAncestors message and
	// further back ancestors are later in [containers]
	//
	// It is not safe to assume this message is in response to a GetAncestor
	// message, that this message has a unique requestID or that any of the
	// containers in [containers] are valid.
	Ancestors(
		validatorID ids.NodeID,
		requestID uint32,
		containers [][]byte,
	) error

	// Notify this engine that a GetAncestors request it issued has failed.
	//
	// This function will be called if the engine sent a GetAncestors message
	// that is not anticipated to be responded to. This could be because the
	// recipient of the message is unknown or if the message request has timed
	// out.
	//
	// The validatorID and requestID are assumed to be the same as those sent in
	// the GetAncestors message.
	GetAncestorsFailed(validatorID ids.NodeID, requestID uint32) error
}

AncestorsHandler defines how a consensus engine reacts to bootstrapping retrieval messages from other validators. Functions only return fatal errors.

func NewNoOpAncestorsHandler added in v1.7.4

func NewNoOpAncestorsHandler(log logging.Logger) AncestorsHandler

type AppHandler added in v1.5.3

type AppHandler interface {
	// Notify this engine of a request for data from [nodeID].
	//
	// The meaning of [request], and what should be sent in response to it, is
	// application (VM) specific.
	//
	// It is not guaranteed that:
	// * [request] is well-formed/valid.
	//
	// This node should typically send an AppResponse to [nodeID] in response to
	// a valid message using the same request ID before the deadline. However,
	// the VM may arbitrarily choose to not send a response to this request.
	AppRequest(nodeID ids.NodeID, requestID uint32, deadline time.Time, request []byte) error

	// Notify this engine that an AppRequest message it sent to [nodeID] with
	// request ID [requestID] failed.
	//
	// This may be because the request timed out or because the message couldn't
	// be sent to [nodeID].
	//
	// It is guaranteed that:
	// * This engine sent a request to [nodeID] with ID [requestID].
	// * AppRequestFailed([nodeID], [requestID]) has not already been called.
	// * AppResponse([nodeID], [requestID]) has not already been called.
	AppRequestFailed(nodeID ids.NodeID, requestID uint32) error

	// Notify this engine of a response to the AppRequest message it sent to
	// [nodeID] with request ID [requestID].
	//
	// The meaning of [response] is application (VM) specifc.
	//
	// It is guaranteed that:
	// * This engine sent a request to [nodeID] with ID [requestID].
	// * AppRequestFailed([nodeID], [requestID]) has not already been called.
	// * AppResponse([nodeID], [requestID]) has not already been called.
	//
	// It is not guaranteed that:
	// * [response] contains the expected response
	// * [response] is well-formed/valid.
	//
	// If [response] is invalid or not the expected response, the VM chooses how
	// to react. For example, the VM may send another AppRequest, or it may give
	// up trying to get the requested information.
	AppResponse(nodeID ids.NodeID, requestID uint32, response []byte) error

	// Notify this engine of a gossip message from [nodeID].
	//
	// The meaning of [msg] is application (VM) specific, and the VM defines how
	// to react to this message.
	//
	// This message is not expected in response to any event, and it does not
	// need to be responded to.
	//
	// A node may gossip the same message multiple times. That is,
	// AppGossip([nodeID], [msg]) may be called multiple times.
	AppGossip(nodeID ids.NodeID, msg []byte) error
}

AppHandler defines how a consensus engine reacts to app specific messages. Functions only return fatal errors.

func NewNoOpAppHandler added in v1.7.4

func NewNoOpAppHandler(log logging.Logger) AppHandler

type AppSender added in v1.5.3

type AppSender interface {
	// Send an application-level request.
	// A nil return value guarantees that for each nodeID in [nodeIDs],
	// the VM corresponding to this AppSender eventually receives either:
	// * An AppResponse from nodeID with ID [requestID]
	// * An AppRequestFailed from nodeID with ID [requestID]
	// Exactly one of the above messages will eventually be received per nodeID.
	// A non-nil error should be considered fatal.
	SendAppRequest(nodeIDs ids.NodeIDSet, requestID uint32, appRequestBytes []byte) error
	// Send an application-level response to a request.
	// This response must be in response to an AppRequest that the VM corresponding
	// to this AppSender received from [nodeID] with ID [requestID].
	// A non-nil error should be considered fatal.
	SendAppResponse(nodeID ids.NodeID, requestID uint32, appResponseBytes []byte) error
	// Gossip an application-level message.
	// A non-nil error should be considered fatal.
	SendAppGossip(appGossipBytes []byte) error
	SendAppGossipSpecific(nodeIDs ids.NodeIDSet, appGossipBytes []byte) error
}

AppSender sends application (VM) level messages. See also common.AppHandler.

type Bootstrapable

type Bootstrapable interface {
	// Force the provided containers to be accepted. Only returns fatal errors
	// if they occur.
	ForceAccepted(acceptedContainerIDs []ids.ID) error

	// Clear removes all containers to be processed upon bootstrapping
	Clear() error
}

Bootstrapable defines the functionality required to support bootstrapping

type BootstrapableEngine added in v1.7.4

type BootstrapableEngine interface {
	Bootstrapable
	Engine
}

type BootstrapableTest

type BootstrapableTest struct {
	T *testing.T

	CantForceAccepted, CantClear bool

	ClearF         func() error
	ForceAcceptedF func(acceptedContainerIDs []ids.ID) error
}

BootstrapableTest is a test engine that supports bootstrapping

func (*BootstrapableTest) Clear added in v1.7.5

func (b *BootstrapableTest) Clear() error

func (*BootstrapableTest) Default

func (b *BootstrapableTest) Default(cant bool)

Default sets the default on call handling

func (*BootstrapableTest) ForceAccepted

func (b *BootstrapableTest) ForceAccepted(containerIDs []ids.ID) error

type Bootstrapper

type Bootstrapper interface {
	AcceptedFrontierHandler
	AcceptedHandler
	Haltable
	Startup() error
	Restart(reset bool) error
}

func NewCommonBootstrapper added in v1.7.4

func NewCommonBootstrapper(config Config) Bootstrapper

type BootstrapperTest added in v1.7.4

type BootstrapperTest struct {
	BootstrapableTest
	EngineTest
}

EngineTest is a test engine

func (*BootstrapperTest) Default added in v1.7.4

func (b *BootstrapperTest) Default(cant bool)

type ChitsHandler added in v1.7.4

type ChitsHandler interface {
	// Notify this engine of the specified validators preferences.
	//
	// This function can be called by any validator. It is not safe to assume
	// this message is in response to a PullQuery or a PushQuery message.
	// However, the validatorID is assumed to be authenticated.
	Chits(validatorID ids.NodeID, requestID uint32, containerIDs []ids.ID) error

	// Notify this engine that a query it issued has failed.
	//
	// This function will be called if the engine sent a PullQuery or PushQuery
	// message that is not anticipated to be responded to. This could be because
	// the recipient of the message is unknown or if the message request has
	// timed out.
	//
	// The validatorID and the requestID are assumed to be the same as those
	// sent in the Query message.
	QueryFailed(validatorID ids.NodeID, requestID uint32) error
}

ChitsHandler defines how a consensus engine reacts to query response messages from other validators. Functions only return fatal errors.

func NewNoOpChitsHandler added in v1.7.4

func NewNoOpChitsHandler(log logging.Logger) ChitsHandler

type Config

type Config struct {
	Ctx        *snow.ConsensusContext
	Validators validators.Set
	Beacons    validators.Set

	SampleK        int
	Alpha          uint64
	StartupTracker tracker.Startup
	Sender         Sender
	Bootstrapable  Bootstrapable
	Subnet         Subnet
	Timer          Timer

	// Should Bootstrap be retried
	RetryBootstrap bool

	// Max number of times to retry bootstrap before warning the node operator
	RetryBootstrapWarnFrequency int

	// Max time to spend fetching a container and its ancestors when responding
	// to a GetAncestors
	MaxTimeGetAncestors time.Duration

	// Max number of containers in an ancestors message sent by this node.
	AncestorsMaxContainersSent int

	// This node will only consider the first [AncestorsMaxContainersReceived]
	// containers in an ancestors message it receives.
	AncestorsMaxContainersReceived int

	SharedCfg *SharedConfig
}

Config wraps the common configurations that are needed by a Snow consensus engine

func DefaultConfigTest

func DefaultConfigTest() Config

DefaultConfigTest returns a test configuration

func (*Config) Context

func (c *Config) Context() *snow.ConsensusContext

func (*Config) IsBootstrapped added in v0.8.0

func (c *Config) IsBootstrapped() bool

IsBootstrapped returns true iff this chain is done bootstrapping

type Engine

type Engine interface {
	Handler

	// Return the context of the chain this engine is working on
	Context() *snow.ConsensusContext

	// Start engine operations from given request ID
	Start(startReqID uint32) error

	// Returns nil if the engine is healthy.
	// Periodically called and reported through the health API
	health.Checker

	// GetVM returns this engine's VM
	GetVM() VM
}

Engine describes the standard interface of a consensus engine

type EngineTest

type EngineTest struct {
	T *testing.T

	CantStart,

	CantIsBootstrapped,
	CantTimeout,
	CantGossip,
	CantHalt,
	CantShutdown,

	CantContext,

	CantNotify,

	CantGetStateSummaryFrontier,
	CantGetStateSummaryFrontierFailed,
	CantStateSummaryFrontier,

	CantGetAcceptedStateSummary,
	CantGetAcceptedStateSummaryFailed,
	CantAcceptedStateSummary,

	CantGetAcceptedFrontier,
	CantGetAcceptedFrontierFailed,
	CantAcceptedFrontier,

	CantGetAccepted,
	CantGetAcceptedFailed,
	CantAccepted,

	CantGet,
	CantGetAncestors,
	CantGetFailed,
	CantGetAncestorsFailed,
	CantPut,
	CantAncestors,

	CantPushQuery,
	CantPullQuery,
	CantQueryFailed,
	CantChits,

	CantConnected,
	CantDisconnected,

	CantHealth,

	CantAppRequest,
	CantAppResponse,
	CantAppGossip,
	CantAppRequestFailed,

	CantGetVM bool

	StartF                                             func(startReqID uint32) error
	IsBootstrappedF                                    func() bool
	ContextF                                           func() *snow.ConsensusContext
	HaltF                                              func()
	TimeoutF, GossipF, ShutdownF                       func() error
	NotifyF                                            func(Message) error
	GetF, GetAncestorsF, PullQueryF                    func(nodeID ids.NodeID, requestID uint32, containerID ids.ID) error
	PutF, PushQueryF                                   func(nodeID ids.NodeID, requestID uint32, container []byte) error
	AncestorsF                                         func(nodeID ids.NodeID, requestID uint32, containers [][]byte) error
	AcceptedFrontierF, GetAcceptedF, AcceptedF, ChitsF func(nodeID ids.NodeID, requestID uint32, containerIDs []ids.ID) error
	GetStateSummaryFrontierF, GetStateSummaryFrontierFailedF, GetAcceptedStateSummaryFailedF,
	GetAcceptedFrontierF, GetFailedF, GetAncestorsFailedF,
	QueryFailedF, GetAcceptedFrontierFailedF, GetAcceptedFailedF, AppRequestFailedF func(nodeID ids.NodeID, requestID uint32) error
	StateSummaryFrontierF     func(nodeID ids.NodeID, requestID uint32, summary []byte) error
	GetAcceptedStateSummaryF  func(nodeID ids.NodeID, requestID uint32, keys []uint64) error
	AcceptedStateSummaryF     func(nodeID ids.NodeID, requestID uint32, summaryIDs []ids.ID) error
	ConnectedF                func(nodeID ids.NodeID, nodeVersion version.Application) error
	DisconnectedF             func(nodeID ids.NodeID) error
	HealthF                   func() (interface{}, error)
	GetVMF                    func() VM
	AppRequestF, AppResponseF func(nodeID ids.NodeID, requestID uint32, msg []byte) error
	AppGossipF                func(nodeID ids.NodeID, msg []byte) error
}

EngineTest is a test engine

func (*EngineTest) Accepted

func (e *EngineTest) Accepted(nodeID ids.NodeID, requestID uint32, containerIDs []ids.ID) error

func (*EngineTest) AcceptedFrontier

func (e *EngineTest) AcceptedFrontier(nodeID ids.NodeID, requestID uint32, containerIDs []ids.ID) error

func (*EngineTest) AcceptedStateSummary added in v1.7.11

func (e *EngineTest) AcceptedStateSummary(validatorID ids.NodeID, requestID uint32, summaryIDs []ids.ID) error

func (*EngineTest) Ancestors added in v1.7.4

func (e *EngineTest) Ancestors(nodeID ids.NodeID, requestID uint32, containers [][]byte) error

func (*EngineTest) AppGossip added in v1.5.3

func (e *EngineTest) AppGossip(nodeID ids.NodeID, msg []byte) error

func (*EngineTest) AppRequest added in v1.5.3

func (e *EngineTest) AppRequest(nodeID ids.NodeID, requestID uint32, deadline time.Time, request []byte) error

func (*EngineTest) AppRequestFailed added in v1.5.3

func (e *EngineTest) AppRequestFailed(nodeID ids.NodeID, requestID uint32) error

func (*EngineTest) AppResponse added in v1.5.3

func (e *EngineTest) AppResponse(nodeID ids.NodeID, requestID uint32, response []byte) error

func (*EngineTest) Chits

func (e *EngineTest) Chits(nodeID ids.NodeID, requestID uint32, containerIDs []ids.ID) error

func (*EngineTest) Connected added in v0.8.2

func (e *EngineTest) Connected(nodeID ids.NodeID, nodeVersion version.Application) error

func (*EngineTest) Context

func (e *EngineTest) Context() *snow.ConsensusContext

func (*EngineTest) Default

func (e *EngineTest) Default(cant bool)

func (*EngineTest) Disconnected added in v0.8.2

func (e *EngineTest) Disconnected(nodeID ids.NodeID) error

func (*EngineTest) Get

func (e *EngineTest) Get(nodeID ids.NodeID, requestID uint32, containerID ids.ID) error

func (*EngineTest) GetAccepted

func (e *EngineTest) GetAccepted(nodeID ids.NodeID, requestID uint32, containerIDs []ids.ID) error

func (*EngineTest) GetAcceptedFailed

func (e *EngineTest) GetAcceptedFailed(nodeID ids.NodeID, requestID uint32) error

func (*EngineTest) GetAcceptedFrontier

func (e *EngineTest) GetAcceptedFrontier(nodeID ids.NodeID, requestID uint32) error

func (*EngineTest) GetAcceptedFrontierFailed

func (e *EngineTest) GetAcceptedFrontierFailed(nodeID ids.NodeID, requestID uint32) error

func (*EngineTest) GetAcceptedStateSummary added in v1.7.11

func (e *EngineTest) GetAcceptedStateSummary(validatorID ids.NodeID, requestID uint32, keys []uint64) error

func (*EngineTest) GetAcceptedStateSummaryFailed added in v1.7.11

func (e *EngineTest) GetAcceptedStateSummaryFailed(validatorID ids.NodeID, requestID uint32) error

func (*EngineTest) GetAncestors added in v0.8.0

func (e *EngineTest) GetAncestors(nodeID ids.NodeID, requestID uint32, containerID ids.ID) error

func (*EngineTest) GetAncestorsFailed added in v0.8.0

func (e *EngineTest) GetAncestorsFailed(nodeID ids.NodeID, requestID uint32) error

func (*EngineTest) GetFailed

func (e *EngineTest) GetFailed(nodeID ids.NodeID, requestID uint32) error

func (*EngineTest) GetStateSummaryFrontier added in v1.7.11

func (e *EngineTest) GetStateSummaryFrontier(validatorID ids.NodeID, requestID uint32) error

func (*EngineTest) GetStateSummaryFrontierFailed added in v1.7.11

func (e *EngineTest) GetStateSummaryFrontierFailed(validatorID ids.NodeID, requestID uint32) error

func (*EngineTest) GetVM added in v1.3.2

func (e *EngineTest) GetVM() VM

func (*EngineTest) Gossip added in v0.8.0

func (e *EngineTest) Gossip() error

func (*EngineTest) Halt added in v1.4.0

func (e *EngineTest) Halt()

func (*EngineTest) HealthCheck added in v1.2.1

func (e *EngineTest) HealthCheck() (interface{}, error)

func (*EngineTest) Notify

func (e *EngineTest) Notify(msg Message) error

func (*EngineTest) PullQuery

func (e *EngineTest) PullQuery(nodeID ids.NodeID, requestID uint32, containerID ids.ID) error

func (*EngineTest) PushQuery

func (e *EngineTest) PushQuery(nodeID ids.NodeID, requestID uint32, container []byte) error

func (*EngineTest) Put

func (e *EngineTest) Put(nodeID ids.NodeID, requestID uint32, container []byte) error

func (*EngineTest) QueryFailed

func (e *EngineTest) QueryFailed(nodeID ids.NodeID, requestID uint32) error

func (*EngineTest) Shutdown

func (e *EngineTest) Shutdown() error

func (*EngineTest) Start added in v1.7.4

func (e *EngineTest) Start(startReqID uint32) error

func (*EngineTest) StateSummaryFrontier added in v1.7.11

func (e *EngineTest) StateSummaryFrontier(validatorID ids.NodeID, requestID uint32, summary []byte) error

func (*EngineTest) Timeout added in v1.4.4

func (e *EngineTest) Timeout() error

type FetchSender

type FetchSender interface {
	// Request that the specified node send the specified container to this
	// node.
	SendGet(nodeID ids.NodeID, requestID uint32, containerID ids.ID)

	// SendGetAncestors requests that node [nodeID] send container [containerID]
	// and its ancestors.
	SendGetAncestors(nodeID ids.NodeID, requestID uint32, containerID ids.ID)

	// Tell the specified node that the container whose ID is [containerID] has
	// body [container].
	SendPut(
		nodeID ids.NodeID,
		requestID uint32,
		containerID ids.ID,
		container []byte,
	)

	// Give the specified node several containers at once. Should be in response
	// to a GetAncestors message with request ID [requestID] from the node.
	SendAncestors(nodeID ids.NodeID, requestID uint32, containers [][]byte)
}

FetchSender defines how a consensus engine sends retrieval messages to other nodes.

type Fetcher added in v0.8.0

type Fetcher struct {
	// tracks which validators were asked for which containers in which requests
	OutstandingRequests Requests

	// Called when bootstrapping is done on a specific chain
	OnFinished func(lastReqID uint32) error
}

type FrontierSender

type FrontierSender interface {
	// SendGetAcceptedFrontier requests that every node in [nodeIDs] sends an
	// AcceptedFrontier message.
	SendGetAcceptedFrontier(nodeIDs ids.NodeIDSet, requestID uint32)

	// SendAcceptedFrontier responds to a AcceptedFrontier message with this
	// engine's current accepted frontier.
	SendAcceptedFrontier(
		nodeID ids.NodeID,
		requestID uint32,
		containerIDs []ids.ID,
	)
}

FrontierSender defines how a consensus engine sends frontier messages to other nodes.

type Fx

type Fx struct {
	ID ids.ID
	Fx interface{}
}

Fx wraps an instance of a feature extension

type GetAcceptedFrontierHandler added in v1.7.4

type GetAcceptedFrontierHandler interface {
	// Notify this engine of a request for the accepted frontier of vertices.
	//
	// The accepted frontier is the set of accepted vertices that do not have
	// any accepted descendants.
	//
	// This function can be called by any validator. It is not safe to assume
	// this message is utilizing a unique requestID.
	//
	// This engine should respond with an AcceptedFrontier message with the same
	// requestID, and the engine's current accepted frontier.
	GetAcceptedFrontier(validatorID ids.NodeID, requestID uint32) error
}

GetAcceptedFrontierHandler defines how a consensus engine reacts to a get accepted frontier message from another validator. Functions only return fatal errors.

type GetAcceptedHandler added in v1.7.4

type GetAcceptedHandler interface {
	// Notify this engine of a request to filter non-accepted vertices.
	//
	// This function can be called by any validator. It is not safe to assume
	// this message is utilizing a unique requestID. However, the validatorID is
	// assumed to be authenticated.
	//
	// This engine should respond with an Accepted message with the same
	// requestID, and the subset of the containerIDs that this node has decided
	// are accepted.
	GetAccepted(
		validatorID ids.NodeID,
		requestID uint32,
		containerIDs []ids.ID,
	) error
}

GetAcceptedHandler defines how a consensus engine reacts to a get accepted message from another validator. Functions only return fatal errors.

type GetAcceptedStateSummaryHandler added in v1.7.11

type GetAcceptedStateSummaryHandler interface {
	// Notify this engine of a request to return state summary IDs referenced by
	// the provided keys.
	//
	// This function can be called by any validator. It is not safe to assume
	// this message is utilizing a unique requestID. However, the validatorID is
	// assumed to be authenticated.
	//
	// This engine should respond with an AcceptedStateSummary message with the
	// same requestID, and the subset of the state summaries that this node has
	// locally available.
	GetAcceptedStateSummary(validatorID ids.NodeID, requestID uint32, keys []uint64) error
}

GetAcceptedStateSummaryHandler defines how a consensus engine reacts to a get accepted state summary message from another validator. Functions only return fatal errors.

type GetAncestorsHandler added in v1.7.4

type GetAncestorsHandler interface {
	// Notify this engine of a request for a container and its ancestors.
	//
	// The request is from validator [validatorID]. The requested container is
	// [containerID].
	//
	// This function can be called by any validator. It is not safe to assume
	// this message is utilizing a unique requestID. It is also not safe to
	// assume the requested containerID exists.
	//
	// This engine should respond with an Ancestors message with the same
	// requestID, which contains [containerID] as well as its ancestors. See
	// Ancestors's documentation.
	//
	// If this engine doesn't have some ancestors, it should reply with its best
	// effort attempt at getting them. If this engine doesn't have [containerID]
	// it can ignore this message.
	GetAncestors(validatorID ids.NodeID, requestID uint32, containerID ids.ID) error
}

GetAncestorsHandler defines how a consensus engine reacts to a get ancestors message from another validator. Functions only return fatal errors.

type GetHandler added in v1.7.4

type GetHandler interface {
	// Notify this engine of a request for a container.
	//
	// This function can be called by any validator. It is not safe to assume
	// this message is utilizing a unique requestID. It is also not safe to
	// assume the requested containerID exists.
	//
	// There should never be a situation where a virtuous node sends a Get
	// request to another virtuous node that does not have the requested
	// container.
	//
	// This engine should respond with a Put message with the same requestID if
	// the container was locally available. Otherwise, the message can be safely
	// dropped.
	Get(validatorID ids.NodeID, requestID uint32, containerID ids.ID) error
}

GetHandler defines how a consensus engine reacts to get message from another validator. Functions only return fatal errors.

type GetStateSummaryFrontierHandler added in v1.7.11

type GetStateSummaryFrontierHandler interface {
	// Notify this engine of a request for the frontier of state summaries.
	//
	// The accepted frontier is the last state summary available locally.
	//
	// This function can be called by any validator. It is not safe to assume
	// this message is utilizing a unique requestID.
	//
	// This engine should respond with an StateSummaryFrontier message with the
	// same requestID, and the engine's current state summary frontier.
	GetStateSummaryFrontier(validatorID ids.NodeID, requestID uint32) error
}

GetStateSummaryFrontierHandler defines how a consensus engine reacts to a get state summary frontier message from another validator. Functions only return fatal errors.

type Gossiper added in v0.8.0

type Gossiper interface {
	// Gossip the provided container throughout the network
	SendGossip(containerID ids.ID, container []byte)
}

Gossiper defines how a consensus engine gossips a container on the accepted frontier to other nodes

type HTTPHandler

type HTTPHandler struct {
	LockOptions LockOption
	Handler     http.Handler
}

type Haltable added in v1.4.5

type Haltable interface {
	Halt()
	Halted() bool
}

type Halter added in v1.4.0

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

func (*Halter) Halt added in v1.4.0

func (h *Halter) Halt()

func (*Halter) Halted added in v1.4.0

func (h *Halter) Halted() bool

type InternalHandler

type InternalHandler interface {
	// Notify this engine of peer changes.
	validators.Connector

	// Notify this engine that a registered timeout has fired.
	Timeout() error

	// Gossip to the network a container on the accepted frontier
	Gossip() error

	// Halt this engine.
	//
	// This function will be called before the environment starts exiting. This
	// function is slightly special, in that it does not expect the chain's
	// context lock to be held before calling this function.
	Halt()

	// Shutdown this engine.
	//
	// This function will be called when the environment is exiting.
	Shutdown() error

	// Notify this engine of a message from the virtual machine.
	Notify(Message) error
}

InternalHandler defines how this consensus engine reacts to messages from other components of this validator. Functions only return fatal errors if they occur.

type LockOption

type LockOption uint32

LockOption allows the vm to specify their lock option based on their endpoint

type Message

type Message uint32

Message is an enum of the message types that vms can send to consensus

const (
	// PendingTxs notifies a consensus engine that
	// its VM has pending transactions
	// (i.e. it would like to add a new block/vertex to consensus)
	PendingTxs Message = iota

	// StateSyncDone notifies the state syncer engine that the VM has finishing
	// syncing the requested state summary.
	StateSyncDone

	// StopVertex notifies a consensus that it has a pending stop vertex
	StopVertex
)

func (Message) String

func (msg Message) String() string

type MockAcceptedSender added in v1.7.11

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

MockAcceptedSender is a mock of AcceptedSender interface.

func NewMockAcceptedSender added in v1.7.11

func NewMockAcceptedSender(ctrl *gomock.Controller) *MockAcceptedSender

NewMockAcceptedSender creates a new mock instance.

func (*MockAcceptedSender) EXPECT added in v1.7.11

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockAcceptedSender) SendAccepted added in v1.7.11

func (m *MockAcceptedSender) SendAccepted(nodeID ids.NodeID, requestID uint32, containerIDs []ids.ID)

SendAccepted mocks base method.

func (*MockAcceptedSender) SendGetAccepted added in v1.7.11

func (m *MockAcceptedSender) SendGetAccepted(nodeIDs ids.NodeIDSet, requestID uint32, containerIDs []ids.ID)

SendGetAccepted mocks base method.

type MockAcceptedSenderMockRecorder added in v1.7.11

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

MockAcceptedSenderMockRecorder is the mock recorder for MockAcceptedSender.

func (*MockAcceptedSenderMockRecorder) SendAccepted added in v1.7.11

func (mr *MockAcceptedSenderMockRecorder) SendAccepted(nodeID, requestID, containerIDs interface{}) *gomock.Call

SendAccepted indicates an expected call of SendAccepted.

func (*MockAcceptedSenderMockRecorder) SendGetAccepted added in v1.7.11

func (mr *MockAcceptedSenderMockRecorder) SendGetAccepted(nodeIDs, requestID, containerIDs interface{}) *gomock.Call

SendGetAccepted indicates an expected call of SendGetAccepted.

type MockAcceptedStateSummarySender added in v1.7.11

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

MockAcceptedStateSummarySender is a mock of AcceptedStateSummarySender interface.

func NewMockAcceptedStateSummarySender added in v1.7.11

func NewMockAcceptedStateSummarySender(ctrl *gomock.Controller) *MockAcceptedStateSummarySender

NewMockAcceptedStateSummarySender creates a new mock instance.

func (*MockAcceptedStateSummarySender) EXPECT added in v1.7.11

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockAcceptedStateSummarySender) SendAcceptedStateSummary added in v1.7.11

func (m *MockAcceptedStateSummarySender) SendAcceptedStateSummary(nodeID ids.NodeID, requestID uint32, summaryIDs []ids.ID)

SendAcceptedStateSummary mocks base method.

func (*MockAcceptedStateSummarySender) SendGetAcceptedStateSummary added in v1.7.11

func (m *MockAcceptedStateSummarySender) SendGetAcceptedStateSummary(nodeIDs ids.NodeIDSet, requestID uint32, heights []uint64)

SendGetAcceptedStateSummary mocks base method.

type MockAcceptedStateSummarySenderMockRecorder added in v1.7.11

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

MockAcceptedStateSummarySenderMockRecorder is the mock recorder for MockAcceptedStateSummarySender.

func (*MockAcceptedStateSummarySenderMockRecorder) SendAcceptedStateSummary added in v1.7.11

func (mr *MockAcceptedStateSummarySenderMockRecorder) SendAcceptedStateSummary(nodeID, requestID, summaryIDs interface{}) *gomock.Call

SendAcceptedStateSummary indicates an expected call of SendAcceptedStateSummary.

func (*MockAcceptedStateSummarySenderMockRecorder) SendGetAcceptedStateSummary added in v1.7.11

func (mr *MockAcceptedStateSummarySenderMockRecorder) SendGetAcceptedStateSummary(nodeIDs, requestID, heights interface{}) *gomock.Call

SendGetAcceptedStateSummary indicates an expected call of SendGetAcceptedStateSummary.

type MockAppSender added in v1.7.11

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

MockAppSender is a mock of AppSender interface.

func NewMockAppSender added in v1.7.11

func NewMockAppSender(ctrl *gomock.Controller) *MockAppSender

NewMockAppSender creates a new mock instance.

func (*MockAppSender) EXPECT added in v1.7.11

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockAppSender) SendAppGossip added in v1.7.11

func (m *MockAppSender) SendAppGossip(appGossipBytes []byte) error

SendAppGossip mocks base method.

func (*MockAppSender) SendAppGossipSpecific added in v1.7.11

func (m *MockAppSender) SendAppGossipSpecific(nodeIDs ids.NodeIDSet, appGossipBytes []byte) error

SendAppGossipSpecific mocks base method.

func (*MockAppSender) SendAppRequest added in v1.7.11

func (m *MockAppSender) SendAppRequest(nodeIDs ids.NodeIDSet, requestID uint32, appRequestBytes []byte) error

SendAppRequest mocks base method.

func (*MockAppSender) SendAppResponse added in v1.7.11

func (m *MockAppSender) SendAppResponse(nodeID ids.NodeID, requestID uint32, appResponseBytes []byte) error

SendAppResponse mocks base method.

type MockAppSenderMockRecorder added in v1.7.11

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

MockAppSenderMockRecorder is the mock recorder for MockAppSender.

func (*MockAppSenderMockRecorder) SendAppGossip added in v1.7.11

func (mr *MockAppSenderMockRecorder) SendAppGossip(appGossipBytes interface{}) *gomock.Call

SendAppGossip indicates an expected call of SendAppGossip.

func (*MockAppSenderMockRecorder) SendAppGossipSpecific added in v1.7.11

func (mr *MockAppSenderMockRecorder) SendAppGossipSpecific(nodeIDs, appGossipBytes interface{}) *gomock.Call

SendAppGossipSpecific indicates an expected call of SendAppGossipSpecific.

func (*MockAppSenderMockRecorder) SendAppRequest added in v1.7.11

func (mr *MockAppSenderMockRecorder) SendAppRequest(nodeIDs, requestID, appRequestBytes interface{}) *gomock.Call

SendAppRequest indicates an expected call of SendAppRequest.

func (*MockAppSenderMockRecorder) SendAppResponse added in v1.7.11

func (mr *MockAppSenderMockRecorder) SendAppResponse(nodeID, requestID, appResponseBytes interface{}) *gomock.Call

SendAppResponse indicates an expected call of SendAppResponse.

type MockFetchSender added in v1.7.11

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

MockFetchSender is a mock of FetchSender interface.

func NewMockFetchSender added in v1.7.11

func NewMockFetchSender(ctrl *gomock.Controller) *MockFetchSender

NewMockFetchSender creates a new mock instance.

func (*MockFetchSender) EXPECT added in v1.7.11

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockFetchSender) SendAncestors added in v1.7.11

func (m *MockFetchSender) SendAncestors(nodeID ids.NodeID, requestID uint32, containers [][]byte)

SendAncestors mocks base method.

func (*MockFetchSender) SendGet added in v1.7.11

func (m *MockFetchSender) SendGet(nodeID ids.NodeID, requestID uint32, containerID ids.ID)

SendGet mocks base method.

func (*MockFetchSender) SendGetAncestors added in v1.7.11

func (m *MockFetchSender) SendGetAncestors(nodeID ids.NodeID, requestID uint32, containerID ids.ID)

SendGetAncestors mocks base method.

func (*MockFetchSender) SendPut added in v1.7.11

func (m *MockFetchSender) SendPut(nodeID ids.NodeID, requestID uint32, containerID ids.ID, container []byte)

SendPut mocks base method.

type MockFetchSenderMockRecorder added in v1.7.11

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

MockFetchSenderMockRecorder is the mock recorder for MockFetchSender.

func (*MockFetchSenderMockRecorder) SendAncestors added in v1.7.11

func (mr *MockFetchSenderMockRecorder) SendAncestors(nodeID, requestID, containers interface{}) *gomock.Call

SendAncestors indicates an expected call of SendAncestors.

func (*MockFetchSenderMockRecorder) SendGet added in v1.7.11

func (mr *MockFetchSenderMockRecorder) SendGet(nodeID, requestID, containerID interface{}) *gomock.Call

SendGet indicates an expected call of SendGet.

func (*MockFetchSenderMockRecorder) SendGetAncestors added in v1.7.11

func (mr *MockFetchSenderMockRecorder) SendGetAncestors(nodeID, requestID, containerID interface{}) *gomock.Call

SendGetAncestors indicates an expected call of SendGetAncestors.

func (*MockFetchSenderMockRecorder) SendPut added in v1.7.11

func (mr *MockFetchSenderMockRecorder) SendPut(nodeID, requestID, containerID, container interface{}) *gomock.Call

SendPut indicates an expected call of SendPut.

type MockFrontierSender added in v1.7.11

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

MockFrontierSender is a mock of FrontierSender interface.

func NewMockFrontierSender added in v1.7.11

func NewMockFrontierSender(ctrl *gomock.Controller) *MockFrontierSender

NewMockFrontierSender creates a new mock instance.

func (*MockFrontierSender) EXPECT added in v1.7.11

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockFrontierSender) SendAcceptedFrontier added in v1.7.11

func (m *MockFrontierSender) SendAcceptedFrontier(nodeID ids.NodeID, requestID uint32, containerIDs []ids.ID)

SendAcceptedFrontier mocks base method.

func (*MockFrontierSender) SendGetAcceptedFrontier added in v1.7.11

func (m *MockFrontierSender) SendGetAcceptedFrontier(nodeIDs ids.NodeIDSet, requestID uint32)

SendGetAcceptedFrontier mocks base method.

type MockFrontierSenderMockRecorder added in v1.7.11

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

MockFrontierSenderMockRecorder is the mock recorder for MockFrontierSender.

func (*MockFrontierSenderMockRecorder) SendAcceptedFrontier added in v1.7.11

func (mr *MockFrontierSenderMockRecorder) SendAcceptedFrontier(nodeID, requestID, containerIDs interface{}) *gomock.Call

SendAcceptedFrontier indicates an expected call of SendAcceptedFrontier.

func (*MockFrontierSenderMockRecorder) SendGetAcceptedFrontier added in v1.7.11

func (mr *MockFrontierSenderMockRecorder) SendGetAcceptedFrontier(nodeIDs, requestID interface{}) *gomock.Call

SendGetAcceptedFrontier indicates an expected call of SendGetAcceptedFrontier.

type MockGossiper added in v1.7.11

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

MockGossiper is a mock of Gossiper interface.

func NewMockGossiper added in v1.7.11

func NewMockGossiper(ctrl *gomock.Controller) *MockGossiper

NewMockGossiper creates a new mock instance.

func (*MockGossiper) EXPECT added in v1.7.11

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockGossiper) SendGossip added in v1.7.11

func (m *MockGossiper) SendGossip(containerID ids.ID, container []byte)

SendGossip mocks base method.

type MockGossiperMockRecorder added in v1.7.11

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

MockGossiperMockRecorder is the mock recorder for MockGossiper.

func (*MockGossiperMockRecorder) SendGossip added in v1.7.11

func (mr *MockGossiperMockRecorder) SendGossip(containerID, container interface{}) *gomock.Call

SendGossip indicates an expected call of SendGossip.

type MockQuerySender added in v1.7.11

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

MockQuerySender is a mock of QuerySender interface.

func NewMockQuerySender added in v1.7.11

func NewMockQuerySender(ctrl *gomock.Controller) *MockQuerySender

NewMockQuerySender creates a new mock instance.

func (*MockQuerySender) EXPECT added in v1.7.11

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockQuerySender) SendChits added in v1.7.11

func (m *MockQuerySender) SendChits(nodeID ids.NodeID, requestID uint32, votes []ids.ID)

SendChits mocks base method.

func (*MockQuerySender) SendPullQuery added in v1.7.11

func (m *MockQuerySender) SendPullQuery(nodeIDs ids.NodeIDSet, requestID uint32, containerID ids.ID)

SendPullQuery mocks base method.

func (*MockQuerySender) SendPushQuery added in v1.7.11

func (m *MockQuerySender) SendPushQuery(nodeIDs ids.NodeIDSet, requestID uint32, containerID ids.ID, container []byte)

SendPushQuery mocks base method.

type MockQuerySenderMockRecorder added in v1.7.11

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

MockQuerySenderMockRecorder is the mock recorder for MockQuerySender.

func (*MockQuerySenderMockRecorder) SendChits added in v1.7.11

func (mr *MockQuerySenderMockRecorder) SendChits(nodeID, requestID, votes interface{}) *gomock.Call

SendChits indicates an expected call of SendChits.

func (*MockQuerySenderMockRecorder) SendPullQuery added in v1.7.11

func (mr *MockQuerySenderMockRecorder) SendPullQuery(nodeIDs, requestID, containerID interface{}) *gomock.Call

SendPullQuery indicates an expected call of SendPullQuery.

func (*MockQuerySenderMockRecorder) SendPushQuery added in v1.7.11

func (mr *MockQuerySenderMockRecorder) SendPushQuery(nodeIDs, requestID, containerID, container interface{}) *gomock.Call

SendPushQuery indicates an expected call of SendPushQuery.

type MockSender added in v1.7.11

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

MockSender is a mock of Sender interface.

func NewMockSender added in v1.7.11

func NewMockSender(ctrl *gomock.Controller) *MockSender

NewMockSender creates a new mock instance.

func (*MockSender) Accept added in v1.7.11

func (m *MockSender) Accept(ctx *snow.ConsensusContext, containerID ids.ID, container []byte) error

Accept mocks base method.

func (*MockSender) EXPECT added in v1.7.11

func (m *MockSender) EXPECT() *MockSenderMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockSender) SendAccepted added in v1.7.11

func (m *MockSender) SendAccepted(nodeID ids.NodeID, requestID uint32, containerIDs []ids.ID)

SendAccepted mocks base method.

func (*MockSender) SendAcceptedFrontier added in v1.7.11

func (m *MockSender) SendAcceptedFrontier(nodeID ids.NodeID, requestID uint32, containerIDs []ids.ID)

SendAcceptedFrontier mocks base method.

func (*MockSender) SendAcceptedStateSummary added in v1.7.11

func (m *MockSender) SendAcceptedStateSummary(nodeID ids.NodeID, requestID uint32, summaryIDs []ids.ID)

SendAcceptedStateSummary mocks base method.

func (*MockSender) SendAncestors added in v1.7.11

func (m *MockSender) SendAncestors(nodeID ids.NodeID, requestID uint32, containers [][]byte)

SendAncestors mocks base method.

func (*MockSender) SendAppGossip added in v1.7.11

func (m *MockSender) SendAppGossip(appGossipBytes []byte) error

SendAppGossip mocks base method.

func (*MockSender) SendAppGossipSpecific added in v1.7.11

func (m *MockSender) SendAppGossipSpecific(nodeIDs ids.NodeIDSet, appGossipBytes []byte) error

SendAppGossipSpecific mocks base method.

func (*MockSender) SendAppRequest added in v1.7.11

func (m *MockSender) SendAppRequest(nodeIDs ids.NodeIDSet, requestID uint32, appRequestBytes []byte) error

SendAppRequest mocks base method.

func (*MockSender) SendAppResponse added in v1.7.11

func (m *MockSender) SendAppResponse(nodeID ids.NodeID, requestID uint32, appResponseBytes []byte) error

SendAppResponse mocks base method.

func (*MockSender) SendChits added in v1.7.11

func (m *MockSender) SendChits(nodeID ids.NodeID, requestID uint32, votes []ids.ID)

SendChits mocks base method.

func (*MockSender) SendGet added in v1.7.11

func (m *MockSender) SendGet(nodeID ids.NodeID, requestID uint32, containerID ids.ID)

SendGet mocks base method.

func (*MockSender) SendGetAccepted added in v1.7.11

func (m *MockSender) SendGetAccepted(nodeIDs ids.NodeIDSet, requestID uint32, containerIDs []ids.ID)

SendGetAccepted mocks base method.

func (*MockSender) SendGetAcceptedFrontier added in v1.7.11

func (m *MockSender) SendGetAcceptedFrontier(nodeIDs ids.NodeIDSet, requestID uint32)

SendGetAcceptedFrontier mocks base method.

func (*MockSender) SendGetAcceptedStateSummary added in v1.7.11

func (m *MockSender) SendGetAcceptedStateSummary(nodeIDs ids.NodeIDSet, requestID uint32, heights []uint64)

SendGetAcceptedStateSummary mocks base method.

func (*MockSender) SendGetAncestors added in v1.7.11

func (m *MockSender) SendGetAncestors(nodeID ids.NodeID, requestID uint32, containerID ids.ID)

SendGetAncestors mocks base method.

func (*MockSender) SendGetStateSummaryFrontier added in v1.7.11

func (m *MockSender) SendGetStateSummaryFrontier(nodeIDs ids.NodeIDSet, requestID uint32)

SendGetStateSummaryFrontier mocks base method.

func (*MockSender) SendGossip added in v1.7.11

func (m *MockSender) SendGossip(containerID ids.ID, container []byte)

SendGossip mocks base method.

func (*MockSender) SendPullQuery added in v1.7.11

func (m *MockSender) SendPullQuery(nodeIDs ids.NodeIDSet, requestID uint32, containerID ids.ID)

SendPullQuery mocks base method.

func (*MockSender) SendPushQuery added in v1.7.11

func (m *MockSender) SendPushQuery(nodeIDs ids.NodeIDSet, requestID uint32, containerID ids.ID, container []byte)

SendPushQuery mocks base method.

func (*MockSender) SendPut added in v1.7.11

func (m *MockSender) SendPut(nodeID ids.NodeID, requestID uint32, containerID ids.ID, container []byte)

SendPut mocks base method.

func (*MockSender) SendStateSummaryFrontier added in v1.7.11

func (m *MockSender) SendStateSummaryFrontier(nodeID ids.NodeID, requestID uint32, summary []byte)

SendStateSummaryFrontier mocks base method.

type MockSenderMockRecorder added in v1.7.11

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

MockSenderMockRecorder is the mock recorder for MockSender.

func (*MockSenderMockRecorder) Accept added in v1.7.11

func (mr *MockSenderMockRecorder) Accept(ctx, containerID, container interface{}) *gomock.Call

Accept indicates an expected call of Accept.

func (*MockSenderMockRecorder) SendAccepted added in v1.7.11

func (mr *MockSenderMockRecorder) SendAccepted(nodeID, requestID, containerIDs interface{}) *gomock.Call

SendAccepted indicates an expected call of SendAccepted.

func (*MockSenderMockRecorder) SendAcceptedFrontier added in v1.7.11

func (mr *MockSenderMockRecorder) SendAcceptedFrontier(nodeID, requestID, containerIDs interface{}) *gomock.Call

SendAcceptedFrontier indicates an expected call of SendAcceptedFrontier.

func (*MockSenderMockRecorder) SendAcceptedStateSummary added in v1.7.11

func (mr *MockSenderMockRecorder) SendAcceptedStateSummary(nodeID, requestID, summaryIDs interface{}) *gomock.Call

SendAcceptedStateSummary indicates an expected call of SendAcceptedStateSummary.

func (*MockSenderMockRecorder) SendAncestors added in v1.7.11

func (mr *MockSenderMockRecorder) SendAncestors(nodeID, requestID, containers interface{}) *gomock.Call

SendAncestors indicates an expected call of SendAncestors.

func (*MockSenderMockRecorder) SendAppGossip added in v1.7.11

func (mr *MockSenderMockRecorder) SendAppGossip(appGossipBytes interface{}) *gomock.Call

SendAppGossip indicates an expected call of SendAppGossip.

func (*MockSenderMockRecorder) SendAppGossipSpecific added in v1.7.11

func (mr *MockSenderMockRecorder) SendAppGossipSpecific(nodeIDs, appGossipBytes interface{}) *gomock.Call

SendAppGossipSpecific indicates an expected call of SendAppGossipSpecific.

func (*MockSenderMockRecorder) SendAppRequest added in v1.7.11

func (mr *MockSenderMockRecorder) SendAppRequest(nodeIDs, requestID, appRequestBytes interface{}) *gomock.Call

SendAppRequest indicates an expected call of SendAppRequest.

func (*MockSenderMockRecorder) SendAppResponse added in v1.7.11

func (mr *MockSenderMockRecorder) SendAppResponse(nodeID, requestID, appResponseBytes interface{}) *gomock.Call

SendAppResponse indicates an expected call of SendAppResponse.

func (*MockSenderMockRecorder) SendChits added in v1.7.11

func (mr *MockSenderMockRecorder) SendChits(nodeID, requestID, votes interface{}) *gomock.Call

SendChits indicates an expected call of SendChits.

func (*MockSenderMockRecorder) SendGet added in v1.7.11

func (mr *MockSenderMockRecorder) SendGet(nodeID, requestID, containerID interface{}) *gomock.Call

SendGet indicates an expected call of SendGet.

func (*MockSenderMockRecorder) SendGetAccepted added in v1.7.11

func (mr *MockSenderMockRecorder) SendGetAccepted(nodeIDs, requestID, containerIDs interface{}) *gomock.Call

SendGetAccepted indicates an expected call of SendGetAccepted.

func (*MockSenderMockRecorder) SendGetAcceptedFrontier added in v1.7.11

func (mr *MockSenderMockRecorder) SendGetAcceptedFrontier(nodeIDs, requestID interface{}) *gomock.Call

SendGetAcceptedFrontier indicates an expected call of SendGetAcceptedFrontier.

func (*MockSenderMockRecorder) SendGetAcceptedStateSummary added in v1.7.11

func (mr *MockSenderMockRecorder) SendGetAcceptedStateSummary(nodeIDs, requestID, heights interface{}) *gomock.Call

SendGetAcceptedStateSummary indicates an expected call of SendGetAcceptedStateSummary.

func (*MockSenderMockRecorder) SendGetAncestors added in v1.7.11

func (mr *MockSenderMockRecorder) SendGetAncestors(nodeID, requestID, containerID interface{}) *gomock.Call

SendGetAncestors indicates an expected call of SendGetAncestors.

func (*MockSenderMockRecorder) SendGetStateSummaryFrontier added in v1.7.11

func (mr *MockSenderMockRecorder) SendGetStateSummaryFrontier(nodeIDs, requestID interface{}) *gomock.Call

SendGetStateSummaryFrontier indicates an expected call of SendGetStateSummaryFrontier.

func (*MockSenderMockRecorder) SendGossip added in v1.7.11

func (mr *MockSenderMockRecorder) SendGossip(containerID, container interface{}) *gomock.Call

SendGossip indicates an expected call of SendGossip.

func (*MockSenderMockRecorder) SendPullQuery added in v1.7.11

func (mr *MockSenderMockRecorder) SendPullQuery(nodeIDs, requestID, containerID interface{}) *gomock.Call

SendPullQuery indicates an expected call of SendPullQuery.

func (*MockSenderMockRecorder) SendPushQuery added in v1.7.11

func (mr *MockSenderMockRecorder) SendPushQuery(nodeIDs, requestID, containerID, container interface{}) *gomock.Call

SendPushQuery indicates an expected call of SendPushQuery.

func (*MockSenderMockRecorder) SendPut added in v1.7.11

func (mr *MockSenderMockRecorder) SendPut(nodeID, requestID, containerID, container interface{}) *gomock.Call

SendPut indicates an expected call of SendPut.

func (*MockSenderMockRecorder) SendStateSummaryFrontier added in v1.7.11

func (mr *MockSenderMockRecorder) SendStateSummaryFrontier(nodeID, requestID, summary interface{}) *gomock.Call

SendStateSummaryFrontier indicates an expected call of SendStateSummaryFrontier.

type MockStateSummarySender added in v1.7.11

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

MockStateSummarySender is a mock of StateSummarySender interface.

func NewMockStateSummarySender added in v1.7.11

func NewMockStateSummarySender(ctrl *gomock.Controller) *MockStateSummarySender

NewMockStateSummarySender creates a new mock instance.

func (*MockStateSummarySender) EXPECT added in v1.7.11

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockStateSummarySender) SendGetStateSummaryFrontier added in v1.7.11

func (m *MockStateSummarySender) SendGetStateSummaryFrontier(nodeIDs ids.NodeIDSet, requestID uint32)

SendGetStateSummaryFrontier mocks base method.

func (*MockStateSummarySender) SendStateSummaryFrontier added in v1.7.11

func (m *MockStateSummarySender) SendStateSummaryFrontier(nodeID ids.NodeID, requestID uint32, summary []byte)

SendStateSummaryFrontier mocks base method.

type MockStateSummarySenderMockRecorder added in v1.7.11

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

MockStateSummarySenderMockRecorder is the mock recorder for MockStateSummarySender.

func (*MockStateSummarySenderMockRecorder) SendGetStateSummaryFrontier added in v1.7.11

func (mr *MockStateSummarySenderMockRecorder) SendGetStateSummaryFrontier(nodeIDs, requestID interface{}) *gomock.Call

SendGetStateSummaryFrontier indicates an expected call of SendGetStateSummaryFrontier.

func (*MockStateSummarySenderMockRecorder) SendStateSummaryFrontier added in v1.7.11

func (mr *MockStateSummarySenderMockRecorder) SendStateSummaryFrontier(nodeID, requestID, summary interface{}) *gomock.Call

SendStateSummaryFrontier indicates an expected call of SendStateSummaryFrontier.

type PutHandler added in v1.7.4

type PutHandler interface {
	// Notify this engine of a container.
	//
	// This function can be called by any validator. It is not safe to assume
	// this message is utilizing a unique requestID.
	Put(
		validatorID ids.NodeID,
		requestID uint32,
		container []byte,
	) error

	// Notify this engine that a get request it issued has failed.
	//
	// This function will be called if the engine sent a Get message that is not
	// anticipated to be responded to. This could be because the recipient of
	// the message is unknown or if the message request has timed out.
	//
	// The validatorID and requestID are assumed to be the same as those sent in
	// the Get message.
	GetFailed(validatorID ids.NodeID, requestID uint32) error
}

PutHandler defines how a consensus engine reacts to put messages from other validators. Functions only return fatal errors.

func NewNoOpPutHandler added in v1.7.4

func NewNoOpPutHandler(log logging.Logger) PutHandler

type QueryHandler

type QueryHandler interface {
	// Notify this engine of a request for our preferences.
	//
	// This function can be called by any validator. It is not safe to assume
	// this message is utilizing a unique requestID. However, the validatorID is
	// assumed to be authenticated.
	//
	// If the container or its ancestry is incomplete, this engine is expected
	// to request the missing containers from the validator. Once the ancestry
	// is complete, this engine should send this validator the current
	// preferences in a Chits message. The Chits message should have the same
	// requestID that was passed in here.
	PullQuery(
		validatorID ids.NodeID,
		requestID uint32,
		containerID ids.ID,
	) error

	// Notify this engine of a request for our preferences.
	//
	// This function can be called by any validator. It is not safe to assume
	// this message is utilizing a unique requestID.
	//
	// This function is meant to behave the same way as PullQuery, except the
	// container is optimistically provided to potentially remove the need for
	// a series of Get/Put messages.
	//
	// If the ancestry of the container is incomplete, this engine is expected
	// to request the ancestry from the validator. Once the ancestry is
	// complete, this engine should send this validator the current preferences
	// in a Chits message. The Chits message should have the same requestID that
	// was passed in here.
	PushQuery(
		validatorID ids.NodeID,
		requestID uint32,
		container []byte,
	) error
}

QueryHandler defines how a consensus engine reacts to query messages from other validators. Functions only return fatal errors.

func NewNoOpQueryHandler added in v1.7.4

func NewNoOpQueryHandler(log logging.Logger) QueryHandler

type QuerySender

type QuerySender interface {
	// Request from the specified nodes their preferred frontier, given the
	// existence of the specified container.
	// This is the same as PullQuery, except that this message includes not only
	// the ID of the container but also its body.
	SendPushQuery(
		nodeIDs ids.NodeIDSet,
		requestID uint32,
		containerID ids.ID,
		container []byte,
	)

	// Request from the specified nodes their preferred frontier, given the
	// existence of the specified container.
	SendPullQuery(nodeIDs ids.NodeIDSet, requestID uint32, containerID ids.ID)

	// Send chits to the specified node
	SendChits(nodeID ids.NodeID, requestID uint32, votes []ids.ID)
}

QuerySender defines how a consensus engine sends query messages to other nodes.

type Requests added in v0.8.0

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

Requests tracks pending container messages from a peer.

func (*Requests) Add added in v0.8.0

func (r *Requests) Add(vdr ids.NodeID, requestID uint32, containerID ids.ID)

Add a request. Assumes that requestIDs are unique. Assumes that containerIDs are only in one request at a time.

func (*Requests) Contains added in v0.8.0

func (r *Requests) Contains(containerID ids.ID) bool

Contains returns true if there is an outstanding request for the container ID.

func (*Requests) Len added in v0.8.0

func (r *Requests) Len() int

Len returns the total number of outstanding requests.

func (*Requests) Remove added in v0.8.0

func (r *Requests) Remove(vdr ids.NodeID, requestID uint32) (ids.ID, bool)

Remove attempts to abandon a requestID sent to a validator. If the request is currently outstanding, the requested ID will be returned along with true. If the request isn't currently outstanding, false will be returned.

func (*Requests) RemoveAny added in v0.8.0

func (r *Requests) RemoveAny(containerID ids.ID) bool

RemoveAny outstanding requests for the container ID. True is returned if the container ID had an outstanding request.

func (Requests) String added in v1.2.0

func (r Requests) String() string

type Sender

Sender defines how a consensus engine sends messages and requests to other validators

type SenderTest

type SenderTest struct {
	T *testing.T

	CantAccept,
	CantSendGetStateSummaryFrontier, CantSendStateSummaryFrontier,
	CantSendGetAcceptedStateSummary, CantSendAcceptedStateSummary,
	CantSendGetAcceptedFrontier, CantSendAcceptedFrontier,
	CantSendGetAccepted, CantSendAccepted,
	CantSendGet, CantSendGetAncestors, CantSendPut, CantSendAncestors,
	CantSendPullQuery, CantSendPushQuery, CantSendChits,
	CantSendGossip,
	CantSendAppRequest, CantSendAppResponse, CantSendAppGossip, CantSendAppGossipSpecific bool

	AcceptF                      func(*snow.ConsensusContext, ids.ID, []byte) error
	SendGetStateSummaryFrontierF func(ids.NodeIDSet, uint32)
	SendStateSummaryFrontierF    func(ids.NodeID, uint32, []byte)
	SendGetAcceptedStateSummaryF func(ids.NodeIDSet, uint32, []uint64)
	SendAcceptedStateSummaryF    func(ids.NodeID, uint32, []ids.ID)
	SendGetAcceptedFrontierF     func(ids.NodeIDSet, uint32)
	SendAcceptedFrontierF        func(ids.NodeID, uint32, []ids.ID)
	SendGetAcceptedF             func(ids.NodeIDSet, uint32, []ids.ID)
	SendAcceptedF                func(ids.NodeID, uint32, []ids.ID)
	SendGetF                     func(ids.NodeID, uint32, ids.ID)
	SendGetAncestorsF            func(ids.NodeID, uint32, ids.ID)
	SendPutF                     func(ids.NodeID, uint32, ids.ID, []byte)
	SendAncestorsF               func(ids.NodeID, uint32, [][]byte)
	SendPushQueryF               func(ids.NodeIDSet, uint32, ids.ID, []byte)
	SendPullQueryF               func(ids.NodeIDSet, uint32, ids.ID)
	SendChitsF                   func(ids.NodeID, uint32, []ids.ID)
	SendGossipF                  func(ids.ID, []byte)
	SendAppRequestF              func(ids.NodeIDSet, uint32, []byte) error
	SendAppResponseF             func(ids.NodeID, uint32, []byte) error
	SendAppGossipF               func([]byte) error
	SendAppGossipSpecificF       func(ids.NodeIDSet, []byte) error
}

SenderTest is a test sender

func (*SenderTest) Accept added in v1.7.11

func (s *SenderTest) Accept(ctx *snow.ConsensusContext, containerID ids.ID, container []byte) error

SendGetStateSummaryFrontier calls SendGetStateSummaryFrontierF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) Default

func (s *SenderTest) Default(cant bool)

Default set the default callable value to [cant]

func (*SenderTest) SendAccepted added in v1.5.3

func (s *SenderTest) SendAccepted(validatorID ids.NodeID, requestID uint32, containerIDs []ids.ID)

SendAccepted calls SendAcceptedF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendAcceptedFrontier added in v1.5.3

func (s *SenderTest) SendAcceptedFrontier(validatorID ids.NodeID, requestID uint32, containerIDs []ids.ID)

SendAcceptedFrontier calls SendAcceptedFrontierF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendAcceptedStateSummary added in v1.7.11

func (s *SenderTest) SendAcceptedStateSummary(validatorID ids.NodeID, requestID uint32, summaryIDs []ids.ID)

SendAcceptedStateSummary calls SendAcceptedStateSummaryF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendAncestors added in v1.7.4

func (s *SenderTest) SendAncestors(vdr ids.NodeID, requestID uint32, vtxs [][]byte)

SendAncestors calls SendAncestorsF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendAppGossip added in v1.5.3

func (s *SenderTest) SendAppGossip(appGossipBytes []byte) error

SendAppGossip calls SendAppGossipF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendAppGossipSpecific added in v1.6.2

func (s *SenderTest) SendAppGossipSpecific(nodeIDs ids.NodeIDSet, appGossipBytes []byte) error

SendAppGossipSpecific calls SendAppGossipSpecificF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendAppRequest added in v1.5.3

func (s *SenderTest) SendAppRequest(nodeIDs ids.NodeIDSet, requestID uint32, appRequestBytes []byte) error

SendAppRequest calls SendAppRequestF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendAppResponse added in v1.5.3

func (s *SenderTest) SendAppResponse(nodeID ids.NodeID, requestID uint32, appResponseBytes []byte) error

SendAppResponse calls SendAppResponseF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendChits added in v1.5.3

func (s *SenderTest) SendChits(vdr ids.NodeID, requestID uint32, votes []ids.ID)

SendChits calls SendChitsF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendGet added in v1.5.3

func (s *SenderTest) SendGet(vdr ids.NodeID, requestID uint32, vtxID ids.ID)

SendGet calls SendGetF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendGetAccepted added in v1.5.3

func (s *SenderTest) SendGetAccepted(nodeIDs ids.NodeIDSet, requestID uint32, containerIDs []ids.ID)

SendGetAccepted calls SendGetAcceptedF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendGetAcceptedFrontier added in v1.5.3

func (s *SenderTest) SendGetAcceptedFrontier(validatorIDs ids.NodeIDSet, requestID uint32)

SendGetAcceptedFrontier calls SendGetAcceptedFrontierF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendGetAcceptedStateSummary added in v1.7.11

func (s *SenderTest) SendGetAcceptedStateSummary(nodeIDs ids.NodeIDSet, requestID uint32, heights []uint64)

SendGetAcceptedStateSummary calls SendGetAcceptedStateSummaryF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendGetAncestors added in v1.5.3

func (s *SenderTest) SendGetAncestors(validatorID ids.NodeID, requestID uint32, vtxID ids.ID)

SendGetAncestors calls SendGetAncestorsF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendGetStateSummaryFrontier added in v1.7.11

func (s *SenderTest) SendGetStateSummaryFrontier(validatorIDs ids.NodeIDSet, requestID uint32)

SendGetStateSummaryFrontier calls SendGetStateSummaryFrontierF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendGossip added in v1.5.3

func (s *SenderTest) SendGossip(containerID ids.ID, container []byte)

SendGossip calls SendGossipF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendPullQuery added in v1.5.3

func (s *SenderTest) SendPullQuery(vdrs ids.NodeIDSet, requestID uint32, vtxID ids.ID)

SendPullQuery calls SendPullQueryF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendPushQuery added in v1.5.3

func (s *SenderTest) SendPushQuery(vdrs ids.NodeIDSet, requestID uint32, vtxID ids.ID, vtx []byte)

SendPushQuery calls SendPushQueryF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendPut added in v1.5.3

func (s *SenderTest) SendPut(vdr ids.NodeID, requestID uint32, vtxID ids.ID, vtx []byte)

SendPut calls SendPutF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SenderTest) SendStateSummaryFrontier added in v1.7.11

func (s *SenderTest) SendStateSummaryFrontier(validatorID ids.NodeID, requestID uint32, summary []byte)

SendAcceptedFrontier calls SendAcceptedFrontierF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

type SharedConfig added in v1.7.4

type SharedConfig struct {
	// Tracks the last requestID that was used in a request
	RequestID uint32

	// True if RestartBootstrap has been called at least once
	Restarted bool
}

Shared among common.bootstrapper and snowman/avalanche bootstrapper

type StateSummaryFrontierHandler added in v1.7.11

type StateSummaryFrontierHandler interface {
	// Notify this engine of a state summary frontier.
	//
	// This function can be called by any validator. It is not safe to assume
	// this message is in response to a GetStateSummaryFrontier message, is
	// utilizing a unique requestID, or that the summary bytes are from a valid
	// state summary.
	StateSummaryFrontier(validatorID ids.NodeID, requestID uint32, summary []byte) error

	// Notify this engine that a get state summary frontier request it issued
	// has failed.
	//
	// This function will be called if the engine sent a GetStateSummaryFrontier
	// message that is not anticipated to be responded to. This could be because
	// the recipient of the message is unknown or if the message request has
	// timed out.
	//
	// The validatorID, and requestID, are assumed to be the same as those sent
	// in the GetStateSummaryFrontier message.
	GetStateSummaryFrontierFailed(validatorID ids.NodeID, requestID uint32) error
}

StateSummaryFrontierHandler defines how a consensus engine reacts to a state summary frontier message from other validators. Functions only return fatal errors.

func NewNoOpStateSummaryFrontierHandler added in v1.7.11

func NewNoOpStateSummaryFrontierHandler(log logging.Logger) StateSummaryFrontierHandler

type StateSummarySender added in v1.7.11

type StateSummarySender interface {
	// SendGetStateSummaryFrontier requests that every node in [nodeIDs] sends a
	// StateSummaryFrontier message.
	SendGetStateSummaryFrontier(nodeIDs ids.NodeIDSet, requestID uint32)

	// SendStateSummaryFrontier responds to a StateSummaryFrontier message with this
	// engine's current state summary frontier.
	SendStateSummaryFrontier(nodeID ids.NodeID, requestID uint32, summary []byte)
}

StateSummarySender defines how a consensus engine sends state sync messages to other nodes.

type StateSyncer added in v1.7.11

type StateSyncer interface {
	Engine

	// IsEnabled returns true if the underlying VM wants to perform state sync.
	// Any returned error will be considered fatal.
	IsEnabled() (bool, error)
}

StateSyncer controls the selection and verification of state summaries to drive VM state syncing. It collects the latest state summaries and elicit votes on them, making sure that a qualified majority of nodes support the selected state summary.

type Subnet added in v1.2.1

type Subnet interface {
	// Returns true iff the subnet is done bootstrapping
	IsBootstrapped() bool

	// Bootstrapped marks the named chain as being bootstrapped
	Bootstrapped(chainID ids.ID)
}

Subnet describes the standard interface of a subnet description

type SubnetTest added in v1.2.1

type SubnetTest struct {
	T *testing.T

	CantIsBootstrapped, CantBootstrapped bool

	IsBootstrappedF func() bool
	BootstrappedF   func(ids.ID)
}

SubnetTest is a test subnet

func (*SubnetTest) Bootstrapped added in v1.2.1

func (s *SubnetTest) Bootstrapped(chainID ids.ID)

Bootstrapped calls BootstrappedF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*SubnetTest) Default added in v1.2.1

func (s *SubnetTest) Default(cant bool)

Default set the default callable value to [cant]

func (*SubnetTest) IsBootstrapped added in v1.2.1

func (s *SubnetTest) IsBootstrapped() bool

IsBootstrapped calls IsBootstrappedF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail. Defaults to returning false.

type SubnetTracker added in v1.7.11

type SubnetTracker interface {
	// TracksSubnet returns true if [nodeID] tracks [subnetID]
	TracksSubnet(nodeID ids.NodeID, subnetID ids.ID) bool
}

SubnetTracker describes the interface for checking if a node is tracking a subnet

type TestVM added in v0.8.0

type TestVM struct {
	T *testing.T

	CantInitialize, CantSetState,
	CantShutdown, CantCreateHandlers, CantCreateStaticHandlers,
	CantHealthCheck, CantConnected, CantDisconnected, CantVersion,
	CantAppRequest, CantAppResponse, CantAppGossip, CantAppRequestFailed bool

	InitializeF           func(*snow.Context, manager.Manager, []byte, []byte, []byte, chan<- Message, []*Fx, AppSender) error
	SetStateF             func(snow.State) error
	ShutdownF             func() error
	CreateHandlersF       func() (map[string]*HTTPHandler, error)
	CreateStaticHandlersF func() (map[string]*HTTPHandler, error)
	ConnectedF            func(nodeID ids.NodeID, nodeVersion version.Application) error
	DisconnectedF         func(nodeID ids.NodeID) error
	HealthCheckF          func() (interface{}, error)
	AppRequestF           func(nodeID ids.NodeID, requestID uint32, deadline time.Time, msg []byte) error
	AppResponseF          func(nodeID ids.NodeID, requestID uint32, msg []byte) error
	AppGossipF            func(nodeID ids.NodeID, msg []byte) error
	AppRequestFailedF     func(nodeID ids.NodeID, requestID uint32) error
	VersionF              func() (string, error)
}

TestVM is a test vm

func (*TestVM) AppGossip added in v1.5.3

func (vm *TestVM) AppGossip(nodeID ids.NodeID, msg []byte) error

func (*TestVM) AppRequest added in v1.5.3

func (vm *TestVM) AppRequest(nodeID ids.NodeID, requestID uint32, deadline time.Time, request []byte) error

func (*TestVM) AppRequestFailed added in v1.5.3

func (vm *TestVM) AppRequestFailed(nodeID ids.NodeID, requestID uint32) error

func (*TestVM) AppResponse added in v1.5.3

func (vm *TestVM) AppResponse(nodeID ids.NodeID, requestID uint32, response []byte) error

func (*TestVM) Connected added in v1.4.8

func (vm *TestVM) Connected(id ids.NodeID, nodeVersion version.Application) error

func (*TestVM) CreateHandlers added in v0.8.0

func (vm *TestVM) CreateHandlers() (map[string]*HTTPHandler, error)

func (*TestVM) CreateStaticHandlers added in v0.8.0

func (vm *TestVM) CreateStaticHandlers() (map[string]*HTTPHandler, error)

func (*TestVM) Default added in v0.8.0

func (vm *TestVM) Default(cant bool)

func (*TestVM) Disconnected added in v1.4.8

func (vm *TestVM) Disconnected(id ids.NodeID) error

func (*TestVM) HealthCheck added in v1.2.1

func (vm *TestVM) HealthCheck() (interface{}, error)

func (*TestVM) Initialize added in v0.8.0

func (vm *TestVM) Initialize(ctx *snow.Context, db manager.Manager, genesisBytes, upgradeBytes, configBytes []byte, msgChan chan<- Message, fxs []*Fx, appSender AppSender) error

func (*TestVM) SetState added in v1.7.5

func (vm *TestVM) SetState(state snow.State) error

func (*TestVM) Shutdown added in v0.8.0

func (vm *TestVM) Shutdown() error

func (*TestVM) Version added in v1.4.10

func (vm *TestVM) Version() (string, error)

type Timer added in v1.4.4

type Timer interface {
	// RegisterTimeout specifies how much time to delay the next timeout message
	// by. If the subnet has been bootstrapped, the timeout will fire
	// immediately.
	RegisterTimeout(time.Duration)
}

Timer describes the standard interface for specifying a timeout

type TimerTest added in v1.4.4

type TimerTest struct {
	T *testing.T

	CantRegisterTimout bool

	RegisterTimeoutF func(time.Duration)
}

TimerTest is a test timer

func (*TimerTest) Default added in v1.4.4

func (t *TimerTest) Default(cant bool)

Default set the default callable value to [cant]

func (*TimerTest) RegisterTimeout added in v1.4.4

func (t *TimerTest) RegisterTimeout(delay time.Duration)

type VM

type VM interface {
	AppHandler

	// Returns nil if the VM is healthy.
	// Periodically called and reported via the node's Health API.
	health.Checker

	// Connector represents a handler that is called on connection connect/disconnect
	validators.Connector

	// Initialize this VM.
	// [ctx]: Metadata about this VM.
	//     [ctx.networkID]: The ID of the network this VM's chain is running on.
	//     [ctx.chainID]: The unique ID of the chain this VM is running on.
	//     [ctx.Log]: Used to log messages
	//     [ctx.NodeID]: The unique staker ID of this node.
	//     [ctx.Lock]: A Read/Write lock shared by this VM and the consensus
	//                 engine that manages this VM. The write lock is held
	//                 whenever code in the consensus engine calls the VM.
	// [dbManager]: The manager of the database this VM will persist data to.
	// [genesisBytes]: The byte-encoding of the genesis information of this
	//                 VM. The VM uses it to initialize its state. For
	//                 example, if this VM were an account-based payments
	//                 system, `genesisBytes` would probably contain a genesis
	//                 transaction that gives coins to some accounts, and this
	//                 transaction would be in the genesis block.
	// [toEngine]: The channel used to send messages to the consensus engine.
	// [fxs]: Feature extensions that attach to this VM.
	Initialize(
		ctx *snow.Context,
		dbManager manager.Manager,
		genesisBytes []byte,
		upgradeBytes []byte,
		configBytes []byte,
		toEngine chan<- Message,
		fxs []*Fx,
		appSender AppSender,
	) error

	// SetState communicates to VM its next state it starts
	SetState(state snow.State) error

	// Shutdown is called when the node is shutting down.
	Shutdown() error

	// Version returns the version of the VM this node is running.
	Version() (string, error)

	// Creates the HTTP handlers for custom VM network calls.
	//
	// This exposes handlers that the outside world can use to communicate with
	// a static reference to the VM. Each handler has the path:
	// [Address of node]/ext/VM/[VM ID]/[extension]
	//
	// Returns a mapping from [extension]s to HTTP handlers.
	//
	// Each extension can specify how locking is managed for convenience.
	//
	// For example, it might make sense to have an extension for creating
	// genesis bytes this VM can interpret.
	CreateStaticHandlers() (map[string]*HTTPHandler, error)

	// Creates the HTTP handlers for custom chain network calls.
	//
	// This exposes handlers that the outside world can use to communicate with
	// the chain. Each handler has the path:
	// [Address of node]/ext/bc/[chain ID]/[extension]
	//
	// Returns a mapping from [extension]s to HTTP handlers.
	//
	// Each extension can specify how locking is managed for convenience.
	//
	// For example, if this VM implements an account-based payments system,
	// it have an extension called `accounts`, where clients could get
	// information about their accounts.
	CreateHandlers() (map[string]*HTTPHandler, error)
}

VM describes the interface that all consensus VMs must implement

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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