2021-03-03 17:05:37 +00:00
|
|
|
package slashing_protection
|
2021-01-22 23:12:22 +00:00
|
|
|
|
|
|
|
import (
|
2021-09-21 18:11:16 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/cmd"
|
2021-03-02 18:58:40 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/cmd/validator/flags"
|
2021-09-15 01:18:39 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/config/features"
|
2021-09-16 09:46:29 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/runtime/tos"
|
2021-03-09 19:56:05 +00:00
|
|
|
slashingprotection "github.com/prysmaticlabs/prysm/validator/slashing-protection"
|
2021-08-11 17:24:24 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
2021-01-22 23:12:22 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Commands for slashing protection.
|
|
|
|
var Commands = &cli.Command{
|
|
|
|
Name: "slashing-protection",
|
|
|
|
Category: "slashing-protection",
|
|
|
|
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,
|
|
|
|
}),
|
|
|
|
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 {
|
2021-09-15 01:18:39 +00:00
|
|
|
features.ConfigureValidator(cliCtx)
|
2021-08-11 17:24:24 +00:00
|
|
|
if err := slashingprotection.ExportSlashingProtectionJSONCli(cliCtx); err != nil {
|
|
|
|
logrus.Fatalf("Could not export slashing protection file: %v", err)
|
|
|
|
}
|
|
|
|
return nil
|
2021-01-22 23:12:22 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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,
|
2021-09-15 01:18:39 +00:00
|
|
|
features.Mainnet,
|
|
|
|
features.PyrmontTestnet,
|
|
|
|
features.PraterTestnet,
|
2021-01-22 23:12:22 +00:00
|
|
|
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 {
|
2021-09-15 01:18:39 +00:00
|
|
|
features.ConfigureValidator(cliCtx)
|
2021-08-11 17:24:24 +00:00
|
|
|
err := slashingprotection.ImportSlashingProtectionCLI(cliCtx)
|
|
|
|
if err != nil {
|
|
|
|
logrus.Fatalf("Could not import slashing protection cli: %v", err)
|
|
|
|
}
|
|
|
|
return nil
|
2021-01-22 23:12:22 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|