github.com/unicornultrafoundation/go-u2u@v1.0.0-rc1.0.20240205080301-e74a83d3fadc/gossip/evmstore/config.go (about) 1 package evmstore 2 3 import ( 4 "github.com/syndtr/goleveldb/leveldb/opt" 5 "github.com/unicornultrafoundation/go-helios/utils/cachescale" 6 ) 7 8 type ( 9 // StoreCacheConfig is a config for the db. 10 StoreCacheConfig struct { 11 // Cache size for Receipts (size in bytes). 12 ReceiptsSize uint 13 // Cache size for Receipts (number of blocks). 14 ReceiptsBlocks int 15 // Cache size for TxPositions. 16 TxPositions int 17 // Cache size for EVM database. 18 EvmDatabase int 19 // Cache size for EVM snapshot. 20 EvmSnap int 21 // Cache size for EvmBlock (number of blocks). 22 EvmBlocksNum int 23 // Cache size for EvmBlock (size in bytes). 24 EvmBlocksSize uint 25 // Disk journal for saving clean cache entries. 26 TrieCleanJournal string 27 // Whether to disable trie write caching and GC altogether (archive node) 28 TrieDirtyDisabled bool 29 // Memory limit (MB) at which to start flushing dirty trie nodes to disk 30 TrieDirtyLimit uint 31 // Whether to enable greedy gc mode 32 GreedyGC bool 33 } 34 // StoreConfig is a config for store db. 35 StoreConfig struct { 36 Cache StoreCacheConfig 37 // Enables tracking of SHA3 preimages in the VM 38 EnablePreimageRecording bool 39 } 40 ) 41 42 // DefaultStoreConfig for product. 43 func DefaultStoreConfig(scale cachescale.Func) StoreConfig { 44 return StoreConfig{ 45 Cache: StoreCacheConfig{ 46 ReceiptsSize: scale.U(4 * opt.MiB), 47 ReceiptsBlocks: scale.I(4000), 48 TxPositions: scale.I(20000), 49 EvmDatabase: scale.I(32 * opt.MiB), 50 EvmSnap: scale.I(32 * opt.MiB), 51 EvmBlocksNum: scale.I(5000), 52 EvmBlocksSize: scale.U(6 * opt.MiB), 53 TrieDirtyDisabled: true, 54 GreedyGC: false, 55 TrieDirtyLimit: scale.U(256 * opt.MiB), 56 }, 57 EnablePreimageRecording: true, 58 } 59 } 60 61 // LiteStoreConfig is for tests or inmemory. 62 func LiteStoreConfig() StoreConfig { 63 return DefaultStoreConfig(cachescale.Ratio{Base: 10, Target: 1}) 64 }