Skip to content

Backport release/v6.7: fix(seidb): fix stale FlatKV migration gauges on snapshotting nodes - #4442

Merged
alexander-sei merged 2 commits into
release/v6.7from
backport-4436-to-release/v6.7
Oct 4, 2026
Merged

alexander-sei merged 2 commits into
release/v6.7from
backport-4436-to-release/v6.7

Conversation

@seidroid

@seidroid seidroid Bot commented Oct 4, 2026

Copy link
Copy Markdown

Backport of #4436 to release/v6.7.

…4436)

On atlantic-2, archive-0-0-0, snapshotter-0 and state-sync-node-0
finished the EVM migration (all 123,876,555 keys moved,
`seidb_migration_version` went to 1), but the FlatKV migration dashboard
still shows them as migrating, at 99.3% with ~875k EVM keys left in
memIAVL. The migration is complete; two gauges report stale values, and
only on nodes that export state-sync snapshots. A snapshot export opens
a read-only composite store at the snapshot height, and when that height
is before completion, the `MigrationManager` built for that handle
records version 0 on the process-wide `seidb_migration_version` gauge.
Nothing records 1 again until restart. Separately,
`rootmulti.Store.Snapshot` records `iavl_total_num_keys` only for stores
that exported at least one node, so once the memIAVL `evm` tree is empty
its last pre-migration value is exported forever. This is the same
retention problem #4327 fixed for `seidb_migration_boundary_snapshot`.

`migration.BuildRouter` now takes `RouterOption`s, and
`WithoutTelemetry()` gives the router's `MigrationManager`
`newLocalMigrationMetrics()` instead of the OTel-backed instance.
`CompositeCommitStore.buildRouter` passes it for derived stores (the
`LoadVersionReadOnly` view and `Copy`), so only the live store publishes
migration metrics. `Snapshot` sets the per-store totals to zero on each
store header, so a store with no nodes records 0. Converting the version
gauge to an observable gauge would also work, but it leaves read-only
handles publishing the other migration counters, so they are cut off at
the router instead.

No consensus, state, or wire-format impact: only metric emission
changes, and the option is variadic, so existing `BuildRouter` callers
are unchanged. A store absent from an export entirely (rather than
exported empty) still keeps its last value; that does not occur for
`evm` after the migration. Affected nodes show correct values after
deploy, once they restart and export their next snapshot.
`TestLoadVersionReadOnlyDoesNotReportMigrationVersion` and
`TestSnapshotReportsZeroKeysForEmptyStore` each fail without their half
of the fix; the migration, composite and rootmulti suites pass.

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
(cherry picked from commit 82c0cda)
@cursor

cursor Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes when snapshot and derived-store code publishes OTel metrics during state sync; behavior is limited to observability but affects operational signals on migrating chains.

Overview
Fixes stale OpenTelemetry gauges on nodes that export state-sync snapshots after EVM/FlatKV migration: empty memIAVL stores (e.g. evm) no longer leave old key counts, and read-only derived commit stores no longer overwrite live migration version metrics.

During snapshot export, each store header now resets per-store key/size counters to zero so stores with no exported nodes still emit iavl_total_num_keys = 0 instead of being omitted and keeping pre-migration values.

For derived composite stores (including read-only views opened at historical heights for snapshotting), buildRouter passes migration.WithoutTelemetry(), routing migration managers through local-only metrics instead of process-wide OTel instruments. BuildRouter gains optional RouterOption hooks used by the migrate-EVM / migrate-all-but-bank / migrate-bank paths.

Adds regression tests for zero-key reporting on empty post-migration evm snapshots and for seidb_migration_version staying at the live manager value after LoadVersionReadOnly at a mid-migration height.

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

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

This is a clean backport of #4436 to release/v6.7. A store exported empty in Snapshot is now reported as zero keys instead of keeping its stale gauge, and derived (read-only) composite stores no longer publish migration gauges, so they can't overwrite the values the live store reports. Everything the change relies on (newLocalMigrationMetrics, cs.derived, and the rootmulti test helpers) exists on the release branch, and both fixes have regression tests.

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

Blockers

  • None at the file/PR level.

Non-blocking

  • None at the file/PR level.

@github-actions

github-actions Bot commented Oct 4, 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 4, 2026, 6:50 PM

@codecov

