Holograph contest - Satyam_Sharma'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: 85/144

Findings: 1

Award: $26.35

Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

1.No need to initialize variables with default values

Impact If a variable is not set/initialized, it is assumed to have the default value (0, false, 0x0 etc depending on the data type). Explicitly initializing it with its default value is an anti-pattern and wastes gas.

for (uint256 i = 0; i < length; i++) {

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L208 https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L224 https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L241 https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L257 https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L295 https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L315

https://github.com/code-423n4/2022-10-holograph/blob/main/src/HolographOperator.sol#L682

for (uint256 i = 0; i < addresses.length; i++) {

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L338 https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L355 https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L375

https://github.com/code-423n4/2022-10-holograph/blob/main/src/HolographOperator.sol#L682

for (uint256 t = 0; t < tokenAddresses.length; t++) { https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L333

uint256 gasLimit = 0; uint256 gasPrice = 0;

https://github.com/code-423n4/2022-10-holograph/blob/main/src/HolographOperator.sol#L211-L212

Recommended Mitigation Steps Remove explicit initialization for default values

  • change everyi++ in your for loops tunchecked{++i} . prefix arithmetic is a bit cheaper than postfix arithmetic, but if you do it in a for loop, this small amount of gas can pile up and be a big waste. also, in solidity 0.8.0+, every arithmetic operation is checked for overflow and underflow, which adds a lot of gas to a single operation. Since in your for loop you don't have the risk for overflow, you can surround the operation in

to save a lot of gas (which will save a huge amount since it saves a lot in a single loop iteration.)

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L208

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L224 https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L241 https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L257 https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L295 https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L315

for (uint256 i = 0; i < addresses.length; i++) {

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L338 https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L355 https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L375

for (uint256 t = 0; t < tokenAddresses.length; t++) {

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L333

Use Custom Errors to save Gas

require(balance - gasCost > 10000, "PA1D: Not enough ETH to transfer");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L291

require(balance > 10000, "PA1D: Not enough tokens to transfer");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L312

require(balance > 10000, "PA1D: Not enough tokens to transfer");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L336

require(matched, "PA1D: sender not authorized");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L361

require(addresses.length == bps.length, "PA1D: missmatched array lenghts");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L373

require(totalBp == 10000, "PA1D: bps down't equal 10000");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L378

require(_operatorJobs[hash] > 0, "HOLOGRAPH: invalid job");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/HolographOperator.sol#L210

require(timeDifference > 0, "HOLOGRAPH: operator has time");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/HolographOperator.sol#L251

require(gasPrice >= tx.gasprice, "HOLOGRAPH: gas spike detected");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/HolographOperator.sol#L255

require(gasleft() > gasLimit, "HOLOGRAPH: not enough gas left");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/HolographOperator.sol#L316

require(msg.sender == address(_messagingModule()), "HOLOGRAPH: messaging only call");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/HolographOperator.sol#L386

require(msg.sender == _bridge(), "HOLOGRAPH: bridge only call");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/HolographOperator.sol#L492

require(hlgFee < msg.value, "HOLOGRAPH: not enough value");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/HolographOperator.sol#L496

require(initialized == 0, "PA1D: already initialized");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L91

require(balance - gasCost > 10000, "PA1D: Not enough ETH to transfer");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L291

require(balance > 10000, "PA1D: Not enough tokens to transfer");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L312

require(balance > 10000, "PA1D: Not enough tokens to transfer");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L336

require(matched, "PA1D: sender not authorized");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L361

require(addresses.length == bps.length, "PA1D: missmatched array lenghts");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L373

require(totalBp == 10000, "PA1D: bps down't equal 10000");

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L378

Issue:Low-Risk In function _payoutEth a require condition should implement to check length should not never be equal to zero.Otherwise if length = 0 can effect whole function implementation.

https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L283 https://github.com/code-423n4/2022-10-holograph/blob/main/src/enforcer/PA1D.sol#L309

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