From 9f44d6e45292315f6103159d2ef88d9c0c900ea0 Mon Sep 17 00:00:00 2001 From: Sammy Rosso <15244892+saolyn@users.noreply.github.com> Date: Wed, 18 Jan 2023 22:52:53 +0100 Subject: [PATCH] Add flag for custom slasher database directory (#11890) * Add slasher database directory flag * Fix up some beacon chain flag uses * fmt Co-authored-by: rauljordan Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> --- beacon-chain/node/node.go | 5 +++++ cmd/beacon-chain/flags/base.go | 7 +++++++ cmd/beacon-chain/main.go | 1 + cmd/beacon-chain/usage.go | 1 + 4 files changed, 14 insertions(+) diff --git a/beacon-chain/node/node.go b/beacon-chain/node/node.go index 62069b9af..e08a8c7c7 100644 --- a/beacon-chain/node/node.go +++ b/beacon-chain/node/node.go @@ -448,6 +448,11 @@ func (b *BeaconNode) startSlasherDB(cliCtx *cli.Context) error { return nil } baseDir := cliCtx.String(cmd.DataDirFlag.Name) + + if cliCtx.IsSet(flags.SlasherDirFlag.Name) { + baseDir = cliCtx.String(flags.SlasherDirFlag.Name) + } + dbPath := filepath.Join(baseDir, kv.BeaconNodeDbDirName) clearDB := cliCtx.Bool(cmd.ClearDB.Name) forceClearDB := cliCtx.Bool(cmd.ForceClearDB.Name) diff --git a/cmd/beacon-chain/flags/base.go b/cmd/beacon-chain/flags/base.go index 8b3e1e6a9..76d5154ea 100644 --- a/cmd/beacon-chain/flags/base.go +++ b/cmd/beacon-chain/flags/base.go @@ -5,6 +5,7 @@ package flags import ( "strings" + "github.com/prysmaticlabs/prysm/v3/cmd" "github.com/prysmaticlabs/prysm/v3/config/params" "github.com/urfave/cli/v2" ) @@ -246,4 +247,10 @@ var ( "WARNING: This flag should be used only if you have a clear understanding that community has decided to override the terminal block hash activation epoch. " + "Incorrect usage will result in your node experience consensus failure.", } + // SlasherDirFlag defines a path on disk where the slasher database is stored. + SlasherDirFlag = &cli.StringFlag{ + Name: "slasher-datadir", + Usage: "Directory for the slasher database", + Value: cmd.DefaultDataDir(), + } ) diff --git a/cmd/beacon-chain/main.go b/cmd/beacon-chain/main.go index bbdb41101..976b5bc26 100644 --- a/cmd/beacon-chain/main.go +++ b/cmd/beacon-chain/main.go @@ -130,6 +130,7 @@ var appFlags = []cli.Flag{ checkpoint.RemoteURL, genesis.StatePath, genesis.BeaconAPIURL, + flags.SlasherDirFlag, } func init() { diff --git a/cmd/beacon-chain/usage.go b/cmd/beacon-chain/usage.go index 8e67f4a56..d3ac45402 100644 --- a/cmd/beacon-chain/usage.go +++ b/cmd/beacon-chain/usage.go @@ -126,6 +126,7 @@ var appHelpFlagGroups = []flagGroup{ flags.MaxBuilderEpochMissedSlots, flags.MaxBuilderConsecutiveMissedSlots, flags.EngineEndpointTimeoutSeconds, + flags.SlasherDirFlag, checkpoint.BlockPath, checkpoint.StatePath, checkpoint.RemoteURL,