Platform: Code4rena
Start Date: 15/06/2022
Pot Size: $35,000 USDC
Total HM: 1
Participants: 36
Period: 3 days
Judge: Jack the Pug
Total Solo HM: 1
Id: 137
League: ETH
Rank: 15/36
Findings: 2
Award: $116.54
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0xNazgul
Also found by: 0xDjango, 0xFar5eer, 0xf15ers, BowTiedWardens, Chom, Dravee, IllIllI, Meera, MiloTruck, PierrickGT, TerrierLover, _Adam, cccz, codexploder, cryptphi, delfin454000, fatherOfBlocks, hansfriese, joestakey, oyc_109, simon135
81.8216 USDC - $81.82
_
at their prefixes but others do not at NestedFactory.solThroughout the file NestedFactory.sol
, arguments of functions have _
at their prefixes like function setFeeSplitter(FeeSplitter _feeSplitter)
. However, following 2 arguments do not have _
at their prefixes which are not consistent.
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L121
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L133
_msgSender()
or msg.sender
Throughout the file NestedFactory.sol
, _msgSender()
is used to get the sender. However, following 2 places use msg.sender
which seem not consistent.
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L89
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L177
#0 - Yashiru
2022-06-22T15:33:29Z
Quality assurance confirmed
#1 - Yashiru
2022-06-22T15:39:13Z
_msgSender()
or msg.sender
(Confirmed)receive()
- ConfirmedunlockTokens()
- Disputed Meta-transaction are not supported by this onlyOwner function🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0xKitsune, 0xNazgul, 0xkatana, Chom, ElKu, JC, Meera, MiloTruck, Picodes, PierrickGT, SooYa, TerrierLover, UnusualTurtle, Waze, _Adam, asutorufos, c3phas, delfin454000, fatherOfBlocks, joestakey, minhquanym, oyc_109, robee, sach1r0, simon135
34.7201 USDC - $34.72
Following variables or operations can be wrapped by unchecked to reduce gas cost.
i
in the for loopFollowing codebase which contains for loop can wrap i++
by unchecked since the end condition of the for loop uses uint256 variable.
Here is an example.
for (uint256 i = 0; i < operatorsLength; i++) {
operatorsLength
is uint256, and i++ will not overflow in the for loop since it has the end condition i < operatorsLength
. The above part can be written like this by using unchecked which reduces the gas cost.
for (uint256 i = 0; i < operatorsLength; ) { // .... omitted unchecked { i++ } }
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L136
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L196
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L256
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L315
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L333
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L369
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L412
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/OperatorResolver.sol#L40
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/OperatorResolver.sol#L60
operators[operatorsLength - 1]
can be wrapped by uncheckedhttps://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L138
uint256 operatorsLength = operatorsCache.length; for (uint256 i = 0; i < operatorsLength; i++) { if (operatorsCache[i] == operator) { operatorsCache[i] = operators[operatorsLength - 1];
Since operatorsLength
is uint256, operatorsLength - 1
will not be underflown. Therefore, this part can be written like this:
uint256 operatorsLength = operatorsCache.length; for (uint256 i = 0; i < operatorsLength; i++) { if (operatorsCache[i] == operator) { unchecked { operatorsCache[i] = operators[operatorsLength - 1]; }
The default value of uint varibles are 0. Therefore, there is no need to set 0 on uint variables. Not setting 0 on uint variables can reduce the deployment gas cost.
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L124
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L136
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L196
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L315
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L333
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L369
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L412
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L651
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/OperatorResolver.sol#L40
https://github.com/code-423n4/2022-06-nested/blob/main/contracts/OperatorResolver.sol#L60
#0 - Yashiru
2022-06-24T15:37:13Z
Duplicated of #2 at For loop optimizaion
Duplicated of #2 at For loop optimizaion