Skip to content

Backport release/v6.7: fix(flatkv): keep 10 old checkpoints instead of mirroring memIAVL's count - #4347

Merged
alexander-sei merged 1 commit into
release/v6.7from
backport-4322-to-release/v6.7
Sep 25, 2026
Merged

alexander-sei merged 1 commit into
release/v6.7from
backport-4322-to-release/v6.7

Conversation

@seidroid

@seidroid seidroid Bot commented Sep 25, 2026

Copy link
Copy Markdown

Backport of #4322 to release/v6.7.

@seidroid

seidroid Bot commented Sep 25, 2026

Copy link
Copy Markdown
Author

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin backport-4322-to-release/v6.7
git worktree add --checkout .worktree/backport-4322-to-release/v6.7 backport-4322-to-release/v6.7
cd .worktree/backport-4322-to-release/v6.7
git reset --hard HEAD^
git cherry-pick -x 8c95ff34abd8634c1bfbabaddc6fbe85823a2c02
git push --force-with-lease

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedSep 25, 2026, 7:21 PM

@alexander-sei
alexander-sei requested review from alexander-sei, blindchaser, masih and yzang2019 and removed request for yzang2019 September 25, 2026 18:18
@blindchaser
blindchaser force-pushed the backport-4322-to-release/v6.7 branch from 7745b05 to c21346a Compare September 25, 2026 18:22
@blindchaser
blindchaser marked this pull request as ready for review September 25, 2026 18:22
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-25T18:26:25.413316Z c21346a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cursor

cursor Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes state-commit snapshot pruning defaults and composite alignment behavior, which affects rollback/recovery and disk use on validators running FlatKV alongside memIAVL.

Overview
FlatKV snapshot retention is decoupled from memIAVL and deepened by default. alignFlatKVSnapshotWithMemIAVL still mirrors memIAVL’s effective snapshot interval onto FlatKV, but it no longer copies keep-recent; FlatKV uses its own configured value (default raised from 1 → 10 old checkpoints, ~100k blocks at the default interval).

Docs, config comments, golden fixtures, and composite-store tests are updated to match, including coverage that default-config nodes keep FlatKV’s independent keep-recent after store construction.

Reviewed by Cursor Bugbot for commit b7d710a. 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.

The backport correctly separates FlatKV's keep-recent from memIAVL's, raises its default to 10, and adds tests for the new behavior. However, it does not regenerate app/testdata/state-commit.golden, so app.TestDefaultsMatchTheRecordedValues will fail on this branch.

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

Blockers

  • None at the file/PR level.
  • 1 blocking issue(s) flagged inline on specific lines.

Non-blocking

  • None at the file/PR level.

Inline comments (could not post inline; listed here)

  • sei-db/state_db/sc/flatkv/config/config.go:13 (RIGHT) -- [blocker] Changing DefaultSnapshotKeepRecent to 10 means app/testdata/state-commit.golden must be regenerated too. Line 17 of that file still records FlatKVConfig.SnapshotKeepRecent = uint32(1). app/config_fuzz_test.go TestDefaultsMatchTheRecordedValues runs configtest.CheckDefaults(t, "state-commit", config.DefaultStateCommitConfig()) against that file, so it will fail. The comment above that test warns about exactly this: moving a StateCommitConfig default breaks both app and sei-cosmos/server/config, and this PR regenerates only server_config.golden. Regenerate the app golden too and include its diff (see testutil/configtest/AGENTS.md).

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

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c21346a. Configure here.