codecov Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.88%. Comparing base (a37a6bd) to head (9c943fe).

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff                @@
##           release/v6.7    #4442      +/-   ##
================================================
- Coverage         61.70%   60.88%   -0.82%     
================================================
  Files              2171     2088      -83     
  Lines            189908   179957    -9951     
================================================
- Hits             117187   109572    -7615     
+ Misses            61838    60311    -1527     
+ Partials          10883    10074     -809     
Flag Coverage Δ
sei-chain-pr 68.49% <100.00%> (?)
sei-db 69.80% <ø> (ø)
sei-db-state-db ?
sei-db-state-db-pr 79.27% <100.00%> (?)

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 69.79% <100.00%> (+0.12%) ⬆️
sei-db/state_db/sc/composite/store.go 70.62% <100.00%> (+0.13%) ⬆️
sei-db/state_db/sc/migration/router_builder.go 58.95% <100.00%> (+1.23%) ⬆️

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

Co-authored-by: Cursor <cursoragent@cursor.com>
@alexander-sei

Copy link
Copy Markdown
Contributor

@seidroid review

@alexander-sei
alexander-sei enabled auto-merge (squash) October 4, 2026 19:08

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

This backport stops derived composite stores (read-only handles and copies) from writing to the process-wide migration gauges, and makes snapshot export report zero for stores that export no keys, so neither gauge keeps a stale value. The fix is right: derived is set before every buildRouter call on read-only handles and copies, and newLocalMigrationMetrics is nil-safe on every recording path. Nothing blocks; the one scout reading (codex, which found nothing) matches this, and the new tests were not run because the sandbox has no Go toolchain.

seidroid review · decision approve · session 8ffdf524d0e04c5abccf9bd37e54d9d1 · turn resp_claude_03e791c6446521b228be8ec73700cebd · item 6f3c3b9f5f5a5ef299f1f8e9863d4b4e

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

@alexander-sei
alexander-sei merged commit 0ef669d into release/v6.7 Oct 4, 2026
74 checks passed
@alexander-sei
alexander-sei deleted the backport-4436-to-release/v6.7 branch October 4, 2026 19:16
masih pushed a commit that referenced this pull request Oct 5, 2026
## Summary
- Bump `version.json` from `v6.7.0-rc4` to `v6.7.0` to cut the final
`v6.7` release for mainnet. There is no rc5: this goes straight from rc4
to the release. (v6.6.0 was tagged on the rc5 bump, #3783, with
`version.json` still reading `v6.6.0-rc5`; this keeps `version.json` in
step with the tag.)

Contents since rc4: #4442 and #4439, plus the changelog update (#4443).
Merge this after #4443's backport has landed on `release/v6.7`, so the
`v6.7.0` tag includes the updated changelog.

- Both are labeled `non-app-hash-breaking` (a FlatKV migration metrics
fix and `seidb` digest tooling), so moving from rc4 to `v6.7.0` should
not need a coordinated validator switch.
- Push `v6.7.0` by hand on this PR's merge commit once it has merged;
the tagging ruleset stops `uci-release-publish` from creating it.

## Test plan
- [x] `git diff --check`

Made with [Cursor](https://cursor.com)

Co-authored-by: Cursor <cursoragent@cursor.com>
revofusion pushed a commit to revofusion/sei-chain that referenced this pull request Oct 5, 2026
Adds the `release/v6.7` entries merged since the rc4 changelog (sei-protocol#4406),
in prep to cut **v6.7.0**, the mainnet release (there is no rc5; the
version bump is sei-protocol#4444):

- [sei-protocol#4442](sei-protocol#4442) —
fix(seidb): fix stale FlatKV migration gauges on snapshotting nodes
- [sei-protocol#4439](sei-protocol#4439) — seidb:
add changelog mode and --inspect-plan to speed up EVM digest
- [sei-protocol#4416](sei-protocol#4416) — removal
of the conflict markers the rc4 changelog backport left on
`release/v6.7`
- [sei-protocol#4415](sei-protocol#4415) — rc4
changelog backport
- [sei-protocol#4407](sei-protocol#4407) — rc4
version bump

Regenerated with `./scripts/generate-changelog.sh release/v6.6
release/v6.7`; only the `## v6.7` PR list changes, so the `backport
release/v6.7` cherry-pick applies cleanly (simulated with `git
merge-tree` against `origin/release/v6.7`). Docs-only; no code change.

Made with [Cursor](https://cursor.com)

Co-authored-by: Cursor <cursoragent@cursor.com>
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