 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
- func LoadNodeMachineAccountInfoFile(bootstrapDir string, nodeID flow.Identifier) (*bootstrap.NodeMachineAccountInfo, error)
- func MarkFlagRequired(command *cobra.Command, flagName string)
- type BaseConfig
- type FlowNodeBuilder
- func (fnb *FlowNodeBuilder) AdminCommand(command string, handler admin.CommandHandler, validator admin.CommandValidator) NodeBuilder
- func (fnb *FlowNodeBuilder) BaseFlags()
- func (fnb *FlowNodeBuilder) Component(name string, ...) NodeBuilder
- func (fnb *FlowNodeBuilder) Done() <-chan struct{}
- func (fnb *FlowNodeBuilder) EnqueueAdminServerInit(ctx context.Context)
- func (fnb *FlowNodeBuilder) EnqueueMetricsServerInit()
- func (fnb *FlowNodeBuilder) EnqueueNetworkInit(ctx context.Context)
- func (fnb *FlowNodeBuilder) EnqueueTracer()
- func (fnb *FlowNodeBuilder) ExtraFlags(f func(*pflag.FlagSet)) NodeBuilder
- func (fnb *FlowNodeBuilder) InitIDProviders()
- func (fnb *FlowNodeBuilder) Initialize() error
- func (fnb *FlowNodeBuilder) Module(name string, f func(builder NodeBuilder, node *NodeConfig) error) NodeBuilder
- func (fnb *FlowNodeBuilder) MustNot(err error) *zerolog.Event
- func (fnb *FlowNodeBuilder) ParseAndPrintFlags()
- func (fnb *FlowNodeBuilder) PostInit(f func(builder NodeBuilder, node *NodeConfig)) NodeBuilder
- func (fnb *FlowNodeBuilder) PreInit(f func(builder NodeBuilder, node *NodeConfig)) NodeBuilder
- func (fnb *FlowNodeBuilder) PrintBuildVersionDetails()
- func (fnb *FlowNodeBuilder) Ready() <-chan struct{}
- func (fnb *FlowNodeBuilder) RegisterBadgerMetrics() error
- func (fnb *FlowNodeBuilder) Run()
- func (fnb *FlowNodeBuilder) ValidateFlags(f func() error) NodeBuilder
 
- type Metrics
- type NodeBuilder
- type NodeConfig
- type Option
- func WithBindAddress(bindAddress string) Option
- func WithBootstrapDir(bootstrapDir string) Option
- func WithDB(db *badger.DB) Option
- func WithDataDir(dataDir string) Option
- func WithLogLevel(level string) Option
- func WithMetricsEnabled(enabled bool) Option
- func WithSecretsDBEnabled(enabled bool) Option
 
- type Storage
Constants ¶
const NotSet = "not set"
    Variables ¶
This section is empty.
Functions ¶
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
func MarkFlagRequired ¶ added in v0.22.0
MarkFlagRequired marks a flag added to a cobra command as required. Panics if the flag has not been added to the cobra command (indicates misconfiguration or typo).
Types ¶
type BaseConfig ¶
type BaseConfig struct {
	BindAddr string
	NodeRole string
	BootstrapDir          string
	PeerUpdateInterval    time.Duration
	UnicastMessageTimeout time.Duration
	DNSCacheTTL           time.Duration
	// contains filtered or unexported fields
}
    BaseConfig is the general config for the NodeBuilder and the command line params For a node running as a standalone process, the config fields will be populated from the command line params, while for a node running as a library, the config fields are expected to be initialized by the caller.
func DefaultBaseConfig ¶ added in v0.21.0
func DefaultBaseConfig() *BaseConfig
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, opts ...Option) *FlowNodeBuilder
FlowNode creates a new Flow node builder with the given name.
func (*FlowNodeBuilder) AdminCommand ¶ added in v0.22.0
func (fnb *FlowNodeBuilder) AdminCommand(command string, handler admin.CommandHandler, validator admin.CommandValidator) NodeBuilder
AdminCommand registers a new admin command with the admin server
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) Done ¶ added in v0.21.0
func (fnb *FlowNodeBuilder) Done() <-chan struct{}
Done returns a channel that closes after all registered components are stopped
func (*FlowNodeBuilder) EnqueueAdminServerInit ¶ added in v0.22.0
func (fnb *FlowNodeBuilder) EnqueueAdminServerInit(ctx context.Context)
func (*FlowNodeBuilder) EnqueueMetricsServerInit ¶ added in v0.20.0
func (fnb *FlowNodeBuilder) EnqueueMetricsServerInit()
func (*FlowNodeBuilder) EnqueueNetworkInit ¶ added in v0.20.0
func (fnb *FlowNodeBuilder) EnqueueNetworkInit(ctx context.Context)
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) InitIDProviders ¶ added in v0.21.1
func (fnb *FlowNodeBuilder) InitIDProviders()
func (*FlowNodeBuilder) Initialize ¶ added in v0.20.0
func (fnb *FlowNodeBuilder) Initialize() error
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) Ready ¶ added in v0.21.0
func (fnb *FlowNodeBuilder) Ready() <-chan struct{}
Ready returns a channel that closes after initiating all common components (logger, database, protocol state etc.) and then starting all modules and components.
func (*FlowNodeBuilder) RegisterBadgerMetrics ¶ added in v0.20.0
func (fnb *FlowNodeBuilder) RegisterBadgerMetrics() error
func (*FlowNodeBuilder) Run ¶
func (fnb *FlowNodeBuilder) Run()
Run calls Ready() to start all the node modules and components. It also sets up a channel to gracefully shut down each component if a SIGINT is received. Until a SIGINT is received, Run will block. Since, Run is a blocking call it should only be used when running a node as it's own independent process.
func (*FlowNodeBuilder) ValidateFlags ¶ added in v0.20.6
func (fnb *FlowNodeBuilder) ValidateFlags(f func() error) NodeBuilder
type Metrics ¶
type Metrics struct {
	Network        module.NetworkMetrics
	Engine         module.EngineMetrics
	Compliance     module.ComplianceMetrics
	Cache          module.CacheMetrics
	Mempool        module.MempoolMetrics
	CleanCollector module.CleanerMetrics
}
    type NodeBuilder ¶ added in v0.20.0
type NodeBuilder interface {
	module.ReadyDoneAware
	// 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() error
	// PrintBuildVersionDetails prints the node software build version
	PrintBuildVersionDetails()
	// InitIDProviders initializes the ID providers needed by various components
	InitIDProviders()
	// EnqueueNetworkInit enqueues the default network component with the given context
	EnqueueNetworkInit(ctx context.Context)
	// 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
	// AdminCommand registers a new admin command with the admin server
	AdminCommand(command string, handler admin.CommandHandler, validator admin.CommandValidator) 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() error
	// ValidateFlags is an extra method called after parsing flags, intended for extra check of flag validity
	// for example where certain combinations aren't allowed
	ValidateFlags(func() error) NodeBuilder
}
    NodeBuilder declares the initialization methods needed to bootstrap up a Flow node
type NodeConfig ¶ added in v0.20.0
type NodeConfig struct {
	Cancel context.CancelFunc // cancel function for the context that is passed to the networking layer
	BaseConfig
	Logger            zerolog.Logger
	NodeID            flow.Identifier
	Me                *local.Local
	Tracer            module.Tracer
	MetricsRegisterer prometheus.Registerer
	Metrics           Metrics
	DB                *badger.DB
	SecretsDB         *badger.DB
	Storage           Storage
	ProtocolEvents    *events.Distributor
	State             protocol.State
	Middleware        network.Middleware
	Network           module.ReadyDoneAwareNetwork
	MsgValidators     []network.MessageValidator
	FvmOptions        []fvm.Option
	StakingKey        crypto.PrivateKey
	NetworkKey        crypto.PrivateKey
	// ID providers
	IdentityProvider             id.IdentityProvider
	IDTranslator                 p2p.IDTranslator
	NetworkingIdentifierProvider id.IdentifierProvider
	SyncEngineIdentifierProvider id.IdentifierProvider
	// root state information
	RootBlock                     *flow.Block
	RootQC                        *flow.QuorumCertificate
	RootResult                    *flow.ExecutionResult
	RootSeal                      *flow.Seal
	RootChainID                   flow.ChainID
	SkipNwAddressBasedValidations bool
}
    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 Option ¶ added in v0.21.0
type Option func(*BaseConfig)
func WithBindAddress ¶ added in v0.21.1
func WithBootstrapDir ¶ added in v0.21.0
func WithDB ¶ added in v0.21.1
func WithDB(db *badger.DB) Option
WithDB takes precedence over WithDataDir and datadir will be set to empty if DB is set using this option
func WithDataDir ¶ added in v0.21.0
func WithLogLevel ¶ added in v0.21.1
func WithMetricsEnabled ¶ added in v0.21.0
func WithSecretsDBEnabled ¶ added in v0.22.4
type Storage ¶
type Storage struct {
	Headers      storage.Headers
	Index        storage.Index
	Identities   storage.Identities
	Guarantees   storage.Guarantees
	Receipts     *bstorage.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
}
    
       Directories
      ¶
      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. | 
| 
          
            run
            
            
          
           contains reusable logic that does not know about a CLI. | contains reusable logic that does not know about a CLI. | 
| 
          
            transit
            
            command
          
          
         | |
| 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/epochs
            
            command
          
          
         | |
| 
          
            cmd/read-badger
            
            command
          
          
         | |
| 
          
            cmd/read-protocol-state
            
            command
          
          
         | |
| 
          
            cmd/remove-execution-fork
            
            command
          
          
         | |