PartyDAO contest - lukris02'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: 43/110

Findings: 2

Award: $117.87

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

QA Report for Party DAO contest

Overview

During the audit, 3 low and 3 non-critical issues were found.

β„–TitleRisk RatingInstance Count
L-1Storage variables can be packed tightlyLow6
L-2Check zero denominatorLow2
L-3Large number of elements may cause out-of-gas errorLow6
NC-1Order of FunctionsNon-Critical5
NC-2Floating pragmaNon-Critical46
NC-3Missing NatSpecNon-Critical74

Low Risk Findings (3)

L-1. Storage variables can be packed tightly

Description

According to docs, multiple, contiguous items that need less than 32 bytes are packed into a single storage slot if possible. It might be beneficial to use reduced-size types if you are dealing with storage values because the compiler will pack multiple elements into one storage slot, and thus, combine multiple reads or writes into a single operation.

Instances
Recommendation

Consider changing order of variables to, for example:

uint40 duration; uint96 maximumPrice; uint16 splitBps; address payable splitRecipient;

L-2. Check zero denominator

Description

If the input parameter totalVotingPower is equal to zero, this will cause the function call failure on division.

Instances
Recommendation

Add the check to prevent function call failure.

L-3. Large number of elements may cause out-of-gas error

Description

Loops that do not have a fixed number of iterations, for example, loops that depend on storage values, have to be used carefully: Due to the block gas limit, transactions can only consume a certain amount of gas. Either explicitly or just due to normal operation, the number of iterations in a loop can grow beyond the block gas limit, which can cause the complete contract to be stalled at a certain point.

Instances
Recommendation

Restrict the maximum number of elements.

Non-Critical Risk Findings (3)

NC-1. Order of Functions

Description

According to Style Guide, ordering helps readers identify which functions they can call and to find the constructor and fallback definitions easier.
Functions should be grouped according to their visibility and ordered:

  1. constructor
  2. receive function (if exists)
  3. fallback function (if exists)
  4. external
  5. public
  6. internal
  7. private
Instances
Recommendation

Reorder functions where possible.

NC-2. Floating pragma

Description

Contracts should be deployed with the same compiler version. It helps to ensure that contracts do not accidentally get deployed using, for example, an outdated compiler version that might introduce bugs that affect the contract system negatively.

Instances

All contracts.

Recommendation

According to SWC-103, pragma version should be locked.

NC-3. Missing NatSpec

Description

No NatSpec or any comments for 74 functions in 17 contracts.

Instances
Recommendation

Add NatSpec for all functions.

#0 - HardlyDifficult

2022-09-30T19:09:44Z

Gas Optimizations Report for Party DAO contest

Overview

During the audit, 6 gas issues were found.

Gas Optimizations Findings (6)

G-1. Postfix increment

Description

Prefix increment costs less gas than postfix.

Instances
Recommendation

Consider using prefix increment where it is relevant.

G-2. <>.length in loops

Description

Reading the length of an array at each iteration of the loop consumes extra gas.

Instances
Recommendation

Store the length of an array in a variable before the loop, and use it.

G-3. Initializing variables with default value

Description

It costs gas to initialize integer variables with 0 or bool variables with false but it is not necessary.

Instances
Recommendation

Remove initialization for default values.
For example: for (uint256 i; i < hadPreciouses.length; ++i) {

G-4. > 0 is more expensive than =! 0

Instances
Recommendation

Use =! 0 instead of > 0, where possible.

G-5. x += y is more expensive than x = x + y

Instances
Recommendation

Use x = x + y instead of x += y. Use x = x - y instead of x -= y.

G-6. Using unchecked blocks saves gas

Description

In Solidity 0.8+, there’s a default overflow and underflow check on unsigned integers. When an overflow or underflow isn’t possible, some gas can be saved by using unchecked blocks.

Instances
Recommendation

Change:

for (uint256 i; i < n; ++i) { // ... }

to:

for (uint256 i; i < n;) { // ... unchecked { ++i; } }
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