feat: Add a provider to persist additional nodes to disk during full pruning and shutdown#11023
feat: Add a provider to persist additional nodes to disk during full pruning and shutdown#11023
Conversation
…pruning and shutdown
|
@claude review |
|
Claude finished @svlachakis's task in 1m 43s —— View job Code Review
The PR adds a hook ( Ordering issue in
|
| # | Severity | Issue |
|---|---|---|
| 1 | Bug | AdditionalRootsProvider runs even when cancellation is requested; runs before visitor.Finish() |
| 2 | Medium | Setter injection bypasses DI; fragile if not wired |
| 3 | Medium | upToBlockNumberExclusive name contradicts documented semantics |
| 4 | Low | No tests for the new hook invocation |
| 5 | Low | FullPruner property on MainPruningTrieStoreFactory only exists to work around setter injection |
src/Nethermind/Nethermind.Trie/Pruning/IAdditionalRootsProvider.cs
Outdated
Show resolved
Hide resolved
|
please target claude review issues |
…ge is called in all cases (_commitSetQueue.IsEmpty too) CopyAdditionalStatesToNodeStorage might add nodes that were not present in dirty nodes cache
| ) where TContext : struct, ITreePathContextWithStorage, INodeContext<TContext> | ||
| { | ||
| CopyTreeVisitor<TContext> copyTreeVisitor = new(targetNodeStorage, writeFlags, _logManager, cancellationToken); | ||
| _stateReader.RunTreeVisitor(copyTreeVisitor, baseBlock, visitingOptions); |
There was a problem hiding this comment.
Wouldn't it be simpler to provide to FullPrunner a decorator over IStateReader and just run the copy in the RunTreeVisitor?
It is a bit side-effecty, but the extension point is already there, no need to change anything on the Nethermind side if possible - everything goes into the plugin
There was a problem hiding this comment.
yes true, that looks cleaner overall.
I updated the PR, still requires very small change in nethermind side because full pruner gets the state reader after manually constructed and not from DI, as the state reader gets registered in DI right after PruningTrieStateFactory.Build() finishes.
I was also wondering about performances because CopyTree implies: FindCachedOrUnknown miss + LoadRlp + full RLP decode into TrieNode, whereas my initial solution directly stored the node's byte[], but actually i think i could come up with a solution where full pruning requires only the storage of 1-2 additional states rather than potentially many states as in the original solution. So, this solution's slight per-node overhead is negligible and doesn’t offset the cleaner design !
(And i could find an alternative for persisting additional states on shutdown fully in the plugin)
…or for full pruning instead
This reverts commit ac076b9.
LukaszRozmej
left a comment
There was a problem hiding this comment.
It's ok, not sure if we can do better.
@asdacap any better ideas how to supply a decorator of IStateReader here?
|
Can you show the implementation? And how does it effect FullPruner? |
@asdacap Here is how i use it: NethermindEth/nethermind-arbitrum#792
|
Needed for arbitrum's validators.
The blocks being validated might lag behind the tip of the chain and therefore:
Types of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Notes on testing
Optional. Remove if not applicable.
Documentation
Requires documentation update
If yes, link the PR to the docs update or the issue with the details labeled
docs. Remove if not applicable.Requires explanation in Release Notes
If yes, fill in the details here. Remove if not applicable.
Remarks
Optional. Remove if not applicable.