mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
Create config package for Shared/featureconfig (#9593)
* add config/features * Gazelle * Gazelle * Fix build * Go mod tidy * active cache Co-authored-by: rauljordan <raul@prysmaticlabs.com>
This commit is contained in:
32
config/features/BUILD.bazel
Normal file
32
config/features/BUILD.bazel
Normal file
@@ -0,0 +1,32 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"config.go",
|
||||
"deprecated_flags.go",
|
||||
"filter_flags.go",
|
||||
"flags.go",
|
||||
],
|
||||
importpath = "github.com/prysmaticlabs/prysm/config/features",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//shared/params:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@com_github_urfave_cli_v2//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "small",
|
||||
srcs = [
|
||||
"config_test.go",
|
||||
"deprecated_flags_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//shared/testutil/assert:go_default_library",
|
||||
"@com_github_urfave_cli_v2//:go_default_library",
|
||||
],
|
||||
)
|
||||
61
config/features/README.md
Normal file
61
config/features/README.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# Prysm Feature Flags
|
||||
|
||||
Part of Prysm's feature development often involves use of feature flags which serve as a way to
|
||||
toggle new features as they are introduced. Using this methodology, you are assured that your
|
||||
feature can be safely tested in production with a fall back option if any regression were to occur.
|
||||
This reduces the likelihood of an emergency release or rollback of a given feature due to
|
||||
unforeseen issues.
|
||||
|
||||
## When to use a feature flag?
|
||||
|
||||
It is best to use a feature flag any time you are adding or removing functionality in an existing
|
||||
critical application path.
|
||||
|
||||
Examples of when to use a feature flag:
|
||||
|
||||
- Adding a caching layer to an expensive RPC call.
|
||||
- Optimizing a particular algorithm or routine.
|
||||
- Introducing a temporary public testnet configuration.
|
||||
|
||||
Examples of when not to use a feature flag:
|
||||
|
||||
- Adding a new gRPC endpoint. (Unless dangerous or expensive to expose).
|
||||
- Adding new logging statements.
|
||||
- Removing dead code.
|
||||
- Adding any trivial feature with no risk of regressions to existing functionality.
|
||||
|
||||
## How to use a feature flag?
|
||||
|
||||
Once it has been decided that you should use a feature flag. Follow these steps to safely
|
||||
releasing your feature. In general, try to create a single PR for each step of this process.
|
||||
|
||||
1. Add your feature flag to shared/featureconfig/flags.go, use the flag to toggle a boolean in the
|
||||
feature config in shared/featureconfig/config.go. It is a good idea to use the `enable` prefix for
|
||||
your flag since you're going to invert the flag in a later step. i.e you will use `disable` prefix
|
||||
later. For example, `--enable-my-feature`. Additionally, [create a feature flag tracking issue](https://github.com/prysmaticlabs/prysm/issues/new?template=feature_flag.md)
|
||||
for your feature using the appropriate issue template.
|
||||
2. Use the feature throughout the application to enable your new functionality and be sure to write
|
||||
tests carefully and thoughtfully to ensure you have tested all of your new funcitonality without losing
|
||||
coverage on the existing functionality. This is considered an opt-in feature flag. Example usage:
|
||||
```go
|
||||
func someExistingMethod(ctx context.Context) error {
|
||||
if featureconfig.Get().MyNewFeature {
|
||||
return newMethod(ctx)
|
||||
}
|
||||
// Otherwise continue with the existing code path.
|
||||
}
|
||||
```
|
||||
3. Add the flag to the end to end tests. This set of flags can also be found in shared/featureconfig/flags.go.
|
||||
4. Test the functionality locally and safely in production. Once you have enough confidence that
|
||||
your new function works and is safe to release then move onto the next step.
|
||||
5. Move your existing flag to the deprecated section of shared/featureconfig/flags.go. It is
|
||||
important NOT to delete your existing flag outright. Deleting a flag can be extremely frustrating
|
||||
to users as it may break their existing workflow! Marking a flag as deprecated gives users time to
|
||||
adjust their start scripts and workflow. Add another feature flag to represent the inverse of your
|
||||
flag from step 1. For example `--disable-my-feature`. Read the value of this flag to appropriately
|
||||
the config value in shared/featureconfig/config.go.
|
||||
6. After your feature has been included in a release as "opt-out" and there are no issues,
|
||||
deprecate the opt-out feature flag, delete the config field from shared/featureconfig/config.go,
|
||||
delete any deprecated / obsolete code paths.
|
||||
|
||||
Deprecated flags are deleted upon each major semver point release. Ex: v1, v2, v3.
|
||||
302
config/features/config.go
Normal file
302
config/features/config.go
Normal file
@@ -0,0 +1,302 @@
|
||||
/*
|
||||
Package featureconfig defines which features are enabled for runtime
|
||||
in order to selectively enable certain features to maintain a stable runtime.
|
||||
|
||||
The process for implementing new features using this package is as follows:
|
||||
1. Add a new CMD flag in flags.go, and place it in the proper list(s) var for its client.
|
||||
2. Add a condition for the flag in the proper Configure function(s) below.
|
||||
3. Place any "new" behavior in the `if flagEnabled` statement.
|
||||
4. Place any "previous" behavior in the `else` statement.
|
||||
5. Ensure any tests using the new feature fail if the flag isn't enabled.
|
||||
5a. Use the following to enable your flag for tests:
|
||||
cfg := &featureconfig.Flags{
|
||||
VerifyAttestationSigs: true,
|
||||
}
|
||||
resetCfg := featureconfig.InitWithReset(cfg)
|
||||
defer resetCfg()
|
||||
6. Add the string for the flags that should be running within E2E to E2EValidatorFlags
|
||||
and E2EBeaconChainFlags.
|
||||
*/
|
||||
package features
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var log = logrus.WithField("prefix", "flags")
|
||||
|
||||
const enabledFeatureFlag = "Enabled feature flag"
|
||||
const disabledFeatureFlag = "Disabled feature flag"
|
||||
|
||||
// Flags is a struct to represent which features the client will perform on runtime.
|
||||
type Flags struct {
|
||||
// Testnet Flags.
|
||||
PyrmontTestnet bool // PyrmontTestnet defines the flag through which we can enable the node to run on the Pyrmont testnet.
|
||||
|
||||
// Feature related flags.
|
||||
WriteSSZStateTransitions bool // WriteSSZStateTransitions to tmp directory.
|
||||
SkipBLSVerify bool // Skips BLS verification across the runtime.
|
||||
SlasherProtection bool // SlasherProtection protects validator fron sending over a slashable offense over the network using external slasher.
|
||||
EnablePeerScorer bool // EnablePeerScorer enables experimental peer scoring in p2p.
|
||||
EnableLargerGossipHistory bool // EnableLargerGossipHistory increases the gossip history we store in our caches.
|
||||
WriteWalletPasswordOnWebOnboarding bool // WriteWalletPasswordOnWebOnboarding writes the password to disk after Prysm web signup.
|
||||
DisableAttestingHistoryDBCache bool // DisableAttestingHistoryDBCache for the validator client increases disk reads/writes.
|
||||
UpdateHeadTimely bool // UpdateHeadTimely updates head right after state transition.
|
||||
ProposerAttsSelectionUsingMaxCover bool // ProposerAttsSelectionUsingMaxCover enables max-cover algorithm when selecting attestations for proposing.
|
||||
EnableOptimizedBalanceUpdate bool // EnableOptimizedBalanceUpdate uses an updated method of performing balance updates.
|
||||
EnableDoppelGanger bool // EnableDoppelGanger enables doppelganger protection on startup for the validator.
|
||||
EnableHistoricalSpaceRepresentation bool // EnableHistoricalSpaceRepresentation enables the saving of registry validators in separate buckets to save space
|
||||
// Logging related toggles.
|
||||
DisableGRPCConnectionLogs bool // Disables logging when a new grpc client has connected.
|
||||
|
||||
// Slasher toggles.
|
||||
DisableLookback bool // DisableLookback updates slasher to not use the lookback and update validator histories until epoch 0.
|
||||
DisableBroadcastSlashings bool // DisableBroadcastSlashings disables p2p broadcasting of proposer and attester slashings.
|
||||
|
||||
// Cache toggles.
|
||||
EnableSSZCache bool // EnableSSZCache see https://github.com/prysmaticlabs/prysm/pull/4558.
|
||||
EnableNextSlotStateCache bool // EnableNextSlotStateCache enables next slot state cache to improve validator performance.
|
||||
EnableActiveBalanceCache bool // EnableActiveBalanceCache enables active balance cache.
|
||||
|
||||
// Bug fixes related flags.
|
||||
AttestTimely bool // AttestTimely fixes #8185. It is gated behind a flag to ensure beacon node's fix can safely roll out first. We'll invert this in v1.1.0.
|
||||
|
||||
// EnableSlashingProtectionPruning for the validator client.
|
||||
EnableSlashingProtectionPruning bool
|
||||
|
||||
// Bug fixes related flags.
|
||||
CorrectlyInsertOrphanedAtts bool
|
||||
CorrectlyPruneCanonicalAtts bool
|
||||
|
||||
// KeystoreImportDebounceInterval specifies the time duration the validator waits to reload new keys if they have
|
||||
// changed on disk. This feature is for advanced use cases only.
|
||||
KeystoreImportDebounceInterval time.Duration
|
||||
|
||||
AttestationAggregationStrategy string // AttestationAggregationStrategy defines aggregation strategy to be used when aggregating.
|
||||
}
|
||||
|
||||
var featureConfig *Flags
|
||||
var featureConfigLock sync.RWMutex
|
||||
|
||||
// Get retrieves feature config.
|
||||
func Get() *Flags {
|
||||
featureConfigLock.RLock()
|
||||
defer featureConfigLock.RUnlock()
|
||||
|
||||
if featureConfig == nil {
|
||||
return &Flags{}
|
||||
}
|
||||
return featureConfig
|
||||
}
|
||||
|
||||
// Init sets the global config equal to the config that is passed in.
|
||||
func Init(c *Flags) {
|
||||
featureConfigLock.Lock()
|
||||
defer featureConfigLock.Unlock()
|
||||
|
||||
featureConfig = c
|
||||
}
|
||||
|
||||
// InitWithReset sets the global config and returns function that is used to reset configuration.
|
||||
func InitWithReset(c *Flags) func() {
|
||||
var prevConfig Flags
|
||||
if featureConfig != nil {
|
||||
prevConfig = *featureConfig
|
||||
} else {
|
||||
prevConfig = Flags{}
|
||||
}
|
||||
resetFunc := func() {
|
||||
Init(&prevConfig)
|
||||
}
|
||||
Init(c)
|
||||
return resetFunc
|
||||
}
|
||||
|
||||
// configureTestnet sets the config according to specified testnet flag
|
||||
func configureTestnet(ctx *cli.Context, cfg *Flags) {
|
||||
if ctx.Bool(PyrmontTestnet.Name) {
|
||||
log.Warn("Running on Pyrmont Testnet")
|
||||
params.UsePyrmontConfig()
|
||||
params.UsePyrmontNetworkConfig()
|
||||
cfg.PyrmontTestnet = true
|
||||
} else if ctx.Bool(PraterTestnet.Name) {
|
||||
log.Warn("Running on the Prater Testnet")
|
||||
params.UsePraterConfig()
|
||||
params.UsePraterNetworkConfig()
|
||||
} else {
|
||||
log.Warn("Running on Ethereum Consensus Mainnet")
|
||||
params.UseMainnetConfig()
|
||||
}
|
||||
}
|
||||
|
||||
// ConfigureBeaconChain sets the global config based
|
||||
// on what flags are enabled for the beacon-chain client.
|
||||
func ConfigureBeaconChain(ctx *cli.Context) {
|
||||
complainOnDeprecatedFlags(ctx)
|
||||
cfg := &Flags{}
|
||||
if ctx.Bool(devModeFlag.Name) {
|
||||
enableDevModeFlags(ctx)
|
||||
}
|
||||
configureTestnet(ctx, cfg)
|
||||
|
||||
if ctx.Bool(writeSSZStateTransitionsFlag.Name) {
|
||||
logEnabled(writeSSZStateTransitionsFlag)
|
||||
cfg.WriteSSZStateTransitions = true
|
||||
}
|
||||
|
||||
cfg.EnableSSZCache = true
|
||||
|
||||
if ctx.IsSet(disableGRPCConnectionLogging.Name) {
|
||||
logDisabled(disableGRPCConnectionLogging)
|
||||
cfg.DisableGRPCConnectionLogs = true
|
||||
}
|
||||
cfg.AttestationAggregationStrategy = ctx.String(attestationAggregationStrategy.Name)
|
||||
if ctx.Bool(forceOptMaxCoverAggregationStategy.Name) {
|
||||
logEnabled(forceOptMaxCoverAggregationStategy)
|
||||
cfg.AttestationAggregationStrategy = "opt_max_cover"
|
||||
}
|
||||
if ctx.Bool(enablePeerScorer.Name) {
|
||||
logEnabled(enablePeerScorer)
|
||||
cfg.EnablePeerScorer = true
|
||||
}
|
||||
if ctx.Bool(checkPtInfoCache.Name) {
|
||||
log.Warn("Advance check point info cache is no longer supported and will soon be deleted")
|
||||
}
|
||||
if ctx.Bool(enableLargerGossipHistory.Name) {
|
||||
logEnabled(enableLargerGossipHistory)
|
||||
cfg.EnableLargerGossipHistory = true
|
||||
}
|
||||
if ctx.Bool(disableBroadcastSlashingFlag.Name) {
|
||||
logDisabled(disableBroadcastSlashingFlag)
|
||||
cfg.DisableBroadcastSlashings = true
|
||||
}
|
||||
if ctx.Bool(enableNextSlotStateCache.Name) {
|
||||
logEnabled(enableNextSlotStateCache)
|
||||
cfg.EnableNextSlotStateCache = true
|
||||
}
|
||||
cfg.UpdateHeadTimely = true
|
||||
if ctx.Bool(disableUpdateHeadTimely.Name) {
|
||||
logDisabled(disableUpdateHeadTimely)
|
||||
cfg.UpdateHeadTimely = false
|
||||
}
|
||||
cfg.ProposerAttsSelectionUsingMaxCover = true
|
||||
if ctx.Bool(disableProposerAttsSelectionUsingMaxCover.Name) {
|
||||
logDisabled(disableProposerAttsSelectionUsingMaxCover)
|
||||
cfg.ProposerAttsSelectionUsingMaxCover = false
|
||||
}
|
||||
cfg.EnableOptimizedBalanceUpdate = true
|
||||
if ctx.Bool(disableOptimizedBalanceUpdate.Name) {
|
||||
logDisabled(disableOptimizedBalanceUpdate)
|
||||
cfg.EnableOptimizedBalanceUpdate = false
|
||||
}
|
||||
if ctx.Bool(enableHistoricalSpaceRepresentation.Name) {
|
||||
log.WithField(enableHistoricalSpaceRepresentation.Name, enableHistoricalSpaceRepresentation.Usage).Warn(enabledFeatureFlag)
|
||||
cfg.EnableHistoricalSpaceRepresentation = true
|
||||
}
|
||||
cfg.CorrectlyInsertOrphanedAtts = true
|
||||
if ctx.Bool(disableCorrectlyInsertOrphanedAtts.Name) {
|
||||
logDisabled(disableCorrectlyInsertOrphanedAtts)
|
||||
cfg.CorrectlyInsertOrphanedAtts = false
|
||||
}
|
||||
cfg.CorrectlyPruneCanonicalAtts = true
|
||||
if ctx.Bool(disableCorrectlyPruneCanonicalAtts.Name) {
|
||||
logDisabled(disableCorrectlyPruneCanonicalAtts)
|
||||
cfg.CorrectlyPruneCanonicalAtts = false
|
||||
}
|
||||
cfg.EnableActiveBalanceCache = true
|
||||
if ctx.Bool(disableActiveBalanceCache.Name) {
|
||||
logDisabled(disableActiveBalanceCache)
|
||||
cfg.EnableActiveBalanceCache = false
|
||||
}
|
||||
Init(cfg)
|
||||
}
|
||||
|
||||
// ConfigureSlasher sets the global config based
|
||||
// on what flags are enabled for the slasher client.
|
||||
func ConfigureSlasher(ctx *cli.Context) {
|
||||
complainOnDeprecatedFlags(ctx)
|
||||
cfg := &Flags{}
|
||||
configureTestnet(ctx, cfg)
|
||||
|
||||
if ctx.Bool(disableLookbackFlag.Name) {
|
||||
logDisabled(disableLookbackFlag)
|
||||
cfg.DisableLookback = true
|
||||
}
|
||||
Init(cfg)
|
||||
}
|
||||
|
||||
// ConfigureValidator sets the global config based
|
||||
// on what flags are enabled for the validator client.
|
||||
func ConfigureValidator(ctx *cli.Context) {
|
||||
complainOnDeprecatedFlags(ctx)
|
||||
cfg := &Flags{}
|
||||
configureTestnet(ctx, cfg)
|
||||
if ctx.Bool(enableExternalSlasherProtectionFlag.Name) {
|
||||
logEnabled(enableExternalSlasherProtectionFlag)
|
||||
cfg.SlasherProtection = true
|
||||
}
|
||||
if ctx.Bool(writeWalletPasswordOnWebOnboarding.Name) {
|
||||
logEnabled(writeWalletPasswordOnWebOnboarding)
|
||||
cfg.WriteWalletPasswordOnWebOnboarding = true
|
||||
}
|
||||
if ctx.Bool(disableAttestingHistoryDBCache.Name) {
|
||||
logDisabled(disableAttestingHistoryDBCache)
|
||||
cfg.DisableAttestingHistoryDBCache = true
|
||||
}
|
||||
if ctx.Bool(attestTimely.Name) {
|
||||
logEnabled(attestTimely)
|
||||
cfg.AttestTimely = true
|
||||
}
|
||||
if ctx.Bool(enableSlashingProtectionPruning.Name) {
|
||||
logEnabled(enableSlashingProtectionPruning)
|
||||
cfg.EnableSlashingProtectionPruning = true
|
||||
}
|
||||
if ctx.Bool(enableDoppelGangerProtection.Name) {
|
||||
logEnabled(enableDoppelGangerProtection)
|
||||
cfg.EnableDoppelGanger = true
|
||||
}
|
||||
cfg.KeystoreImportDebounceInterval = ctx.Duration(dynamicKeyReloadDebounceInterval.Name)
|
||||
Init(cfg)
|
||||
}
|
||||
|
||||
// enableDevModeFlags switches development mode features on.
|
||||
func enableDevModeFlags(ctx *cli.Context) {
|
||||
log.Warn("Enabling development mode flags")
|
||||
for _, f := range devModeFlags {
|
||||
log.WithField("flag", f.Names()[0]).Debug("Enabling development mode flag")
|
||||
if !ctx.IsSet(f.Names()[0]) {
|
||||
if err := ctx.Set(f.Names()[0], "true"); err != nil {
|
||||
log.WithError(err).Debug("Error enabling development mode flag")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func complainOnDeprecatedFlags(ctx *cli.Context) {
|
||||
for _, f := range deprecatedFlags {
|
||||
if ctx.IsSet(f.Names()[0]) {
|
||||
log.Errorf("%s is deprecated and has no effect. Do not use this flag, it will be deleted soon.", f.Names()[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func logEnabled(flag cli.DocGenerationFlag) {
|
||||
var name string
|
||||
if names := flag.Names(); len(names) > 0 {
|
||||
name = names[0]
|
||||
}
|
||||
log.WithField(name, flag.GetUsage()).Warn(enabledFeatureFlag)
|
||||
}
|
||||
|
||||
func logDisabled(flag cli.DocGenerationFlag) {
|
||||
var name string
|
||||
if names := flag.Names(); len(names) > 0 {
|
||||
name = names[0]
|
||||
}
|
||||
log.WithField(name, flag.GetUsage()).Warn(disabledFeatureFlag)
|
||||
}
|
||||
51
config/features/config_test.go
Normal file
51
config/features/config_test.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package features
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
func TestInitFeatureConfig(t *testing.T) {
|
||||
defer Init(&Flags{})
|
||||
cfg := &Flags{
|
||||
PyrmontTestnet: true,
|
||||
}
|
||||
Init(cfg)
|
||||
c := Get()
|
||||
assert.Equal(t, true, c.PyrmontTestnet)
|
||||
|
||||
// Reset back to false for the follow up tests.
|
||||
cfg = &Flags{PyrmontTestnet: false}
|
||||
Init(cfg)
|
||||
}
|
||||
|
||||
func TestInitWithReset(t *testing.T) {
|
||||
defer Init(&Flags{})
|
||||
Init(&Flags{
|
||||
PyrmontTestnet: true,
|
||||
})
|
||||
assert.Equal(t, true, Get().PyrmontTestnet)
|
||||
|
||||
// Overwrite previously set value (value that didn't come by default).
|
||||
resetCfg := InitWithReset(&Flags{
|
||||
PyrmontTestnet: false,
|
||||
})
|
||||
assert.Equal(t, false, Get().PyrmontTestnet)
|
||||
|
||||
// Reset must get to previously set configuration (not to default config values).
|
||||
resetCfg()
|
||||
assert.Equal(t, true, Get().PyrmontTestnet)
|
||||
}
|
||||
|
||||
func TestConfigureBeaconConfig(t *testing.T) {
|
||||
app := cli.App{}
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
set.Bool(PyrmontTestnet.Name, true, "test")
|
||||
context := cli.NewContext(&app, set, nil)
|
||||
ConfigureBeaconChain(context)
|
||||
c := Get()
|
||||
assert.Equal(t, true, c.PyrmontTestnet)
|
||||
}
|
||||
40
config/features/deprecated_flags.go
Normal file
40
config/features/deprecated_flags.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package features
|
||||
|
||||
import "github.com/urfave/cli/v2"
|
||||
|
||||
// Deprecated flags list.
|
||||
const deprecatedUsage = "DEPRECATED. DO NOT USE."
|
||||
|
||||
var (
|
||||
// To deprecate a feature flag, first copy the example below, then insert deprecated flag in `deprecatedFlags`.
|
||||
exampleDeprecatedFeatureFlag = &cli.StringFlag{
|
||||
Name: "name",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
|
||||
deprecatedEnableActiveBalanceCache = &cli.BoolFlag{
|
||||
Name: "enable-active-balance-cache",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
|
||||
deprecatedCorrectlyPruneCanonicalAtts = &cli.BoolFlag{
|
||||
Name: "correctly-prune-canonical-atts",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
|
||||
deprecatedCorrectlyInsertOrphanedAtts = &cli.BoolFlag{
|
||||
Name: "correctly-insert-orphaned-atts",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
)
|
||||
|
||||
var deprecatedFlags = []cli.Flag{
|
||||
exampleDeprecatedFeatureFlag,
|
||||
deprecatedEnableActiveBalanceCache,
|
||||
deprecatedCorrectlyPruneCanonicalAtts,
|
||||
deprecatedCorrectlyInsertOrphanedAtts,
|
||||
}
|
||||
18
config/features/deprecated_flags_test.go
Normal file
18
config/features/deprecated_flags_test.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package features
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
)
|
||||
|
||||
func TestDeprecatedFlags(t *testing.T) {
|
||||
for _, f := range deprecatedFlags {
|
||||
fv := reflect.ValueOf(f)
|
||||
field := reflect.Indirect(fv).FieldByName("Hidden")
|
||||
assert.Equal(t, false, !field.IsValid() || !field.Bool())
|
||||
assert.Equal(t, false, !strings.Contains(reflect.Indirect(fv).FieldByName("Usage").String(), "DEPRECATED. DO NOT USE."))
|
||||
}
|
||||
}
|
||||
27
config/features/filter_flags.go
Normal file
27
config/features/filter_flags.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package features
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// ActiveFlags returns all of the flags that are not Hidden.
|
||||
func ActiveFlags(flags []cli.Flag) []cli.Flag {
|
||||
visible := make([]cli.Flag, 0, len(flags))
|
||||
for _, flag := range flags {
|
||||
field := flagValue(flag).FieldByName("Hidden")
|
||||
if !field.IsValid() || !field.Bool() {
|
||||
visible = append(visible, flag)
|
||||
}
|
||||
}
|
||||
return visible
|
||||
}
|
||||
|
||||
func flagValue(f cli.Flag) reflect.Value {
|
||||
fv := reflect.ValueOf(f)
|
||||
for fv.Kind() == reflect.Ptr {
|
||||
fv = reflect.Indirect(fv)
|
||||
}
|
||||
return fv
|
||||
}
|
||||
204
config/features/flags.go
Normal file
204
config/features/flags.go
Normal file
@@ -0,0 +1,204 @@
|
||||
package features
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var (
|
||||
// PyrmontTestnet flag for the multiclient Ethereum consensus testnet.
|
||||
PyrmontTestnet = &cli.BoolFlag{
|
||||
Name: "pyrmont",
|
||||
Usage: "This defines the flag through which we can run on the Pyrmont Multiclient Testnet",
|
||||
}
|
||||
// PraterTestnet flag for the multiclient Ethereum consensus testnet.
|
||||
PraterTestnet = &cli.BoolFlag{
|
||||
Name: "prater",
|
||||
Usage: "Run Prysm configured for the Prater test network",
|
||||
}
|
||||
// Mainnet flag for easier tooling, no-op
|
||||
Mainnet = &cli.BoolFlag{
|
||||
Value: true,
|
||||
Name: "mainnet",
|
||||
Usage: "Run on Ethereum Beacon Chain Main Net. This is the default and can be omitted.",
|
||||
}
|
||||
devModeFlag = &cli.BoolFlag{
|
||||
Name: "dev",
|
||||
Usage: "Enable experimental features still in development. These features may not be stable.",
|
||||
}
|
||||
writeSSZStateTransitionsFlag = &cli.BoolFlag{
|
||||
Name: "interop-write-ssz-state-transitions",
|
||||
Usage: "Write ssz states to disk after attempted state transition",
|
||||
}
|
||||
enableExternalSlasherProtectionFlag = &cli.BoolFlag{
|
||||
Name: "enable-external-slasher-protection",
|
||||
Usage: "Enables the validator to connect to external slasher to prevent it from " +
|
||||
"transmitting a slashable offence over the network.",
|
||||
}
|
||||
disableLookbackFlag = &cli.BoolFlag{
|
||||
Name: "disable-lookback",
|
||||
Usage: "Disables use of the lookback feature and updates attestation history for validators from head to epoch 0",
|
||||
}
|
||||
disableGRPCConnectionLogging = &cli.BoolFlag{
|
||||
Name: "disable-grpc-connection-logging",
|
||||
Usage: "Disables displaying logs for newly connected grpc clients",
|
||||
}
|
||||
attestationAggregationStrategy = &cli.StringFlag{
|
||||
Name: "attestation-aggregation-strategy",
|
||||
Usage: "Which strategy to use when aggregating attestations, one of: naive, max_cover, opt_max_cover.",
|
||||
Value: "max_cover",
|
||||
}
|
||||
forceOptMaxCoverAggregationStategy = &cli.BoolFlag{
|
||||
Name: "attestation-aggregation-force-opt-maxcover",
|
||||
Usage: "When enabled, forces --attestation-aggregation-strategy=opt_max_cover setting.",
|
||||
}
|
||||
enablePeerScorer = &cli.BoolFlag{
|
||||
Name: "enable-peer-scorer",
|
||||
Usage: "Enable experimental P2P peer scorer",
|
||||
}
|
||||
checkPtInfoCache = &cli.BoolFlag{
|
||||
Name: "use-check-point-cache",
|
||||
Usage: "Enables check point info caching",
|
||||
}
|
||||
enableLargerGossipHistory = &cli.BoolFlag{
|
||||
Name: "enable-larger-gossip-history",
|
||||
Usage: "Enables the node to store a larger amount of gossip messages in its cache.",
|
||||
}
|
||||
writeWalletPasswordOnWebOnboarding = &cli.BoolFlag{
|
||||
Name: "write-wallet-password-on-web-onboarding",
|
||||
Usage: "(Danger): Writes the wallet password to the wallet directory on completing Prysm web onboarding. " +
|
||||
"We recommend against this flag unless you are an advanced user.",
|
||||
}
|
||||
disableAttestingHistoryDBCache = &cli.BoolFlag{
|
||||
Name: "disable-attesting-history-db-cache",
|
||||
Usage: "(Danger): Disables the cache for attesting history in the validator DB, greatly increasing " +
|
||||
"disk reads and writes as well as increasing time required for attestations to be produced",
|
||||
}
|
||||
dynamicKeyReloadDebounceInterval = &cli.DurationFlag{
|
||||
Name: "dynamic-key-reload-debounce-interval",
|
||||
Usage: "(Advanced): Specifies the time duration the validator waits to reload new keys if they have " +
|
||||
"changed on disk. Default 1s, can be any type of duration such as 1.5s, 1000ms, 1m.",
|
||||
Value: time.Second,
|
||||
}
|
||||
disableBroadcastSlashingFlag = &cli.BoolFlag{
|
||||
Name: "disable-broadcast-slashings",
|
||||
Usage: "Disables broadcasting slashings submitted to the beacon node.",
|
||||
}
|
||||
attestTimely = &cli.BoolFlag{
|
||||
Name: "attest-timely",
|
||||
Usage: "Fixes validator can attest timely after current block processes. See #8185 for more details",
|
||||
}
|
||||
enableNextSlotStateCache = &cli.BoolFlag{
|
||||
Name: "enable-next-slot-state-cache",
|
||||
Usage: "Improves attesting and proposing efficiency by caching the next slot state at the end of the current slot",
|
||||
}
|
||||
disableUpdateHeadTimely = &cli.BoolFlag{
|
||||
Name: "disable-update-head-timely",
|
||||
Usage: "Disables updating head right after state transition",
|
||||
}
|
||||
disableProposerAttsSelectionUsingMaxCover = &cli.BoolFlag{
|
||||
Name: "disable-proposer-atts-selection-using-max-cover",
|
||||
Usage: "Disable max-cover algorithm when selecting attestations for proposer",
|
||||
}
|
||||
enableSlashingProtectionPruning = &cli.BoolFlag{
|
||||
Name: "enable-slashing-protection-pruning",
|
||||
Usage: "Enables the pruning of the validator client's slashing protection database",
|
||||
}
|
||||
disableOptimizedBalanceUpdate = &cli.BoolFlag{
|
||||
Name: "disable-optimized-balance-update",
|
||||
Usage: "Disable the optimized method of updating validator balances.",
|
||||
}
|
||||
enableDoppelGangerProtection = &cli.BoolFlag{
|
||||
Name: "enable-doppelganger",
|
||||
Usage: "Enables the validator to perform a doppelganger check. (Warning): This is not " +
|
||||
"a foolproof method to find duplicate instances in the network. Your validator will still be" +
|
||||
" vulnerable if it is being run in unsafe configurations.",
|
||||
}
|
||||
enableHistoricalSpaceRepresentation = &cli.BoolFlag{
|
||||
Name: "enable-historical-state-representation",
|
||||
Usage: "Enables the beacon chain to save historical states in a space efficient manner." +
|
||||
" (Warning): Once enabled, this feature migrates your database in to a new schema and " +
|
||||
"there is no going back. At worst, your entire database might get corrupted.",
|
||||
}
|
||||
disableCorrectlyInsertOrphanedAtts = &cli.BoolFlag{
|
||||
Name: "disable-correctly-insert-orphaned-atts",
|
||||
Usage: "Disable the fix for bug where orphaned attestations don't get reinserted back to mem pool. Which is an improves validator profitability and overall network health," +
|
||||
"see issue #9441 for further detail",
|
||||
}
|
||||
disableCorrectlyPruneCanonicalAtts = &cli.BoolFlag{
|
||||
Name: "disable-correctly-prune-canonical-atts",
|
||||
Usage: "Disable the fix for bug where any block attestations can get incorrectly pruned, which improves validator profitability and overall network health," +
|
||||
"see issue #9443 for further detail",
|
||||
}
|
||||
disableActiveBalanceCache = &cli.BoolFlag{
|
||||
Name: "disable-active-balance-cache",
|
||||
Usage: "This disables active balance cache, which improves node performance during block processing",
|
||||
}
|
||||
)
|
||||
|
||||
// devModeFlags holds list of flags that are set when development mode is on.
|
||||
var devModeFlags = []cli.Flag{
|
||||
enableLargerGossipHistory,
|
||||
enableNextSlotStateCache,
|
||||
forceOptMaxCoverAggregationStategy,
|
||||
}
|
||||
|
||||
// ValidatorFlags contains a list of all the feature flags that apply to the validator client.
|
||||
var ValidatorFlags = append(deprecatedFlags, []cli.Flag{
|
||||
writeWalletPasswordOnWebOnboarding,
|
||||
enableExternalSlasherProtectionFlag,
|
||||
disableAttestingHistoryDBCache,
|
||||
PyrmontTestnet,
|
||||
PraterTestnet,
|
||||
Mainnet,
|
||||
dynamicKeyReloadDebounceInterval,
|
||||
attestTimely,
|
||||
enableSlashingProtectionPruning,
|
||||
enableDoppelGangerProtection,
|
||||
}...)
|
||||
|
||||
// SlasherFlags contains a list of all the feature flags that apply to the slasher client.
|
||||
var SlasherFlags = append(deprecatedFlags, []cli.Flag{
|
||||
disableLookbackFlag,
|
||||
PyrmontTestnet,
|
||||
PraterTestnet,
|
||||
Mainnet,
|
||||
}...)
|
||||
|
||||
// E2EValidatorFlags contains a list of the validator feature flags to be tested in E2E.
|
||||
var E2EValidatorFlags = []string{
|
||||
"--enable-doppelganger",
|
||||
}
|
||||
|
||||
// BeaconChainFlags contains a list of all the feature flags that apply to the beacon-chain client.
|
||||
var BeaconChainFlags = append(deprecatedFlags, []cli.Flag{
|
||||
devModeFlag,
|
||||
writeSSZStateTransitionsFlag,
|
||||
disableGRPCConnectionLogging,
|
||||
attestationAggregationStrategy,
|
||||
PyrmontTestnet,
|
||||
PraterTestnet,
|
||||
Mainnet,
|
||||
enablePeerScorer,
|
||||
enableLargerGossipHistory,
|
||||
checkPtInfoCache,
|
||||
disableBroadcastSlashingFlag,
|
||||
enableNextSlotStateCache,
|
||||
forceOptMaxCoverAggregationStategy,
|
||||
disableUpdateHeadTimely,
|
||||
disableProposerAttsSelectionUsingMaxCover,
|
||||
disableOptimizedBalanceUpdate,
|
||||
enableHistoricalSpaceRepresentation,
|
||||
disableCorrectlyInsertOrphanedAtts,
|
||||
disableCorrectlyPruneCanonicalAtts,
|
||||
disableActiveBalanceCache,
|
||||
}...)
|
||||
|
||||
// E2EBeaconChainFlags contains a list of the beacon chain feature flags to be tested in E2E.
|
||||
var E2EBeaconChainFlags = []string{
|
||||
"--attestation-aggregation-strategy=opt_max_cover",
|
||||
"--dev",
|
||||
"--use-check-point-cache",
|
||||
"--enable-active-balance-cache",
|
||||
}
|
||||
Reference in New Issue
Block a user