Platform: Code4rena
Start Date: 30/06/2023
Pot Size: $100,000 USDC
Total HM: 8
Participants: 22
Period: 14 days
Judge: Trust
Total Solo HM: 6
Id: 253
League: ETH
Rank: 20/22
Findings: 1
Award: $33.48
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Raihan
Also found by: DavidGiladi, LeoS, Rageur, ReyAdmirado, Rolezn, SAAJ, SAQ, SM3_SS, Sathish9098, hunter_w3b, matrix_0wl, naman1778, petrichor
33.4768 USDC - $33.48
This report focuses on Lukso 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 Lukso protocol are categorised into 08 main areas; with further multiple instances in each of the category.
#Summary [G-01] Use hardcode address instead address(this) (07 Instances) [G-02] Use != 0 instead of > 0 for unsigned integer comparison (07 Instances) [G 03] abi.encode() is less efficient than abi.encodepacked()(03 Instances) [G 04] String literals passed to abi. encodeWithSelector()/abi.encodePacked() should not be split by commas (14 Instances) [G-05] Use assembly to check for address(0) (09 Instances) [G-06] Use calldata instead of memory for function parameters (23 Instances) [G-07] It's cheaper to declare the variable outside the loop (02 Instances) [G-08] Uint/Int lower than 32 bytes consumes more gas (09 Instances)
Instead of using address(this), it is more gas-efficient to pre-calculate and use the hardcoded address.
Link to the code:
Link to the Code:
Refer to this article.
Link to the Code:
String literals can be split into multiple parts and still be considered as a single string literal. EACH new comma costs 21 gas due to stack operations and separate MSTOREs.
Link to the Code:
Link to the Code:
Using calldata in external function does not require data to be stored, which reduced the process time as compared to memory. This in return saves gas during calling the data.
Link to the Code:
Declaring a variable inside a loop result in variable being redeclared during each loop iteration which consume higher gas. The variable gets reallocated when declared outside loop making it more gas efficient.
Link to the Code:
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:
#0 - c4-judge
2023-08-02T11:34:12Z
trust1995 marked the issue as grade-b