From 14cd25f9dc5d51e688770bc3eaec943c4ee3125e Mon Sep 17 00:00:00 2001 From: Shay Zluf Date: Tue, 18 Aug 2020 14:18:33 +0300 Subject: [PATCH] Slasher span cache size flag (#7043) * Span cache size by using flag * Merge refs/heads/master into set_span_cache_size --- slasher/flags/flags.go | 6 ++++++ slasher/main.go | 1 + slasher/node/node.go | 4 +++- slasher/usage.go | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/slasher/flags/flags.go b/slasher/flags/flags.go index ef7a34fe708c..b188ce04d1bc 100644 --- a/slasher/flags/flags.go +++ b/slasher/flags/flags.go @@ -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, + } ) diff --git a/slasher/main.go b/slasher/main.go index 21df6538cc2c..5de54f53ab02 100644 --- a/slasher/main.go +++ b/slasher/main.go @@ -69,6 +69,7 @@ var appFlags = []cli.Flag{ flags.BeaconCertFlag, flags.BeaconRPCProviderFlag, flags.EnableHistoricalDetectionFlag, + flags.SpanCacheSize, } func init() { diff --git a/slasher/node/node.go b/slasher/node/node.go index 1538055cf241..29fffdb6b43a 100644 --- a/slasher/node/node.go +++ b/slasher/node/node.go @@ -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 diff --git a/slasher/usage.go b/slasher/usage.go index 61fd21436ce1..f441dff59ff8 100644 --- a/slasher/usage.go +++ b/slasher/usage.go @@ -83,6 +83,7 @@ var appHelpFlagGroups = []flagGroup{ flags.RPCHost, flags.BeaconRPCProviderFlag, flags.EnableHistoricalDetectionFlag, + flags.SpanCacheSize, }, }, {