Skip to content

refactor: extract FullPruner init into overridable IFullPrunerFactory#11066

Merged
asdacap merged 4 commits into
masterfrom
pruner-init-override
Apr 8, 2026
Merged

refactor: extract FullPruner init into overridable IFullPrunerFactory#11066
asdacap merged 4 commits into
masterfrom
pruner-init-override

Conversation

@asdacap
Copy link
Copy Markdown
Contributor

@asdacap asdacap commented Apr 7, 2026

Summary

  • Extract FullPruner initialization from PruningTrieStateFactory.Build() side effect into a new IFullPrunerFactory interface
  • Default FullPrunerFactory implementation preserves existing behavior
  • Promotes CompositePruningTrigger to a DI singleton
  • Plugins can now override full pruning behavior by registering a custom IFullPrunerFactory

Changes

  • New: IFullPrunerFactory interface in Nethermind.Blockchain/FullPruning/
  • New: FullPrunerFactory default implementation in Nethermind.Init/
  • Modified: WorldStateModule — registers CompositePruningTrigger and IFullPrunerFactory as singletons
  • Modified: PruningTrieStateFactory — delegates to IFullPrunerFactory.Initialize(), removes 4 unused constructor params
  • Modified: FlatWorldStateModule — adds stubs for new registrations

Test plan

  • dotnet build passes
  • All 100 FullPrun* tests pass
  • API tests pass (DI wiring validation)

🤖 Generated with Claude Code

FullPruner was instantiated as a side effect inside
PruningTrieStateFactory.Build(), making it impossible to override via DI.
Extract the initialization into IFullPrunerFactory with a default
FullPrunerFactory implementation registered in WorldStateModule. This
allows plugins to swap full pruning behavior by overriding the
IFullPrunerFactory registration.

Also promotes CompositePruningTrigger to a DI singleton.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

public interface IFullPrunerFactory
{
void Initialize(IStateReader stateReader, IPruningTrieStore trieStore);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is bit weird that it doesn't retuen anything

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its side effect thing, making it icky.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Changed to FullPruner? Create(...) — the caller now handles dispose registration. -- Claude

}

IDriveInfo? drive = fileSystem.GetDriveInfos(pruningDbPath).FirstOrDefault();
FullPruner pruner = new(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe return FullPrunner here and add to Dispose stack in the caller?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Factory now returns FullPruner? and the caller in PruningTrieStateFactory.Build() pushes it to the dispose stack. Also removed IDisposableStack from the factory constructor. -- Claude

asdacap and others added 2 commits April 8, 2026 17:43
Make IFullPrunerFactory.Create return FullPruner? so the caller manages
dispose registration, removing the hidden side-effect of the factory
pushing to IDisposableStack internally.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@asdacap asdacap merged commit 438c4fc into master Apr 8, 2026
638 of 639 checks passed
@asdacap asdacap deleted the pruner-init-override branch April 8, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants