2018-08-09 18:25:48 +00:00
|
|
|
// Package beacon-chain defines all the utlities needed for a beacon chain node.
|
2018-07-14 02:15:37 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"runtime"
|
|
|
|
|
2018-07-20 21:31:26 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/node"
|
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/utils"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/cmd"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/debug"
|
2019-03-21 02:57:25 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
2019-01-10 04:19:33 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/version"
|
2018-07-21 17:51:18 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
2018-07-14 02:15:37 +00:00
|
|
|
"github.com/urfave/cli"
|
2018-07-21 17:51:18 +00:00
|
|
|
prefixed "github.com/x-cray/logrus-prefixed-formatter"
|
2018-07-14 02:15:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func startNode(ctx *cli.Context) error {
|
2018-07-21 17:51:18 +00:00
|
|
|
verbosity := ctx.GlobalString(cmd.VerbosityFlag.Name)
|
|
|
|
level, err := logrus.ParseLevel(verbosity)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
logrus.SetLevel(level)
|
|
|
|
|
2018-08-09 18:25:48 +00:00
|
|
|
beacon, err := node.NewBeaconNode(ctx)
|
2018-07-14 02:15:37 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
beacon.Start()
|
|
|
|
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-14 02:15:37 +00:00
|
|
|
app := cli.NewApp()
|
|
|
|
app.Name = "beacon-chain"
|
|
|
|
app.Usage = "this is a beacon chain implementation for Ethereum 2.0"
|
|
|
|
app.Action = startNode
|
2019-01-10 04:19:33 +00:00
|
|
|
app.Version = version.GetVersion()
|
2018-07-14 02:15:37 +00:00
|
|
|
|
2018-08-08 22:43:25 +00:00
|
|
|
app.Flags = []cli.Flag{
|
2019-03-18 15:45:28 +00:00
|
|
|
utils.NoCustomConfigFlag,
|
2019-02-13 19:08:28 +00:00
|
|
|
utils.DepositContractFlag,
|
2018-08-08 22:43:25 +00:00
|
|
|
utils.Web3ProviderFlag,
|
2019-04-19 00:05:13 +00:00
|
|
|
utils.HTTPWeb3ProviderFlag,
|
2018-08-08 22:43:25 +00:00
|
|
|
utils.RPCPort,
|
|
|
|
utils.CertFlag,
|
|
|
|
utils.KeyFlag,
|
2018-11-28 09:02:35 +00:00
|
|
|
utils.EnableDBCleanup,
|
2018-11-15 02:25:06 +00:00
|
|
|
cmd.BootstrapNode,
|
2018-11-25 16:55:02 +00:00
|
|
|
cmd.RelayNode,
|
2018-11-26 02:54:02 +00:00
|
|
|
cmd.P2PPort,
|
2018-08-08 22:43:25 +00:00
|
|
|
cmd.DataDirFlag,
|
|
|
|
cmd.VerbosityFlag,
|
2018-09-20 11:46:35 +00:00
|
|
|
cmd.EnableTracingFlag,
|
|
|
|
cmd.TracingEndpointFlag,
|
|
|
|
cmd.TraceSampleFractionFlag,
|
2018-11-15 12:54:45 +00:00
|
|
|
cmd.MonitoringPortFlag,
|
|
|
|
cmd.DisableMonitoringFlag,
|
2019-03-15 03:20:49 +00:00
|
|
|
cmd.ClearDBFlag,
|
2018-08-08 22:43:25 +00:00
|
|
|
debug.PProfFlag,
|
|
|
|
debug.PProfAddrFlag,
|
|
|
|
debug.PProfPortFlag,
|
|
|
|
debug.MemProfileRateFlag,
|
|
|
|
debug.CPUProfileFlag,
|
|
|
|
debug.TraceFlag,
|
|
|
|
}
|
2018-07-14 03:35:15 +00:00
|
|
|
|
2019-03-21 02:57:25 +00:00
|
|
|
app.Flags = append(app.Flags, featureconfig.BeaconChainFlags...)
|
|
|
|
|
2018-07-14 02:15:37 +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-14 02:15:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
|
|
log.Error(err.Error())
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|