Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var StartNodeCmd = &cobra.Command{ Use: "start-node", Short: "Starts an instance of SSV node", Run: func(cmd *cobra.Command, args []string) { commons.SetBuildData(cmd.Parent().Short, cmd.Parent().Version) log.Printf("starting %s", commons.GetBuildData()) if err := cleanenv.ReadConfig(globalArgs.ConfigPath, &cfg); err != nil { log.Fatal(err) } if globalArgs.ShareConfigPath != "" { if err := cleanenv.ReadConfig(globalArgs.ShareConfigPath, &cfg); err != nil { log.Fatal(err) } } loggerLevel, errLogLevel := logex.GetLoggerLevelValue(cfg.LogLevel) Logger := logex.Build(commons.GetBuildData(), loggerLevel, &logex.EncodingConfig{ Format: cfg.GlobalConfig.LogFormat, LevelEncoder: logex.LevelEncoder([]byte(cfg.LogLevelFormat)), }) if errLogLevel != nil { Logger.Warn(fmt.Sprintf("Default log level set to %s", loggerLevel), zap.Error(errLogLevel)) } ok, err := migrationutils.E2kmMigration(Logger) if err != nil { log.Fatal("Failed to create e2km migration file", zap.Error(err)) } if ok { cfg.ETH1Options.CleanRegistryData = true } fork := v0.New() cfg.DBOptions.Logger = Logger cfg.DBOptions.Ctx = cmd.Context() db, err := storage.GetStorageFactory(cfg.DBOptions) if err != nil { Logger.Fatal("failed to create db!", zap.Error(err)) } eth2Network := core.NetworkFromString(cfg.ETH2Options.Network) cfg.ETH2Options.Context = cmd.Context() cfg.ETH2Options.Logger = Logger cfg.ETH2Options.Graffiti = []byte("SSV.Network") cfg.ETH2Options.DB = db beaconClient, err := goclient.New(cfg.ETH2Options) if err != nil { Logger.Fatal("failed to create beacon go-client", zap.Error(err), zap.String("addr", cfg.ETH2Options.BeaconNodeAddr)) } operatorStorage := operator.NewOperatorNodeStorage(db, Logger) if err := operatorStorage.SetupPrivateKey(cfg.OperatorPrivateKey); err != nil { Logger.Fatal("failed to setup operator private key", zap.Error(err)) } operatorPrivKey, found, err := operatorStorage.GetPrivateKey() if err != nil || !found { Logger.Fatal("failed to get operator private key", zap.Error(err)) } cfg.P2pNetworkConfig.OperatorPrivateKey = operatorPrivKey cfg.P2pNetworkConfig.NetworkPrivateKey = utils.ECDSAPrivateKey(Logger, cfg.NetworkPrivateKey) cfg.P2pNetworkConfig.Fork = fork.NetworkFork() p2pNet, err := p2p.New(cmd.Context(), Logger, &cfg.P2pNetworkConfig) if err != nil { Logger.Fatal("failed to create network", zap.Error(err)) } ctx := cmd.Context() cfg.SSVOptions.Fork = fork cfg.SSVOptions.Context = ctx cfg.SSVOptions.Logger = Logger cfg.SSVOptions.DB = db cfg.SSVOptions.Beacon = beaconClient cfg.SSVOptions.ETHNetwork = ð2Network cfg.SSVOptions.Network = p2pNet cfg.SSVOptions.ValidatorOptions.Fork = cfg.SSVOptions.Fork cfg.SSVOptions.ValidatorOptions.ETHNetwork = ð2Network cfg.SSVOptions.ValidatorOptions.Logger = Logger cfg.SSVOptions.ValidatorOptions.Context = ctx cfg.SSVOptions.ValidatorOptions.DB = db cfg.SSVOptions.ValidatorOptions.Network = p2pNet cfg.SSVOptions.ValidatorOptions.Beacon = beaconClient cfg.SSVOptions.ValidatorOptions.CleanRegistryData = cfg.ETH1Options.CleanRegistryData cfg.SSVOptions.ValidatorOptions.KeyManager = beaconClient cfg.SSVOptions.ValidatorOptions.ShareEncryptionKeyProvider = operatorStorage.GetPrivateKey if len(cfg.ETH1Options.RegistryContractABI) > 0 { Logger.Info("using registry contract abi", zap.String("abi", cfg.ETH1Options.RegistryContractABI)) if err = eth1.LoadABI(cfg.ETH1Options.RegistryContractABI); err != nil { Logger.Fatal("failed to load ABI JSON", zap.Error(err)) } } cfg.SSVOptions.Eth1Client, err = goeth.NewEth1Client(goeth.ClientOptions{ Ctx: cmd.Context(), Logger: Logger, NodeAddr: cfg.ETH1Options.ETH1Addr, ConnectionTimeout: cfg.ETH1Options.ETH1ConnectionTimeout, ContractABI: eth1.ContractABI(), RegistryContractAddr: cfg.ETH1Options.RegistryContractAddr, ShareEncryptionKeyProvider: operatorStorage.GetPrivateKey, }) if err != nil { Logger.Fatal("failed to create eth1 client", zap.Error(err)) } validatorCtrl := validator.NewController(cfg.SSVOptions.ValidatorOptions) cfg.SSVOptions.ValidatorController = validatorCtrl operatorNode = operator.New(cfg.SSVOptions) metrics.WaitUntilHealthy(Logger, cfg.SSVOptions.Eth1Client, "eth1 node") metrics.WaitUntilHealthy(Logger, beaconClient, "beacon node") if err := operatorNode.StartEth1(eth1.HexStringToSyncOffset(cfg.ETH1Options.ETH1SyncOffset)); err != nil { Logger.Fatal("failed to start eth1", zap.Error(err)) } if cfg.MetricsAPIPort > 0 { go startMetricsHandler(Logger, cfg.MetricsAPIPort, cfg.EnableProfile) } if err := operatorNode.Start(); err != nil { Logger.Fatal("failed to start SSV node", zap.Error(err)) } }, }
StartNodeCmd is the command to start SSV node
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.