Skip to content

Commit 11ea6dd

Browse files
committed
cmd: disable preimage in pbss archive
Signed-off-by: jsvisa <[email protected]>
1 parent 6af5201 commit 11ea6dd

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

cmd/utils/flags.go

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,15 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
16321632
if ctx.IsSet(CacheNoPrefetchFlag.Name) {
16331633
cfg.NoPrefetch = ctx.Bool(CacheNoPrefetchFlag.Name)
16341634
}
1635+
if ctx.IsSet(DataDirFlag.Name) {
1636+
chaindb := tryMakeReadOnlyDatabase(ctx, stack)
1637+
scheme, err := rawdb.ParseStateScheme(ctx.String(StateSchemeFlag.Name), chaindb)
1638+
if err != nil {
1639+
Fatalf("%v", err)
1640+
}
1641+
cfg.StateScheme = scheme
1642+
chaindb.Close()
1643+
}
16351644
// Read the value from the flag no matter if it's set or not.
16361645
cfg.Preimages = ctx.Bool(CachePreimagesFlag.Name)
16371646
if cfg.NoPruning && !cfg.Preimages {
@@ -1641,9 +1650,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
16411650
if ctx.IsSet(StateHistoryFlag.Name) {
16421651
cfg.StateHistory = ctx.Uint64(StateHistoryFlag.Name)
16431652
}
1644-
if ctx.IsSet(StateSchemeFlag.Name) {
1645-
cfg.StateScheme = ctx.String(StateSchemeFlag.Name)
1646-
}
16471653
// Parse transaction history flag, if user is still using legacy config
16481654
// file with 'TxLookupLimit' configured, copy the value to 'TransactionHistory'.
16491655
if cfg.TransactionHistory == ethconfig.Defaults.TransactionHistory && cfg.TxLookupLimit != ethconfig.Defaults.TxLookupLimit {
@@ -1657,17 +1663,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
16571663
cfg.TransactionHistory = ctx.Uint64(TxLookupLimitFlag.Name)
16581664
}
16591665

1660-
if ctx.String(GCModeFlag.Name) == "archive" && cfg.TransactionHistory != 0 && ctx.IsSet(DataDirFlag.Name) {
1661-
chaindb := tryMakeReadOnlyDatabase(ctx, stack)
1662-
scheme, err := rawdb.ParseStateScheme(cfg.StateScheme, chaindb)
1663-
if err != nil {
1664-
Fatalf("%v", err)
1665-
}
1666-
if scheme == rawdb.HashScheme {
1667-
cfg.TransactionHistory = 0
1668-
log.Warn("Disabled transaction unindexing for archive node with hash state scheme")
1669-
}
1670-
chaindb.Close()
1666+
if ctx.String(GCModeFlag.Name) == "archive" && cfg.TransactionHistory != 0 && cfg.StateScheme == rawdb.HashScheme {
1667+
cfg.TransactionHistory = 0
1668+
log.Warn("Disabled transaction unindexing for archive node with hash state scheme")
16711669
}
16721670
if ctx.IsSet(LogHistoryFlag.Name) {
16731671
cfg.LogHistory = ctx.Uint64(LogHistoryFlag.Name)
@@ -2206,9 +2204,9 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
22062204
// Disable transaction indexing/unindexing.
22072205
TxLookupLimit: -1,
22082206
}
2209-
if options.ArchiveMode && !options.Preimages {
2207+
if options.ArchiveMode && !options.Preimages && scheme == rawdb.HashScheme {
22102208
options.Preimages = true
2211-
log.Info("Enabling recording of key preimages since archive mode is used")
2209+
log.Info("Enabling recording of key preimages since archive mode is used in hash state scheme")
22122210
}
22132211
if !ctx.Bool(SnapshotFlag.Name) {
22142212
options.SnapshotLimit = 0 // Disabled

0 commit comments

Comments
 (0)