code-423n4 / 2022-09-artgobblers-findings

0 stars 0 forks source link

Gas Optimizations #367

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Gas Optimizations

GalloDaSballo commented 2 years ago

Variables like UNREVEALED_URI and BASE_URI, which can't be changed, can be marked as immutable to save gas when accessing them.

4.2k

getCopiesOfArtGobbledByGobbler

This saves the keccak cost, at the cost of packing, so prob 20 gas

400 gas from SLAODs

Modify the expression legendaryGobblerAuctionData.startPrice = uint120(cost <=

We know shift wont' save gas (sponsor feedback) 3 gas from caching the other value

Use prefix incrementation and decrementation when incrementing or decrementing variables by one:

Prefix is 11 per instance = 33

Neat unique report, would recommend using bigger blocks for code, but really nice jbo!

4636

transmissions11 commented 2 years ago

Decided to selectively implement some of them. Lots of clever and good optimizations but not all are worth the readability costs.