Platform: Code4rena
Start Date: 17/03/2023
Pot Size: $36,500 USDC
Total HM: 10
Participants: 98
Period: 3 days
Judge: leastwood
Total Solo HM: 5
Id: 223
League: ETH
Rank: 33/98
Findings: 1
Award: $77.59
π Selected for report: 0
π Solo Findings: 0
π Selected for report: 0xSmartContract
Also found by: 0xdaydream, 0xnev, Aymen0909, Deekshith99, Diana, EvanW, Fanz, JCN, Jerry0x, K42, Kresh, Madalad, MiniGlome, Polaris_tow, Rageur, ReyAdmirado, Rolezn, SAAJ, SaeedAlipoor01988, Sathish9098, Shubham, Udsen, Viktor_Cortess, Walter, anodaram, arialblack14, atharvasama, caspersolangii, codeslide, descharre, fatherOfBlocks, felipe, ginlee, igingu, lukris02, nadin, slvDev, tnevler, turvy_fuzz, viking71
77.5893 USDC - $77.59
This report focuses on Canto Identity Protocol 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 Canto Identity Protocol are categorised into 05 main areas; with further multiple instances in each of the category.
Contract gas usage increases as EVM standard operation are of 32 bytes. If any element is smaller than 32 bytes (i.e.; 256 bits) it will cause EVM to consume more gas which can be around 12 gas depending on size for reducing the size to given output like uint8.
Link to the Code:
Compound assignment operators (+= / -=) are more expensive in terms of gas consumption and needs to be avoided.
Operator assignment (a = a + b / a - b) is preferable in terms of increasing gas optimization.
Link to the Code:
Functions with public visibility, if not called within the contract needed to be changed external.
Link to the Code:
When multiple mappings are used in same function, itβs better to combined them into a single mapping of an address 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:
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:
#0 - c4-judge
2023-04-11T04:18:06Z
0xleastwood marked the issue as grade-a