From 3083e20e2e51e21145808faf56689b199c1b7079 Mon Sep 17 00:00:00 2001 From: yzang2019 Date: Thu, 8 Jan 2026 03:16:45 -0800 Subject: [PATCH 1/2] Only take new snapshot on snapshot interval heights --- sei-db/state_db/sc/memiavl/db.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sei-db/state_db/sc/memiavl/db.go b/sei-db/state_db/sc/memiavl/db.go index 458f3db81c..07473549a2 100644 --- a/sei-db/state_db/sc/memiavl/db.go +++ b/sei-db/state_db/sc/memiavl/db.go @@ -720,7 +720,7 @@ func (db *DB) rewriteIfApplicable(height int64) { // Create snapshot when both conditions are met: // 1. Block height interval is reached (height - last snapshot >= interval) // 2. Minimum time interval has elapsed (prevents excessive snapshots during catch-up) - if blocksSinceLastSnapshot >= int64(db.snapshotInterval) { + if blocksSinceLastSnapshot >= int64(db.snapshotInterval) && height%int64(db.snapshotInterval) == 0 { timeSinceLastSnapshot := time.Since(db.lastSnapshotTime) if timeSinceLastSnapshot < db.snapshotMinTimeInterval { From 7aa7c0e89995e8863e2e60e054b6f5c99debcf6f Mon Sep 17 00:00:00 2001 From: yzang2019 Date: Thu, 8 Jan 2026 03:17:31 -0800 Subject: [PATCH 2/2] Fix comments --- sei-db/state_db/sc/memiavl/db.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sei-db/state_db/sc/memiavl/db.go b/sei-db/state_db/sc/memiavl/db.go index 07473549a2..bdc2c90223 100644 --- a/sei-db/state_db/sc/memiavl/db.go +++ b/sei-db/state_db/sc/memiavl/db.go @@ -717,9 +717,10 @@ func (db *DB) rewriteIfApplicable(height int64) { snapshotVersion := db.SnapshotVersion() blocksSinceLastSnapshot := height - snapshotVersion - // Create snapshot when both conditions are met: + // Create snapshot when all conditions are met: // 1. Block height interval is reached (height - last snapshot >= interval) // 2. Minimum time interval has elapsed (prevents excessive snapshots during catch-up) + // 3. Block height % snapshot interval == 0 if blocksSinceLastSnapshot >= int64(db.snapshotInterval) && height%int64(db.snapshotInterval) == 0 { timeSinceLastSnapshot := time.Since(db.lastSnapshotTime)