Forgeries contest - PaludoX0's results

A protocol for on-chain games with NFT prizes on Ethereum.

General Information

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

Forgeries

Findings Distribution

Researcher Performance

Rank: 57/77

Findings: 1

Award: $25.95

Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

25.9485 USDC - $25.95

Labels

bug
G (Gas Optimization)
grade-b
G-21

External Links

Admin caching increase gas consumption

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.

Check of request.drawTimelock != 0 is useless

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

Use memory variable in event emit

VRFNFTRandomDraw.sol#L123 You can use _setting memory variable instead of setting storage variable, this will save 831 gas on calling makeNewDraw() function

Cache storage variables

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.

Move checking of drawing NFT ownership to VRFNFTRandomDrawFactory

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.

Constants instead of immutable if size is less than 32B

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

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter