core: improve state recovery logging after unexpected shutdown #31932
+46
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses issue #31812 by significantly improving the user experience during state recovery after unexpected shutdowns. The changes provide clear, informative logging that helps users understand what's happening and reduces confusion during the recovery process.
Problem
When geth experiences an unexpected shutdown (power failure, system crash, etc.), users see cryptic log messages like:
This leads to user confusion and questions like:
Solution
Enhanced Logging Features
Initial Context Message: Clear explanation that recovery is normal
Progress Tracking: Added scan rate and block count for better progress visibility
Performance Metrics: Users can now see:
Changes Made
Modified Functions
rewindHashHead()
: Enhanced with progress tracking and user-friendly messagesrewindPathHead()
: Same improvements for path-based storage schemeAdded Variables
blocksScanned
: Tracks number of blocks processed during recoveryinitialLogged
: Ensures initial context message is shown only oncerate
: Calculates and displays scanning performanceImproved Messages
"Block state missing, rewinding further"
"State recovery in progress"
with comprehensive contextBenefits
Testing
make geth
Example Output
Before
After
Impact
This change directly addresses the user confusion reported in issue #31812 without affecting:
Related Issues
Fixes #31812 - Error log on geth & prysm when unexpected interruption
Type of Change
Checklist
make geth
)