set triedb.journal as a switch

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2025-06-25 15:03:49 +08:00 committed by Gary Rong
parent fef157dde2
commit 3cc8e23b6a
4 changed files with 13 additions and 18 deletions

View file

@ -448,10 +448,10 @@ var (
} }
// Trie database settings // Trie database settings
TrieDBJournalFlag = &cli.StringFlag{ TrieDBJournalFlag = &cli.BoolFlag{
Name: "triedb.journal", Name: "triedb.journal",
Usage: "Path to the journal used for persisting trie data across node restarts", Usage: "Enable persisting the trie database journal to disk (only used with pbss state scheme, default path: <datadir>/triedb.journal.rlp)",
Value: ethconfig.Defaults.TrieDBJournal, Value: true,
Category: flags.TrieDatabaseCategory, Category: flags.TrieDatabaseCategory,
} }
@ -1654,6 +1654,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
if ctx.IsSet(StateSchemeFlag.Name) { if ctx.IsSet(StateSchemeFlag.Name) {
cfg.StateScheme = ctx.String(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 // Parse transaction history flag, if user is still using legacy config
// file with 'TxLookupLimit' configured, copy the value to 'TransactionHistory'. // file with 'TxLookupLimit' configured, copy the value to 'TransactionHistory'.
if cfg.TransactionHistory == ethconfig.Defaults.TransactionHistory && cfg.TxLookupLimit != ethconfig.Defaults.TxLookupLimit { 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) { if ctx.IsSet(CacheFlag.Name) || ctx.IsSet(CacheSnapshotFlag.Name) {
cfg.SnapshotCache = ctx.Int(CacheFlag.Name) * ctx.Int(CacheSnapshotFlag.Name) / 100 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) { if ctx.IsSet(CacheLogSizeFlag.Name) {
cfg.FilterLogCacheSize = ctx.Int(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 options.Preimages = true
log.Info("Enabling recording of key preimages since archive mode is used") log.Info("Enabling recording of key preimages since archive mode is used")
} }
journal := ethconfig.Defaults.TrieDBJournal if !ctx.Bool(TrieDBJournalFlag.Name) {
if ctx.IsSet(TrieDBJournalFlag.Name) { options.TrieDBJournal = stack.ResolvePath("triedb.journal.rlp")
journal = ctx.String(TrieDBJournalFlag.Name)
}
if journal != "" {
options.TrieDBJournal = stack.ResolvePath(journal)
} }
if !ctx.Bool(SnapshotFlag.Name) { if !ctx.Bool(SnapshotFlag.Name) {
options.SnapshotLimit = 0 // Disabled options.SnapshotLimit = 0 // Disabled

View file

@ -238,8 +238,8 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
}, },
} }
) )
if config.TrieDBJournal != "" { if config.TrieDBJournal {
options.TrieDBJournal = stack.ResolvePath(config.TrieDBJournal) options.TrieDBJournal = stack.ResolvePath("triedb.journal.rlp")
} else { } else {
log.Warn("Trie database journal is persisted within the database") log.Warn("Trie database journal is persisted within the database")
} }

View file

@ -60,7 +60,6 @@ var Defaults = Config{
TrieCleanCache: 154, TrieCleanCache: 154,
TrieDirtyCache: 256, TrieDirtyCache: 256,
TrieTimeout: 60 * time.Minute, TrieTimeout: 60 * time.Minute,
TrieDBJournal: "triedb.journal.rlp",
SnapshotCache: 102, SnapshotCache: 102,
FilterLogCacheSize: 32, FilterLogCacheSize: 32,
Miner: miner.DefaultConfig, Miner: miner.DefaultConfig,
@ -125,7 +124,7 @@ type Config struct {
SnapshotCache int SnapshotCache int
Preimages bool Preimages bool
StateHistory uint64 `toml:",omitempty"` // The maximum number of blocks from head whose state histories are reserved. 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 // 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 // nodes on top. It can be 'hash', 'path', or none which means use the scheme

View file

@ -42,7 +42,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
SnapshotCache int SnapshotCache int
Preimages bool Preimages bool
StateHistory uint64 `toml:",omitempty"` StateHistory uint64 `toml:",omitempty"`
TrieDBJournal string TrieDBJournal bool
StateScheme string `toml:",omitempty"` StateScheme string `toml:",omitempty"`
FilterLogCacheSize int FilterLogCacheSize int
Miner miner.Config Miner miner.Config
@ -130,7 +130,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
SnapshotCache *int SnapshotCache *int
Preimages *bool Preimages *bool
StateHistory *uint64 `toml:",omitempty"` StateHistory *uint64 `toml:",omitempty"`
TrieDBJournal *string TrieDBJournal *bool
StateScheme *string `toml:",omitempty"` StateScheme *string `toml:",omitempty"`
FilterLogCacheSize *int FilterLogCacheSize *int
Miner *miner.Config Miner *miner.Config