Holograph contest - w0Lfrum's results

Omnichain protocol for deploying, minting, & bridging NFTs between blockchains.

General Information

Platform: Code4rena

Start Date: 18/10/2022

Pot Size: $75,000 USDC

Total HM: 27

Participants: 144

Period: 7 days

Judge: gzeon

Total Solo HM: 13

Id: 170

League: ETH

Holograph

Findings Distribution

Researcher Performance

Rank: 121/144

Findings: 2

Award: $0.00

QA:
grade-c
Gas:
grade-c

🌟 Selected for report: 0

🚀 Solo Findings: 0

QA Report

Summary

The overall code is well-commented. Unit tests are provided. The logic is split into the corresponding files. The logic is clear when referring to the docs/information given in the code4rena contest page. There may be instances where ether may be sent to the contract via the receive() or fallback functions. These contracts may lock the sent ether as they do not have functionality to withdraw ether from the contract.

1. Payable Fallback Function :

It is optional whether to add the payable functionality for a fallback function. Since the fallback() is purposefully made to revert to prevent any calls to undefined functions and there is no need to send any ether to the contract. Hence the payable keyword may be removed.

fallback() external payable { revert(); }

Can be changed to :

fallback() external { revert(); }

Gas Optimization Report

This report describes opportunity for gas optimization in the order of appearance in the code.

1. Using Unchecked Blocks(Along with Pre-Increment) for Incrementing the Loop Variable

Lines of Code :

HolographOperator.sol#L781-783

HolographOperator.sol#L871-L876

Details :

Checks for overflow/underflow consume extra gas. Using an unchecked block for incrementing loop variable saves gas.

For Example :

for (uint256 i = 0; i < length; i++) { operators[i] = _operatorPods[pod][index + i]; }

Can be changed to :

for (uint256 i; i < length;) { // default value of i will be 0 operators[i] = _operatorPods[pod][index + i]; unchecked { ++i; } }

The value of length would not be greater than (2^256) - 1, so the value of i would not overflow. Hence an unchecked block can be used.

2. Using Custom Strings instead of require Strings to Save Gas

Custom errors are available from solidity version 0.8.4. These custom errors avoid having to allocate space to store revert strings. Not defining the error strings in the custom errors also saves gas.

3. In For Loops, ++i Costs Much Lesser Gas than i++

Saves 5 gas per iteration in the For loop.

4. Using 1e10 Instead of 10**10

Lines of Code:

LayerZeroModule.sol#L274

LayerZeroModule.sol#L293

Using 1e10 Instead of 10**10 saves gas.

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