Skip to content

Conversation

@Kbhat1
Copy link
Contributor

@Kbhat1 Kbhat1 commented Jan 23, 2026

Describe your changes and provide context

  • EVMDatabase: Single PebbleDB with DefaultComparer for each EVM data type
  • EVMStateStore: Manages multiple EVMDatabase instances (nonce, code, codehash, codesize, storage)
  • Versioned key encoding with big-endian version suffix
  • ApplyBatch and ApplyChangesetParallel for efficient concurrent writes
  • Uses commonevm.ParseMemIAVLEVMKey directly for key routing

Testing performed to validate your change

  • Unit tests

@Kbhat1 Kbhat1 changed the title Composite State Store part 2: EVM database implementation Composite State Store Part 2: EVM database implementation Jan 23, 2026
@github-actions
Copy link

github-actions bot commented Jan 23, 2026

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJan 30, 2026, 4:41 AM

@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

❌ Patch coverage is 55.10836% with 145 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.87%. Comparing base (57817ce) to head (0e57958).
⚠️ Report is 1 commits behind head on feature/evm-ss-router-config.

Files with missing lines Patch % Lines
sei-db/state_db/ss/evm/store.go 27.61% 67 Missing and 9 partials ⚠️
sei-db/state_db/ss/evm/db.go 68.34% 40 Missing and 29 partials ⚠️

❗ There is a different number of reports uploaded between BASE (57817ce) and HEAD (0e57958). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (57817ce) HEAD (0e57958)
sei-tendermint 1 0
Additional details and impacted files

Impacted file tree graph

@@                       Coverage Diff                        @@
##           feature/evm-ss-router-config    #2755      +/-   ##
================================================================
- Coverage                         52.14%   42.87%   -9.28%     
================================================================
  Files                              1963     1644     -319     
  Lines                            156946   129682   -27264     
================================================================
- Hits                              81835    55597   -26238     
- Misses                            67466    69074    +1608     
+ Partials                           7645     5011    -2634     
Flag Coverage Δ
sei-chain 45.97% <55.10%> (+4.30%) ⬆️
sei-cosmos 37.72% <ø> (?)
sei-db 68.72% <ø> (ø)
sei-tendermint ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sei-db/state_db/ss/evm/db.go 68.34% <68.34%> (ø)
sei-db/state_db/ss/evm/store.go 27.61% <27.61%> (ø)

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

Comment on lines +367 to +368
for keyStr, value := range keyValues {
if value != nil { // Skip tombstones
keys = append(keys, []byte(keyStr))
values = append(values, value)
}
}

Check warning

Code scanning / CodeQL

Iteration over map Warning

Iteration over map may be a possible source of non-determinism
@Kbhat1 Kbhat1 force-pushed the feature/evm-ss-router-config branch from ac83d2f to 0935d03 Compare January 23, 2026 22:08
@Kbhat1 Kbhat1 force-pushed the feature/evm-ss-database branch from 7271005 to 7ef1b00 Compare January 23, 2026 22:08
@Kbhat1 Kbhat1 force-pushed the feature/evm-ss-database branch from 7ef1b00 to 906d2ed Compare January 27, 2026 19:34
Comment on lines +75 to +83
for storeType, pairs := range changes {
db := s.databases[storeType]
if db == nil {
continue
}
if err := db.ApplyBatch(pairs, version); err != nil {
return fmt.Errorf("failed to apply batch for %s: %w", StoreTypeName(storeType), err)
}
}

Check warning

Code scanning / CodeQL

Iteration over map Warning

Iteration over map may be a possible source of non-determinism
Comment on lines +101 to +114
for storeType, pairs := range changes {
db := s.databases[storeType]
if db == nil {
continue
}

wg.Add(1)
go func(db *EVMDatabase, pairs []*iavl.KVPair) {
defer wg.Done()
if err := db.ApplyBatch(pairs, version); err != nil {
errCh <- err
}
}(db, pairs)
}

Check warning

Code scanning / CodeQL

Iteration over map Warning

Iteration over map may be a possible source of non-determinism
Comment on lines +129 to +133
for _, db := range s.databases {
if v := db.GetLatestVersion(); v > maxVersion {
maxVersion = v
}
}

