bnb-chain/zkbnb

Get Changed Asset Logic incorrect

Closed this issue · 0 comments

Describe the Issue
When GetChanges ,this will always return null change , we will not store the Changed AssetInfo into Kvrock.

// Returns slice of indexes of asset trees that were changned
func (c *AssetTreeCache) GetChanges() []int64 {
c.mainLock.Lock()
c.changesLock.Lock()
defer c.mainLock.Unlock()
defer c.changesLock.Unlock()
for _, key := range c.treeCache.Keys() {
tree, _ := c.treeCache.Peek(key)
if tree.(bsmt.SparseMerkleTree).LatestVersion()-tree.(bsmt.SparseMerkleTree).RecentVersion() > 1 {
c.changes[key.(int64)] = true
}
}
ret := make([]int64, 0, len(c.changes))
for key := range c.changes {
ret = append(ret, key)
}
return ret
}
As we can see from above codes, committer service uses 【tree.(bsmt.SparseMerkleTree).LatestVersion()-tree.(bsmt.SparseMerkleTree).RecentVersion() > 1】 which is not correct. The reason is that the LatestVersion only change after the tree committed.

Your Environment

N/A

To Reproduce

N/A

Expected behavior
Assign correct GetChanges logic by