-
Notifications
You must be signed in to change notification settings - Fork 829
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
Add tools to scan and compute hash for IAVL db #2059
Conversation
go func(index int, data chan types.RawSnapshotNode) { | ||
defer wg.Done() | ||
var hashResult []byte | ||
for item := range subsetChan { | ||
entryHash := x.HashSingle(Serialize(item)) | ||
if hashResult == nil { | ||
hashResult = entryHash | ||
} else { | ||
hashResult = x.HashTwo(hashResult, entryHash) | ||
} | ||
} | ||
allHashes[i] = hashResult | ||
}(i, subsetChan) |
Check notice
Code scanning / CodeQL
Spawning a Go routine Note
go func() { | ||
prefixDB := dbm.NewPrefixDB(s.db, []byte(utils.BuildRawPrefix(module))) | ||
itr, err := prefixDB.Iterator(nil, nil) | ||
count := 0 | ||
if err != nil { | ||
panic(fmt.Errorf("failed to create iterator: %w", err)) | ||
} | ||
defer itr.Close() | ||
for ; itr.Valid(); itr.Next() { | ||
value := bytes.Clone(itr.Value()) | ||
node, err := iavl.MakeNode(value) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to parse iavl node: %w", err)) | ||
} | ||
|
||
// Only scan leaf nodes | ||
if node.GetHeight() != 0 { | ||
continue | ||
} | ||
snapshotNode := types.RawSnapshotNode{ | ||
StoreKey: module, | ||
Key: node.GetNodeKey(), | ||
Value: node.GetValue(), | ||
Version: node.GetVersion(), | ||
} | ||
dataCh <- snapshotNode | ||
count++ | ||
if count%1000000 == 0 { | ||
fmt.Printf("Scanned %d items for module %s\n", count, module) | ||
} | ||
} | ||
close(dataCh) | ||
}() |
Check notice
Code scanning / CodeQL
Spawning a Go routine Note
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2059 +/- ##
==========================================
- Coverage 61.47% 61.35% -0.12%
==========================================
Files 264 264
Lines 24608 24630 +22
==========================================
- Hits 15127 15111 -16
- Misses 8356 8391 +35
- Partials 1125 1128 +3 |
* Pebble scanner * Update name * Update command
go func() { | ||
count := 0 | ||
_, err := s.db.RawIterate(module, func(key, value []byte, version int64) bool { | ||
dataCh <- types.RawSnapshotNode{ | ||
StoreKey: module, | ||
Key: key, | ||
Value: value, | ||
Version: version, | ||
} | ||
|
||
count++ | ||
if count%1000000 == 0 { | ||
fmt.Printf("Scanned %d items for module %s\n", count, module) | ||
} | ||
|
||
return false | ||
}) | ||
if err != nil { | ||
panic(fmt.Errorf("RawIterate error: %w", err)) | ||
} | ||
close(dataCh) | ||
}() |
Check notice
Code scanning / CodeQL
Spawning a Go routine Note
* Add tools to scan and compute hash for IAVL db * Fix lint * Fix lint * Fix * Fix * Fix * Pebble scanner (#2061) * Pebble scanner * Update name * Update command --------- Co-authored-by: Kartik Bhat <[email protected]>
* Add tools to scan and compute hash for IAVL db * Fix lint * Fix lint * Fix * Fix * Fix * Pebble scanner (#2061) * Pebble scanner * Update name * Update command --------- Co-authored-by: Kartik Bhat <[email protected]>
* Add tools to scan and compute hash for IAVL db * Fix lint * Fix lint * Fix * Fix * Fix * Pebble scanner (#2061) * Pebble scanner * Update name * Update command --------- Co-authored-by: Kartik Bhat <[email protected]>
* Add tools to scan and compute hash for IAVL db * Fix lint * Fix lint * Fix * Fix * Fix * Pebble scanner (#2061) * Pebble scanner * Update name * Update command --------- Co-authored-by: Kartik Bhat <[email protected]>
Describe your changes and provide context
Testing performed to validate your change