LSD Network - Stakehouse contest - lukris02's results

A permissionless 3 pool liquid staking solution for Ethereum.

General Information

Platform: Code4rena

Start Date: 11/11/2022

Pot Size: $90,500 USDC

Total HM: 52

Participants: 92

Period: 7 days

Judge: LSDan

Total Solo HM: 20

Id: 182

League: ETH

Stakehouse Protocol

Findings Distribution

Researcher Performance

Rank: 26/92

Findings: 2

Award: $543.70

QA:
grade-a
Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

QA Report for LSD Network - Stakehouse contest

Overview

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

â„–TitleRisk RatingInstance Count
L-1Missing check for zero addressLow2
L-2Open TODOLow1
NC-1Order of FunctionsNon-Critical18
NC-2Order of LayoutNon-Critical13
NC-3Public functions can be externalNon-Critical10
NC-4Open questionNon-Critical1
NC-5Unused eventNon-Critical1
NC-6TyposNon-Critical7
NC-7Constants may be usedNon-Critical24
NC-8Missing NatSpecNon-Critical10
NC-9No space between the control structuresNon-Critical13
NC-10Maximum line length exceededNon-Critical63

Low Risk Findings(2)

L-1. Missing check for zero address

Description

If address(0x0) is set it may cause the contract to revert or work wrong.

Instances
Recommendation

Add checks.

L-2. Open TODO

Instances
Recommendation

Resolve issue.

Non-Critical Risk Findings(10)

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

function receive() is not right after the constructor:

external functions after/between public:

public function after internal:

Recommendation

Reorder functions where possible.

NC-2. Order of Layout

Description

According to Order of Layout, inside each contract, library or interface, use the following order:

  1. Type declarations
  2. State variables
  3. Events
  4. Modifiers
  5. Functions
Instances

events before state variables:

modifier should be before constructor:

Recommendation

Place events after state variables and before modifiers.
Place modifiers before constructor.

NC-3. Public functions can be external

Description

If functions are not called by the contract where they are defined, they can be declared external.

Instances
Recommendation

Make public functions external, where possible.

NC-4. Open question

Instances

NC-5. Unused event

Instances
Recommendation

Remove event or use it.

NC-6. Typos

Instances

NC-7. Constants may be used

Description

Constants may be used instead of literal values.

Instances

for 32:

for 24:

for 12:

for 4:

Recommendation

Define constant variables, especially for repeated values.

NC-8. Missing NatSpec

Description

NatSpec is missing for 10 functions in 4 contracts.

Instances
Recommendation

Add NatSpec for all functions.

NC-9. No space between the control structures

Description

According to Style Guide, there should be a single space between the control structures if, while, and for and the parenthetic block representing the conditional.

Instances
Recommendation

Change:

if(...) { ... }

to:

if (...) { ... }

NC-10. Maximum line length exceeded

Description

According to Style Guide, maximum suggested line length is 120 characters.

Instances

GiantLP.sol:

LPToken.sol:

SavETHVault.sol:

GiantMevAndFeesPool.sol:

StakingFundsVault.sol:

Syndicate.sol:

LiquidStakingManager.sol:

ETHPoolLPFactory.sol:

Recommendation

Make the lines shorter.

#0 - c4-judge

2022-12-02T22:10:37Z

dmvt marked the issue as grade-a

Findings Information

Awards

68.1383 USDC - $68.14

Labels

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

External Links

Gas Optimizations Report for LSD Network - Stakehouse contest

Overview

During the audit, 5 gas issues were found.
Total savings are more than 2700.

â„–TitleInstance CountSaved
G-1Use unchecked blocks for incrementing i381330
G-2Use calldata instead of memory for read-only arguments15900
G-3Using storage pointer to bytes is cheaper than using memory13
G-4Cache state variables instead of reading them from storage multiple times3300
G-5Use local variable cache instead of accessing mapping or array multiple times4160

Gas Optimizations Findings(5)

G-1. 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*38 = 1330

G-2. 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*15 = 900

G-3. Using storage pointer to bytes is cheaper than using memory

Instances
Recommendation

Change:

bytes memory x = y;

to:

bytes storage x = y
Saved

This saves ~ X.

G-4. Cache state variables instead of reading them from storage multiple times

Description

Memory read is much cheaper than storage read.

Instances
Saved

This saves ~100.
So, ~100*3 = 300

G-5. Use local variable cache instead of accessing mapping or array multiple times

Description

It saves gas due to not having to perform the same key’s keccak256 hash and/or offset recalculation.

Instances
Saved

This saves ~40.
So, ~40*4 = 160

#0 - c4-judge

2022-12-02T22:10:52Z

dmvt 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