Skip to content

Backport release/v6.7: Validate snapshots before publication - #4054

Merged
masih merged 1 commit into
release/v6.7from
backport-4036-to-release/v6.7
Aug 28, 2026
Merged

Backport release/v6.7: Validate snapshots before publication#4054
masih merged 1 commit into
release/v6.7from
backport-4036-to-release/v6.7

Conversation

@seidroid

@seidroid seidroid Bot commented Aug 28, 2026

Copy link
Copy Markdown

Backport of #4036 to release/v6.7.

Reject malformed node hashes before writing snapshot records and
validate
completed snapshots before updating the current symlink. Add regression
coverage for partial leaf records and corrupt snapshot publication.

(cherry picked from commit f28da4c)
@cursor

cursor Bot commented Aug 28, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Changes critical state persistence (snapshot publication, current symlink, and empty-DB initialization) where mistakes could cause data loss or silent reset; behavior is defensive but touches core node storage paths.

Overview
Hardens MemIAVL snapshot rewrite and startup so corrupt on-disk snapshots are detected and replaced safely, while transient failures (cancelled context, permissions) never delete a good current target.

Introduces errCorruptedSnapshot and threads it through metadata load, mmap layout checks, and validateSnapshot (reload + match multi-tree version, store set, per-store version, and root hash against lastCommitInfo). RewriteSnapshot / publishSnapshot validate before skip, adopt, or replace; a corrupted target is removed only after a validated -tmp directory exists.

Startup: createDBIfNotExist refuses to silently initEmptyDB when current is a dangling symlink. Write path: snapshot writer rejects non-32-byte node hashes. LoadMultiTree closes partially opened trees on failed load.

Reviewed by Cursor Bugbot for commit aa44ba7. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.92982% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.61%. Comparing base (5eb099e) to head (aa44ba7).

Files with missing lines Patch % Lines
sei-db/state_db/sc/memiavl/db.go 74.71% 12 Missing and 10 partials ⚠️
sei-db/state_db/sc/memiavl/multitree.go 61.53% 3 Missing and 2 partials ⚠️
sei-db/state_db/sc/memiavl/snapshot.go 64.28% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff                @@
##           release/v6.7    #4054      +/-   ##
================================================
- Coverage         61.33%   60.61%   -0.73%     
================================================
  Files              2163     2083      -80     
  Lines            188823   180280    -8543     
================================================
- Hits             115813   109274    -6539     
+ Misses            62286    60984    -1302     
+ Partials          10724    10022     -702     
Flag Coverage Δ
sei-db 69.80% <ø> (ø)
sei-db-state-db ?
sei-db-state-db-pr 77.13% <71.92%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sei-db/state_db/sc/memiavl/multitree.go 80.76% <61.53%> (+1.37%) ⬆️
sei-db/state_db/sc/memiavl/snapshot.go 67.70% <64.28%> (+1.94%) ⬆️
sei-db/state_db/sc/memiavl/db.go 69.86% <74.71%> (+3.43%) ⬆️

... and 82 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedAug 28, 2026, 4:13 PM

@seidroid seidroid Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The automated review did not complete; see the failing AI Review check for details.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit aa44ba7. Configure here.

}
if renameErr := os.Rename(path, targetPath); renameErr != nil {
return fmt.Errorf("rename snapshot directory to %q: %w", targetPath, renameErr)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Snapshot replacement can orphan current

High Severity

When replacing a corrupted snapshot, publishSnapshot removes the existing target before the validated temp is renamed into place. A failed second rename or a crash in that window, then cleanupFailedSnapshotRewrite, deletes the replacement too and leaves current dangling. createDBIfNotExist then refuses to open the store.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit aa44ba7. Configure here.

@masih
masih merged commit 5968480 into release/v6.7 Aug 28, 2026
77 of 82 checks passed
@masih
masih deleted the backport-4036-to-release/v6.7 branch August 28, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants