From 3cc8e23b6a19b3087fd7dd9f82fcee8dac37be77 Mon Sep 17 00:00:00 2001 From: jsvisa Date: Wed, 25 Jun 2025 15:03:49 +0800 Subject: [PATCH] set triedb.journal as a switch Signed-off-by: jsvisa --- cmd/utils/flags.go | 20 ++++++++------------ eth/backend.go | 4 ++-- eth/ethconfig/config.go | 3 +-- eth/ethconfig/gen_config.go | 4 ++-- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 8508a3237b..6f0170babc 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -448,10 +448,10 @@ var ( } // Trie database settings - TrieDBJournalFlag = &cli.StringFlag{ + TrieDBJournalFlag = &cli.BoolFlag{ Name: "triedb.journal", - Usage: "Path to the journal used for persisting trie data across node restarts", - Value: ethconfig.Defaults.TrieDBJournal, + Usage: "Enable persisting the trie database journal to disk (only used with pbss state scheme, default path: /triedb.journal.rlp)", + Value: true, Category: flags.TrieDatabaseCategory, } @@ -1654,6 +1654,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { if ctx.IsSet(StateSchemeFlag.Name) { cfg.StateScheme = ctx.String(StateSchemeFlag.Name) } + if !ctx.Bool(TrieDBJournalFlag.Name) { + cfg.TrieDBJournal = false + } // Parse transaction history flag, if user is still using legacy config // file with 'TxLookupLimit' configured, copy the value to 'TransactionHistory'. if cfg.TransactionHistory == ethconfig.Defaults.TransactionHistory && cfg.TxLookupLimit != ethconfig.Defaults.TxLookupLimit { @@ -1690,9 +1693,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { if ctx.IsSet(CacheFlag.Name) || ctx.IsSet(CacheSnapshotFlag.Name) { cfg.SnapshotCache = ctx.Int(CacheFlag.Name) * ctx.Int(CacheSnapshotFlag.Name) / 100 } - if ctx.IsSet(TrieDBJournalFlag.Name) { - cfg.TrieDBJournal = ctx.String(TrieDBJournalFlag.Name) - } if ctx.IsSet(CacheLogSizeFlag.Name) { cfg.FilterLogCacheSize = ctx.Int(CacheLogSizeFlag.Name) } @@ -2216,12 +2216,8 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh options.Preimages = true log.Info("Enabling recording of key preimages since archive mode is used") } - journal := ethconfig.Defaults.TrieDBJournal - if ctx.IsSet(TrieDBJournalFlag.Name) { - journal = ctx.String(TrieDBJournalFlag.Name) - } - if journal != "" { - options.TrieDBJournal = stack.ResolvePath(journal) + if !ctx.Bool(TrieDBJournalFlag.Name) { + options.TrieDBJournal = stack.ResolvePath("triedb.journal.rlp") } if !ctx.Bool(SnapshotFlag.Name) { options.SnapshotLimit = 0 // Disabled diff --git a/eth/backend.go b/eth/backend.go index d6441c8bff..ad72efb5e5 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -238,8 +238,8 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { }, } ) - if config.TrieDBJournal != "" { - options.TrieDBJournal = stack.ResolvePath(config.TrieDBJournal) + if config.TrieDBJournal { + options.TrieDBJournal = stack.ResolvePath("triedb.journal.rlp") } else { log.Warn("Trie database journal is persisted within the database") } diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 950206c657..4b3319202a 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -60,7 +60,6 @@ var Defaults = Config{ TrieCleanCache: 154, TrieDirtyCache: 256, TrieTimeout: 60 * time.Minute, - TrieDBJournal: "triedb.journal.rlp", SnapshotCache: 102, FilterLogCacheSize: 32, Miner: miner.DefaultConfig, @@ -125,7 +124,7 @@ type Config struct { SnapshotCache int Preimages bool StateHistory uint64 `toml:",omitempty"` // The maximum number of blocks from head whose state histories are reserved. - TrieDBJournal string // Path to the journal used for persisting trie data across node restarts + TrieDBJournal bool // Enable persisting the trie database journal to disk. // State scheme represents the scheme used to store ethereum states and trie // nodes on top. It can be 'hash', 'path', or none which means use the scheme diff --git a/eth/ethconfig/gen_config.go b/eth/ethconfig/gen_config.go index 883dc1b490..e530b6fc6a 100644 --- a/eth/ethconfig/gen_config.go +++ b/eth/ethconfig/gen_config.go @@ -42,7 +42,7 @@ func (c Config) MarshalTOML() (interface{}, error) { SnapshotCache int Preimages bool StateHistory uint64 `toml:",omitempty"` - TrieDBJournal string + TrieDBJournal bool StateScheme string `toml:",omitempty"` FilterLogCacheSize int Miner miner.Config @@ -130,7 +130,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { SnapshotCache *int Preimages *bool StateHistory *uint64 `toml:",omitempty"` - TrieDBJournal *string + TrieDBJournal *bool StateScheme *string `toml:",omitempty"` FilterLogCacheSize *int Miner *miner.Config