mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-26 05:17:22 +00:00
d077483577
* v3 import renamings * tidy * fmt * rev * Update beacon-chain/core/epoch/precompute/reward_penalty_test.go * Update beacon-chain/core/helpers/validators_test.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/iface/BUILD.bazel * Update beacon-chain/db/kv/kv.go * Update beacon-chain/db/kv/state.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/sync/initial-sync/service.go * fix deps * fix bad replacements * fix bad replacements * change back * gohashtree version * fix deps Co-authored-by: Nishant Das <nishdas93@gmail.com> Co-authored-by: Potuz <potuz@prysmaticlabs.com>
71 lines
1.9 KiB
Go
71 lines
1.9 KiB
Go
package db
|
|
|
|
import (
|
|
"github.com/prysmaticlabs/prysm/v3/cmd"
|
|
"github.com/prysmaticlabs/prysm/v3/runtime/tos"
|
|
validatordb "github.com/prysmaticlabs/prysm/v3/validator/db"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
var log = logrus.WithField("prefix", "db")
|
|
|
|
// Commands for interacting with the Prysm validator database.
|
|
var Commands = &cli.Command{
|
|
Name: "db",
|
|
Category: "db",
|
|
Usage: "defines commands for interacting with the Prysm validator database",
|
|
Subcommands: []*cli.Command{
|
|
{
|
|
Name: "restore",
|
|
Description: `restores a database from a backup file`,
|
|
Flags: cmd.WrapFlags([]cli.Flag{
|
|
cmd.RestoreSourceFileFlag,
|
|
cmd.RestoreTargetDirFlag,
|
|
}),
|
|
Before: tos.VerifyTosAcceptedOrPrompt,
|
|
Action: func(cliCtx *cli.Context) error {
|
|
if err := validatordb.Restore(cliCtx); err != nil {
|
|
log.WithError(err).Fatal("Could not restore database")
|
|
}
|
|
return nil
|
|
},
|
|
},
|
|
{
|
|
Name: "migrate",
|
|
Category: "db",
|
|
Usage: "Defines commands for running validator database migrations",
|
|
Subcommands: []*cli.Command{
|
|
{
|
|
Name: "up",
|
|
Usage: "Runs up migrations for the validator database",
|
|
Flags: cmd.WrapFlags([]cli.Flag{
|
|
cmd.DataDirFlag,
|
|
}),
|
|
Before: tos.VerifyTosAcceptedOrPrompt,
|
|
Action: func(cliCtx *cli.Context) error {
|
|
if err := validatordb.MigrateUp(cliCtx); err != nil {
|
|
log.WithError(err).Fatal("Could not run database migrations")
|
|
}
|
|
return nil
|
|
},
|
|
},
|
|
{
|
|
Name: "down",
|
|
Usage: "Runs down migrations for the validator database",
|
|
Flags: cmd.WrapFlags([]cli.Flag{
|
|
cmd.DataDirFlag,
|
|
}),
|
|
Before: tos.VerifyTosAcceptedOrPrompt,
|
|
Action: func(cliCtx *cli.Context) error {
|
|
if err := validatordb.MigrateDown(cliCtx); err != nil {
|
|
log.WithError(err).Fatal("Could not run database migrations")
|
|
}
|
|
return nil
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|