Bug: Incorrect Use of Append Function in StoreKeys Method
yuxuan-xie opened this issue · 0 comments
yuxuan-xie commented
Hello Team,
During a recent code review, I found a persistent bug in the StoreKeys method of our Store struct.
func (rs *Store) StoreKeys() []types.StoreKey {
res := make([]types.StoreKey, len(rs.keysByName))
for _, sk := range rs.keysByName {
res = append(res, sk)
}
return res
}
The code can be found at
sei-cosmos/store/rootmulti/store.go
Line 1210 in 9ad11f9
This is a common bug with respect to append
. The original code piece are actually appending new keys at the end of some zero-values, thus doubling the slice size.