statesync: record finalized version only after state root validation - #2455
Open
kkuehlz wants to merge 1 commit into
Open
statesync: record finalized version only after state root validation#2455kkuehlz wants to merge 1 commit into
kkuehlz wants to merge 1 commit into
Conversation
kkuehlz
force-pushed
the
statesync-validate-before-finalize
branch
from
July 23, 2026 20:47
ba94759 to
e6198db
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a statesync correctness issue where monad_statesync_client_finalize could persist a corrupted sync target as the client’s restart baseline by updating the finalized version before validating the canonical trie’s state root against the trusted header.
Changes:
- Delay
update_finalized_version(tgrt.number)until afterstate_root()matches the trusted target header. - Emit a warning when the target is rejected due to a root mismatch.
- Add a regression test to ensure restart-after-failure does not inherit the corrupted baseline.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| category/statesync/statesync_client.cpp | Reorders finalize to validate state root before persisting finalized version; adds warning log on mismatch. |
| category/statesync/test/test_statesync.cpp | Adds regression test covering retry behavior after failed root validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Chen-Yifan
previously approved these changes
Aug 7, 2026
Chen-Yifan
left a comment
Contributor
There was a problem hiding this comment.
approved but need to address copilot comments.
kkuehlz
force-pushed
the
statesync-validate-before-finalize
branch
from
August 24, 2026 17:26
e6198db to
3bcced3
Compare
monad_statesync_client_finalize previously marked the target finalized before comparing the canonical trie's state root against the trusted header. A peer supplying syntactically valid but corrupted state thus became the client's restart baseline: reopening rewinds to the recorded finalized version and initializes sync progress from it, so a normal retry never re-requested the corrupted range. Validate the root first and only then update the finalized version, and warn when a target is rejected. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
kkuehlz
force-pushed
the
statesync-validate-before-finalize
branch
from
August 24, 2026 17:26
3bcced3 to
dd2e635
Compare
Chen-Yifan
approved these changes
Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
monad_statesync_client_finalize previously marked the target finalized before comparing the canonical trie's state root against the trusted header. A peer supplying syntactically valid but corrupted state thus became the client's restart baseline: reopening rewinds to the recorded finalized version and initializes sync progress from it, so a normal retry never re-requested the corrupted range. Validate the root first and only then update the finalized version, and warn when a target is rejected.