Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#3818](https://github.com/sei-protocol/sei-chain/pull/3818) feat(evmrpc): extend HTTP admission control (`max_request_body_bytes`, `max_concurrent_request_bytes`, `ws_admission_timeout`) to the WebSocket plane (:8546). WS oversize frames close with WebSocket close code 1009; budget-wait timeouts return JSON-RPC error `-32005` before the connection closes. `evmrpc_requests_rejected_total` gains a `protocol` label (`http` / `ws`).
* [#3984](https://github.com/sei-protocol/sei-chain/pull/3984) feat(query): origin-aware pagination limits for ABCI queries. Untrusted callers on the ABCI/gRPC query path get configurable `max-limit`, `max-offset`, and flat `max-iterations` (defaults: 1000 / 10000 / 11000); requests above the caps are rejected upfront, and an exhausted iteration budget returns a partial page with `next_key` instead of failing. Trusted origins (new `[query] trusted-cidrs`) and the `[query] disable-limits` kill switch bypass the caps; the consensus/EVM precompile path is unaffected.
* [#3990](https://github.com/sei-protocol/sei-chain/pull/3990) Freeze mode is limited to full nodes and disables transaction and evidence submission, mempool gossip, and state sync from startup while preserving query RPC and mempool-backed reads. Frozen and Autobahn nodes no longer advertise the unused mempool P2P channel.
* [#4158](https://github.com/sei-protocol/sei-chain/pull/4158) fix(flatkv): FlatKV keeps 10 old PebbleDB checkpoints instead of the 1 it inherited from memIAVL's `state-commit.sc-keep-recent`. Its snapshot *interval* is unchanged; only the retention count moves. This raises the guaranteed reach of `migrate-evm-status`, `dump-flatkv`, a cross-backend digest and a FlatKV rollback from 10,000 blocks (about 74 minutes) to 100,000 blocks (about 12 hours), which covers the roughly 50,000-block gap between memIAVL snapshot publications at mainnet state size — below that gap the two backends never retain a common version. It costs about 2.8 GiB of extra disk on a mainnet-sized node, because checkpoints hardlink their SSTs and so pin only what compaction has since obsoleted. No `app.toml` change is needed.

### Upgrade guide
* **IBC core removal.** Removes the retired IBC core source, protobufs, light clients, CLI, and simulation support. Retired IBC stores remain mounted but are omitted from `export-genesis`; preserve the state database or use v6.6 freeze nodes for historical IBC data.
Expand Down
2 changes: 1 addition & 1 deletion app/testdata/state-commit.golden
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ FlatKVConfig.DataDir = string("")
FlatKVConfig.Fsync = bool(false)
FlatKVConfig.AsyncWriteBuffer = int(0)
FlatKVConfig.SnapshotInterval = uint32(10000)
FlatKVConfig.SnapshotKeepRecent = uint32(1)
FlatKVConfig.SnapshotKeepRecent = uint32(10)
FlatKVConfig.ExternalPruning = bool(false)
FlatKVConfig.EnablePebbleMetrics = bool(true)
FlatKVConfig.EnableReadWriteMetrics = bool(false)
Expand Down
2 changes: 1 addition & 1 deletion sei-cosmos/server/config/testdata/server_config.golden
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ StateCommit.FlatKVConfig.DataDir = string("")
StateCommit.FlatKVConfig.Fsync = bool(false)
StateCommit.FlatKVConfig.AsyncWriteBuffer = int(0)
StateCommit.FlatKVConfig.SnapshotInterval = uint32(10000)
StateCommit.FlatKVConfig.SnapshotKeepRecent = uint32(1)
StateCommit.FlatKVConfig.SnapshotKeepRecent = uint32(10)
StateCommit.FlatKVConfig.ExternalPruning = bool(false)
StateCommit.FlatKVConfig.EnablePebbleMetrics = bool(true)
StateCommit.FlatKVConfig.EnableReadWriteMetrics = bool(false)
Expand Down
26 changes: 23 additions & 3 deletions sei-db/state_db/sc/flatkv/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,25 @@ import (
)

const (
DefaultSnapshotInterval uint32 = 10000
DefaultSnapshotKeepRecent uint32 = 1
DefaultSnapshotInterval uint32 = 10000
// DefaultSnapshotKeepRecent is how many old checkpoints (besides the latest) to keep,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[suggestion] This godoc is three paragraphs of rationale, measurement, and mechanism, which is what AGENTS.md's "Godoc" section rules out: godocs say what a thing is, not why it came to be or how it works inside; rationale belongs in an inline comment at the line that needs it, and multi-paragraph godocs are rare.

Suggest collapsing to the what and moving the sizing argument to an inline comment on the constant:

// DefaultSnapshotKeepRecent is how many old checkpoints, besides the latest, FlatKV
// retains. At DefaultSnapshotInterval that is a guaranteed reach of 100,000 blocks.

The memIAVL-publication-rate derivation and the 2.8 GiB disk measurement are genuinely load-bearing and worth keeping — just not in the godoc. The measured numbers in particular will age, and an inline comment is where a future reader expects to find a value that was tuned against a specific state size.

// which at the default interval is a guaranteed reach of 100,000 blocks — about 12 hours
// at mainnet's block rate.
//
// It is sized against memIAVL's publication rate rather than against FlatKV's own disk
// use. A composite read needs a version both backends still hold, and at mainnet state
// size a memIAVL rewrite takes about six hours against this 10000-block interval, so
// memIAVL skips generations and publishes roughly every 50,000 blocks. Keeping a single
// old checkpoint reaches back 10,000 to 20,000 blocks, so FlatKV prunes each version
Comment on lines +17 to +21

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 Shorten the exported constant's Godoc

This exported constant's Godoc devotes three paragraphs to publication mechanics, operational rationale, and measured disk costs rather than briefly describing what the constant represents. Move any load-bearing rationale to the relevant implementation and keep this Godoc to one or two subject-focused sentences, as required by the repository's documentation rules.

AGENTS.md reference: AGENTS.md:L61-L72

Useful? React with 👍 / 👎.

// before memIAVL publishes it and no common version ever exists — which is what blocks a
// cross-backend digest and leaves a composite rollback with no shared base.
//
// Depth is affordable here because a checkpoint hardlinks its SSTs, so one costs only the
// bytes compaction has since made obsolete: measured at mainnet state size, 261 MiB of
// pinned SSTs plus about 25 MiB of retained state WAL, or roughly 2.8 GiB for ten. The
// cost is linear in depth, because each older checkpoint pins exactly the files obsoleted
// during its own interval and those sets are disjoint.
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 Stop overwriting the new FlatKV retention default

Whenever FlatKV is opened through the production composite constructor, NewCompositeCommitStore calls alignFlatKVSnapshotWithMemIAVL (sei-db/state_db/sc/composite/store.go:152), which unconditionally replaces this value with memIAVL's effective keep-recent count (store.go:225-228), still 1 by default. Consequently, default-configured nodes continue retaining one old FlatKV checkpoint, so the intended shared-version window and rollback fix never take effect; update the alignment logic rather than only this overwritten default.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[blocker] This new default never takes effect on a production node, so the PR does not change FlatKV retention at all.

NewCompositeCommitStore calls alignFlatKVSnapshotWithMemIAVL(&cfg) (sei-db/state_db/sc/composite/store.go:152), which unconditionally does:

interval, keepRecent := config.EffectiveMemIAVLSnapshotCadence(cfg.MemIAVLConfig)
cfg.FlatKVConfig.SnapshotInterval = interval
cfg.FlatKVConfig.SnapshotKeepRecent = keepRecent   // store.go:228

EffectiveMemIAVLSnapshotCadence resolves to memiavl.DefaultSnapshotKeepRecent, which is still 1 (sei-db/state_db/sc/memiavl/config.go:8). The production path sei-cosmos/storev2/rootmulti/store.go:130 goes through that constructor, and app/seidb.go never sets FlatKVConfig.SnapshotKeepRecent either — so the store that actually prunes (pruneSnapshotsByCount, sei-db/state_db/sc/flatkv/snapshot.go:462) still reads 1. The reach stays at 10,000–20,000 blocks and the memIAVL publication gap the PR describes is not covered.

The two updated golden files only pin the GetConfig/DefaultConfig parse result, which is upstream of the override, so they go green without the behavior changing.

The fix belongs at the choke point that creates the divergence: drop SnapshotKeepRecent from alignFlatKVSnapshotWithMemIAVL (keeping the interval mirror, which the surrounding doc comment justifies separately), rewrite that function's doc comment so it no longer claims keep-recent is derived from sc-keep-recent, and update the TestAlignFlatKVSnapshotWithMemIAVL subtests at sei-db/state_db/sc/composite/store_test.go:2574 that currently assert the mirroring.

Relatedly, the new field doc below (line 61) — "It is not mirrored from memIAVL's sc-keep-recent ... so a production node runs the DefaultConfig value" — is the statement this PR needs to make true; today it is contradicted by store.go:228.

)

// Config defines configuration for the FlatKV (EVM) commit store.
Expand Down Expand Up @@ -40,7 +57,10 @@ type Config struct {
// SnapshotKeepRecent defines how many old snapshots to keep besides the
// latest one. 0 means keep only the current snapshot (no old snapshots).
// Ignored entirely when ExternalPruning is set.
// Default: 1
//
// It is not mirrored from memIAVL's sc-keep-recent, and no app.toml key is rendered for
// it, so a production node runs the DefaultConfig value.
// Default: 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.

Alignment overwrites new keep-recent default

High Severity

Raising DefaultSnapshotKeepRecent to 10 does not change what a production node keeps. NewCompositeCommitStore still runs alignFlatKVSnapshotWithMemIAVL, which overwrites FlatKV's keep-recent with memIAVL's sc-keep-recent (default 1). Nodes therefore still retain one old checkpoint, so the cross-backend digest and composite rollback gap this change aims to close remains.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1c02b9a. Configure here.

SnapshotKeepRecent uint32 `mapstructure:"snapshot-keep-recent"`

// ExternalPruning hands retention to the StorageGarbageCollector: the store stops pruning its
Expand Down
Loading