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
Rank: 87/144
Findings: 1
Award: $26.35
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: oyc_109
Also found by: 0x040, 0x1f8b, 0x5rings, 0xNazgul, 0xSmartContract, 0xZaharina, 0xsam, 0xzh, 2997ms, Amithuddar, Aymen0909, B2, Bnke0x0, Deivitto, Diana, Dinesh11G, Franfran, JC, JrNet, Jujic, KingNFT, KoKo, Mathieu, Metatron, Mukund, Olivierdem, PaludoX0, Pheonix, Picodes, RaymondFam, RedOneN, ReyAdmirado, Rolezn, Saintcode_, Satyam_Sharma, Shinchan, Tagir2003, Tomio, Waze, Yiko, __141345__, adriro, ajtra, aysha, ballx, beardofginger, bobirichman, brgltd, bulej93, catchup, catwhiskeys, cdahlheimer, ch0bu, chaduke, chrisdior4, cryptostellar5, cylzxje, d3e4, delfin454000, dharma09, djxploit, durianSausage, emrekocak, erictee, exolorkistis, fatherOfBlocks, gianganhnguyen, gogo, halden, hxzy, i_got_hacked, iepathos, karanctf, leosathya, lucacez, lukris02, lyncurion, m_Rassska, martin, mcwildy, mics, nicobevi, peanuts, peiw, rbserver, ret2basic, rotcivegaf, ryshaw, sakman, sakshamguruji, saneryee, sikorico, skyle, svskaushik, tnevler, vv7, w0Lfrum, zishansami
26.3525 USDC - $26.35
In solidity ^0.8.4 you can use custom error which are more efficient than reverting with string https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/HolographBridge.sol#L163 https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/HolographBridge.sol#L148 https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/HolographBridge.sol#L205
uint by default is initialize with 0 so explicitly declaring it to 0 will cost gas https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/HolographBridge.sol#L380 https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/enforcer/PA1D.sol#L414 https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/enforcer/PA1D.sol#L432 https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/enforcer/PA1D.sol#L437
++jobNonce
COST LESS GAS THAN jobNonce+1
https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/HolographBridge.sol#L393
Uint256 is more efficient than bools so using uint256(0) for true and uint256(1) will save gas
>0
COST MORE GAS THAN !=0
FOR UINT IN REQUIREhttps://github.com/code-423n4/2022-10-holograph/blob/main/contracts/HolographOperator.sol#L309 https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/HolographOperator.sol#L350
<X> +=/-= <Y>
COST MORE GAS THAN <X> = <X> +/- <Y>
https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/HolographOperator.sol#L378 https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/HolographOperator.sol#L382 https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/HolographOperator.sol#L834
https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/HolographOperator.sol#L433
--pod
COST LESS GAS THAN pod--
https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/HolographOperator.sol#L760
i++/i--
SAVES GAShttps://github.com/code-423n4/2022-10-holograph/blob/main/contracts/enforcer/PA1D.sol#L437 https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/enforcer/PA1D.sol#L432 https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/enforcer/PA1D.sol#L414 https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/enforcer/PA1D.sol#L394 https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/enforcer/PA1D.sol#L454
<array>.length
should not be looked up in every loop of a for-loop
CACHING LENGTH WILL SAVE GAS https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/enforcer/PA1D.sol#L437 https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/enforcer/PA1D.sol#L432 https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/enforcer/PA1D.sol#L454