PartyDAO contest - LeoS's results

A protocol for buying, using, and selling NFTs as a group.

General Information

Platform: Code4rena

Start Date: 12/09/2022

Pot Size: $75,000 USDC

Total HM: 19

Participants: 110

Period: 7 days

Judge: HardlyDifficult

Total Solo HM: 9

Id: 160

League: ETH

PartyDAO

Findings Distribution

Researcher Performance

Rank: 104/110

Findings: 1

Award: $35.35

🌟 Selected for report: 0

🚀 Solo Findings: 0

Low effect on readability

[G-01] Optimisation fo for loop

The easiest thing to do is to optimize every for loop, the objective is to replace those like the following example:

for (uint256 i = 0; i < array.length; i++) { //do something }

to

uint256 len = array.length; for (uint256 i; i < len;) { //do something unchecked{ ++i; } }

By doing so, the length is cached which is cheaper than looking at it every loop, i = 0 is not initialized since uint have already a default value of 0 and the increment is transformed to a cheaper form since it can't overflow. (This is cheaper because without unchecked there is a check for overflow at each calculation and with the post-increment, the EVM need to store the value with and without increment, but the pre-increment only store the value with increment.)

3 instances:

Consider optimizing for loop.

With those change, these evolutions in gas average report can be observed:

CollectionBuyCrowdfund: Deployment: 2582486 -> 2581279 (-1207) CollectionBuyCrowdfund: buy: 42786 -> 42771 (-15) TokenDistributor: Deployment: 1492622 -> 1490022 (-2600)

[G-02] Using calldata instead of memory for read only argument in external function

If a function parameter is read only, it is cheaper in gas to use calldata instead of memory.

7 instance:

Consider changing memory to calldata in these lines

With those change, these evolutions in gas average report can be observed:

AuctionCrowdfund: Deployment: 2790146 -> 2817977 (+27831) AuctionCrowdfund: initialize: 209495 -> 207640 (-1855) AuctionCrowdfund: finalize: 30202 -> 29426 (-776) CollectionBuyCrowdfund: Deployment: 2582486 -> 2613717 (+31231) CollectionBuyCrowdfund: buy: 42786 -> 42736 (-50) Party: Deployment: 4528700 -> 4570961 (+42261) Party: initialize: 182337 -> 177648 (-4689) PartyFactory: Deployment: 655926 -> 637307 (-18619) PartyFactory: createParty: 297056 -> 291766 (-5290)
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