#15854·cosmos-sdk

[Bug]: gas consumption inaccuracy of `gaskv`'s iterator

Author: tkxkd0159Created Apr 17, 2023Updated Aug 12, 2026
LabelsC:Store

Summary of Bug

gaskv's iterator consume gas for first key, value when it's initiated(internally Next() in iavl). But after that when it looks for the next key, value using Next(), I don't understand why it consumes gas with the length of the current key and value rather than the length of the next key and value. In this structure, gas is consumed twice for the data length of the first key and value, and gas is not consumed for the data length of the last key and value.

Version

0931193521596dc801207ddf3c26124b401a7072

Steps to Reproduce