Skip to content

dynamic router switching#3581

Open
cody-littley wants to merge 5 commits into
mainfrom
cjl/dynamic-router-switching
Open

dynamic router switching#3581
cody-littley wants to merge 5 commits into
mainfrom
cjl/dynamic-router-switching

Conversation

@cody-littley

Copy link
Copy Markdown
Contributor

Describe your changes and provide context

Add the ability to change router type at runtime. Allows us to initiate migration at times other than upgrade boundaries (assuming we have control plane infrastructure that can decide when to initiate upgrade).

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJun 22, 2026, 1:26 PM

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.18310% with 81 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.05%. Comparing base (f83a111) to head (2599546).

Files with missing lines Patch % Lines
sei-db/state_db/sc/composite/store.go 71.28% 36 Missing and 22 partials ⚠️
sei-db/state_db/sc/flatkv/store_meta.go 42.85% 7 Missing and 5 partials ⚠️
sei-db/state_db/sc/migration/derive_write_mode.go 90.24% 2 Missing and 2 partials ⚠️
sei-cosmos/storev2/rootmulti/store.go 89.47% 1 Missing and 1 partial ⚠️
sei-db/state_db/sc/composite/importer.go 84.61% 1 Missing and 1 partial ⚠️
sei-db/state_db/sc/flatkv/store.go 66.66% 1 Missing and 1 partial ⚠️
app/seidb.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3581      +/-   ##
==========================================
+ Coverage   59.01%   59.05%   +0.03%     
==========================================
  Files        2224     2191      -33     
  Lines      182814   181825     -989     
==========================================
- Hits       107893   107379     -514     
+ Misses      65220    64743     -477     
- Partials     9701     9703       +2     
Flag Coverage Δ
sei-chain-pr 61.06% <87.50%> (?)
sei-db 70.41% <ø> (-0.22%) ⬇️
sei-db-state-db ?
sei-db-state-db-pr 76.54% <76.43%> (?)

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

Files with missing lines Coverage Δ
sei-cosmos/server/config/config.go 94.53% <100.00%> (ø)
sei-cosmos/storev2/commitment/store.go 54.08% <100.00%> (+0.95%) ⬆️
sei-db/config/sc_config.go 87.50% <100.00%> (ø)
sei-db/state_db/sc/flatkv/ktype/meta.go 100.00% <ø> (ø)
sei-db/state_db/sc/memiavl/store.go 92.70% <100.00%> (+0.10%) ⬆️
sei-db/state_db/sc/migration/router_builder.go 55.70% <100.00%> (ø)
sei-db/state_db/sc/migration/router_kvstore.go 95.55% <100.00%> (ø)
sei-db/state_db/sc/types/write_mode.go 100.00% <100.00%> (ø)
app/seidb.go 73.61% <0.00%> (ø)
sei-cosmos/storev2/rootmulti/store.go 68.02% <89.47%> (+0.65%) ⬆️
... and 5 more

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

@cody-littley cody-littley marked this pull request as ready for review June 22, 2026 13:24
@cursor

cursor Bot commented Jun 22, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Changes consensus-critical state-commit routing, AppHash composition, migration metadata, and state-sync streams; incorrect transitions or gating could fork nodes or corrupt restored state.

Overview
Introduces auto as a state-commit write mode and runtime migration stepping without node restarts. WriteMode moves from sei-db/config to sei-db/state_db/sc/types (including ParseWriteMode); callers now reference that package.

With sc-write-mode = auto, the composite commit store derives the effective mode from flatkv migration metadata on load, lazy-opens flatkv only after the first MigrateEVM transition, and exposes SetWriteMode for single-step forward moves along the migration chain (completion required before leaving an in-flight migration). rootmulti.Store.SetWriteMode enforces between-block use (rejects buffered writes via HasPendingChanges) and reloads cached IAVL module views so reads follow the new router; RouterCommitKVStore resolves the router at call time so pre-transition views stay correct after migration drains memiavl.

Consensus-facing behavior is tightened for coordinated upgrades: AppHash / commit-info gating uses effective mode and persisted migration state (evm_lattice, dropping memiavl store infos when bank migration completes), state-sync export/import matches hash participation (metadata-gated sections, on-demand flatkv materialization from snapshots), and flatkv records EarliestVersion so read-only queries for pre-flatkv heights under auto can be served from memiavl only.

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

@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 2599546. Configure here.

}
return fmt.Errorf("failed to build router for write mode %q: %w", targetWriteMode, err)
}
cs.migrationAdvancedThisCommit = false

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SetWriteMode resets migration guard

Medium Severity

SetWriteMode clears migrationAdvancedThisCommit, which normally blocks a second migration batch in the same commit cycle. If it runs after GetWorkingHash (first flush) but before Commit (second flush), the next flush can advance migration again in one block, diverging AppHash from peers that only advanced once.

Fix in Cursor Fix in Web

Triggered by learned rule: sei-db migration: guard ApplyChangeSets against double-advance per commit cycle

Reviewed by Cursor Bugbot for commit 2599546. Configure here.

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.

2 participants