Skip to content

Conversation

@Kbhat1
Copy link
Contributor

@Kbhat1 Kbhat1 commented Jan 12, 2026

Describe your changes and provide context

PebbleDB v2 Upgrade:

  • Benchmarks show significant improvements in write/read throughput and latency
  • Updated imports across sei-db/db_engine/pebbledb/ and sei-db/db_engine/pebbledb/mvcc/
  • Added required v2 comparer functions (ComparePointSuffixes, CompareRangeSuffixes)
  • Updated metrics API to use v2 field names

DefaultComparer Option:

  • UseDefaultComparer config enables Pebble's default lexicographic comparer instead of custom MVCCComparer
  • Only available programmatically via StateStoreConfig - intentionally NOT exposed in TOML
  • Useful for modules like EVM where MVCC iteration isn't needed
  • MVCC key encoding already uses BigEndian for versions, so ordering is compatible

Testing performed to validate your change

  • Added unit tests
  • Tested on node to verify state sync + queries worked

@github-actions
Copy link

github-actions bot commented Jan 12, 2026

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJan 16, 2026, 8:02 PM

@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

❌ Patch coverage is 24.07407% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.74%. Comparing base (91ef5cb) to head (8d16815).

Files with missing lines Patch % Lines
sei-db/state_db/ss/test/storage_test_suite.go 0.00% 36 Missing ⚠️
sei-db/db_engine/pebbledb/mvcc/db.go 69.23% 4 Missing ⚠️
sei-db/config/config.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2695      +/-   ##
==========================================
- Coverage   43.76%   43.74%   -0.02%     
==========================================
  Files        1914     1914              
  Lines      159504   159536      +32     
==========================================
- Hits        69801    69785      -16     
- Misses      83284    83329      +45     
- Partials     6419     6422       +3     
Flag Coverage Δ
sei-chain 45.73% <24.07%> (-0.04%) ⬇️
sei-cosmos 38.20% <ø> (-0.01%) ⬇️
sei-db 68.72% <ø> (ø)
sei-tendermint 47.26% <ø> (-0.02%) ⬇️

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

Files with missing lines Coverage Δ
sei-db/db_engine/pebbledb/batch.go 100.00% <ø> (ø)
sei-db/db_engine/pebbledb/db.go 89.39% <100.00%> (-0.75%) ⬇️
sei-db/db_engine/pebbledb/iterator.go 100.00% <ø> (ø)
sei-db/db_engine/pebbledb/mvcc/batch.go 77.90% <ø> (ø)
sei-db/db_engine/pebbledb/mvcc/comparator.go 60.00% <ø> (ø)
sei-db/db_engine/pebbledb/mvcc/iterator.go 54.20% <ø> (ø)
sei-db/config/config.go 0.00% <0.00%> (ø)
sei-db/db_engine/pebbledb/mvcc/db.go 55.25% <69.23%> (ø)
sei-db/state_db/ss/test/storage_test_suite.go 0.00% <0.00%> (ø)

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

@Kbhat1 Kbhat1 requested review from blindchaser and yzang2019 and removed request for yzang2019 January 12, 2026 23:56
@Kbhat1 Kbhat1 requested a review from jewei1997 January 13, 2026 05:03

// Select comparer based on config. Note: UseDefaultComparer is NOT backwards compatible
// with existing databases created with MVCCComparer - Pebble will refuse to open due to
// comparer name mismatch. Only use UseDefaultComparer for NEW databases.
Copy link
Contributor

Choose a reason for hiding this comment

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

if mismatch happens, is there a way we can show some errors to the user?

Copy link
Contributor

Choose a reason for hiding this comment

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

or the pebble already has the error inside?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will fail to open the db @blindchaser , so error will show up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will paste snippet of the error

@Kbhat1 Kbhat1 changed the title Support Default Pebble Comparer PebbleDB V2 and Default Comparer Jan 14, 2026
@Kbhat1 Kbhat1 changed the title PebbleDB V2 and Default Comparer Upgrade to PebbleDB v2 + Add DefaultComparer Config Option Jan 14, 2026
@Kbhat1
Copy link
Contributor Author

Kbhat1 commented Jan 14, 2026

@yzang2019 @yzang2019 @jewei1997 please take a look again

@Kbhat1 Kbhat1 requested a review from masih January 16, 2026 15:13
// instead of MVCCComparer. This is useful for new databases that don't need backwards compatibility.
// Note: Iterator tests are skipped because DefaultComparer doesn't have the Split function
// configured for MVCC key encoding, so NextPrefix/SeekLT operations won't work correctly.
func TestStorageTestSuiteDefaultComparer(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@masih likely a cleaner way to do this, but we want to eventually remove all iteration from state store. Right now its an artifact of cosmos (iteration) in v2

}

func (s *StorageTestSuite) TestDatabaseIteratorEmptyDomain() {
if slices.Contains(s.SkipTests, s.T().Name()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@masih again, likely a cleaner way to do this, but we want to eventually remove all iteration from state store. Right now its an artifact of cosmos (iteration) in v2

}

func OpenDB(dataDir string, config config.StateStoreConfig) (*Database, error) {
cache := pebble.NewCache(1024 * 1024 * 32)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unrelated to this PR: we probably should bump this value. It seems small for seid?

"TestStorageTestSuiteDefaultComparer/TestDatabasePrune",
"TestStorageTestSuiteDefaultComparer/TestDatabasePruneKeepRecent",
"TestStorageTestSuiteDefaultComparer/TestParallelWriteAndPruning",
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is unfortunately error-prone, and can silently result in false negative test failures if we rename any of the tests.

My advice would be to avoid this. I see 2 options:

  1. fork the test sets that we want to have going forward for the default comparator. Then when the MVCC comparator retires remove entire tests for it.

  2. break up the test suits into 2, and have one extend the other where the extended suit runs the current superset of tests for MVCC. This solves your concern about code drift and would avoid the kind of config we see here as well as conditional skip tests. Let me know if you have questions on how to extend the suit while avoiding duplicate code

Copy link
Contributor Author

@Kbhat1 Kbhat1 Jan 16, 2026

Choose a reason for hiding this comment

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

Yea I think for (1) I was concerned about the forks not matching. (2) seems reasonable, let me think on this though if there is a more efficient approach

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.

5 participants