Check warning

Code scanning / CodeQL

Iteration over map Warning

Iteration over map may be a possible source of non-determinism
Comment on lines +139 to +143
for _, db := range s.databases {
if err := db.SetLatestVersion(version); err != nil {
return err
}
}

Check warning

Code scanning / CodeQL

Iteration over map Warning

Iteration over map may be a possible source of non-determinism
Comment on lines +150 to +155
for _, db := range s.databases {
v := db.GetEarliestVersion()
if minVersion < 0 || v < minVersion {
minVersion = v
}
}

Check warning

Code scanning / CodeQL

Iteration over map Warning

Iteration over map may be a possible source of non-determinism
Comment on lines +164 to +168
for _, db := range s.databases {
if err := db.SetEarliestVersion(version); err != nil {
return err
}
}

Check warning

Code scanning / CodeQL

Iteration over map Warning

Iteration over map may be a possible source of non-determinism
Comment on lines +185 to +208
for _, db := range s.databases {
if err := db.Close(); err != nil {
lastErr = err
}
}

Check warning

Code scanning / CodeQL

Iteration over map Warning

Iteration over map may be a possible source of non-determinism
Comment on lines +108 to +113
go func(db *EVMDatabase, pairs []*iavl.KVPair) {
defer wg.Done()
if err := db.ApplyBatch(pairs, version); err != nil {
errCh <- err
}
}(db, pairs)

Check notice

Code scanning / CodeQL

Spawning a Go routine Note

Spawning a Go routine may be a possible source of non-determinism
Adds the core EVM state store components:

db.go - EVMDatabase (single PebbleDB for a specific EVM data type):
- Uses DefaultComparer (lexicographic byte ordering)
- Versioned key encoding with big-endian version suffix
- ApplyBatch for efficient batch writes
- EVMIterator for version-aware iteration (for state dumps/full scans)

store.go - EVMStateStore (manages multiple EVMDatabase instances):
- Manages databases for nonce, code, codehash, codesize, storage
- ApplyChangesetParallel for concurrent writes to multiple DBs
- Uses commonevm.ParseEVMKey directly for key routing
@Kbhat1 Kbhat1 force-pushed the feature/evm-ss-database branch from 906d2ed to 851b64c Compare January 28, 2026 02:35
Comment on lines +181 to +189
for _, db := range s.databases {
wg.Add(1)
go func(db *EVMDatabase) {
defer wg.Done()
if err := db.Prune(version); err != nil {
errCh <- err
}
}(db)
}

Check warning

Code scanning / CodeQL

Iteration over map Warning

Iteration over map may be a possible source of non-determinism
Comment on lines +183 to +188
go func(db *EVMDatabase) {
defer wg.Done()
if err := db.Prune(version); err != nil {
errCh <- err
}
}(db)

Check notice

Code scanning / CodeQL

Spawning a Go routine Note

Spawning a Go routine may be a possible source of non-determinism
Copy link
Contributor

@yzang2019 yzang2019 left a comment

Choose a reason for hiding this comment

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

Please also address all lint issues

- Use runtime.NumCPU() for MaxConcurrentCompactions
- Remove sync writes for version metadata (improves performance)
- Parallelize EVMStateStore.Prune across all databases
@Kbhat1 Kbhat1 force-pushed the feature/evm-ss-database branch from 851b64c to 3801df9 Compare January 29, 2026 17:53
- Fix errcheck: properly handle Close() error returns with _ = or defer func
- Fix gosec G115: add nolint comments for safe int64/uint64 conversions
- Fix staticcheck S1009: remove redundant nil checks before len()
- Use atomic.Int64 for latestVersion/earliestVersion to fix race condition
- Add github.com/cockroachdb/pebble v1.1.2 as direct dependency (was indirect)
- All lint fixes from previous commit included
"encoding/binary"
"fmt"
"path/filepath"
"runtime"

Check notice

Code scanning / CodeQL

Sensitive package import Note

Certain system packages contain functions which may be a possible source of non-determinism
@Kbhat1 Kbhat1 requested a review from yzang2019 January 30, 2026 04:47
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.

4 participants