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) { 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, err := logex.GetLoggerLevelValue(cfg.LogLevel) Logger := logex.Build(cmd.Parent().Short, loggerLevel) if err != nil { Logger.Warn(fmt.Sprintf("Default log level set to %s", loggerLevel), zap.Error(err)) } cfg.DBOptions.Logger = Logger db, err := storage.GetStorageFactory(cfg.DBOptions) if err != nil { Logger.Fatal("failed to create db!", zap.Error(err)) } eth2Network := core.NetworkFromString(cfg.Network) beaconClient, err := prysmgrpc.New(cmd.Context(), Logger, eth2Network, []byte("BloxStaking"), cfg.BeaconNodeAddr) if err != nil { Logger.Fatal("failed to create beacon client", zap.Error(err)) } enr := []string{ "enr:-LK4QHVq6HEA2KVnAw593SRMqUOvMGlkP8Jb-qHn4yPLHx--cStvWc38Or2xLcWgDPynVxXPT9NWIEXRzrBUsLmcFkUBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpD1pf1CAAAAAP__________gmlkgnY0gmlwhDbUHcyJc2VjcDI1NmsxoQO8KQz5L1UEXzEr-CXFFq1th0eG6gopbdul2OQVMuxfMoN0Y3CCE4iDdWRwgg-g", } if cfg.Enr != "" { enr = []string{ cfg.Enr, } } p2pCfg := p2p.Config{ DiscoveryType: cfg.DiscoveryType, BootstrapNodeAddr: enr, UDPPort: cfg.UDPPort, TCPPort: cfg.TCPPort, HostDNS: cfg.HostDNS, HostAddress: cfg.HostAddress, RequestTimeout: cfg.RequestTimeout, } network, err := p2p.New(cmd.Context(), Logger, &p2pCfg) if err != nil { Logger.Fatal("failed to create network", zap.Error(err)) } ctx := cmd.Context() cfg.SSVOptions.Context = ctx cfg.SSVOptions.Logger = Logger cfg.SSVOptions.Beacon = &beaconClient cfg.SSVOptions.ETHNetwork = ð2Network cfg.SSVOptions.ValidatorOptions.ETHNetwork = ð2Network cfg.SSVOptions.ValidatorOptions.Logger = Logger cfg.SSVOptions.ValidatorOptions.Context = ctx cfg.SSVOptions.ValidatorOptions.DB = db cfg.SSVOptions.ValidatorOptions.Network = network cfg.SSVOptions.ValidatorOptions.Beacon = beaconClient if cfg.ETH1Addr != "" { operatorStorage := collections.NewOperatorStorage(db, Logger) if err := operatorStorage.SetupPrivateKey(cfg.OperatorKey); err != nil { Logger.Fatal("failed to setup operator private key", zap.Error(err)) } if cfg.SmartContractAddr != "" { Logger.Info("using smart contract addr from cfg", zap.String("addr", cfg.SmartContractAddr)) params.SsvConfig().OperatorContractAddress = cfg.SmartContractAddr } cfg.SSVOptions.Eth1Client, err = goeth.NewEth1Client(goeth.ClientOptions{ Ctx: cmd.Context(), Logger: Logger, NodeAddr: cfg.ETH1Addr, PrivKeyProvider: operatorStorage.GetPrivateKey, }) if err != nil { Logger.Error("failed to create eth1 client", zap.Error(err)) } } ssvNode := node.New(cfg.SSVOptions) if err := ssvNode.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.