From c2147ee154b4d638c3b241fce0b1e185b72c0c2b Mon Sep 17 00:00:00 2001 From: ploui <64719999+ploui@users.noreply.github.com> Date: Wed, 6 May 2020 06:01:01 -0400 Subject: [PATCH] eth: don't inadvertently enable snapshots in archive nodes (#21025) * eth: don't reassign more cache than is being made available * eth: don't inadvertently enable snapshot in a case where --snapshot wasn't given --- eth/backend.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/eth/backend.go b/eth/backend.go index c669fa974..3418a587a 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -125,8 +125,12 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { config.Miner.GasPrice = new(big.Int).Set(DefaultConfig.Miner.GasPrice) } if config.NoPruning && config.TrieDirtyCache > 0 { - config.TrieCleanCache += config.TrieDirtyCache * 3 / 5 - config.SnapshotCache += config.TrieDirtyCache * 3 / 5 + if config.SnapshotCache > 0 { + config.TrieCleanCache += config.TrieDirtyCache * 3 / 5 + config.SnapshotCache += config.TrieDirtyCache * 2 / 5 + } else { + config.TrieCleanCache += config.TrieDirtyCache + } config.TrieDirtyCache = 0 } log.Info("Allocated trie memory caches", "clean", common.StorageSize(config.TrieCleanCache)*1024*1024, "dirty", common.StorageSize(config.TrieDirtyCache)*1024*1024)