-
Notifications
You must be signed in to change notification settings - Fork 861
Composite State Store Part 2: EVM database implementation #2755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/evm-ss-router-config
Are you sure you want to change the base?
Conversation
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| 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
ac83d2f to
0935d03
Compare
7271005 to
7ef1b00
Compare
7ef1b00 to
906d2ed
Compare
| 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
| 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
| for _, db := range s.databases { | ||
| if v := db.GetLatestVersion(); v > maxVersion { | ||
| maxVersion = v | ||
| } | ||
| } |
Check warning
Code scanning / CodeQL
Iteration over map Warning
| for _, db := range s.databases { | ||
| if err := db.SetLatestVersion(version); err != nil { | ||
| return err | ||
| } | ||
| } |
Check warning
Code scanning / CodeQL
Iteration over map Warning
| for _, db := range s.databases { | ||
| v := db.GetEarliestVersion() | ||
| if minVersion < 0 || v < minVersion { | ||
| minVersion = v | ||
| } | ||
| } |
Check warning
Code scanning / CodeQL
Iteration over map Warning
| for _, db := range s.databases { | ||
| if err := db.SetEarliestVersion(version); err != nil { | ||
| return err | ||
| } | ||
| } |
Check warning
Code scanning / CodeQL
Iteration over map Warning
| for _, db := range s.databases { | ||
| if err := db.Close(); err != nil { | ||
| lastErr = err | ||
| } | ||
| } |
Check warning
Code scanning / CodeQL
Iteration over map Warning
| 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
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
906d2ed to
851b64c
Compare
| 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
| 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
yzang2019
left a comment
There was a problem hiding this 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
851b64c to
3801df9
Compare
- 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
Describe your changes and provide context
Testing performed to validate your change