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: 98/133
Findings: 1
Award: $12.99
🌟 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.994 USDC - $12.99
require()
/revert()
strings will save deployment gasContracts use version 0.8.14 and can use custom errors that will save of deployment gas also when the trasaction failed duo to return the gas will be less.
There have 2 istance of this issues:
require(sfrxeth_recieved > 0, 'No sfrxETH was returned');
require(numDeposits > 0, "Not enough ETH in contract");
uncheck()
in for loops whenere overflow and undeflow is not possibleUsing of uncheck(i++)
/uncheck(++i)
will save about 30 gas per iteration because compiler not save check everytime. This feature come from 0.8
There have 5 istance of this issues:
for (uint i = 0; i < minters_array.length; i++){
for (uint256 i = 0; i < arrayLength; ++i) {
for (uint256 i = 0; i < times; ++i) {
for (uint256 i = 0; i < original_validators.length; ++i) {
for (uint256 i = 0; i < numDeposits; ++i) {
There have 5 istance of this issues:
currentWithheldETH += withheld_amt;
++i will save about 5 gas for each iteration
There have 1 istance of this issues:
for (uint i = 0; i < minters_array.length; i++){
uint256(1)
/uint256(2)
for true and falseIf you don't use boolean for storage you will avoid Gwarmaccess 100 gas. Also boolean from true to false cost 20000 gas rather than uint256(2) to uint256(1) that cost less.
There have 4 istance of this issues:
File: ERC20PermitPermissionedMint.sol line 20
mapping(address => bool) public minters; // Mapping is also used for faster verification
File: frxETHMinter.sol lines 43,49,50
mapping(bytes => bool) public activeValidators; // Tracks validators (via their pubkeys) that already have 32 ETH in them
bool public submitPaused;
bool public depositEtherPaused;
If you use >=
or <=
this will cost more gas because in the EVM there is no implementation of Opcodes for >=
and `<= and two operations are done.
There have 1 istance of this issues:
if (block.timestamp >= rewardsCycleEnd) { syncRewards(); }
!=
cost 6 gas less than >
in requireThere have 2 istance of this issues:
File: frxETHMinter.sol lines 79, 126
require(sfrxeth_recieved > 0, 'No sfrxETH was returned');
require(numDeposits > 0, "Not enough ETH in contract");
If you use longer require strings than 32 bytes that will cost more expensive than short require string.
File : frxETHMinter.sol line 167
There have 1 istance of this issues:
require(amount <= currentWithheldETH, "Not enough withheld ETH in contract");
Overriting varibles with defualt values with their default value will waste only gas and not necessary.
There have 5 istance of this issues:
for (uint i = 0; i < minters_array.length; i++){
for (uint256 i = 0; i < arrayLength; ++i) {
for (uint256 i = 0; i < times; ++i) {
for (uint256 i = 0; i < original_validators.length; ++i) {
for (uint256 i = 0; i < numDeposits; ++i) {
For loop written like thisfor (uint256 i; i < array.length; ++i) {
will cost more gas than for (uint256 i; i < _lengthOfArray; ++i) {
because for every iteration we use mload and memory_offset
that will cost about 6 gas
There are 2 instances of this issue:
for (uint i = 0; i < minters_array.length; i++){
for (uint256 i = 0; i < original_validators.length; ++i) {