Skip to content

Commit

Permalink
fix snap flag behavior (erigontech#6743)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored Jan 30, 2023
1 parent f13016c commit 62746c6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cmd/erigon-el/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func NewBackend(stack *node.Node, config *ethconfig.Config, logger log.Logger) (
}); err != nil {
panic(err)
}
config.Snapshot.Enabled = ethconfig.UseSnapshotsByChainName(chainConfig.ChainName) && config.Sync.UseSnapshots
config.Snapshot.Enabled = config.Sync.UseSnapshots

log.Info("Initialised chain configuration", "config", chainConfig, "genesis", genesis.Hash())

Expand Down Expand Up @@ -235,7 +235,7 @@ func NewBackend(stack *node.Node, config *ethconfig.Config, logger log.Logger) (
if !isCorrectSync {
log.Warn("Incorrect snapshot enablement", "got", config.Sync.UseSnapshots, "change_to", useSnapshots)
config.Sync.UseSnapshots = useSnapshots
config.Snapshot.Enabled = ethconfig.UseSnapshotsByChainName(chainConfig.ChainName) && useSnapshots
config.Snapshot.Enabled = useSnapshots
}
log.Info("Effective", "prune_flags", config.Prune.String(), "snapshot_flags", config.Snapshot.String(), "history.v3", config.HistoryV3)

Expand Down
6 changes: 5 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,11 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C
cfg.SentinelAddr = ctx.String(SentinelAddrFlag.Name)
cfg.SentinelPort = ctx.Uint64(SentinelPortFlag.Name)

cfg.Sync.UseSnapshots = ctx.Bool(SnapshotFlag.Name)
cfg.Sync.UseSnapshots = ethconfig.UseSnapshotsByChainName(ctx.String(ChainFlag.Name))
if ctx.IsSet(SnapshotFlag.Name) { //force override default by cli
cfg.Sync.UseSnapshots = ctx.Bool(SnapshotFlag.Name)
}

cfg.Dirs = nodeConfig.Dirs
cfg.Snapshot.KeepBlocks = ctx.Bool(SnapKeepBlocksFlag.Name)
cfg.Snapshot.Produce = !ctx.Bool(SnapStopFlag.Name)
Expand Down
2 changes: 1 addition & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere
panic(err)
}

config.Snapshot.Enabled = ethconfig.UseSnapshotsByChainName(chainConfig.ChainName) || config.Sync.UseSnapshots
config.Snapshot.Enabled = config.Sync.UseSnapshots

log.Info("Initialised chain configuration", "config", chainConfig, "genesis", genesis.Hash())

Expand Down

0 comments on commit 62746c6

Please sign in to comment.