Platform: Code4rena
Start Date: 23/11/2022
Pot Size: $24,500 CANTO
Total HM: 5
Participants: 37
Period: 5 days
Judge: berndartmueller
Total Solo HM: 2
Id: 185
League: ETH
Rank: 32/37
Findings: 1
Award: $13.69
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Tricko
Also found by: 0xhacksmithh, AkshaySrivastav, Awesome, Beepidibop, Deivitto, DijkstraDev, Dinesh11G, Englave, JC, Rahoz, RaymondFam, ReyAdmirado, SaeedAlipoor01988, Sathish9098, abiih, aphak5010, chaduke, chrisdior4, exolorkistis, gzeon, martin, nicobevi, oyc_109, peritoflores, rotcivegaf
84.7394 CANTO - $13.69
Issue | Instances | Total Gas Saved on Deployment[Estimated] | |
---|---|---|---|
GAS-1 | Use global variable msg.sender directly without caching | 3 | 4760 |
GAS-2 | Strict inequalities are expensive than Non-strict ones | 1 | 216 |
Total: 4 instances over 2 issues with estimated 4976 gas saved on deployment.
It is cheaper to use the global variable msg.sender directly rather than caching it. We can save about 4760 in gas at deployment and also save gas on every call.
File: /CIP-001/src/Turnstile.sol 50: address smartContract = msg.sender; 87: address smartContract = msg.sender; 108: address smartContract = msg.sender;
Use the msg.sender directly
Non-strict inequalities (>=) are cheaper than strict ones (>). This is so as strict inequalities add a check of nonequality which costs around 3 gas.
File: /CIP-001/src/Turnstile.sol 135: if (_amount > earnedFees) _amount = earnedFees;
File: /CIP-001/src/Turnstile.sol 135: if (_amount >= earnedFees) _amount = earnedFees;
#0 - c4-judge
2022-11-29T19:20:01Z
berndartmueller marked the issue as grade-b