Skip to content

fix: Skip duplicate reads during full pruning for validator operations#827

Merged
hudem1 merged 4 commits intomainfrom
hudem1/fix/duplicate-read-during-full-pruning
Apr 15, 2026
Merged

fix: Skip duplicate reads during full pruning for validator operations#827
hudem1 merged 4 commits intomainfrom
hudem1/fix/duplicate-read-during-full-pruning

Conversation

@hudem1
Copy link
Copy Markdown
Collaborator

@hudem1 hudem1 commented Apr 14, 2026

This PR provides a fix to a quite tricky unexpected behavior:

  1. During full pruning, node RLP reads also get written to the new DB, called DuplicateReads (see FullPruningDb.Get).
  2. During full pruning, validator operations continue to execute up to a certain point (when the validator's last valid state get copied to new DB). During those operations, there might be some ReconstructedStateTrieStore.TryLoadRlp calls fallbacking to the baseStore's underlying db, which then end up in the new DB as well (due to DuplicateReads).
  3. After full pruning, reconstructed state memDB overlay gets cleared to remove any partial state that have been reconstructed, after last valid state and before base pruning block.
  4. So, if the state root for a block X -- between last valid state and base pruning block -- gets read (through ReconstructedStateTrieStore.TryLoadRlp) and hence written to new DB, then if after full pruning, a validator-related operation (RecordBlockCreation / PrepareForRecord) gets called on a block between X and base pruning block, then the most recent available state found would be X and would be incomplete (as only the root or at best a small set of block X's full state trie nodes would be on new DB). In that case, state reconstruction from that state would throw a missing node RLP exception when reconstructing X+1.

The fix is pretty simple: add the flag ReadFlags.SkipDuplicateRead to TryLoadRlp so that during full pruning, read (through ReconstructedStateTrieStore) would not get duplicated (written to new DB)

Copilot AI review requested due to automatic review settings April 14, 2026 11:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a full-pruning edge case where reads performed during validator/state reconstruction could be “duplicate-written” into the new pruning DB, leaving partial intermediate state roots that later break reconstruction.

Changes:

  • Ensure ReconstructedStateTrieStore passes ReadFlags.SkipDuplicateRead when falling back to the base store (TryLoadRlp, HasRoot, TryReference) to prevent polluting the new DB during full pruning.
  • Add an end-to-end regression test intended to reproduce the “DuplicateReads partial state” failure mode during/after pruning.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/Nethermind.Arbitrum/Execution/Stateless/ReconstructedStateTrieStore.cs Adds SkipDuplicateRead to base-store read paths to avoid duplicate-write side effects during full pruning.
src/Nethermind.Arbitrum.Test/Execution/Stateless/MarkValidTests.cs Adds a regression test covering pruning + reconstruction behavior, and a new using directive.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Nethermind.Arbitrum.Test/Execution/Stateless/MarkValidTests.cs
Comment thread src/Nethermind.Arbitrum.Test/Execution/Stateless/MarkValidTests.cs
Comment thread src/Nethermind.Arbitrum.Test/Execution/Stateless/MarkValidTests.cs
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.39%. Comparing base (5c8d816) to head (107cb42).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #827      +/-   ##
==========================================
+ Coverage   76.37%   76.39%   +0.01%     
==========================================
  Files         227      227              
  Lines       14151    14151              
  Branches     2107     2107              
==========================================
+ Hits        10808    10810       +2     
+ Misses       2585     2584       -1     
+ Partials      758      757       -1     
Files with missing lines Coverage Δ
...Execution/Stateless/ReconstructedStateTrieStore.cs 90.41% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/Nethermind.Arbitrum.Test/Execution/Stateless/MarkValidTests.cs Outdated
Comment thread src/Nethermind.Arbitrum.Test/Execution/Stateless/MarkValidTests.cs Outdated
@hudem1 hudem1 merged commit 83a3d65 into main Apr 15, 2026
12 checks passed
@hudem1 hudem1 deleted the hudem1/fix/duplicate-read-during-full-pruning branch April 15, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants