Platform: Code4rena
Start Date: 12/04/2023
Pot Size: $60,500 USDC
Total HM: 21
Participants: 199
Period: 7 days
Judge: hansfriese
Total Solo HM: 5
Id: 231
League: ETH
Rank: 174/199
Findings: 1
Award: $21.03
π Selected for report: 0
π Solo Findings: 0
π Selected for report: c3phas
Also found by: 0xDACA, 0xRB, 0xSmartContract, 0xhacksmithh, 0xnev, Aymen0909, BenRai, Breeje, DishWasher, Erko, EvanW, JCN, MohammedRizwan, NoamYakov, Polaris_tow, Proxy, Rageur, Raihan, RaymondFam, ReyAdmirado, SAAJ, Sathish9098, Satyam_Sharma, Udsen, __141345__, aria, codeslide, decade, fatherOfBlocks, hunter_w3b, karanctf, matrix_0wl, nadin, naman1778, niser93, pavankv, petrichor, pfapostol, sebghatullah, slvDev, trysam2003, xmxanuel
21.0255 USDC - $21.03
This report focuses on Frankencoin contest, in context of various improvements that can be made in terms of gas cost.
Some of the opportunities identified for improving gas efficiency for the code in scope of Frankencoin are categorised into 04 main areas; with further multiple instances in each of the category.
[G-01] Multiple mappings can be combine into a single one (06 Instances) [G 02] Declare Public library as internal library (02 Instances) [G-03] Immutable has more gas efficiency than constant (06 Instances) [G-04] Use != 0 instead of > 0 for unsigned integer comparison (02 Instances)
β
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:
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:
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:
Link to the Code:
#0 - c4-pre-sort
2023-04-27T13:22:49Z
0xA5DF marked the issue as high quality report
#1 - 0xA5DF
2023-04-27T13:23:40Z
Edit: MathUtil
isn't used as a library here, but as a parent contract
#2 - c4-pre-sort
2023-04-27T13:25:02Z
0xA5DF marked the issue as low quality report
#3 - c4-judge
2023-05-16T12:58:20Z
hansfriese marked the issue as grade-b