Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: ApplyFlagsForEthConfig to handle different pruning modes based on chainId #507

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading