Documentation ¶
Index ¶
- Constants
- func BootstrapIdentities(addresses []string, keys []string) (flow.IdentityList, error)
- func CreatePublicIDTranslatorAndIdentifierProvider(logger zerolog.Logger, networkKey crypto.PrivateKey, sporkID flow.Identifier, ...) (p2p.IDTranslator, func() module.IdentifierProvider, error)
- func DhtSystemActivationStatus(roleStr string, enabled bool) (p2pbuilder.DhtSystemActivation, error)
- 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 LoadNetworkPrivateKey(dir string, myID flow.Identifier) (crypto.PrivateKey, 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 OpenChunkDataPackDB(dbPath string, logger zerolog.Logger) (*badgerDB.DB, error)
- func ValidateDynamicStartupFlags(accessPublicKey, accessAddress string, startPhase flow.EpochPhase) error
- type BadgerConfig
- 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) LoadConsensusCommittee(node *NodeConfig) (module.ReadyDoneAware, 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) LoadFollowerCore(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadFollowerDistributor(node *NodeConfig) 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) LoadProviderEngine(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadReceiptProviderEngine(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadRegisterStore(node *NodeConfig) error
- func (exeNode *ExecutionNode) LoadS3BlockDataUploader(node *NodeConfig) (module.ReadyDoneAware, error)
- func (exeNode *ExecutionNode) LoadScriptsEngine(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) BuildPublicLibp2pNode(address string) (p2p.LibP2PNode, 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) HeroCacheMetricsFactory() metrics.HeroCacheMetricsFactory
- func (fnb *FlowNodeBuilder) InitFlowNetworkWithConduitFactory(node *NodeConfig, cf network.ConduitFactory, ...) (network.EngineRegistry, 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
- func (fnb *FlowNodeBuilder) ValidateRootSnapshot(f func(protocol.Snapshot) error) NodeBuilder
- type FlowNodeImp
- type GetProtocolSnapshot
- type Metrics
- 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 *pebble.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 StateExcerptAtBoot
- 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 BootstrapIdentities ¶ added in v0.33.12
func BootstrapIdentities(addresses []string, keys []string) (flow.IdentityList, error)
BootstrapIdentities converts the bootstrap node addresses and keys to a Flow Identity list where each Flow Identity is initialized with the passed address, the networking key and the Node ID set to ZeroID, role set to Access, 0 stake and no staking key.
func CreatePublicIDTranslatorAndIdentifierProvider ¶ added in v0.33.12
func CreatePublicIDTranslatorAndIdentifierProvider( logger zerolog.Logger, networkKey crypto.PrivateKey, sporkID flow.Identifier, getLibp2pNode func() p2p.LibP2PNode, idCache *cache.ProtocolStateIDCache, ) ( p2p.IDTranslator, func() module.IdentifierProvider, error, )
func DhtSystemActivationStatus ¶ added in v0.31.24
func DhtSystemActivationStatus(roleStr string, enabled bool) (p2pbuilder.DhtSystemActivation, error)
DhtSystemActivationStatus parses the given role string and returns the corresponding DHT system activation status. Args: - roleStr: the role string to parse. - enabled: whether the DHT system is configured to be enabled. Only meaningful for access and execution nodes. Returns: - DhtSystemActivation: the corresponding DHT system activation status. - error: if the role string is invalid, returns an error.
func DynamicStartPreInit ¶ added in v0.23.9
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 ¶ added in v0.23.9
GetSnapshot will attempt to get the latest finalized protocol snapshot with the given flow configs
func GetSnapshotAtEpochAndPhase ¶ added in v0.23.9
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 LoadNetworkPrivateKey ¶ added in v0.33.12
func LoadNetworkPrivateKey(dir string, myID flow.Identifier) (crypto.PrivateKey, error)
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 LoadPrivateNodeInfo ¶ added in v0.22.8
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 ¶ 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).
func OpenChunkDataPackDB ¶ added in v0.33.36
func ValidateDynamicStartupFlags ¶ added in v0.23.9
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 BadgerConfig ¶ added in v0.33.38
type BadgerConfig struct { TableLoadingMode int ValueLogLoadingMode int MaxTableSize int64 LevelSizeMultiplier int MaxLevels int ValueThreshold int NumMemtables int BloomFalsePositive float64 KeepL0InMemory bool BlockCacheSize int64 IndexCacheSize int64 NumLevelZeroTables int NumLevelZeroTablesStall int LevelOneSize int64 ValueLogFileSize int64 ValueLogMaxEntries uint32 }
BadgerConfig is a subset of badger.Options which are configurable via flags. CAUTION: These are provided as-is and are passed directly to Badger without any additional validation by flow-go; please make sure you understand what you are doing when using these.
func DefaultBadgerConfig ¶ added in v0.33.38
func DefaultBadgerConfig() BadgerConfig
DefaultBadgerConfig returns BadgerConfig populated by badger.DefaultOptions and any global Flow-specific config overrides.
type BaseConfig ¶
type BaseConfig struct { AdminAddr string AdminCert string AdminKey string AdminClientCAs string AdminMaxMsgSize uint BindAddr string NodeRole string ObserverMode bool 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 // Configures Badger BadgerConfig BadgerConfig // FlowConfig Flow configuration. FlowConfig config.FlowConfig // DhtSystemEnabled configures whether the DHT system is enabled on Access and Execution nodes. DhtSystemEnabled bool // BitswapReprovideEnabled configures whether the Bitswap reprovide mechanism is enabled. // This is only meaningful to Access and Execution nodes. BitswapReprovideEnabled bool // 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 BuilderFunc ¶ added in v0.23.9
type BuilderFunc func(nodeConfig *NodeConfig) error
type DependencyList ¶ added in v0.28.0
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 dependencies that must be ready before starting the component.
func NewDependencyList ¶ added in v0.29.0
func NewDependencyList(components ...module.ReadyDoneAware) *DependencyList
func (*DependencyList) Add ¶ added in v0.28.0
func (d *DependencyList) Add(component module.ReadyDoneAware)
Add adds a new ReadyDoneAware implementation to the list of dependencies.
type ExecutionConfig ¶ added in v0.26.0
type ExecutionConfig struct {
// contains filtered or unexported fields
}
ExecutionConfig contains the configs for starting up execution nodes
func (*ExecutionConfig) SetupFlags ¶ added in v0.28.0
func (exeConf *ExecutionConfig) SetupFlags(flags *pflag.FlagSet)
func (*ExecutionConfig) ValidateFlags ¶ added in v0.28.0
func (exeConf *ExecutionConfig) ValidateFlags() error
type ExecutionNode ¶ added in v0.28.0
type ExecutionNode struct {
// contains filtered or unexported fields
}
ExecutionNode contains the running modules and their loading code.
func (*ExecutionNode) LoadAuthorizationCheckingFunction ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadAuthorizationCheckingFunction( node *NodeConfig, ) error
func (*ExecutionNode) LoadBlobService ¶ added in v0.28.8
func (exeNode *ExecutionNode) LoadBlobService( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadBlobservicePeerManagerDependencies ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadBlobservicePeerManagerDependencies(node *NodeConfig) error
func (*ExecutionNode) LoadBlockUploaderManager ¶ added in v0.30.0
func (exeNode *ExecutionNode) LoadBlockUploaderManager( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadBootstrapper ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadBootstrapper(node *NodeConfig) error
func (*ExecutionNode) LoadCheckerEngine ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadCheckerEngine( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadCollectionRequesterEngine ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadCollectionRequesterEngine( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadConsensusCommittee ¶ added in v0.29.0
func (exeNode *ExecutionNode) LoadConsensusCommittee( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadExecutionDataDatastore ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadExecutionDataDatastore( node *NodeConfig, ) error
func (*ExecutionNode) LoadExecutionDataGetter ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadExecutionDataGetter(node *NodeConfig) error
func (*ExecutionNode) LoadExecutionDataPruner ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadExecutionDataPruner( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadExecutionMetrics ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadExecutionMetrics(node *NodeConfig) error
func (*ExecutionNode) LoadExecutionReceiptsStorage ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadExecutionReceiptsStorage( node *NodeConfig, ) error
func (*ExecutionNode) LoadExecutionState ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadExecutionState( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadExecutionStateLedger ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadExecutionStateLedger( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadExecutionStateLedgerWALCompactor ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadExecutionStateLedgerWALCompactor( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadFollowerCore ¶ added in v0.29.0
func (exeNode *ExecutionNode) LoadFollowerCore( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadFollowerDistributor ¶ added in v0.31.0
func (exeNode *ExecutionNode) LoadFollowerDistributor(node *NodeConfig) error
func (*ExecutionNode) LoadFollowerEngine ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadFollowerEngine( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadGCPBlockDataUploader ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadGCPBlockDataUploader( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadGrpcServer ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadGrpcServer( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadIngestionEngine ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadIngestionEngine( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadMutableFollowerState ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadMutableFollowerState(node *NodeConfig) error
func (*ExecutionNode) LoadProviderEngine ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadProviderEngine( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadReceiptProviderEngine ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadReceiptProviderEngine( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadRegisterStore ¶ added in v0.33.1
func (exeNode *ExecutionNode) LoadRegisterStore( node *NodeConfig, ) error
func (*ExecutionNode) LoadS3BlockDataUploader ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadS3BlockDataUploader( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadScriptsEngine ¶ added in v0.32.0
func (exeNode *ExecutionNode) LoadScriptsEngine(node *NodeConfig) (module.ReadyDoneAware, error)
create scripts engine for handling script execution
func (*ExecutionNode) LoadStopControl ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadStopControl( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadSyncCore ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadSyncCore(node *NodeConfig) error
func (*ExecutionNode) LoadSynchronizationEngine ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadSynchronizationEngine( node *NodeConfig, ) ( module.ReadyDoneAware, error, )
func (*ExecutionNode) LoadSystemSpecs ¶ added in v0.28.0
func (exeNode *ExecutionNode) LoadSystemSpecs(node *NodeConfig) error
type ExecutionNodeBuilder ¶ added in v0.26.0
type ExecutionNodeBuilder struct { *FlowNodeBuilder // the common configs as a node // contains filtered or unexported fields }
func NewExecutionNodeBuilder ¶ added in v0.26.0
func NewExecutionNodeBuilder(nodeBuilder *FlowNodeBuilder) *ExecutionNodeBuilder
func (*ExecutionNodeBuilder) LoadComponentsAndModules ¶ added in v0.26.0
func (builder *ExecutionNodeBuilder) LoadComponentsAndModules()
func (*ExecutionNodeBuilder) LoadFlags ¶ added in v0.26.0
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 ¶ added in v0.22.0
func (fnb *FlowNodeBuilder) AdminCommand(command string, f func(config *NodeConfig) commands.AdminCommand) NodeBuilder
func (*FlowNodeBuilder) BaseFlags ¶ added in v0.20.0
func (fnb *FlowNodeBuilder) BaseFlags()
func (*FlowNodeBuilder) Build ¶ added in v0.23.9
func (fnb *FlowNodeBuilder) Build() (Node, error)
func (*FlowNodeBuilder) BuildPublicLibp2pNode ¶ added in v0.33.12
func (fnb *FlowNodeBuilder) BuildPublicLibp2pNode(address string) (p2p.LibP2PNode, error)
initPublicLibp2pNode creates a libp2p node for the observer service in the public (unstaked) network. The factory function is later passed into the initMiddleware function to eventually instantiate the p2p.LibP2PNode instance The LibP2P host is created with the following options: * DHT as client and seeded with the given bootstrap peers * The specified bind address as the listen address * The passed in private key as the libp2p key * No connection gater * No connection manager * No peer manager * Default libp2p pubsub options. Args: - networkKey: the private key to use for the libp2p node Returns: - p2p.LibP2PNode: the libp2p node - error: if any error occurs. Any error returned is considered irrecoverable.
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 ¶ added in v0.28.0
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 ¶ added in v0.22.0
func (fnb *FlowNodeBuilder) EnqueueAdminServerInit() error
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) EnqueuePingService ¶ added in v0.23.9
func (fnb *FlowNodeBuilder) EnqueuePingService()
func (*FlowNodeBuilder) EnqueueResolver ¶ added in v0.23.9
func (fnb *FlowNodeBuilder) EnqueueResolver()
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) HeroCacheMetricsFactory ¶ added in v0.31.0
func (fnb *FlowNodeBuilder) HeroCacheMetricsFactory() metrics.HeroCacheMetricsFactory
HeroCacheMetricsFactory returns a HeroCacheMetricsFactory based on the MetricsEnabled flag. If MetricsEnabled is true, it returns a HeroCacheMetricsFactory that will register metrics with the provided MetricsRegisterer. If MetricsEnabled is false, it returns a no-op HeroCacheMetricsFactory that will not register any metrics.
func (*FlowNodeBuilder) InitFlowNetworkWithConduitFactory ¶ added in v0.26.0
func (fnb *FlowNodeBuilder) InitFlowNetworkWithConduitFactory( node *NodeConfig, cf network.ConduitFactory, unicastRateLimiters *ratelimit.RateLimiters, peerManagerFilters []p2p.PeerFilter) (network.EngineRegistry, error)
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 BuilderFunc) NodeBuilder
Module enables setting up dependencies of the engine with the builder context.
func (*FlowNodeBuilder) OverrideComponent ¶ added in v0.26.0
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 ¶ added in v0.28.0
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 ¶ added in v0.20.0
func (fnb *FlowNodeBuilder) ParseAndPrintFlags() error
func (*FlowNodeBuilder) PostInit ¶
func (fnb *FlowNodeBuilder) PostInit(f BuilderFunc) NodeBuilder
func (*FlowNodeBuilder) PreInit ¶ added in v0.20.0
func (fnb *FlowNodeBuilder) PreInit(f BuilderFunc) 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() error
func (*FlowNodeBuilder) RegisterDefaultAdminCommands ¶ added in v0.23.0
func (fnb *FlowNodeBuilder) RegisterDefaultAdminCommands()
func (*FlowNodeBuilder) RestartableComponent ¶ added in v0.26.2
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 ¶ added in v0.23.9
func (fnb *FlowNodeBuilder) ShutdownFunc(fn func() error) NodeBuilder
ShutdownFunc adds a callback function that is called after all components have exited.
func (*FlowNodeBuilder) ValidateFlags ¶ added in v0.20.6
func (fnb *FlowNodeBuilder) ValidateFlags(f func() error) NodeBuilder
func (*FlowNodeBuilder) ValidateRootSnapshot ¶ added in v0.29.6
func (fnb *FlowNodeBuilder) ValidateRootSnapshot(f func(protocol.Snapshot) error) NodeBuilder
type FlowNodeImp ¶ added in v0.23.9
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 ¶ added in v0.23.9
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 ¶ added in v0.23.9
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 Node ¶ added in v0.23.9
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 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 // ValidateRootSnapshot sets any custom validation rules for the root snapshot. // This check is executed after other checks but before applying any data from root snapshot. ValidateRootSnapshot(f func(protocol.Snapshot) 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 module.Local Tracer module.Tracer ConfigManager *updatable_configs.Manager MetricsRegisterer prometheus.Registerer Metrics Metrics DB *pebble.DB SecretsDB *pebble.DB Storage Storage ProtocolEvents *events.Distributor State protocol.State Resolver madns.BasicResolver EngineRegistry network.EngineRegistry NetworkUnderlay network.Underlay ConduitFactory network.ConduitFactory 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 // excerpt of root snapshot and latest finalized snapshot, when we boot up StateExcerptAtBoot // bootstrapping options SkipNwAddressBasedValidations bool // UnicastRateLimiterDistributor notifies consumers when a peer's unicast message is rate limited. UnicastRateLimiterDistributor p2p.UnicastRateLimiterDistributor // 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 ¶ added in v0.21.0
type Option func(*BaseConfig)
func WithBindAddress ¶ added in v0.21.1
func WithBootstrapDir ¶ added in v0.21.0
func WithComplianceConfig ¶ added in v0.26.16
func WithComplianceConfig(complianceConfig compliance.Config) Option
func WithDB ¶ added in v0.21.1
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
func WithSyncCoreConfig ¶ added in v0.26.0
type ReadyDoneFactory ¶ added in v0.23.9
type ReadyDoneFactory func(node *NodeConfig) (module.ReadyDoneAware, error)
type StateExcerptAtBoot ¶ added in v0.31.0
type StateExcerptAtBoot struct { // properties of RootSnapshot for convenience // For node bootstrapped with a root snapshot for the first block of a spork, // FinalizedRootBlock and SealedRootBlock are the same block (special case of self-sealing block) // For node bootstrapped with a root snapshot for a block above the first block of a spork (dynamically bootstrapped), // FinalizedRootBlock.Height > SealedRootBlock.Height FinalizedRootBlock *flow.Block // The last finalized block when bootstrapped. SealedRootBlock *flow.Block // The last sealed block when bootstrapped. RootQC *flow.QuorumCertificate // QC for Finalized Root Block RootResult *flow.ExecutionResult // Result for SealedRootBlock RootSeal *flow.Seal // Seal for RootResult RootChainID flow.ChainID SporkID flow.Identifier LastFinalizedHeader *flow.Header // last finalized header when the node boots up }
StateExcerptAtBoot stores information about the root snapshot and latest finalized block for use in bootstrapping.
type VerificationConfig ¶ added in v0.26.0
type VerificationConfig struct {
// contains filtered or unexported fields
}
type VerificationNodeBuilder ¶ added in v0.26.0
type VerificationNodeBuilder struct { *FlowNodeBuilder // contains filtered or unexported fields }
func NewVerificationNodeBuilder ¶ added in v0.26.0
func NewVerificationNodeBuilder(nodeBuilder *FlowNodeBuilder) *VerificationNodeBuilder
func (*VerificationNodeBuilder) LoadComponentsAndModules ¶ added in v0.26.0
func (v *VerificationNodeBuilder) LoadComponentsAndModules()
func (*VerificationNodeBuilder) LoadFlags ¶ added in v0.26.0
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. |
testclient
module
|
|