Comment thread sei-db/state_db/sc/flatkv/config/config.go

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c21346a71c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const (
DefaultSnapshotInterval uint32 = 10000
DefaultSnapshotKeepRecent uint32 = 1
DefaultSnapshotKeepRecent uint32 = 10

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Update the state-commit default golden

Changing this default makes config.DefaultStateCommitConfig() report SnapshotKeepRecent = 10, but app/testdata/state-commit.golden still records 1. Consequently, app.TestDefaultsMatchTheRecordedValues (app/config_fuzz_test.go:633-635) deterministically fails when configtest.CheckDefaults compares the new default with the stale record; update that second golden alongside the server-config golden.

AGENTS.md reference: AGENTS.md:L21-L27

Useful? React with 👍 / 👎.

@codecov

codecov Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.39%. Comparing base (ffac3c4) to head (b7d710a).

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff                @@
##           release/v6.7    #4347      +/-   ##
================================================
- Coverage         61.37%   60.39%   -0.98%     
================================================
  Files              2163     2070      -93     
  Lines            189086   178179   -10907     
================================================
- Hits             116057   107617    -8440     
+ Misses            62304    60704    -1600     
+ Partials          10725     9858     -867     
Flag Coverage Δ
sei-chain-pr 75.57% <ø> (?)
sei-db 70.02% <ø> (+0.21%) ⬆️
sei-db-state-db ?
sei-db-state-db-pr 71.25% <100.00%> (?)

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 97.80% <ø> (ø)
sei-db/state_db/sc/composite/store.go 70.48% <100.00%> (-0.05%) ⬇️
sei-db/state_db/sc/flatkv/config/config.go 76.27% <100.00%> (ø)

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

…ount (#4322)

A composite read needs a version that both backends still hold. At
mainnet state size, memIAVL publishes a snapshot only about every 50,000
blocks. One retained FlatKV checkpoint reaches back only 10,000 to
20,000 blocks, so FlatKV prunes each version before memIAVL publishes
it, and no common version exists. On the mainnet shadow pair, memIAVL
published 229810000 when FlatKV held only 229840000 and 229850000. This
blocks a cross-backend digest and leaves a composite rollback with no
shared base snapshot.

- FlatKV's default `SnapshotKeepRecent` goes from 1 to 10. At the
default 10,000-block interval, this is a guaranteed reach of 100,000
blocks (about 12 hours).
- `alignFlatKVSnapshotWithMemIAVL` still copies memIAVL's effective
snapshot **interval** to FlatKV, but it no longer overwrites FlatKV's
**keep-recent** with `sc-keep-recent`. Without this, the new default has
no effect on a node (the review finding on #4158).
- New test `TestNewCompositeCommitStoreKeepsFlatKVKeepRecent` builds a
composite store from the default config and checks the effective FlatKV
retention. `TestAlignFlatKVSnapshotWithMemIAVL` now checks that
keep-recent is left as configured.
- Three test configs that set only memIAVL keep-recent (and relied on
the mirror) now also set FlatKV keep-recent.

A checkpoint hardlinks its SSTs, so each one costs only what compaction
has obsoleted since: about 261 MiB of pinned SSTs plus about 25 MiB of
retained state WAL at mainnet state size, roughly 2.8 GiB for ten.

No `app.toml` change is needed. The node path (`parseSCConfigs` in
`app/seidb.go`) does not read
`state-commit.flatkv.snapshot-keep-recent`, so a key rendered by the
v6.4–v6.6 templates does not pin the old value. Every node gets the new
default on restart.

Replaces #4158, which targeted `release/v6.7` directly. Labelled
`backport release/v6.7`. The FlatKV `config.go` differs between `main`
and `release/v6.7` (v6.7 still has the `DefaultSnapshotKeepRecent`
constant and the config golden records), so the automatic backport can
conflict there.

- `scripts/ramtest.sh` on `sei-db/state_db/sc/composite`,
`sei-db/state_db/sc/flatkv/...`, `sei-db/config`,
`sei-cosmos/storev2/rootmulti`, `sei-cosmos/server/config`, and the
`app` config tests.
- `make fmtcheck`.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
(cherry picked from commit 8c95ff3)
Co-authored-by: Cursor <cursoragent@cursor.com>
@blindchaser
blindchaser force-pushed the backport-4322-to-release/v6.7 branch from e6bc047 to b7d710a Compare September 25, 2026 19:19
@alexander-sei

Copy link
Copy Markdown
Contributor

@seidroid review

@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 cleanly separates FlatKV's keep-recent from memIAVL's, raises the default to 10, and now updates both config golden files, so the earlier blocker is fixed. One non-blocking gap remains: nodes still carrying the old template's explicit flatkv.snapshot-keep-recent value won't get the new depth.

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

Blockers

  • None at the file/PR level.

Non-blocking

  • None at the file/PR level.
  • 1 suggestion(s)/nit(s) flagged inline on specific lines.

Inline comments (could not post inline; listed here)

  • sei-db/state_db/sc/composite/store.go:206 (RIGHT) -- [suggestion] Once keep-recent stops being mirrored, a stale explicit state-commit.flatkv.snapshot-keep-recent wins again. An older app.toml template rendered that key, and the old comment here says so. GetConfig still reads it when it is set (sei-cosmos/server/config/config.go). Before this PR, the unconditional mirror overwrote that stale value; now an upgrading node whose app.toml still has snapshot-keep-recent = 1 keeps retention at 1. That node doesn't get the 100k-block reach this fix is meant to provide. The comment above explicitly handles the stale interval case but not this one. Either document it in the changelog/upgrade notes (operators should remove or raise the key) or decide on a policy for it, such as a startup warning when the value is below the default.

@alexander-sei
alexander-sei merged commit d756203 into release/v6.7 Sep 25, 2026
73 checks passed
@alexander-sei
alexander-sei deleted the backport-4322-to-release/v6.7 branch September 25, 2026 19:47
alexander-sei added a commit that referenced this pull request Sep 25, 2026
Regenerated with ./scripts/generate-changelog.sh release/v6.6 release/v6.7.

Co-authored-by: Cursor <cursoragent@cursor.com>
masih pushed a commit that referenced this pull request Oct 1, 2026
Adds the `release/v6.7` entries merged since the rc2 changelog (#4293),
in prep to cut **v6.7.0-rc4**. The rc3 update (#4335) was closed without
merging, so its entries are included here:

- [#4411](#4411) — Log a
pinned node's skipped migration kick-off once per batch size
- [#4410](#4410) — Apply
compiled KV repair files at a fixed height and generate them from digest
inspect lists
- [#4409](#4409) — feat:
add migration pause handler
- [#4397](#4397) —
fix(evmrpc): release eth_getLogs DB-read slots when a block read panics
- [#4378](#4378) — Raise
goreleaser timeout to 2h
- [#4377](#4377) — Fix
FlatKV state sync bad-hash scenario
- [#4371](#4371) —
fix(seidb): keep writes in the old DB until the migration boundary first
moves
- [#4348](#4348) —
fix(seidb): report only the current migration boundary on the snapshot
gauge
- [#4347](#4347) —
fix(flatkv): keep 10 old checkpoints instead of mirroring memIAVL's
count
- [#4339](#4339) — rc3
version bump
- [#4334](#4334) — Fail
dynamic-gas precompile out-of-gas as an EVM out-of-gas call
- [#4315](#4315) — Pin the
Go builder image per architecture in build-static.sh
- [#4313](#4313) —
fix(memiavl): hold a snapshot reference for an iterator's lifetime
- [#4295](#4295) — rc2
version bump
- [#4294](#4294) — rc2
changelog backport

Also returns `## v6.7` to the format used through v6.6: the version
heading, `sei-chain`, and the generated PR list. The hand-written `###
Improvements` and `### Upgrade guide` sections are removed; every PR
they described is already a line in the generated list.

Regenerated with `./scripts/generate-changelog.sh release/v6.6
release/v6.7`; only the `## v6.7` section changes. Docs-only; no code
change.

**Backport note:** the #4347 backport added its own line to the top of
the `## v6.7` list on `release/v6.7`, and `main` doesn't have it, so the
`backport release/v6.7` cherry-pick of this PR conflicts at that one
spot (simulated with `git merge-tree`). Resolve it by taking this PR's
side: its fifteen lines already include #4347.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
masih pushed a commit that referenced this pull request Oct 1, 2026
#4415, seidroid's backport of #4406, was merged with its
`BACKPORT-CONFLICT` placeholder commit, which committed the unresolved
cherry-pick into `CHANGELOG.md` on `release/v6.7`: three conflict-marker
lines, plus a duplicate #4347 line from the `release/v6.7` side.

This removes those four lines and keeps #4406's side, which already
lists #4347. Afterwards:

- `## v6.7` matches `./scripts/generate-changelog.sh release/v6.6
release/v6.7` again. The #4415 line itself is left for the next
changelog update, as with earlier changelog backports.
- The `## v6.7` section is identical on `release/v6.7` and `main`, so
the next changelog backport applies cleanly.

Docs-only; no code change. Should merge before the rc4 version bump
(#4407), so v6.7.0-rc4 ships a clean changelog.

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