Platform: Code4rena
Start Date: 06/03/2023
Pot Size: $36,500 USDC
Total HM: 8
Participants: 93
Period: 3 days
Judge: cccz
Total Solo HM: 3
Id: 218
League: ETH
Rank: 49/93
Findings: 2
Award: $34.42
π Selected for report: 0
π Solo Findings: 0
π Selected for report: adriro
Also found by: 0x1f8b, 0xAgro, 0xSmartContract, 0xfuje, 0xkazim, 0xnev, Aymen0909, Bason, Cyfrin, DadeKuma, LethL, Madalad, MohammedRizwan, Rolezn, SAAJ, SunSec, Udsen, Yukti_Chinta, ast3ros, bin2chen, brgltd, bshramin, btk, bugradar, catellatech, cryptostellar5, descharre, dontonka, erictee, fatherOfBlocks, georgits, glcanvas, hl_, horsefacts, igingu, juancito, lukris02, martin, nadin, nomoi, peanuts, pipoca, sakshamguruji, seeu, slvDev, tnevler, zaskoh
21.7018 USDC - $21.70
Some of the opportunities identified for improving low severity issues throughout the codebase of Wenwin protocol are categorised into 03 main areas; with further multiple instances in each of the category.
Locking pragma version ensures contracts are not being deployed on an outdated compiler version.
Link to the code:
Precaution should be taken in using solidity latest released version that can impact the project based on reason of unknown bugs.
Link to the code:
Address(0) check is missing in function, consider applying check to ensure tokens or tickets arenβt minted to the zero address.
Link to the code:
Zero-address check should be used in the constructors, to avoid the risk of setting a storage variable as address(0) at deploying time.
Link to the code:
#0 - thereksfour
2023-03-12T09:54:36Z
1 L 3 INFO
#1 - c4-judge
2023-03-12T09:54:40Z
thereksfour marked the issue as grade-b
#2 - c4-sponsor
2023-03-14T10:53:21Z
0xluckydev marked the issue as sponsor confirmed
π Selected for report: Rolezn
Also found by: 0x1f8b, 0x6980, 0xSmartContract, 0xhacksmithh, 0xnev, Haipls, Inspectah, JCN, LethL, Madalad, MiniGlome, Pheonix, Rageur, RaymondFam, ReyAdmirado, SAAJ, Sathish9098, adriro, air, arialblack14, atharvasama, c3phas, ch0bu, ddimitrov22, descharre, hunter_w3b, igingu, matrix_0wl, rokso, saneryee, schrodinger, slvDev, volodya, yongskiws
12.7206 USDC - $12.72
This report focuses on Wenwin contest, in context of various improvements that can be made in terms of gas cost.
Some of the opportunities identified for improving gas efficiency throughout the codebase of Wenwin Protocol are categorised into 07 main areas; with further multiple instances in each of the category.
[G-01] 0perator assignment is more gas efficient than compound assignment (16 Instances) [G-02] Require is more gas efficient than assert (02 Instances) [G-03] Immutable has more gas efficiency than constant (04 Instances) [G-04] Multiple mappings can be combined into a single one (12 Instances) [G-05] Wastage of deployed gas when return is not present for returns function (11 Instances) [G 06] Declare Public library as internal library (05 Instances) [G-07] Public visibility consumes more gas as compared to external in functions (02 Instances) β
Compound assignment operators (+= / -=) are more expensive in terms of gas consumption and needs to be avoided.
Operator assignments (a = a + b / a - b) are preferable in terms of gas optimization.
Link to the Code:
Assert() and require() functions are similar in nature, regarding context of handling error and undone any changes made.
However, assert() consumes all the gas during the process of reverting change while require()refunds any gas remaining that was paid.
Link to the Code:
Using immutable instead of constant, save more gas due to avoiding storage access for state variables.
Variable values are set through constructor when using immutable, which also eliminates the need of assigning initial values to state variable making them more efficient in terms of gas cost
Link to the Code:
When multiple mappings are used in same function, itβs better to combined them into a single mapping using a struct.
Combined mapping reduces storage slot per mapping and also are cheaper in terms of associated stack operations calculation carried out.
Link to the Code:
Wastage of gas during deployment; when return is absent for named variable when function returns.
Link to the Code:
External call to a public library function is very expensive for reference checks this article. When library has only internal functions it can be used as internal library.
Link to the code:
Functions with public visibility, if not called within the contract needed to be changed external.
Link to the Code:
#0 - c4-judge
2023-03-12T14:20:03Z
thereksfour marked the issue as grade-b
#1 - c4-sponsor
2023-03-14T13:10:53Z
TutaRicky marked the issue as sponsor acknowledged