Skip to content
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

Merged
merged 8 commits into from
Feb 1, 2025
Merged

Conversation

yzang2019
Copy link
Contributor

Describe your changes and provide context

Testing performed to validate your change

Comment on lines 56 to 68
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

Spawning a Go routine may be a possible source of non-determinism
Comment on lines +46 to +78
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

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

codecov bot commented Jan 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.35%. Comparing base (c2bc99c) to head (947514f).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            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     

see 3 files with indirect coverage changes

* Pebble scanner

* Update name

* Update command
Comment on lines +45 to +66
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

Spawning a Go routine may be a possible source of non-determinism
@yzang2019 yzang2019 merged commit 51f6572 into main Feb 1, 2025
49 checks passed
@yzang2019 yzang2019 deleted the yzang/SEI-8920 branch February 1, 2025 04:11
Kbhat1 added a commit that referenced this pull request Feb 3, 2025
* 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]>
Kbhat1 added a commit that referenced this pull request Feb 4, 2025
* 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]>
Kbhat1 added a commit that referenced this pull request Feb 5, 2025
* 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]>
Kbhat1 added a commit that referenced this pull request Feb 5, 2025
* 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]>
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.

2 participants