Skip to content

fix(rootmulti): stop snapshot restore when node is rejected by SC importer - #4412

Merged
manav2401 merged 5 commits into
mainfrom
manav/sc-importer-error
Oct 5, 2026
Merged

manav2401 merged 5 commits into
mainfrom
manav/sc-importer-error

Conversation

@manav2401

Copy link
Copy Markdown
Contributor

Snapshot restore now exit early when the SC (State Commitment) importer cannot import a node, instead of continuing without it. Previously the FlatKV importer skipped such nodes silently, while the restore still passed them on to the SS (State Store).

  • Importer.AddNode now returns an error. KVImporter rejects non-leaf nodes, nodes without a key, and nodes at a version other than the import height, instead of skipping them.
  • rootmulti.Store.restore stops on that error, and forwards a leaf to the state store only after SC accepts it.
  • The memiavl importer always returns nil, the composite importer returns its backend's error, and seidb import-flatkv-from-memiavl stops at the first rejected pair.

@cursor

cursor Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

PR Summary

High Risk
Changes snapshot restore and FlatKV import validation on consensus-critical state paths; a malformed or version-mismatched node now aborts restore instead of partially applying SS data.

Overview
Snapshot restore now fails fast when the state-commitment (SC) importer rejects a node, instead of continuing and still feeding leaves to the state store (SS).

Importer.AddNode returns an error across the SC stack. FlatKV’s KVImporter rejects (rather than silently skips) non-leaf nodes, empty keys, version mismatches, and empty physical values; a failed import does not finalize. The composite importer surfaces the active backend’s error; memiavl’s importer adopts the same signature.

rootmulti.Store.restore checks scImporter.AddNode and aborts the restore loop on failure; SS import runs only for leaves SC already accepted. The import-flatkv-from-memiavl tool propagates the first AddNode failure from emitPairs.

Tests cover wrong-version flatkv snapshots end-to-end, partial SS import on mid-stream rejection, and importer version/empty-key behavior.

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

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedOct 5, 2026, 6:55 AM

@seidroid seidroid 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.

This change makes Importer.AddNode return an error. FlatKV now rejects non-leaf nodes, nodes without a key and nodes at the wrong version instead of skipping them, and snapshot restore stops on the first rejection so a rejected leaf never reaches the state store. Nothing blocks: the error path is wired through the composite and memiavl importers, the restore loop and the seidb tool, a failed import aborts and leaves the SS version unset, and tests cover it. I kept codex's one finding as a suggestion, because Close still returns the failure; no reading contributed anything else.

Non-blocking

1 finding on the changed lines, as inline comments.

seidroid review · decision approve · session 6145f229298746e986d8f5c2902d16c1 · turn resp_claude_e91be63b935713d88768a27f5f7988f9 · item bbe66940e7065ddbb2c04149420aafe2

Findings: 0 blocking | 1 non-blocking | 1 posted inline

Comment thread sei-db/state_db/sc/flatkv/importer.go
@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.21053% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.69%. Comparing base (2740979) to head (1c3b5c6).

Files with missing lines Patch % Lines
...cmd/seidb/operations/import_flatkv_from_memiavl.go 75.00% 3 Missing ⚠️
sei-db/state_db/sc/composite/importer.go 50.00% 2 Missing ⚠️
sei-db/state_db/sc/flatkv/importer.go 94.11% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4412      +/-   ##
==========================================
- Coverage   55.70%   55.69%   -0.02%     
==========================================
  Files        2179     2179              
  Lines      169070   169090      +20     
==========================================
- Hits        94174    94167       -7     
- Misses      74891    74918      +27     
  Partials        5        5              
Flag Coverage Δ
sei-chain 53.84% <80.00%> (-0.02%) ⬇️
sei-db 74.81% <ø> (ø)
sei-db-state-db 78.62% <86.95%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
sei-cosmos/storev2/rootmulti/store.go 75.29% <100.00%> (+0.07%) ⬆️
sei-db/state_db/sc/memiavl/import.go 75.95% <100.00%> (ø)
sei-db/state_db/sc/flatkv/importer.go 94.38% <94.11%> (-0.24%) ⬇️
sei-db/state_db/sc/composite/importer.go 90.24% <50.00%> (-4.76%) ⬇️
...cmd/seidb/operations/import_flatkv_from_memiavl.go 50.72% <75.00%> (+0.22%) ⬆️

... and 22 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.

Comment thread sei-db/state_db/sc/flatkv/importer.go Outdated
@manav2401
manav2401 enabled auto-merge October 5, 2026 06:54
@manav2401
manav2401 added this pull request to the merge queue Oct 5, 2026
Merged via the queue into main with commit 5fe90c0 Oct 5, 2026
67 of 68 checks passed
@manav2401
manav2401 deleted the manav/sc-importer-error branch October 5, 2026 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants