Documentation ¶
Index ¶
- Constants
- func DynamicStartPreInit(nodeConfig *NodeConfig) error
- func GetSnapshot(ctx context.Context, client *client.Client) (*inmem.Snapshot, error)
- func GetSnapshotAtEpochAndPhase(ctx context.Context, log zerolog.Logger, startupEpoch uint64, ...) (protocol.Snapshot, error)
- func LoadNodeMachineAccountInfoFile(bootstrapDir string, nodeID flow.Identifier) (*bootstrap.NodeMachineAccountInfo, error)
- func LoadPrivateNodeInfo(dir string, myID flow.Identifier) (*bootstrap.NodeInfoPriv, error)
- func MarkFlagRequired(command *cobra.Command, flagName string)
- func ValidateDynamicStartupFlags(accessPublicKey, accessAddress string, startPhase flow.EpochPhase) error
- type BaseConfig
- type BuilderFunc
- type DependencyList
- type ExecutionConfig
- type ExecutionNode
- func (exeNode *ExecutionNode) LoadAuthorizationCheckingFunction(node *NodeConfig) error
- func (exeNode *ExecutionNode) LoadBlobService(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadBlobservicePeerManagerDependencies(node *NodeConfig) error
- func (exeNode *ExecutionNode) LoadBlockUploaderManager(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadBootstrapper(node *NodeConfig) error
- func (exeNode *ExecutionNode) LoadCheckerEngine(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadCollectionRequesterEngine(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadDeltasMempool(node *NodeConfig) error
- func (exeNode *ExecutionNode) LoadExecutionDataDatastore(node *NodeConfig) error
- func (exeNode *ExecutionNode) LoadExecutionDataGetter(node *NodeConfig) error
- func (exeNode *ExecutionNode) LoadExecutionDataPruner(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadExecutionMetrics(node *NodeConfig) error
- func (exeNode *ExecutionNode) LoadExecutionReceiptsStorage(node *NodeConfig) error
- func (exeNode *ExecutionNode) LoadExecutionState(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadExecutionStateLedger(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadExecutionStateLedgerWALCompactor(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadFinalizedSnapshot(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadFollowerEngine(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadGCPBlockDataUploader(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadGrpcServer(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadIngestionEngine(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadMutableFollowerState(node *NodeConfig) error
- func (exeNode *ExecutionNode) LoadPendingBlockCache(node *NodeConfig) error
- func (exeNode *ExecutionNode) LoadProviderEngine(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadReceiptProviderEngine(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadS3BlockDataUploader(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadStopControl(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadSyncCore(node *NodeConfig) error
- func (exeNode *ExecutionNode) LoadSynchronizationEngine(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadSystemSpecs(node *NodeConfig) error
- type ExecutionNodeBuilder
- type FlowNodeBuilder
- func (fnb *FlowNodeBuilder) AdminCommand(command string, f func(config *NodeConfig) commands.AdminCommand) NodeBuilder
- func (fnb *FlowNodeBuilder) BaseFlags()
- func (fnb *FlowNodeBuilder) Build() (Node, error)
- func (fnb *FlowNodeBuilder) Component(name string, f ReadyDoneFactory) NodeBuilder
- func (fnb *FlowNodeBuilder) DependableComponent(name string, f ReadyDoneFactory, dependencies *DependencyList) NodeBuilder
- func (fnb *FlowNodeBuilder) EnqueueAdminServerInit() error
- func (fnb *FlowNodeBuilder) EnqueueMetricsServerInit()
- func (fnb *FlowNodeBuilder) EnqueueNetworkInit()
- func (fnb *FlowNodeBuilder) EnqueuePingService()
- func (fnb *FlowNodeBuilder) EnqueueResolver()
- func (fnb *FlowNodeBuilder) EnqueueTracer()
- func (fnb *FlowNodeBuilder) ExtraFlags(f func(*pflag.FlagSet)) NodeBuilder
- func (fnb *FlowNodeBuilder) InitFlowNetworkWithConduitFactory(node *NodeConfig, cf network.ConduitFactory, ...) (network.Network, error)
- func (fnb *FlowNodeBuilder) InitIDProviders()
- func (fnb *FlowNodeBuilder) Initialize() error
- func (fnb *FlowNodeBuilder) Module(name string, f BuilderFunc) NodeBuilder
- func (fnb *FlowNodeBuilder) OverrideComponent(name string, f ReadyDoneFactory) NodeBuilder
- func (fnb *FlowNodeBuilder) OverrideModule(name string, f BuilderFunc) NodeBuilder
- func (fnb *FlowNodeBuilder) ParseAndPrintFlags() error
- func (fnb *FlowNodeBuilder) PostInit(f BuilderFunc) NodeBuilder
- func (fnb *FlowNodeBuilder) PreInit(f BuilderFunc) NodeBuilder
- func (fnb *FlowNodeBuilder) PrintBuildVersionDetails()
- func (fnb *FlowNodeBuilder) RegisterBadgerMetrics() error
- func (fnb *FlowNodeBuilder) RegisterDefaultAdminCommands()
- func (fnb *FlowNodeBuilder) RestartableComponent(name string, f ReadyDoneFactory, errorHandler component.OnError) NodeBuilder
- func (fnb *FlowNodeBuilder) ShutdownFunc(fn func() error) NodeBuilder
- func (fnb *FlowNodeBuilder) ValidateFlags(f func() error) NodeBuilder
- type FlowNodeImp
- type GetProtocolSnapshot
- type Metrics
- type NetworkConfig
- type Node
- type NodeBuilder
- type NodeConfig
- type Option
- func WithBindAddress(bindAddress string) Option
- func WithBootstrapDir(bootstrapDir string) Option
- func WithComplianceConfig(complianceConfig compliance.Config) 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
- func WithSyncCoreConfig(syncConfig chainsync.Config) Option
- type ReadyDoneFactory
- type Storage
- type VerificationConfig
- type VerificationNodeBuilder
Constants ¶
const ( NetworkComponent = "network" ConduitFactoryComponent = "conduit-factory" LibP2PNodeComponent = "libp2p-node" )
const NotSet = "not set"
Variables ¶
This section is empty.
Functions ¶
func DynamicStartPreInit ¶
func DynamicStartPreInit(nodeConfig *NodeConfig) error
DynamicStartPreInit is the pre-init func that will check if a node has already bootstrapped from a root protocol snapshot. If not attempt to get a protocol snapshot where the following conditions are met. 1. Target epoch < current epoch (in the past), set root snapshot to current snapshot 2. Target epoch == "current", wait until target phase == current phase before setting root snapshot 3. Target epoch > current epoch (in future), wait until target epoch and target phase is reached before setting root snapshot
func GetSnapshot ¶
GetSnapshot will attempt to get the latest finalized protocol snapshot with the given flow configs
func GetSnapshotAtEpochAndPhase ¶
func GetSnapshotAtEpochAndPhase(ctx context.Context, log zerolog.Logger, startupEpoch uint64, startupEpochPhase flow.EpochPhase, retryInterval time.Duration, getSnapshot GetProtocolSnapshot) (protocol.Snapshot, error)
GetSnapshotAtEpochAndPhase will get the latest finalized protocol snapshot and check the current epoch and epoch phase. If we are past the target epoch and epoch phase we exit the retry mechanism immediately. If not check the snapshot at the specified interval until we reach the target epoch and phase.
func LoadNodeMachineAccountInfoFile ¶
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 LoadPrivateNodeInfo ¶
func LoadPrivateNodeInfo(dir string, myID flow.Identifier) (*bootstrap.NodeInfoPriv, error)
LoadPrivateNodeInfo the private info for this node from disk (e.g., private staking/network keys).
func MarkFlagRequired ¶
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).
func ValidateDynamicStartupFlags ¶
func ValidateDynamicStartupFlags(accessPublicKey, accessAddress string, startPhase flow.EpochPhase) error
ValidateDynamicStartupFlags will validate flags necessary for dynamic node startup - assert dynamic-startup-access-publickey is valid ECDSA_P256 public key hex - assert dynamic-startup-access-address is not empty - assert dynamic-startup-startup-epoch-phase is > 0 (EpochPhaseUndefined)
Types ¶
type BaseConfig ¶
type BaseConfig struct { NetworkConfig AdminAddr string AdminCert string AdminKey string AdminClientCAs string AdminMaxMsgSize uint BindAddr string NodeRole string DynamicStartupANAddress string DynamicStartupANPubkey string DynamicStartupEpochPhase string DynamicStartupEpoch string DynamicStartupSleepInterval time.Duration InsecureSecretsDB bool BootstrapDir string MetricsEnabled bool HeroCacheMetricsEnable bool SyncCoreConfig chainsync.Config CodecFactory func() network.Codec LibP2PNode p2p.LibP2PNode // ComplianceConfig configures either the compliance engine (consensus nodes) // or the follower engine (all other node roles) ComplianceConfig compliance.Config // 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 ¶
func DefaultBaseConfig() *BaseConfig
type BuilderFunc ¶
type BuilderFunc func(nodeConfig *NodeConfig) error
type DependencyList ¶
type DependencyList struct {
// contains filtered or unexported fields
}
DependencyList is a slice of ReadyDoneAware implementations that are used by DependableComponent to define the list of depenencies that must be ready before starting the component.
func NewDependencyList ¶
func NewDependencyList(components ...module.ReadyDoneAware) *DependencyList
func (*DependencyList) Add ¶
func (d *DependencyList) Add(component module.ReadyDoneAware)
Add adds a new ReadyDoneAware implementation to the list of dependencies.
type ExecutionConfig ¶
type ExecutionConfig struct {
// contains filtered or unexported fields
}
ExecutionConfig contains the configs for starting up execution nodes
func (*ExecutionConfig) SetupFlags ¶
func (exeConf *ExecutionConfig) SetupFlags(flags *pflag.FlagSet)
func (*ExecutionConfig) ValidateFlags ¶
func (exeConf *ExecutionConfig) ValidateFlags() error
type ExecutionNode ¶
type ExecutionNode struct {
// contains filtered or unexported fields
}
ExecutionNode contains the running modules and their loading code.
func (*ExecutionNode) LoadAuthorizationCheckingFunction ¶
func (exeNode *ExecutionNode) LoadAuthorizationCheckingFunction( node *NodeConfig, ) error
func (*ExecutionNode) LoadBlobService ¶
func (exeNode *ExecutionNode) LoadBlobService( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadBlobservicePeerManagerDependencies ¶
func (exeNode *ExecutionNode) LoadBlobservicePeerManagerDependencies(node *NodeConfig) error
func (*ExecutionNode) LoadBlockUploaderManager ¶
func (exeNode *ExecutionNode) LoadBlockUploaderManager( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadBootstrapper ¶
func (exeNode *ExecutionNode) LoadBootstrapper(node *NodeConfig) error
func (*ExecutionNode) LoadCheckerEngine ¶
func (exeNode *ExecutionNode) LoadCheckerEngine( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadCollectionRequesterEngine ¶
func (exeNode *ExecutionNode) LoadCollectionRequesterEngine( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadDeltasMempool ¶
func (exeNode *ExecutionNode) LoadDeltasMempool(node *NodeConfig) error
func (*ExecutionNode) LoadExecutionDataDatastore ¶
func (exeNode *ExecutionNode) LoadExecutionDataDatastore( node *NodeConfig, ) error
func (*ExecutionNode) LoadExecutionDataGetter ¶
func (exeNode *ExecutionNode) LoadExecutionDataGetter(node *NodeConfig) error
func (*ExecutionNode) LoadExecutionDataPruner ¶
func (exeNode *ExecutionNode) LoadExecutionDataPruner( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadExecutionMetrics ¶
func (exeNode *ExecutionNode) LoadExecutionMetrics(node *NodeConfig) error
func (*ExecutionNode) LoadExecutionReceiptsStorage ¶
func (exeNode *ExecutionNode) LoadExecutionReceiptsStorage( node *NodeConfig, ) error
func (*ExecutionNode) LoadExecutionState ¶
func (exeNode *ExecutionNode) LoadExecutionState( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadExecutionStateLedger ¶
func (exeNode *ExecutionNode) LoadExecutionStateLedger( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadExecutionStateLedgerWALCompactor ¶
func (exeNode *ExecutionNode) LoadExecutionStateLedgerWALCompactor( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadFinalizedSnapshot ¶
func (exeNode *ExecutionNode) LoadFinalizedSnapshot( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadFollowerEngine ¶
func (exeNode *ExecutionNode) LoadFollowerEngine( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadGCPBlockDataUploader ¶
func (exeNode *ExecutionNode) LoadGCPBlockDataUploader( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadGrpcServer ¶
func (exeNode *ExecutionNode) LoadGrpcServer( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadIngestionEngine ¶
func (exeNode *ExecutionNode) LoadIngestionEngine( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadMutableFollowerState ¶
func (exeNode *ExecutionNode) LoadMutableFollowerState(node *NodeConfig) error
func (*ExecutionNode) LoadPendingBlockCache ¶
func (exeNode *ExecutionNode) LoadPendingBlockCache(node *NodeConfig) error
func (*ExecutionNode) LoadProviderEngine ¶
func (exeNode *ExecutionNode) LoadProviderEngine( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadReceiptProviderEngine ¶
func (exeNode *ExecutionNode) LoadReceiptProviderEngine( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadS3BlockDataUploader ¶
func (exeNode *ExecutionNode) LoadS3BlockDataUploader( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadStopControl ¶
func (exeNode *ExecutionNode) LoadStopControl( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadSyncCore ¶
func (exeNode *ExecutionNode) LoadSyncCore(node *NodeConfig) error
func (*ExecutionNode) LoadSynchronizationEngine ¶
func (exeNode *ExecutionNode) LoadSynchronizationEngine( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadSystemSpecs ¶
func (exeNode *ExecutionNode) LoadSystemSpecs(node *NodeConfig) error
type ExecutionNodeBuilder ¶
type ExecutionNodeBuilder struct { *FlowNodeBuilder // the common configs as a node // contains filtered or unexported fields }
func NewExecutionNodeBuilder ¶
func NewExecutionNodeBuilder(nodeBuilder *FlowNodeBuilder) *ExecutionNodeBuilder
func (*ExecutionNodeBuilder) LoadComponentsAndModules ¶
func (builder *ExecutionNodeBuilder) LoadComponentsAndModules()
func (*ExecutionNodeBuilder) LoadFlags ¶
func (builder *ExecutionNodeBuilder) LoadFlags()
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 ¶
func (fnb *FlowNodeBuilder) AdminCommand(command string, f func(config *NodeConfig) commands.AdminCommand) NodeBuilder
func (*FlowNodeBuilder) BaseFlags ¶
func (fnb *FlowNodeBuilder) BaseFlags()
func (*FlowNodeBuilder) Build ¶
func (fnb *FlowNodeBuilder) Build() (Node, error)
func (*FlowNodeBuilder) Component ¶
func (fnb *FlowNodeBuilder) Component(name string, f ReadyDoneFactory) NodeBuilder
Component adds a new component to the node that conforms to the ReadyDoneAware interface.
The ReadyDoneFactory may return either a `Component` or `ReadyDoneAware` instance. In both cases, the object is started when the node is run, and the node will wait for the component to exit gracefully.
func (*FlowNodeBuilder) DependableComponent ¶
func (fnb *FlowNodeBuilder) DependableComponent(name string, f ReadyDoneFactory, dependencies *DependencyList) NodeBuilder
DependableComponent adds a new component to the node that conforms to the ReadyDoneAware interface. The builder will wait until all of the components in the dependencies list are ready before constructing the component.
The ReadyDoneFactory may return either a `Component` or `ReadyDoneAware` instance. In both cases, the object is started when the node is run, and the node will wait for the component to exit gracefully.
IMPORTANT: Dependable components are started in parallel with no guaranteed run order, so all dependencies must be initialized outside of the ReadyDoneFactory, and their `Ready()` method MUST be idempotent.
func (*FlowNodeBuilder) EnqueueAdminServerInit ¶
func (fnb *FlowNodeBuilder) EnqueueAdminServerInit() error
func (*FlowNodeBuilder) EnqueueMetricsServerInit ¶
func (fnb *FlowNodeBuilder) EnqueueMetricsServerInit()
func (*FlowNodeBuilder) EnqueueNetworkInit ¶
func (fnb *FlowNodeBuilder) EnqueueNetworkInit()
func (*FlowNodeBuilder) EnqueuePingService ¶
func (fnb *FlowNodeBuilder) EnqueuePingService()
func (*FlowNodeBuilder) EnqueueResolver ¶
func (fnb *FlowNodeBuilder) EnqueueResolver()
func (*FlowNodeBuilder) EnqueueTracer ¶
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) InitFlowNetworkWithConduitFactory ¶
func (fnb *FlowNodeBuilder) InitFlowNetworkWithConduitFactory(node *NodeConfig, cf network.ConduitFactory, unicastRateLimiters *ratelimit.RateLimiters, peerManagerFilters []p2p.PeerFilter) (network.Network, error)
func (*FlowNodeBuilder) InitIDProviders ¶
func (fnb *FlowNodeBuilder) InitIDProviders()
func (*FlowNodeBuilder) Initialize ¶
func (fnb *FlowNodeBuilder) Initialize() error
func (*FlowNodeBuilder) Module ¶
func (fnb *FlowNodeBuilder) Module(name string, f BuilderFunc) NodeBuilder
Module enables setting up dependencies of the engine with the builder context.
func (*FlowNodeBuilder) OverrideComponent ¶
func (fnb *FlowNodeBuilder) OverrideComponent(name string, f ReadyDoneFactory) NodeBuilder
OverrideComponent adds given builder function to the components set of the node builder. If a builder function with that name already exists, it will be overridden.
func (*FlowNodeBuilder) OverrideModule ¶
func (fnb *FlowNodeBuilder) OverrideModule(name string, f BuilderFunc) NodeBuilder
OverrideModule adds given builder function to the modules set of the node builder. If a builder function with that name already exists, it will be overridden.
func (*FlowNodeBuilder) ParseAndPrintFlags ¶
func (fnb *FlowNodeBuilder) ParseAndPrintFlags() error
func (*FlowNodeBuilder) PostInit ¶
func (fnb *FlowNodeBuilder) PostInit(f BuilderFunc) NodeBuilder
func (*FlowNodeBuilder) PreInit ¶
func (fnb *FlowNodeBuilder) PreInit(f BuilderFunc) NodeBuilder
func (*FlowNodeBuilder) PrintBuildVersionDetails ¶
func (fnb *FlowNodeBuilder) PrintBuildVersionDetails()
func (*FlowNodeBuilder) RegisterBadgerMetrics ¶
func (fnb *FlowNodeBuilder) RegisterBadgerMetrics() error
func (*FlowNodeBuilder) RegisterDefaultAdminCommands ¶
func (fnb *FlowNodeBuilder) RegisterDefaultAdminCommands()
func (*FlowNodeBuilder) RestartableComponent ¶
func (fnb *FlowNodeBuilder) RestartableComponent(name string, f ReadyDoneFactory, errorHandler component.OnError) NodeBuilder
RestartableComponent adds a new component to the node that conforms to the ReadyDoneAware interface, and calls the provided error handler when an irrecoverable error is encountered. Use RestartableComponent if the component is not critical to the node's safe operation and can/should be independently restarted when an irrecoverable error is encountered.
IMPORTANT: Since a RestartableComponent can be restarted independently of the node, the node and other components must not rely on it for safe operation, and failures must be handled gracefully. As such, RestartableComponents do not block the node from becoming ready, and do not block subsequent components from starting serially. They do start in serial order.
Note: The ReadyDoneFactory method may be called multiple times if the component is restarted.
Any irrecoverable errors thrown by the component will be passed to the provided error handler.
func (*FlowNodeBuilder) ShutdownFunc ¶
func (fnb *FlowNodeBuilder) ShutdownFunc(fn func() error) NodeBuilder
ShutdownFunc adds a callback function that is called after all components have exited.
func (*FlowNodeBuilder) ValidateFlags ¶
func (fnb *FlowNodeBuilder) ValidateFlags(f func() error) NodeBuilder
type FlowNodeImp ¶
type FlowNodeImp struct { component.Component *NodeConfig // contains filtered or unexported fields }
FlowNodeImp is created by the FlowNodeBuilder with all components ready to be started. The Run function starts all the components, and is blocked until either a termination signal is received or a irrecoverable error is encountered.
func (*FlowNodeImp) Run ¶
func (node *FlowNodeImp) Run()
Run starts all the node's components, then blocks until a SIGINT or SIGTERM is received, at which point it gracefully shuts down. Any unhandled irrecoverable errors thrown in child components will propagate up to here and result in a fatal error.
type GetProtocolSnapshot ¶
GetProtocolSnapshot callback that will get latest finalized protocol snapshot
type Metrics ¶
type Metrics struct { Network module.NetworkMetrics Engine module.EngineMetrics Compliance module.ComplianceMetrics Cache module.CacheMetrics Mempool module.MempoolMetrics CleanCollector module.CleanerMetrics Bitswap module.BitswapMetrics }
type NetworkConfig ¶
type NetworkConfig struct { // NetworkConnectionPruning determines whether connections to nodes // that are not part of protocol state should be trimmed // TODO: solely a fallback mechanism, can be removed upon reliable behavior in production. NetworkConnectionPruning bool PeerScoringEnabled bool // enables peer scoring on pubsub PreferredUnicastProtocols []string NetworkReceivedMessageCacheSize uint32 // UnicastRateLimitDryRun will disable connection disconnects and gating when unicast rate limiters are configured UnicastRateLimitDryRun bool //UnicastRateLimitLockoutDuration the number of seconds a peer will be forced to wait before being allowed to successful reconnect to the node // after being rate limited. UnicastRateLimitLockoutDuration time.Duration // UnicastMessageRateLimit amount of unicast messages that can be sent by a peer per second. UnicastMessageRateLimit int // UnicastBandwidthRateLimit bandwidth size in bytes a peer is allowed to send via unicast streams per second. UnicastBandwidthRateLimit int // UnicastBandwidthBurstLimit bandwidth size in bytes a peer is allowed to send via unicast streams at once. UnicastBandwidthBurstLimit int PeerUpdateInterval time.Duration UnicastMessageTimeout time.Duration DNSCacheTTL time.Duration LibP2PResourceManagerConfig *p2pbuilder.ResourceManagerConfig }
type Node ¶
type NodeBuilder ¶
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 and validates all the command line arguments ParseAndPrintFlags() error // 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 networking layer. EnqueueNetworkInit() // EnqueueMetricsServerInit enqueues the metrics component. EnqueueMetricsServerInit() // EnqueueTracer enqueues the Tracer component. EnqueueTracer() // Module enables setting up dependencies of the engine with the builder context Module(name string, f BuilderFunc) NodeBuilder // Component adds a new component to the node that conforms to the ReadyDoneAware // interface, and throws a Fatal() when an irrecoverable error is encountered. // // The ReadyDoneFactory may return either a `Component` or `ReadyDoneAware` instance. // In both cases, the object is started according to its interface when the node is run, // and the node will wait for the component to exit gracefully. Component(name string, f ReadyDoneFactory) NodeBuilder // DependableComponent adds a new component to the node that conforms to the ReadyDoneAware // interface. The builder will wait until all of the components in the dependencies list are ready // before constructing the component. // // The ReadyDoneFactory may return either a `Component` or `ReadyDoneAware` instance. // In both cases, the object is started when the node is run, and the node will wait for the // component to exit gracefully. // // IMPORTANT: Dependable components are started in parallel with no guaranteed run order, so all // dependencies must be initialized outside of the ReadyDoneFactory, and their `Ready()` method // MUST be idempotent. DependableComponent(name string, f ReadyDoneFactory, dependencies *DependencyList) NodeBuilder // RestartableComponent adds a new component to the node that conforms to the ReadyDoneAware // interface, and calls the provided error handler when an irrecoverable error is encountered. // Use RestartableComponent if the component is not critical to the node's safe operation and // can/should be independently restarted when an irrecoverable error is encountered. // // Any irrecoverable errors thrown by the component will be passed to the provided error handler. RestartableComponent(name string, f ReadyDoneFactory, errorHandler component.OnError) NodeBuilder // ShutdownFunc adds a callback function that is called after all components have exited. // All shutdown functions are called regardless of errors returned by previous callbacks. Any // errors returned are captured and passed to the caller. ShutdownFunc(fn func() error) NodeBuilder // AdminCommand registers a new admin command with the admin server AdminCommand(command string, f func(config *NodeConfig) commands.AdminCommand) NodeBuilder // Build finalizes the node configuration in preparation for start and returns a Node // object that can be run Build() (Node, error) // 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 BuilderFunc) 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 BuilderFunc) NodeBuilder // RegisterBadgerMetrics registers all badger related metrics RegisterBadgerMetrics() error // ValidateFlags sets any custom validation rules for the command line flags, // 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 ¶
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 module.Local Tracer module.Tracer ConfigManager *updatable_configs.Manager MetricsRegisterer prometheus.Registerer Metrics Metrics DB *badger.DB SecretsDB *badger.DB Storage Storage ProtocolEvents *events.Distributor State protocol.State Resolver madns.BasicResolver Middleware network.Middleware Network network.Network PingService network.PingService MsgValidators []network.MessageValidator FvmOptions []fvm.Option StakingKey crypto.PrivateKey NetworkKey crypto.PrivateKey // list of dependencies for network peer manager startup PeerManagerDependencies *DependencyList // ID providers IdentityProvider module.IdentityProvider IDTranslator p2p.IDTranslator SyncEngineIdentifierProvider module.IdentifierProvider // root state information RootSnapshot protocol.Snapshot // cached properties of RootSnapshot for convenience RootBlock *flow.Block RootQC *flow.QuorumCertificate RootResult *flow.ExecutionResult RootSeal *flow.Seal RootChainID flow.ChainID SporkID flow.Identifier // bootstrapping options SkipNwAddressBasedValidations bool // contains filtered or unexported fields }
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 ¶
type Option func(*BaseConfig)
func WithBindAddress ¶
func WithBootstrapDir ¶
func WithComplianceConfig ¶
func WithComplianceConfig(complianceConfig compliance.Config) Option
func WithDB ¶
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 ¶
func WithLogLevel ¶
func WithMetricsEnabled ¶
func WithSecretsDBEnabled ¶
func WithSyncCoreConfig ¶
type ReadyDoneFactory ¶
type ReadyDoneFactory func(node *NodeConfig) (module.ReadyDoneAware, error)
type VerificationConfig ¶
type VerificationConfig struct {
// contains filtered or unexported fields
}
type VerificationNodeBuilder ¶
type VerificationNodeBuilder struct { *FlowNodeBuilder // contains filtered or unexported fields }
func NewVerificationNodeBuilder ¶
func NewVerificationNodeBuilder(nodeBuilder *FlowNodeBuilder) *VerificationNodeBuilder
func (*VerificationNodeBuilder) LoadComponentsAndModules ¶
func (v *VerificationNodeBuilder) LoadComponentsAndModules()
func (*VerificationNodeBuilder) LoadFlags ¶
func (v *VerificationNodeBuilder) LoadFlags()
Source Files ¶
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. |
Package build contains information about the build that injected at build-time.
|
Package build contains information about the build that injected at build-time. |