Skip to content

Commit

Permalink
Slasher span cache size flag (prysmaticlabs#7043)
Browse files Browse the repository at this point in the history
* Span cache size by using flag
* Merge refs/heads/master into set_span_cache_size
  • Loading branch information
shayzluf authored Aug 18, 2020
1 parent d81c9ff commit 14cd25f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions slasher/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,10 @@ var (
Name: "enable-historical-detection",
Usage: "Enables historical attestation detection for the slasher. Requires --historical-slasher-node on the beacon node.",
}
// SpanCacheSize is a flag that sets the size of span cache.
SpanCacheSize = &cli.IntFlag{
Name: "spans-cache-size",
Usage: "Sets the span cache size.",
Value: 256,
}
)
1 change: 1 addition & 0 deletions slasher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ var appFlags = []cli.Flag{
flags.BeaconCertFlag,
flags.BeaconRPCProviderFlag,
flags.EnableHistoricalDetectionFlag,
flags.SpanCacheSize,
}

func init() {
Expand Down
4 changes: 3 additions & 1 deletion slasher/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ func (s *SlasherNode) startDB() error {
clearDB := s.cliCtx.Bool(cmd.ClearDB.Name)
forceClearDB := s.cliCtx.Bool(cmd.ForceClearDB.Name)
dbPath := path.Join(baseDir, slasherDBName)
cfg := &kv.Config{}
spanCacheSize := s.cliCtx.Int(flags.SpanCacheSize.Name)
cfg := &kv.Config{SpanCacheSize: spanCacheSize}
log.Infof("Span cache size has been set to: %d", spanCacheSize)
d, err := db.NewDB(dbPath, cfg)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions slasher/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ var appHelpFlagGroups = []flagGroup{
flags.RPCHost,
flags.BeaconRPCProviderFlag,
flags.EnableHistoricalDetectionFlag,
flags.SpanCacheSize,
},
},
{
Expand Down

0 comments on commit 14cd25f

Please sign in to comment.