cryptokitties-bounty-2 icon indicating copy to clipboard operation
cryptokitties-bounty-2 copied to clipboard

major gas inefficiency in batchRemoveExpired due to state variable re-write at every iteration

Open sunsetlover opened this issue 6 years ago • 2 comments

Description

In batchRemoveExpired, at every iteration totalCFOEarnings is updated. Each update corresponds to updating a state variable which costs 5000 gas each time.

Fix

In the beginning of batchRemoveExpired create a local variable called tempEarnings initialized to 0. Use this local variable instead to keep track of the CFO earnings. In the end, set totatotalCFOEarnings = tempEarnings once.

sunsetlover avatar Nov 17 '18 06:11 sunsetlover

Thanks @sunsetlover for your feedback! We will take it into consideration

hwrdtm avatar Nov 19 '18 21:11 hwrdtm

Thanks for your participation, @sunsetlover! Our team has reviewed your submission, and we are pleased to reward you for your report.

Severity: Med Points: 250

arthcmr avatar Nov 27 '18 00:11 arthcmr