Platform: Code4rena
Start Date: 22/09/2022
Pot Size: $30,000 USDC
Total HM: 12
Participants: 133
Period: 3 days
Judge: 0xean
Total Solo HM: 2
Id: 165
League: ETH
Rank: 116/133
Findings: 1
Award: $12.81
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: pfapostol
Also found by: 0x040, 0x1f8b, 0x4non, 0x5rings, 0xA5DF, 0xNazgul, 0xSmartContract, 0xmatt, 0xsam, Amithuddar, Aymen0909, B2, Ben, Bnke0x0, Chom, CodingNameKiki, Deivitto, Diana, Fitraldys, Funen, IllIllI, JAGADESH, JC, Metatron, Ocean_Sky, PaludoX0, Pheonix, RaymondFam, ReyAdmirado, RockingMiles, Rohan16, Rolezn, Satyam_Sharma, Sm4rty, SnowMan, SooYa, Tagir2003, TomJ, Tomio, Triangle, V_B, Waze, __141345__, ajtra, albincsergo, asutorufos, aysha, beardofginger, bobirichman, brgltd, bulej93, bytera, c3phas, ch0bu, cryptostellar5, cryptphi, d3e4, delfin454000, dharma09, drdr, durianSausage, emrekocak, erictee, fatherOfBlocks, gogo, got_targ, imare, jag, karanctf, ladboy233, leosathya, lukris02, medikko, mics, millersplanet, natzuu, neko_nyaa, oyc_109, peanuts, prasantgupta52, rbserver, ret2basic, rokinot, ronnyx2017, rotcivegaf, sach1r0, samruna, seyni, slowmoses, tnevler, wagmi, zishansami
12.811 USDC - $12.81
File: src/DepositContract.sol
76: for (uint height = 0; height < DEPOSIT_CONTRACT_TREE_DEPTH; height++) { 148: for (uint height = 0; height < DEPOSIT_CONTRACT_TREE_DEPTH; height++) {
File: src/OperatorRegistry.sol
63: for (uint256 i = 0; i < arrayLength; ++i) { 84: for (uint256 i = 0; i < times; ++i) { 114: for (uint256 i = 0; i < original_validators.length; ++i) {
File: src/frxETHMinter.sol
63: withholdRatio = 0; // No ETH is withheld initially 64: currentWithheldETH = 0; 129: for (uint256 i = 0; i < numDeposits; ++i) {
++i
/i++
should be unchecked{++i}
/unchecked{i++}
when it is not possible for them to overflow, as is the case when used in for
- and while
-loopsFile: src/DepositContract.sol
76: for (uint height = 0; height < DEPOSIT_CONTRACT_TREE_DEPTH; height++) { 148: for (uint height = 0; height < DEPOSIT_CONTRACT_TREE_DEPTH; height++) {
File: src/OperatorRegistry.sol
63: for (uint256 i = 0; i < arrayLength; ++i) { 84: for (uint256 i = 0; i < times; ++i) { 114: for (uint256 i = 0; i < original_validators.length; ++i) {
File: src/frxETHMinter.sol
129: for (uint256 i = 0; i < numDeposits; ++i) {
File: src/DepositContract.sol
76: for (uint height = 0; height < DEPOSIT_CONTRACT_TREE_DEPTH; height++) { 148: for (uint height = 0; height < DEPOSIT_CONTRACT_TREE_DEPTH; height++) {
<x> / 2
is the same as <x> >> 1
. The DIV
opcode costs 5 gas, whereas SHR
only costs 3 gas
File: src/DepositContract.sol
88: size /= 2; 154: size /= 2;
!= 0
costs less gas compared to > 0
for unsigned integers in require statements with the optimizer enabled (6 gas)
For uints the minimum value would be 0 and never a negative value. Since it cannot be a negative value, then the check > 0
is essentially checking that the value is not equal to 0 therefore >0
can be replaced with !=0
which saves gas.
File: src/frxETHMinter.sol
79: require(sfrxeth_recieved > 0, 'No sfrxETH was returned'); 126: require(numDeposits > 0, "Not enough ETH in contract");
File: src/OperatorRegistry.sol
114: for (uint256 i = 0; i < original_validators.length; ++i) {