diff --git a/eth/backend.go b/eth/backend.go index bd2b3cb23c..70630c6788 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -269,6 +269,11 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { rawdb.WriteDatabaseVersion(chainDb, core.BlockChainVersion) } } + trieJournalDirectory := config.TrieJournalDirectory + if trieJournalDirectory == "" { + trieJournalDirectory = stack.ResolvePath("triedb") + } + var ( options = &core.BlockChainConfig{ TrieCleanLimit: config.TrieCleanCache, @@ -296,7 +301,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { // within the data directory. The corresponding paths will be either: // - DATADIR/triedb/merkle.journal // - DATADIR/triedb/verkle.journal - TrieJournalDirectory: stack.ResolvePath("triedb"), + TrieJournalDirectory: trieJournalDirectory, StateSizeTracking: config.EnableStateSizeTracking, } ) diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index a1d42d7b57..7adb240fcd 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -170,6 +170,8 @@ type Config struct { SnapshotCache int Preimages bool TriesInMemory uint64 + // Directory path to the journal used for persisting trie data across node restarts. + TrieJournalDirectory string // This is the number of blocks for which logs will be cached in the filter system. FilterLogCacheSize int diff --git a/eth/ethconfig/gen_config.go b/eth/ethconfig/gen_config.go index 02e88bd09f..aa318fb2f6 100644 --- a/eth/ethconfig/gen_config.go +++ b/eth/ethconfig/gen_config.go @@ -51,6 +51,7 @@ func (c Config) MarshalTOML() (interface{}, error) { SnapshotCache int Preimages bool TriesInMemory uint64 + TrieJournalDirectory string FilterLogCacheSize int LogQueryLimit int AddressCacheSizes map[common.Address]int @@ -138,6 +139,7 @@ func (c Config) MarshalTOML() (interface{}, error) { enc.SnapshotCache = c.SnapshotCache enc.Preimages = c.Preimages enc.TriesInMemory = c.TriesInMemory + enc.TrieJournalDirectory = c.TrieJournalDirectory enc.FilterLogCacheSize = c.FilterLogCacheSize enc.LogQueryLimit = c.LogQueryLimit enc.AddressCacheSizes = c.AddressCacheSizes @@ -229,6 +231,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { SnapshotCache *int Preimages *bool TriesInMemory *uint64 + TrieJournalDirectory *string FilterLogCacheSize *int LogQueryLimit *int AddressCacheSizes map[common.Address]int @@ -381,6 +384,9 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { if dec.TriesInMemory != nil { c.TriesInMemory = *dec.TriesInMemory } + if dec.TrieJournalDirectory != nil { + c.TrieJournalDirectory = *dec.TrieJournalDirectory + } if dec.FilterLogCacheSize != nil { c.FilterLogCacheSize = *dec.FilterLogCacheSize } diff --git a/internal/cli/server/config.go b/internal/cli/server/config.go index 16a0a791f3..62cefc7617 100644 --- a/internal/cli/server/config.go +++ b/internal/cli/server/config.go @@ -1558,6 +1558,11 @@ func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (* n.TransactionHistory = c.Cache.TxLookupLimit n.TrieTimeout = c.Cache.TrieTimeout n.TriesInMemory = c.Cache.TriesInMemory + trieJournalDirectory := c.Cache.TrieJournalDirectory + if trieJournalDirectory == "" { + trieJournalDirectory = "triedb" + } + n.TrieJournalDirectory = stack.ResolvePath(trieJournalDirectory) n.FilterLogCacheSize = c.Cache.FilterLogCacheSize // Parse address-specific cache sizes