prysm-pulse/cmd/validator/slashing-protection/slashing-protection.go
Manu NALEPA 886d76fe7c
Refactor validator client help. (#13401)
* Define `cli.App` without mutation.

No functional change.

* `usage.go`:  Clean `appHelpTemplate`.

No functional change is added.
Modifications consist in adding prefix/suffix `-` to improve readability of
the template without adding new lines in template inference.

We now see some inconsistencies of the template:
- `if .App.Version` is around the `AUTHOR` section.
- `if .App.Copyright` is around both `COPYRIGHT` and `VERSION` sections.
- `if len .App.Authors` is around nothing.

* `usage.go`: Surround version and author correctly.

* `usage.go`: `AUTHOR` ==> `AUTHORS`

* `usage.go`: `GLOBAL` --> `global`.

* `--grpc-max-msg-size`: Remove double default.

* VC: Standardize help message.

- Flags help begin with a capital letter and end with a period.
- If a flag help begins with a verb, it is conjugated.
- Expermitemtal, danger etc... mentions are between parenthesis.

* VC help message: Wrap too long lines.
2024-01-02 18:02:28 +00:00

77 lines
2.3 KiB
Go

package historycmd
import (
"github.com/prysmaticlabs/prysm/v4/cmd"
"github.com/prysmaticlabs/prysm/v4/cmd/validator/flags"
"github.com/prysmaticlabs/prysm/v4/config/features"
"github.com/prysmaticlabs/prysm/v4/runtime/tos"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
// Commands for slashing protection.
var Commands = &cli.Command{
Name: "slashing-protection-history",
Category: "slashing-protection-history",
Usage: "Defines commands for interacting your validator's slashing protection history.",
Subcommands: []*cli.Command{
{
Name: "export",
Description: `exports your validator slashing protection history into an EIP-3076 compliant JSON`,
Flags: cmd.WrapFlags([]cli.Flag{
cmd.DataDirFlag,
flags.SlashingProtectionExportDirFlag,
features.Mainnet,
features.PraterTestnet,
features.SepoliaTestnet,
features.HoleskyTestnet,
cmd.AcceptTosFlag,
}),
Before: func(cliCtx *cli.Context) error {
if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
return err
}
return tos.VerifyTosAcceptedOrPrompt(cliCtx)
},
Action: func(cliCtx *cli.Context) error {
if err := features.ConfigureValidator(cliCtx); err != nil {
return err
}
if err := exportSlashingProtectionJSON(cliCtx); err != nil {
logrus.Fatalf("Could not export slashing protection file: %v", err)
}
return nil
},
},
{
Name: "import",
Description: `imports a selected EIP-3076 compliant slashing protection JSON to the validator database`,
Flags: cmd.WrapFlags([]cli.Flag{
cmd.DataDirFlag,
flags.SlashingProtectionJSONFileFlag,
features.Mainnet,
features.PraterTestnet,
features.SepoliaTestnet,
features.HoleskyTestnet,
cmd.AcceptTosFlag,
}),
Before: func(cliCtx *cli.Context) error {
if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
return err
}
return tos.VerifyTosAcceptedOrPrompt(cliCtx)
},
Action: func(cliCtx *cli.Context) error {
if err := features.ConfigureValidator(cliCtx); err != nil {
return err
}
err := importSlashingProtectionJSON(cliCtx)
if err != nil {
logrus.Fatalf("Could not import slashing protection cli: %v", err)
}
return nil
},
},
},
}