@@ -23,6 +23,7 @@ import (
23
23
"io"
24
24
"math"
25
25
"math/big"
26
+ "math/rand/v2"
26
27
"runtime"
27
28
"slices"
28
29
"strings"
@@ -160,8 +161,9 @@ type CacheConfig struct {
160
161
SnapshotRestoreMaxGas uint64 // Rollback up to this much gas to restore snapshot (otherwise snapshot recalculated from nothing)
161
162
162
163
// Arbitrum: configure GC window
163
- TriesInMemory uint64 // Height difference before which a trie may not be garbage-collected
164
- TrieRetention time.Duration // Time limit before which a trie may not be garbage-collected
164
+ TriesInMemory uint64 // Height difference before which a trie may not be garbage-collected
165
+ TrieRetention time.Duration // Time limit before which a trie may not be garbage-collected
166
+ TrieTimeLimitRandomOffset time.Duration // Range of random offset of the commit due to TrieTimeLimit period (randomizes initial gcproc value)
165
167
166
168
MaxNumberOfBlocksToSkipStateSaving uint32
167
169
MaxAmountOfGasToSkipStateSaving uint64
@@ -203,6 +205,7 @@ var defaultCacheConfig = &CacheConfig{
203
205
// Arbitrum Config Options
204
206
TriesInMemory : state .DefaultTriesInMemory ,
205
207
TrieRetention : 30 * time .Minute ,
208
+ TrieTimeLimitRandomOffset : 0 ,
206
209
MaxNumberOfBlocksToSkipStateSaving : 0 ,
207
210
MaxAmountOfGasToSkipStateSaving : 0 ,
208
211
@@ -376,6 +379,10 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
376
379
bc .prefetcher = newStatePrefetcher (chainConfig , bc .hc )
377
380
bc .processor = NewStateProcessor (chainConfig , bc .hc )
378
381
382
+ if cacheConfig .TrieTimeLimitRandomOffset > 0 {
383
+ bc .gcproc = time .Duration (rand .Int64N (int64 (cacheConfig .TrieTimeLimitRandomOffset )))
384
+ }
385
+
379
386
bc .genesisBlock = bc .GetBlockByNumber (0 )
380
387
if bc .genesisBlock == nil {
381
388
return nil , ErrNoGenesis
0 commit comments