2018-07-09 02:40:34 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"runtime"
|
|
|
|
|
2018-07-20 21:31:26 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/cmd"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/debug"
|
2019-01-10 04:19:33 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/version"
|
2018-08-22 19:15:21 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/validator/node"
|
|
|
|
"github.com/prysmaticlabs/prysm/validator/types"
|
2018-07-21 17:51:18 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
2018-07-09 02:40:34 +00:00
|
|
|
"github.com/urfave/cli"
|
2018-07-21 17:51:18 +00:00
|
|
|
prefixed "github.com/x-cray/logrus-prefixed-formatter"
|
2018-07-09 02:40:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func startNode(ctx *cli.Context) error {
|
2018-08-15 01:21:49 +00:00
|
|
|
verbosity := ctx.GlobalString(cmd.VerbosityFlag.Name)
|
|
|
|
level, err := logrus.ParseLevel(verbosity)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
logrus.SetLevel(level)
|
|
|
|
|
2019-01-30 15:24:28 +00:00
|
|
|
validatorClient, err := node.NewValidatorClient(ctx)
|
2018-07-09 02:40:34 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-07-17 18:39:04 +00:00
|
|
|
|
2019-01-30 15:24:28 +00:00
|
|
|
validatorClient.Start()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(#1436): Initialize validator secrets.
|
|
|
|
func createValidatorAccount(ctx *cli.Context) error {
|
2018-07-09 02:40:34 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2018-07-21 17:51:18 +00:00
|
|
|
customFormatter := new(prefixed.TextFormatter)
|
|
|
|
customFormatter.TimestampFormat = "2006-01-02 15:04:05"
|
|
|
|
customFormatter.FullTimestamp = true
|
|
|
|
logrus.SetFormatter(customFormatter)
|
|
|
|
log := logrus.WithField("prefix", "main")
|
|
|
|
|
2018-07-09 02:40:34 +00:00
|
|
|
cli.AppHelpTemplate = `NAME:
|
|
|
|
{{.Name}} - {{.Usage}}
|
|
|
|
USAGE:
|
|
|
|
{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}
|
|
|
|
{{if len .Authors}}
|
|
|
|
AUTHOR:
|
|
|
|
{{range .Authors}}{{ . }}{{end}}
|
|
|
|
{{end}}{{if .Commands}}
|
|
|
|
GLOBAL OPTIONS:
|
|
|
|
{{range .VisibleFlags}}{{.}}
|
|
|
|
{{end}}{{end}}{{if .Copyright }}
|
|
|
|
COPYRIGHT:
|
|
|
|
{{.Copyright}}
|
|
|
|
{{end}}{{if .Version}}
|
|
|
|
VERSION:
|
|
|
|
{{.Version}}
|
|
|
|
{{end}}
|
|
|
|
`
|
|
|
|
|
|
|
|
app := cli.NewApp()
|
2018-10-18 17:33:38 +00:00
|
|
|
app.Name = "validator"
|
2019-01-30 15:24:28 +00:00
|
|
|
app.Usage = `launches an Ethereum Serenity validator client that interacts with a beacon chain,
|
|
|
|
starts proposer services, shardp2p connections, and more`
|
2019-01-10 04:19:33 +00:00
|
|
|
app.Version = version.GetVersion()
|
2018-07-09 02:40:34 +00:00
|
|
|
app.Action = startNode
|
2019-01-30 15:24:28 +00:00
|
|
|
|
|
|
|
app.Commands = []cli.Command{
|
|
|
|
{
|
|
|
|
Name: "accounts",
|
|
|
|
Category: "accounts",
|
|
|
|
Usage: "defines useful functions for interacting with the validator client's account",
|
|
|
|
Subcommands: cli.Commands{
|
|
|
|
cli.Command{
|
|
|
|
Name: "create",
|
|
|
|
Description: `creates a new validator account keystore containing private keys for Ethereum Serenity -
|
|
|
|
this command outputs a deposit data string which can be used to deposit Ether into the ETH1.0 deposit
|
|
|
|
contract in order to activate the validator client`,
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
types.KeystorePathFlag,
|
|
|
|
},
|
|
|
|
Action: createValidatorAccount,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2018-08-15 01:21:49 +00:00
|
|
|
app.Flags = []cli.Flag{
|
|
|
|
types.BeaconRPCProviderFlag,
|
|
|
|
cmd.VerbosityFlag,
|
|
|
|
cmd.DataDirFlag,
|
2018-09-20 11:46:35 +00:00
|
|
|
cmd.EnableTracingFlag,
|
|
|
|
cmd.TracingEndpointFlag,
|
|
|
|
cmd.TraceSampleFractionFlag,
|
2018-11-08 03:22:31 +00:00
|
|
|
cmd.KeystorePasswordFlag,
|
|
|
|
cmd.KeystoreDirectoryFlag,
|
2018-11-15 02:25:06 +00:00
|
|
|
cmd.BootstrapNode,
|
2019-01-13 07:01:11 +00:00
|
|
|
cmd.MonitoringPortFlag,
|
2018-08-15 01:21:49 +00:00
|
|
|
debug.PProfFlag,
|
|
|
|
debug.PProfAddrFlag,
|
|
|
|
debug.PProfPortFlag,
|
|
|
|
debug.MemProfileRateFlag,
|
|
|
|
debug.CPUProfileFlag,
|
|
|
|
debug.TraceFlag,
|
|
|
|
}
|
2018-07-09 02:40:34 +00:00
|
|
|
|
|
|
|
app.Before = func(ctx *cli.Context) error {
|
|
|
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
2018-07-15 19:06:36 +00:00
|
|
|
return debug.Setup(ctx)
|
2018-07-09 02:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
app.After = func(ctx *cli.Context) error {
|
2018-09-21 18:35:48 +00:00
|
|
|
debug.Exit(ctx)
|
2018-07-09 02:40:34 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := app.Run(os.Args); err != nil {
|
2018-07-14 02:15:37 +00:00
|
|
|
log.Error(err.Error())
|
2018-07-09 02:40:34 +00:00
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|