SIZE contest - lukris02's results

An on-chain sealed bid auction protocol.

General Information

Platform: Code4rena

Start Date: 04/11/2022

Pot Size: $42,500 USDC

Total HM: 9

Participants: 88

Period: 4 days

Judge: 0xean

Total Solo HM: 2

Id: 180

League: ETH

SIZE

Findings Distribution

Researcher Performance

Rank: 41/88

Findings: 2

Award: $65.42

QA:
grade-b
Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

44.2869 USDC - $44.29

Labels

bug
grade-b
QA (Quality Assurance)
Q-24

External Links

QA Report for SIZE contest

Overview

During the audit, 6 non-critical issues were found.

â„–TitleRisk RatingInstance Count
NC-1Order of FunctionsNon-Critical3
NC-2Missing NatSpecNon-Critical4
NC-3TyposNon-Critical4
NC-4No error message in revertNon-Critical1
NC-5Unused named return variablesNon-Critical2
NC-6Open questionNon-Critical1

Non-Critical Risk Findings(6)

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

public functions before external:

Recommendation

Reorder functions where possible.

NC-2. Missing NatSpec

Description

NatSpec is missing for 4 functions in 1 contracts.

Instances
Recommendation

Add NatSpec for all functions.

NC-3. Typos

Instances

NC-4. No error message in revert

Instances
Recommendation

Add error messages.

NC-5. Unused named return variables

Description

Both named return variable(s) and return statement are used.

Instances
Recommendation

To improve clarity use only named return variables.
For example, change:

function functionName() returns (uint id) { return x;

to

function functionName() returns (uint id) { id = x;

NC-6. Open question

Instances

#0 - c4-judge

2022-11-10T02:52:41Z

0xean marked the issue as grade-b

Awards

21.132 USDC - $21.13

Labels

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

External Links

Gas Optimizations Report for SIZE contest

Overview

During the audit, 4 gas issues were found.
Total savings ~450+.

â„–TitleInstance CountSaved
G-1Use calldata instead of memory for read-only arguments5300
G-2Use unchecked blocks for incrementing i270
G-3Use unchecked blocks for subtractions where underflow is impossible270
G-4Elements that are smaller than 32 bytes (256 bits) may increase gas usage11

Gas Optimizations Findings(4)

G-1. Use calldata instead of memory for read-only arguments

Description

Since Solidity v0.6.9, memory and calldata are allowed in all functions regardless of their visibility type (See "Calldata Variables" section here).
When function arguments should not be modified, it is cheaper to use calldata.

Instances
Recommendation

Consider using calldata where possible.

Saved

This saves at least 60 gas per iteration.
So, ~60*5 = 300

G-2. Use unchecked blocks for incrementing i

Description

In Solidity 0.8+, there’s a default overflow and underflow check on unsigned integers. In the loops, "i" will not overflow because the loop will run out of gas before that.

Instances
Recommendation

Change:

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

to:

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

This saves ~30-40 gas per iteration.
So, ~35*2 = 70

G-3. Use unchecked blocks for subtractions where underflow is impossible

Description

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

Instances
Saved

This saves ~35.
So, ~35*2 = 70

G-4. Elements that are smaller than 32 bytes (256 bits) may increase gas usage

Description

According to docs, when using elements that are smaller than 32 bytes, your contract’s gas usage may be higher. This is because the EVM operates on 32 bytes at a time. Therefore, if the element is smaller than that, the EVM must use more operations in order to reduce the size of the element from 32 bytes to the desired size.

Instances
Recommendation

Consider using a larger size where needed.

#0 - c4-judge

2022-11-10T02:07:29Z

0xean 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