cmd

package
v0.20.3 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: AGPL-3.0 Imports: 38 Imported by: 13

Documentation

Index

Constants

View Source
const NotSet = "not set"

Variables

This section is empty.

Functions

func IsValidNodeMachineAccountConfig added in v0.20.0

func IsValidNodeMachineAccountConfig(node *NodeConfig, accessAddress string) bool

IsValidNodeMachineAccountConfig returns true if the machine account file exists at the default path and if the `access-address` is set else returns false.

func LoadNodeMachineAccountInfoFile added in v0.20.0

func LoadNodeMachineAccountInfoFile(bootstrapDir string, nodeID flow.Identifier) (*bootstrap.NodeMachineAccountInfo, error)

LoadNodeMachineAccountInfoFile loads machine account info from the default location within the bootstrap directory - Currently being used by Collection and Consensus nodes

Types

type BaseConfig

type BaseConfig struct {
	NodeRole string

	BootstrapDir string
	// contains filtered or unexported fields
}

BaseConfig is the general config for the NodeBuilder and the command line params

type FlowNodeBuilder

type FlowNodeBuilder struct {
	*NodeConfig
	// contains filtered or unexported fields
}

FlowNodeBuilder is the default builder struct used for all flow nodes It runs a node process with following structure, in sequential order Base inits (network, storage, state, logger)

PostInit handlers, if any

Components handlers, if any, wait sequentially Run() <- main loop Components destructors, if any The initialization can be proceeded and succeeded with PreInit and PostInit functions that allow customization of the process in case of nodes such as the unstaked access node where the NodeInfo is not part of the genesis data

func FlowNode

func FlowNode(role string) *FlowNodeBuilder

FlowNode creates a new Flow node builder with the given name.

func (*FlowNodeBuilder) BaseFlags added in v0.20.0

func (fnb *FlowNodeBuilder) BaseFlags()

func (*FlowNodeBuilder) Component

func (fnb *FlowNodeBuilder) Component(name string, f func(builder NodeBuilder, node *NodeConfig) (module.ReadyDoneAware, error)) NodeBuilder

Component adds a new component to the node that conforms to the ReadyDone interface.

When the node is run, this component will be started with `Ready`. When the node is stopped, we will wait for the component to exit gracefully with `Done`.

func (*FlowNodeBuilder) EnqueueMetricsServerInit added in v0.20.0

func (fnb *FlowNodeBuilder) EnqueueMetricsServerInit()

func (*FlowNodeBuilder) EnqueueNetworkInit added in v0.20.0

func (fnb *FlowNodeBuilder) EnqueueNetworkInit()

func (*FlowNodeBuilder) EnqueueTracer added in v0.20.0

func (fnb *FlowNodeBuilder) EnqueueTracer()

func (*FlowNodeBuilder) ExtraFlags

func (fnb *FlowNodeBuilder) ExtraFlags(f func(*pflag.FlagSet)) NodeBuilder

ExtraFlags enables binding additional flags beyond those defined in BaseConfig.

func (*FlowNodeBuilder) Initialize added in v0.20.0

func (fnb *FlowNodeBuilder) Initialize() NodeBuilder

func (*FlowNodeBuilder) Module

func (fnb *FlowNodeBuilder) Module(name string, f func(builder NodeBuilder, node *NodeConfig) error) NodeBuilder

Module enables setting up dependencies of the engine with the builder context.

func (*FlowNodeBuilder) MustNot

func (fnb *FlowNodeBuilder) MustNot(err error) *zerolog.Event

MustNot asserts that the given error must not occur.

If the error is nil, returns a nil log event (which acts as a no-op). If the error is not nil, returns a fatal log event containing the error.

func (*FlowNodeBuilder) ParseAndPrintFlags added in v0.20.0

func (fnb *FlowNodeBuilder) ParseAndPrintFlags()

func (*FlowNodeBuilder) PostInit

func (fnb *FlowNodeBuilder) PostInit(f func(builder NodeBuilder, node *NodeConfig)) NodeBuilder

func (*FlowNodeBuilder) PreInit added in v0.20.0

func (fnb *FlowNodeBuilder) PreInit(f func(builder NodeBuilder, node *NodeConfig)) NodeBuilder

func (*FlowNodeBuilder) PrintBuildVersionDetails added in v0.20.0

func (fnb *FlowNodeBuilder) PrintBuildVersionDetails()

func (*FlowNodeBuilder) RegisterBadgerMetrics added in v0.20.0

func (fnb *FlowNodeBuilder) RegisterBadgerMetrics()

func (*FlowNodeBuilder) Run

func (fnb *FlowNodeBuilder) Run()

Run initiates all common components (logger, database, protocol state etc.) then starts each component. It also sets up a channel to gracefully shut down each component if a SIGINT is received.

