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

fix(share/pruner) enable Light node pruner service #3455

Merged
merged 7 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 2 additions & 8 deletions cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,14 @@ func PersistentPreRunEnv(cmd *cobra.Command, nodeType node.Type, _ []string) err
rpc_cfg.ParseFlags(cmd, &cfg.RPC)
gateway.ParseFlags(cmd, &cfg.Gateway)

pruner.ParseFlags(cmd, &cfg.Pruner)
switch nodeType {
case node.Light:
case node.Light, node.Full:
err = header.ParseFlags(cmd, &cfg.Header)
if err != nil {
return err
}
case node.Full:
err = header.ParseFlags(cmd, &cfg.Header)
if err != nil {
return err
}
pruner.ParseFlags(cmd, &cfg.Pruner)
case node.Bridge:
pruner.ParseFlags(cmd, &cfg.Pruner)
Wondertan marked this conversation as resolved.
Show resolved Hide resolved
default:
panic(fmt.Sprintf("invalid node type: %v", nodeType))
}
Expand Down
32 changes: 21 additions & 11 deletions nodebuilder/pruner/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ func ConstructModule(tp node.Type, cfg *Config) fx.Option {
availWindow(tp, cfg.EnableService),
)

fullAndBridgeComponents := fx.Options(
baseComponents,
prunerService := fx.Options(
fx.Provide(fx.Annotate(
newPrunerService,
fx.OnStart(func(ctx context.Context, p *pruner.Service) error {
Expand All @@ -34,31 +33,42 @@ func ConstructModule(tp node.Type, cfg *Config) fx.Option {
// This is necessary to invoke the pruner service as independent thanks to a
// quirk in FX.
fx.Invoke(func(_ *pruner.Service) {}),
fx.Provide(func(store *eds.Store) pruner.Pruner {
return full.NewPruner(store)
}),
)

switch tp {
// TODO: Eventually, light nodes will be capable of pruning samples
// in which case, this can be enabled.
walldiss marked this conversation as resolved.
Show resolved Hide resolved
case node.Light:
if cfg.EnableService {
return fx.Module("prune",
baseComponents,
prunerService,
fx.Provide(light.NewPruner),
)
}
return fx.Module("prune",
baseComponents,
fx.Provide(light.NewPruner),
walldiss marked this conversation as resolved.
Show resolved Hide resolved
)
case node.Full:
opts := baseComponents
if cfg.EnableService {
opts = fullAndBridgeComponents
return fx.Module("prune",
baseComponents,
prunerService,
fx.Provide(func(store *eds.Store) pruner.Pruner {
return full.NewPruner(store)
}),
walldiss marked this conversation as resolved.
Show resolved Hide resolved
)
walldiss marked this conversation as resolved.
Show resolved Hide resolved
}
return fx.Module("prune",
opts,
)
return fx.Module("prune", baseComponents)
case node.Bridge:
if cfg.EnableService {
return fx.Module("prune",
fullAndBridgeComponents,
baseComponents,
prunerService,
fx.Provide(func(store *eds.Store) pruner.Pruner {
return full.NewPruner(store)
walldiss marked this conversation as resolved.
Show resolved Hide resolved
}),
fx.Provide(func(window pruner.AvailabilityWindow) []core.Option {
return []core.Option{core.WithAvailabilityWindow(window)}
}),
Expand Down
Loading