mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
1222ebb6db
* Implementation of graffiti flag without tests. * Updated to pass graffiti as string instead of []byte all the way to the ProposeBlock RPC call. This ensures that the ToBytes32() call is handled in ProposeBlock as opposed to relying on the caller to ensure that the value passed is only 32 bytes. This adds work by doing that conversion on each proposed block for a static value of graffiti, but it also helps protect against an RPC call to ProposeBlock that has more than 32 bytes for graffiti. * Added test case for validator. * Added GraffitiFlag to validate usage test. * Updated data structures and logic to convert graffiti flag from string to byte array earlier in the process. Now converting when setting up ValidatorService. * Updated test case to correctly set up validator using byte array. * Merge branch 'master' into graffitiFlag
117 lines
2.5 KiB
Go
117 lines
2.5 KiB
Go
// This code was adapted from https://github.com/ethereum/go-ethereum/blob/master/cmd/geth/usage.go
|
|
package main
|
|
|
|
import (
|
|
"io"
|
|
"sort"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/cmd"
|
|
"github.com/prysmaticlabs/prysm/shared/debug"
|
|
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
|
"github.com/prysmaticlabs/prysm/validator/flags"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var appHelpTemplate = `NAME:
|
|
{{.App.Name}} - {{.App.Usage}}
|
|
USAGE:
|
|
{{.App.HelpName}} [options]{{if .App.Commands}} command [command options]{{end}} {{if .App.ArgsUsage}}{{.App.ArgsUsage}}{{else}}[arguments...]{{end}}
|
|
{{if .App.Version}}
|
|
AUTHOR:
|
|
{{range .App.Authors}}{{ . }}{{end}}
|
|
{{end}}{{if .App.Commands}}
|
|
GLOBAL OPTIONS:
|
|
{{range .App.Commands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}}
|
|
{{end}}{{end}}{{if .FlagGroups}}
|
|
{{range .FlagGroups}}{{.Name}} OPTIONS:
|
|
{{range .Flags}}{{.}}
|
|
{{end}}
|
|
{{end}}{{end}}{{if .App.Copyright }}
|
|
COPYRIGHT:
|
|
{{.App.Copyright}}
|
|
VERSION:
|
|
{{.App.Version}}
|
|
{{end}}{{if len .App.Authors}}
|
|
{{end}}
|
|
`
|
|
|
|
type flagGroup struct {
|
|
Name string
|
|
Flags []cli.Flag
|
|
}
|
|
|
|
var appHelpFlagGroups = []flagGroup{
|
|
{
|
|
Name: "cmd",
|
|
Flags: []cli.Flag{
|
|
cmd.VerbosityFlag,
|
|
cmd.DataDirFlag,
|
|
cmd.EnableTracingFlag,
|
|
cmd.TracingProcessNameFlag,
|
|
cmd.TracingEndpointFlag,
|
|
cmd.TraceSampleFractionFlag,
|
|
cmd.BootstrapNode,
|
|
cmd.MonitoringPortFlag,
|
|
cmd.LogFormat,
|
|
cmd.LogFileName,
|
|
cmd.EnableUPnPFlag,
|
|
},
|
|
},
|
|
{
|
|
Name: "debug",
|
|
Flags: []cli.Flag{
|
|
debug.PProfFlag,
|
|
debug.PProfAddrFlag,
|
|
debug.PProfPortFlag,
|
|
debug.MemProfileRateFlag,
|
|
debug.CPUProfileFlag,
|
|
debug.TraceFlag,
|
|
},
|
|
},
|
|
{
|
|
Name: "validator",
|
|
Flags: []cli.Flag{
|
|
flags.NoCustomConfigFlag,
|
|
flags.BeaconRPCProviderFlag,
|
|
flags.CertFlag,
|
|
flags.KeystorePathFlag,
|
|
flags.PasswordFlag,
|
|
flags.DisablePenaltyRewardLogFlag,
|
|
flags.UnencryptedKeysFlag,
|
|
flags.GraffitiFlag,
|
|
},
|
|
},
|
|
{
|
|
Name: "features",
|
|
Flags: featureconfig.ValidatorFlags,
|
|
},
|
|
{
|
|
Name: "interop",
|
|
Flags: []cli.Flag{
|
|
flags.InteropNumValidators,
|
|
flags.InteropStartIndex,
|
|
},
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
cli.AppHelpTemplate = appHelpTemplate
|
|
|
|
type helpData struct {
|
|
App interface{}
|
|
FlagGroups []flagGroup
|
|
}
|
|
|
|
originalHelpPrinter := cli.HelpPrinter
|
|
cli.HelpPrinter = func(w io.Writer, tmpl string, data interface{}) {
|
|
if tmpl == appHelpTemplate {
|
|
for _, group := range appHelpFlagGroups {
|
|
sort.Sort(cli.FlagsByName(group.Flags))
|
|
}
|
|
originalHelpPrinter(w, tmpl, helpData{data, appHelpFlagGroups})
|
|
} else {
|
|
originalHelpPrinter(w, tmpl, data)
|
|
}
|
|
}
|
|
}
|