cryptokitties-bounty
cryptokitties-bounty copied to clipboard
Gas inefficiencies in `KittyMinting`
Description
There are a couple of gas inefficiencies in KittyMinting that could be resolved for significantly lower gas consumption:
- promoCreationLimit and gen0CreationLimit are both defined as variables. Making them
constantwould allow the compiler to optimise them out, saving 40k of deployment-time gas, and ~200 gas each time they are read. - createPromoKitty increments both variables, costing ~10k. Incrementing only
promoCreatedCount, and checking the sum of the two variables instead of each separately, would save ~5k gas at update time.
promoCreationLimit and gen0CreationLimit are both defined as variables
Weirdly, I just learned about constant Solidity variables just this morning, I think there some others we can probably fix, also.
createPromoKitty increments both variables
Your suggestion would result in two reads (instead of one) in createGen0Auction, but it's still a net gas savings. We'll definitely look at this!
Thanks again, @Arachnid! Love these reports!
@dete As you suspected, here are two more than can be constant https://github.com/axiomzen/cryptokitties-bounty/blob/03b51a8872d2438851d0ef77cfe29c74a079d26a/contracts/KittyOwnership.sol#L13
https://github.com/axiomzen/cryptokitties-bounty/blob/03b51a8872d2438851d0ef77cfe29c74a079d26a/contracts/KittyOwnership.sol#L14
Thanks for your participation, @Arachnid! Our team has reviewed your submission, and we are pleased to reward you for your report.
Impact: Low Likelihood: Low Points: 50
Please see the final leaderboard here.