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
23 changes: 16 additions & 7 deletions sei-db/config/ss_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ package config
type DBBackend string

const (
DefaultSSKeepRecent = 100000
DefaultSSPruneInterval = 600
DefaultSSImportWorkers = 1
DefaultSSAsyncBuffer = 100
PebbleDBBackend = "pebbledb"
RocksDBBackend = "rocksdb"
DefaultSSBackend = PebbleDBBackend
DefaultSSKeepRecent = 100000
DefaultSSPruneInterval = 600
DefaultSSImportWorkers = 1
DefaultSSAsyncBuffer = 100
PebbleDBBackend = "pebbledb"
RocksDBBackend = "rocksdb"
DefaultSSBackend = PebbleDBBackend
DefaultSSCacheSizeBytes = 32 * 1024 * 1024
)

// StateStoreConfig defines configuration for the state store (SS) layer.
Expand Down Expand Up @@ -76,6 +77,13 @@ type StateStoreConfig struct {
// When true, data is routed to separate DBs by EVM key family while
// preserving the same logical store key and full key encoding inside each DB.
SeparateEVMSubDBs bool `mapstructure:"evm-separate-dbs"`

// CacheSizeBytes defines the pebbledb block cache size (in bytes) for the
// state store backend. Historical reads (e.g. eth debug_trace*, archival
// queries) are served from the SS backend rather than memIAVL, so a larger
// cache reduces disk-bound random reads. Set <= 0 to use the default.
// defaults to 32 MiB
CacheSizeBytes int64 `mapstructure:"cache-size-bytes"`
}

// DefaultStateStoreConfig returns the default StateStoreConfig
Expand All @@ -91,5 +99,6 @@ func DefaultStateStoreConfig() StateStoreConfig {
UseDefaultComparer: false,
EVMSplit: false,
SeparateEVMSubDBs: false,
CacheSizeBytes: DefaultSSCacheSizeBytes,
}
}
6 changes: 6 additions & 0 deletions sei-db/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ evm-ss-split = {{ .StateStore.EVMSplit }}
# When false, all EVM data stays in one DB using the current unified layout.
# When true, data is routed to separate DBs while preserving the same evm key prefix format.
evm-ss-separate-dbs = {{ .StateStore.SeparateEVMSubDBs }}

# CacheSizeBytes defines the pebbledb block cache size (in bytes) for the state store.
# Historical reads (e.g. eth debug_trace*, archival queries) are served from the SS
# backend rather than memIAVL, so a larger cache reduces disk-bound random reads.
# Set <= 0 to use the default. Defaults to 33554432 (32 MiB).
ss-cache-size-bytes = {{ .StateStore.CacheSizeBytes }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

App.toml cache size ignored

Medium Severity

The template adds ss-cache-size-bytes under [state-store], but node startup still builds StateStoreConfig via parseSSConfigs in app/seidb.go, which never reads state-store.ss-cache-size-bytes. Custom values in app.toml therefore never reach OpenDB, so operators cannot increase the Pebble block cache despite the new setting.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ee4960b. Configure here.

`

// ReceiptStoreConfigTemplate defines the configuration template for receipt-store
Expand Down
12 changes: 8 additions & 4 deletions sei-db/db_engine/pebbledb/mvcc/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

errorutils "github.com/sei-protocol/sei-chain/sei-db/common/errors"
"github.com/sei-protocol/sei-chain/sei-db/common/utils"
"github.com/sei-protocol/sei-chain/sei-db/config"
seidbconfig "github.com/sei-protocol/sei-chain/sei-db/config"
"github.com/sei-protocol/sei-chain/sei-db/db_engine/types"
"github.com/sei-protocol/sei-chain/sei-db/proto"
"github.com/sei-protocol/sei-chain/sei-db/wal"
Expand Down Expand Up @@ -60,7 +60,7 @@ var (
type Database struct {
storage *pebble.DB
asyncWriteWG sync.WaitGroup
config config.StateStoreConfig
config seidbconfig.StateStoreConfig
// Earliest version for db after pruning
earliestVersion atomic.Int64
// Latest version for db
Expand Down Expand Up @@ -92,8 +92,12 @@ type VersionedChangesets struct {
Done chan struct{} // non-nil for barrier: closed when this entry is processed
}

func OpenDB(dataDir string, config config.StateStoreConfig) (types.StateStore, error) {
cache := pebble.NewCache(1024 * 1024 * 32)
func OpenDB(dataDir string, config seidbconfig.StateStoreConfig) (types.StateStore, error) {
cacheSizeBytes := config.CacheSizeBytes
if cacheSizeBytes <= 0 {
cacheSizeBytes = seidbconfig.DefaultSSCacheSizeBytes
}
cache := pebble.NewCache(cacheSizeBytes)
defer cache.Unref()

// Select comparer based on config. Note: UseDefaultComparer is NOT backwards compatible
Expand Down