prysm-pulse/cmd/validator/slashing-protection/slashing-protection.go
2024-04-05 15:41:32 -05:00

75 lines
2.3 KiB
Go

package historycmd
import (
"github.com/prysmaticlabs/prysm/v5/cmd"
"github.com/prysmaticlabs/prysm/v5/cmd/validator/flags"
"github.com/prysmaticlabs/prysm/v5/config/features"
"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.PulseChain,
features.PraterTestnet,
features.PulseChainTestnetV4,
features.SepoliaTestnet,
features.HoleskyTestnet,
features.EnableMinimalSlashingProtection,
}),
// Before: tos.VerifyTosAcceptedOrPrompt,
Before: func(cliCtx *cli.Context) error {
return cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags)
},
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.PulseChain,
features.PraterTestnet,
features.PulseChainTestnetV4,
features.SepoliaTestnet,
features.HoleskyTestnet,
features.EnableMinimalSlashingProtection,
}),
Before: func(cliCtx *cli.Context) error {
return cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags)
},
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
},
},
},
}