From 0d13008057d917a5d1d898c34e37180cf5eb3842 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Thu, 23 Sep 2021 19:39:59 +0530 Subject: [PATCH] check valid condition in consumeSeekGas --- store/gaskv/store.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/store/gaskv/store.go b/store/gaskv/store.go index f2e1d60dd3af..008cf905ba42 100644 --- a/store/gaskv/store.go +++ b/store/gaskv/store.go @@ -172,8 +172,11 @@ func (gi *gasIterator) Error() error { // consumeSeekGas consumes on each iteration step a flat gas cost and a variable gas cost // based on the current value's length. func (gi *gasIterator) consumeSeekGas() { - value := gi.Value() + if gi.Valid() { + value := gi.Value() - gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*types.Gas(len(value)), types.GasValuePerByteDesc) - gi.gasMeter.ConsumeGas(gi.gasConfig.IterNextCostFlat, types.GasIterNextCostFlatDesc) + gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*types.Gas(len(value)), types.GasValuePerByteDesc) + gi.gasMeter.ConsumeGas(gi.gasConfig.IterNextCostFlat, types.GasIterNextCostFlatDesc) + + } }