Skip to content

Commit

Permalink
Refactor ApplyFlagsForEthConfig to handle different pruning modes bas…
Browse files Browse the repository at this point in the history
…ed on chainId (#507)
  • Loading branch information
du5 authored Sep 18, 2024
1 parent c45c84c commit ba95a69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions ethdb/prune/storage_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ type Mode struct {
Experiments Experiments
}

func (m *Mode) SetPruneMode(blocks, history uint64) {
m.Blocks = Distance(blocks)
m.History = Distance(history)
}

type BlockAmount interface {
PruneTo(stageHead uint64) uint64
Enabled() bool
Expand Down
11 changes: 7 additions & 4 deletions turbo/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,18 @@ func ApplyFlagsForEthConfig(ctx *cli.Context, cfg *ethconfig.Config, logger log.
if err != nil {
utils.Fatalf(fmt.Sprintf("error while parsing mode: %v", err))
}

// Full mode prunes all but the latest state
if ctx.String(PruneModeFlag.Name) == "full" {
mode.Blocks = prune.Distance(math.MaxUint64)
mode.History = prune.Distance(0)
mode.SetPruneMode(math.MaxUint64, 0)
}
// Minimal mode prunes all but the latest state including blocks
if ctx.String(PruneModeFlag.Name) == "minimal" {
mode.Blocks = prune.Distance(2048) // 2048 is just some blocks to allow reorgs
mode.History = prune.Distance(0)
if chainId == 56 {
mode.SetPruneMode(90_000, 90_000) // 90_000 about 3 day
} else {
mode.SetPruneMode(2048, 0) // 2048 is just some blocks to allow reorgs
}
}

cfg.BlobPrune = ctx.Bool(PruneBscBlobSidecarsFlag.Name)
Expand Down

0 comments on commit ba95a69

Please sign in to comment.