Feature Flag for Enabling Slashing Protection Pruning (#8632)

This commit is contained in:
Raul Jordan 2021-03-19 12:54:47 -05:00 committed by GitHub
parent 9282a73663
commit d2b1115f46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 3 deletions

View File

@ -64,6 +64,7 @@
"external/.*": "Third party code",
"rules_go_work-.*": "Third party code",
"shared/params/config.go": "This config struct needs to be organized for now",
"shared/featureconfig/config.go": "This config struct needs to be organized for now",
"proto/.*": "Excluding protobuf objects for now"
}
},

View File

@ -70,6 +70,9 @@ type Flags struct {
// 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
// EnableSlashingProtectionPruning for the validator client.
EnableSlashingProtectionPruning bool
}
var featureConfig *Flags
@ -237,6 +240,10 @@ func ConfigureValidator(ctx *cli.Context) {
log.WithField(attestTimely.Name, attestTimely.Usage).Warn(enabledFeatureFlag)
cfg.AttestTimely = true
}
if ctx.Bool(enableSlashingProtectionPruning.Name) {
log.WithField(enableSlashingProtectionPruning.Name, enableSlashingProtectionPruning.Usage).Warn(enabledFeatureFlag)
cfg.EnableSlashingProtectionPruning = true
}
cfg.KeystoreImportDebounceInterval = ctx.Duration(dynamicKeyReloadDebounceInterval.Name)
Init(cfg)
}

View File

@ -118,6 +118,10 @@ var (
Name: "proposer-atts-selection-using-max-cover",
Usage: "Rely on 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 protectin database",
}
)
// devModeFlags holds list of flags that are set when development mode is on.
@ -142,6 +146,7 @@ var ValidatorFlags = append(deprecatedFlags, []cli.Flag{
disableBlst,
dynamicKeyReloadDebounceInterval,
attestTimely,
enableSlashingProtectionPruning,
}...)
// SlasherFlags contains a list of all the feature flags that apply to the slasher client.

View File

@ -26,6 +26,7 @@ go_library(
"//shared/abool:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/event:go_default_library",
"//shared/featureconfig:go_default_library",
"//shared/fileutil:go_default_library",
"//shared/params:go_default_library",
"//shared/progressutil:go_default_library",

View File

@ -12,6 +12,7 @@ import (
prombolt "github.com/prysmaticlabs/prombbolt"
"github.com/prysmaticlabs/prysm/shared/abool"
"github.com/prysmaticlabs/prysm/shared/event"
"github.com/prysmaticlabs/prysm/shared/featureconfig"
"github.com/prysmaticlabs/prysm/shared/fileutil"
"github.com/prysmaticlabs/prysm/shared/params"
bolt "go.etcd.io/bbolt"
@ -160,9 +161,11 @@ func NewKVStore(ctx context.Context, dirPath string, config *Config) (*Store, er
}
}
// Prune attesting records older than the current weak subjectivity period.
if err := kv.PruneAttestations(ctx); err != nil {
return nil, errors.Wrap(err, "could not prune old attestations from DB")
if featureconfig.Get().EnableSlashingProtectionPruning {
// Prune attesting records older than the current weak subjectivity period.
if err := kv.PruneAttestations(ctx); err != nil {
return nil, errors.Wrap(err, "could not prune old attestations from DB")
}
}
// Batch save attestation records for slashing protection at timed