From 923c192c7d5c9705a27a19ba51b22635fcc5e6ef Mon Sep 17 00:00:00 2001 From: Pratik Patil Date: Mon, 20 Nov 2023 10:18:11 +0530 Subject: [PATCH] Added cache.blocklogs (FilterLogCacheSize) flag (#1083) * added cache.blocklogs (FilterLogCacheSize) flag * updated docs * minor fix Co-authored-by: Mael Regnery --------- Co-authored-by: Mael Regnery --- builder/files/config.toml | 1 + docs/cli/example_config.toml | 1 + docs/cli/server.md | 10 +++---- internal/cli/server/config.go | 28 +++++++++++-------- internal/cli/server/flags.go | 7 +++++ .../templates/mainnet-v1/archive/config.toml | 1 + .../mainnet-v1/sentry/sentry/bor/config.toml | 1 + .../sentry/validator/bor/config.toml | 1 + .../mainnet-v1/without-sentry/bor/config.toml | 1 + .../templates/testnet-v4/archive/config.toml | 1 + .../testnet-v4/sentry/sentry/bor/config.toml | 1 + .../sentry/validator/bor/config.toml | 1 + .../testnet-v4/without-sentry/bor/config.toml | 1 + 13 files changed, 39 insertions(+), 16 deletions(-) diff --git a/builder/files/config.toml b/builder/files/config.toml index 8d2279b330..824efeeced 100644 --- a/builder/files/config.toml +++ b/builder/files/config.toml @@ -155,6 +155,7 @@ syncmode = "full" # preimages = false # txlookuplimit = 2350000 # triesinmemory = 128 + # blocklogs = 32 # timeout = "1h0m0s" # fdlimit = 0 diff --git a/docs/cli/example_config.toml b/docs/cli/example_config.toml index fb9def8e1f..55d0be7ea4 100644 --- a/docs/cli/example_config.toml +++ b/docs/cli/example_config.toml @@ -160,6 +160,7 @@ devfakeauthor = false # Run miner without validator set authorization preimages = false # Enable recording the SHA3/keccak preimages of trie keys txlookuplimit = 2350000 # Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain) triesinmemory = 128 # Number of block states (tries) to keep in memory + blocklogs = 32 # Size (in number of blocks) of the log cache for filtering timeout = "1h0m0s" # Time after which the Merkle Patricia Trie is stored to disc from memory fdlimit = 0 # Raise the open file descriptor resource limit (default = system fd limit) diff --git a/docs/cli/server.md b/docs/cli/server.md index ecfd4ee19b..6c6a1de4d9 100644 --- a/docs/cli/server.md +++ b/docs/cli/server.md @@ -104,6 +104,8 @@ The ```bor server``` command runs the Bor client. - ```cache```: Megabytes of memory allocated to internal caching (default: 1024) +- ```cache.blocklogs```: Size (in number of blocks) of the log cache for filtering (default: 32) + - ```cache.database```: Percentage of cache memory allowance to use for database io (default: 50) - ```cache.gc```: Percentage of cache memory allowance to use for trie pruning (default: 25) @@ -116,10 +118,6 @@ The ```bor server``` command runs the Bor client. - ```cache.trie```: Percentage of cache memory allowance to use for trie caching (default: 15) -- ```cache.trie.journal```: Disk journal directory for trie cache to survive node restarts (default: triecache) - -- ```cache.trie.rejournal```: Time interval to regenerate the trie cache journal (default: 1h0m0s) - - ```cache.triesinmemory```: Number of block states (tries) to keep in memory (default: 128) - ```fdlimit```: Raise the open file descriptor resource limit (default = system fd limit) (default: 0) @@ -182,7 +180,7 @@ The ```bor server``` command runs the Bor client. - ```rpc.gascap```: Sets a cap on gas that can be used in eth_call/estimateGas (0=infinite) (default: 50000000) -- ```rpc.txfeecap```: Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap) (default: 5) +- ```rpc.txfeecap```: Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap) (default: 1) - ```ws```: Enable the WS-RPC server (default: false) @@ -234,6 +232,8 @@ The ```bor server``` command runs the Bor client. - ```txarrivalwait```: Maximum duration to wait for a transaction before explicitly requesting it (default: 500ms) +- ```v4disc```: Enables the V4 discovery mechanism (default: true) + - ```v5disc```: Enables the experimental RLPx V5 (Topic Discovery) mechanism (default: false) ### Sealer Options diff --git a/internal/cli/server/config.go b/internal/cli/server/config.go index 4a46ba0d1e..fd32a945af 100644 --- a/internal/cli/server/config.go +++ b/internal/cli/server/config.go @@ -540,6 +540,10 @@ type CacheConfig struct { // Number of block states to keep in memory (default = 128) TriesInMemory uint64 `hcl:"triesinmemory,optional" toml:"triesinmemory,optional"` + + // This is the number of blocks for which logs will be cached in the filter system. + FilterLogCacheSize int `hcl:"blocklogs,optional" toml:"blocklogs,optional"` + // Time after which the Merkle Patricia Trie is stored to disc from memory TrieTimeout time.Duration `hcl:"-,optional" toml:"-"` TrieTimeoutRaw string `hcl:"timeout,optional" toml:"timeout,optional"` @@ -734,17 +738,18 @@ func DefaultConfig() *Config { }, }, Cache: &CacheConfig{ - Cache: 1024, // geth's default (suitable for mumbai) - PercDatabase: 50, - PercTrie: 15, - PercGc: 25, - PercSnapshot: 10, - NoPrefetch: false, - Preimages: false, - TxLookupLimit: 2350000, - TriesInMemory: 128, - TrieTimeout: 60 * time.Minute, - FDLimit: 0, + Cache: 1024, // geth's default (suitable for mumbai) + PercDatabase: 50, + PercTrie: 15, + PercGc: 25, + PercSnapshot: 10, + NoPrefetch: false, + Preimages: false, + TxLookupLimit: 2350000, + TriesInMemory: 128, + FilterLogCacheSize: ethconfig.Defaults.FilterLogCacheSize, + TrieTimeout: 60 * time.Minute, + FDLimit: 0, }, ExtraDB: &ExtraDBConfig{ // These are LevelDB defaults, specifying here for clarity in code and in logging. @@ -1108,6 +1113,7 @@ func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (* n.TxLookupLimit = c.Cache.TxLookupLimit n.TrieTimeout = c.Cache.TrieTimeout n.TriesInMemory = c.Cache.TriesInMemory + n.FilterLogCacheSize = c.Cache.FilterLogCacheSize } // LevelDB diff --git a/internal/cli/server/flags.go b/internal/cli/server/flags.go index c1f4d3e069..a49503b36c 100644 --- a/internal/cli/server/flags.go +++ b/internal/cli/server/flags.go @@ -424,6 +424,13 @@ func (c *Command) Flags(config *Config) *flagset.Flagset { Default: c.cliConfig.Cache.TriesInMemory, Group: "Cache", }) + f.IntFlag(&flagset.IntFlag{ + Name: "cache.blocklogs", + Usage: "Size (in number of blocks) of the log cache for filtering", + Value: &c.cliConfig.Cache.FilterLogCacheSize, + Default: c.cliConfig.Cache.FilterLogCacheSize, + Group: "Cache", + }) f.Uint64Flag(&flagset.Uint64Flag{ Name: "txlookuplimit", Usage: "Number of recent blocks to maintain transactions index for", diff --git a/packaging/templates/mainnet-v1/archive/config.toml b/packaging/templates/mainnet-v1/archive/config.toml index bdbe8edc8f..9c4be3a3ca 100644 --- a/packaging/templates/mainnet-v1/archive/config.toml +++ b/packaging/templates/mainnet-v1/archive/config.toml @@ -148,6 +148,7 @@ gcmode = "archive" # noprefetch = false # preimages = false # txlookuplimit = 2350000 + # blocklogs = 32 # timeout = "1h0m0s" # fdlimit = 0 diff --git a/packaging/templates/mainnet-v1/sentry/sentry/bor/config.toml b/packaging/templates/mainnet-v1/sentry/sentry/bor/config.toml index af9cb26113..cbe34de1f8 100644 --- a/packaging/templates/mainnet-v1/sentry/sentry/bor/config.toml +++ b/packaging/templates/mainnet-v1/sentry/sentry/bor/config.toml @@ -148,6 +148,7 @@ syncmode = "full" # noprefetch = false # preimages = false # txlookuplimit = 2350000 + # blocklogs = 32 # timeout = "1h0m0s" # fdlimit = 0 diff --git a/packaging/templates/mainnet-v1/sentry/validator/bor/config.toml b/packaging/templates/mainnet-v1/sentry/validator/bor/config.toml index e01d1fb331..710599ceda 100644 --- a/packaging/templates/mainnet-v1/sentry/validator/bor/config.toml +++ b/packaging/templates/mainnet-v1/sentry/validator/bor/config.toml @@ -150,6 +150,7 @@ syncmode = "full" # noprefetch = false # preimages = false # txlookuplimit = 2350000 + # blocklogs = 32 # timeout = "1h0m0s" # fdlimit = 0 diff --git a/packaging/templates/mainnet-v1/without-sentry/bor/config.toml b/packaging/templates/mainnet-v1/without-sentry/bor/config.toml index 87dfaf54f2..09d40ededc 100644 --- a/packaging/templates/mainnet-v1/without-sentry/bor/config.toml +++ b/packaging/templates/mainnet-v1/without-sentry/bor/config.toml @@ -150,6 +150,7 @@ syncmode = "full" # noprefetch = false # preimages = false # txlookuplimit = 2350000 +# blocklogs = 32 # timeout = "1h0m0s" # fdlimit = 0 diff --git a/packaging/templates/testnet-v4/archive/config.toml b/packaging/templates/testnet-v4/archive/config.toml index b581a687e2..9de6b3afa8 100644 --- a/packaging/templates/testnet-v4/archive/config.toml +++ b/packaging/templates/testnet-v4/archive/config.toml @@ -148,6 +148,7 @@ gcmode = "archive" # noprefetch = false # preimages = false # txlookuplimit = 2350000 + # blocklogs = 32 # timeout = "1h0m0s" # fdlimit = 0 diff --git a/packaging/templates/testnet-v4/sentry/sentry/bor/config.toml b/packaging/templates/testnet-v4/sentry/sentry/bor/config.toml index 0778310d8e..0942fcf6ca 100644 --- a/packaging/templates/testnet-v4/sentry/sentry/bor/config.toml +++ b/packaging/templates/testnet-v4/sentry/sentry/bor/config.toml @@ -148,6 +148,7 @@ syncmode = "full" # noprefetch = false # preimages = false # txlookuplimit = 2350000 + # blocklogs = 32 # timeout = "1h0m0s" # fdlimit = 0 diff --git a/packaging/templates/testnet-v4/sentry/validator/bor/config.toml b/packaging/templates/testnet-v4/sentry/validator/bor/config.toml index 9c0133d7a5..235a3749fe 100644 --- a/packaging/templates/testnet-v4/sentry/validator/bor/config.toml +++ b/packaging/templates/testnet-v4/sentry/validator/bor/config.toml @@ -150,6 +150,7 @@ syncmode = "full" # noprefetch = false # preimages = false # txlookuplimit = 2350000 + # blocklogs = 32 # timeout = "1h0m0s" # fdlimit = 0 diff --git a/packaging/templates/testnet-v4/without-sentry/bor/config.toml b/packaging/templates/testnet-v4/without-sentry/bor/config.toml index 6bcb8c59fc..ae2f94093f 100644 --- a/packaging/templates/testnet-v4/without-sentry/bor/config.toml +++ b/packaging/templates/testnet-v4/without-sentry/bor/config.toml @@ -150,6 +150,7 @@ syncmode = "full" # noprefetch = false # preimages = false # txlookuplimit = 2350000 +# blocklogs = 32 # timeout = "1h0m0s" # fdlimit = 0