type Metrics

type Metrics struct {
	Network    module.NetworkMetrics
	Engine     module.EngineMetrics
	Compliance module.ComplianceMetrics
	Cache      module.CacheMetrics
	Mempool    module.MempoolMetrics
}

type NodeBuilder added in v0.20.0

type NodeBuilder interface {

	// BaseFlags reads the command line arguments common to all nodes
	BaseFlags()

	// ExtraFlags reads the node specific command line arguments and adds it to the FlagSet
	ExtraFlags(f func(*pflag.FlagSet)) NodeBuilder

	// ParseAndPrintFlags parses all the command line arguments
	ParseAndPrintFlags()

	// Initialize performs all the initialization needed at the very start of a node
	Initialize() NodeBuilder

	// PrintBuildVersionDetails prints the node software build version
	PrintBuildVersionDetails()

	// EnqueueNetworkInit enqueues the default network component
	EnqueueNetworkInit()

	// EnqueueMetricsServerInit enqueues the metrics component
	EnqueueMetricsServerInit()

	// Enqueues the Tracer component
	EnqueueTracer()

	// Module enables setting up dependencies of the engine with the builder context
	Module(name string, f func(builder NodeBuilder, node *NodeConfig) error) NodeBuilder

	// Component adds a new component to the node that conforms to the ReadyDone
	// interface.
	//
	// When the node is run, this component will be started with `Ready`. When the
	// node is stopped, we will wait for the component to exit gracefully with
	// `Done`.
	Component(name string, f func(builder NodeBuilder, node *NodeConfig) (module.ReadyDoneAware, error)) NodeBuilder

	// MustNot asserts that the given error must not occur.
	// If the error is nil, returns a nil log event (which acts as a no-op).
	// If the error is not nil, returns a fatal log event containing the error.
	MustNot(err error) *zerolog.Event

	// Run initiates all common components (logger, database, protocol state etc.)
	// then starts each component. It also sets up a channel to gracefully shut
	// down each component if a SIGINT is received.
	Run()

	// PreInit registers a new PreInit function.
	// PreInit functions run before the protocol state is initialized or any other modules or components are initialized
	PreInit(f func(builder NodeBuilder, node *NodeConfig)) NodeBuilder

	// PostInit registers a new PreInit function.
	// PostInit functions run after the protocol state has been initialized but before any other modules or components
	// are initialized
	PostInit(f func(builder NodeBuilder, node *NodeConfig)) NodeBuilder

	// RegisterBadgerMetrics registers all badger related metrics
	RegisterBadgerMetrics()
}

NodeBuilder declares the initialization methods needed to bootstrap up a Flow node

type NodeConfig added in v0.20.0

type NodeConfig struct {
	BaseConfig
	Logger            zerolog.Logger
	NodeID            flow.Identifier
	Me                *local.Local
	Tracer            module.Tracer
	MetricsRegisterer prometheus.Registerer
	Metrics           Metrics
	DB                *badger.DB
	Storage           Storage
	ProtocolEvents    *events.Distributor
	State             protocol.State
	Middleware        *p2p.Middleware
	Network           *p2p.Network
	MsgValidators     []network.MessageValidator
	FvmOptions        []fvm.Option
	StakingKey        crypto.PrivateKey
	NetworkKey        crypto.PrivateKey

	// root state information
	RootBlock   *flow.Block
	RootQC      *flow.QuorumCertificate
	RootResult  *flow.ExecutionResult
	RootSeal    *flow.Seal
	RootChainID flow.ChainID
}

NodeConfig contains all the derived parameters such the NodeID, private keys etc. and initialized instances of structs such as DB, Network etc. The NodeConfig is composed of the BaseConfig and is updated in the NodeBuilder functions as a node is bootstrapped.

type Storage

type Storage struct {
	Headers      storage.Headers
	Index        storage.Index
	Identities   storage.Identities
	Guarantees   storage.Guarantees
	Receipts     storage.ExecutionReceipts
	Results      storage.ExecutionResults
	Seals        storage.Seals
	Payloads     storage.Payloads
	Blocks       storage.Blocks
	Transactions storage.Transactions
	Collections  storage.Collections
	Setups       storage.EpochSetups
	Commits      storage.EpochCommits
	Statuses     storage.EpochStatuses
	DKGKeys      storage.DKGKeys
}

Directories

Path Synopsis
cmd
contains CLI logic that can exit the program and read/write files.
contains CLI logic that can exit the program and read/write files.
gcs
run
contains reusable logic that does not know about a CLI.
contains reusable logic that does not know about a CLI.
Package build contains information about the build that injected at build-time.
Package build contains information about the build that injected at build-time.
testclient module
cmd

Jump to

Keyboard shortcuts

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