Platform: Code4rena
Start Date: 03/05/2022
Pot Size: $75,000 USDC
Total HM: 6
Participants: 55
Period: 7 days
Judge: Albert Chon
Total Solo HM: 2
Id: 116
League: COSMOS
Rank: 36/55
Findings: 2
Award: $180.61
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0x1337, 0x1f8b, 0xDjango, 0xkatana, AmitN, CertoraInc, Dravee, Funen, GermanKuber, GimelSec, Hawkeye, JC, MaratCerby, WatchPug, Waze, broccolirob, cccz, ch13fd357r0y3r, cryptphi, danb, defsec, delfin454000, dipp, dirk_y, ellahi, gzeon, hake, hubble, ilan, jah, jayjonah8, kebabsec, kirk-baird, m9800, orion, oyc_109, robee, shenwilly, simon135, sorrynotsorry
113.5377 USDC - $113.54
Version of solidity under 8.0.0 prone to bugs https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/CosmosToken.sol#L1 Mitigation:use 0.8.0 and above
🌟 Selected for report: GermanKuber
Also found by: 0v3rf10w, 0x1f8b, 0xDjango, 0xNazgul, 0xf15ers, 0xkatana, AlleyCat, CertoraInc, Dravee, Funen, GimelSec, IllIllI, JC, MaratCerby, WatchPug, Waze, defsec, delfin454000, ellahi, gzeon, hake, hansfriese, ilan, jonatascm, nahnah, oyc_109, peritoflores, rfa, robee, simon135, slywaters, sorrynotsorry
67.0735 USDC - $67.07
You can make the initialized variable not initialized bec its already 0 it wastes gas bec your sstore 25000 gas https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L54 Make functions on admin function payable it saves gas bec of not checking for msg.value = zero https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L124 Instead of using && in a require statement use multiple require statements to save gas https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L301 Make require string less than 32 bytes save gas https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L386 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L390 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L405 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L416 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L511 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L527
Use custom errors instead of revert string to save gas Custom errors from Solidity 0.8.4 are cheaper than revert strings (cheaper deployment cost and runtime cost when the revert condition is met) Source: Custom Errors in Solidity: Starting from Solidity v0.8.4, there is a convenient and gas-efficient way to explain to users why an operation failed through the use of custom errors. Until now, you could already use strings to give more information about failures (e.g., revert("Insufficient funds.");), but they are rather expensive, especially when it comes to deploy cost, and it is difficult to use dynamic information in them. Custom errors are defined using the error statement, which can be used inside and outside of contracts (including interfaces and libraries) https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L386 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L390 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L396 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L511 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L527 ++i costs less gas compared to i++ for unsigned integer, as pre-increment is cheaper (about 5 gas per iteration) i++ increments i and returns the initial value of i https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L579 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L660