Platform: Code4rena
Start Date: 04/01/2023
Pot Size: $60,500 USDC
Total HM: 15
Participants: 105
Period: 5 days
Judge: gzeon
Total Solo HM: 1
Id: 200
League: ETH
Rank: 72/105
Findings: 1
Award: $38.76
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0xSmartContract
Also found by: 0x1f8b, 0xhacksmithh, Aymen0909, Bnke0x0, IllIllI, Rageur, RaymondFam, Rickard, Rolezn, Secureverse, arialblack14, chaduke, chrisdior4, cthulhu_cult, giovannidisiena, gz627, lukris02, oyc_109, pavankv, privateconstant, shark
38.7634 USDC - $38.76
Each extra memory word of bytes past the original 32 incurs an MSTORE which costs 3 gas.
• MultiSend.sol (Line: 27) • SmartAccount.sol (Line: 77, 110, 128) • SmartAccountFactory.sol (Line: 18, 77, 110, 128) • VerifyingSingletonPaymaster.sol (Line: 36, 37, 42, 49, 50, 66, 107, 108, 109)
Using shifting instead of multiplication or division for values that are multiple of 2 [2, 4, 8, 16 ...] can reduce gas.
• Math.sol (Line: 36) • SmartAccount.sol (Line: 200, 224)
Using the addition operator instead of plus-equals saves gas
• VerifyingSingletonPaymaster.sol (Line: 51, 58, 128)
Using less or equal required more instruction than a single less hence reducing the gas
• EntryPoint.sol (Line: 213, 237, 397) • SmartAccount.sol (Line: 182, 224, 322, 325, 333) • SmartAccountNoAuth.sol (Line: 182, 224, 317, 320, 328) • VerifyingSingletonPaymaster.sol (Line 57, 109)
require(a <= b); x = b - a => require(a <= b); unchecked { x = b - a } if(a <= b); x = b - a => if(a <= b); unchecked { x = b - a }
This will stop the check for overflow and underflow so it will save gas
• EntryPoint.sol (Line 354)
In Solidity 0.8+, there’s a default overflow check on unsigned integers. It’s possible to uncheck this in for-loops and save some gas at each iteration, but at the cost of some code readability, as this uncheck cannot be made inline. Moreover, to save even more gas, it is recommended to use ++i instead of i++.
• EntryPoint.sol (Line: 74, 80, 100, 107, 112, 128, 134) • SimpleAccount.sol (Line: 71)
The named return variable are not used which cause some extra gas at the deployment
• SmartAccount.sol (Line: 506) • VerifyingSingletonPaymaster.sol (Line: 97)
Checks that involve constants should come before checks that involve state variables, function calls, and calculations. By doing these checks first, the function is able to revert before wasting a Gcoldsload (2100 gas*) in a function that may ultimately revert in the unhappy case.
• ModuleManager.sol (Line 25) • SmartAccount.sol (Line: 171)
#0 - c4-judge
2023-01-22T16:22:52Z
gzeon-c4 marked the issue as grade-b
#1 - c4-sponsor
2023-02-09T11:22:32Z
livingrockrises marked the issue as sponsor confirmed