Platform: Code4rena
Start Date: 13/12/2022
Pot Size: $36,500 USDC
Total HM: 5
Participants: 77
Period: 3 days
Judge: gzeon
Total Solo HM: 1
Id: 191
League: ETH
Rank: 57/77
Findings: 1
Award: $25.95
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: c3phas
Also found by: 0x1f8b, Aymen0909, Bnke0x0, Bobface, IllIllI, PaludoX0, Rahoz, RaymondFam, ReyAdmirado, Rolezn, Sathish9098, adriro, chaduke, codeislight, ctrlc03, indijanc, izhelyazkov, kuldeep, nadin, neko_nyaa, nicobevi, rvierdiiev, shark
25.9485 USDC - $25.95
src/VRFNFTRandomDrawFactory.sol#L42
By caching address admin = msg.sender;
there's more gas consumption.
I've removed cache, change all admin occurances with msg.sender and tested using test_FullDrawing()
and there is a saving of 800gas in VRFNFTRandomDrawFactory
deployment and 12gas with makeNewDraw()
call.
VRFNFTRandomDraw.sol#L152
In expression if request.drawTimelock != 0 && request.drawTimelock > block.timestamp
in case request.drawTimelock > block.timestamp
request.drawTimelock
will be always grater than 0 so there's no need of request.drawTimelock != 0
check
VRFNFTRandomDraw.sol#L123
You can use _setting
memory variable instead of setting
storage variable, this will save 831 gas on calling makeNewDraw()
function
VRFNFTRandomDraw.sol#L180 187 190
You can cache settings
storage variable
Settings memory _setting = settings
and substitute all occurance in fucntion.
This will save 84 gas on calling startDraw()
function.
VRFNFTRandomDraw.sol#L126 Move checking of drawing NFT ownership to src/VRFNFTRandomDrawFactory.sol#L41 in order to save gas in case the control is not satisfied.
VRFNFTRandomDraw.sol#L22 L24 and L26 Declaring constants with size less than 32B should be sometimes cheaper than using immutable according to solidity docs. This is stated in https://docs.soliditylang.org/en/v0.8.16/contracts.html#constant-and-immutable-state-variables
#0 - c4-judge
2022-12-17T17:38:35Z
gzeon-c4 marked the issue as grade-b