Skip to content

Upgrade to PebbleDB v2 + Add DefaultComparer Config Option#2695

Merged
Kbhat1 merged 14 commits intomainfrom
PebbleDefaultMVCC
Jan 20, 2026
Merged

Upgrade to PebbleDB v2 + Add DefaultComparer Config Option#2695
Kbhat1 merged 14 commits intomainfrom
PebbleDefaultMVCC

Conversation

@Kbhat1
Copy link
Copy Markdown
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
Copy Markdown

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 20, 2026, 3:04 PM

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 12, 2026

Codecov Report

❌ Patch coverage is 61.70213% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.00%. Comparing base (7d1130e) to head (c59e1a9).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sei-db/state_db/ss/test/storage_test_suite.go 0.00% 13 Missing ⚠️
sei-db/db_engine/pebbledb/mvcc/db.go 80.95% 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   44.00%   44.00%   -0.01%     
==========================================
  Files        1980     1980              
  Lines      162718   162724       +6     
==========================================
- Hits        71612    71607       -5     
- Misses      84590    84595       +5     
- Partials     6516     6522       +6     
Flag Coverage Δ
sei-chain 46.19% <61.70%> (+<0.01%) ⬆️
sei-cosmos 38.20% <ø> (-0.01%) ⬇️
sei-db 68.72% <ø> (ø)
sei-tendermint 47.27% <ø> (-0.03%) ⬇️

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 90.41% <100.00%> (+0.27%) ⬆️
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.80% <80.95%> (+0.55%) ⬆️
sei-db/state_db/ss/test/storage_test_suite.go 0.00% <0.00%> (ø)

... and 11 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@@ -83,15 +83,24 @@ func OpenDB(dataDir string, config config.StateStoreConfig) (*Database, error) {
cache := pebble.NewCache(1024 * 1024 * 32)
Copy link
Copy Markdown
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?

@Kbhat1 Kbhat1 merged commit e52b2a7 into main Jan 20, 2026
61 of 65 checks passed
@Kbhat1 Kbhat1 deleted the PebbleDefaultMVCC branch January 20, 2026 15:50
jewei1997 pushed a commit that referenced this pull request Feb 24, 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
yzang2019 pushed a commit that referenced this pull request Feb 25, 2026
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

- Added unit tests
- Tested on node to verify state sync + queries worked
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