Gas Optimizations #57
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
GAS :
1.
Title: Unnecessary owner function call
Impact:
In the
https://github.com/code-423n4/2022-02-nested/blob/main/contracts/NestedFactory.sol#L134
it uses owner function call, instead of _owner, using _owner directly can save some gasPOC :
https://github.com/code-423n4/2022-02-nested/blob/main/contracts/NestedFactory.sol#L134
Title: It cheaper to remove the
&&
operator and make the 2 different requirePOC :
https://github.com/code-423n4/2022-02-nested/blob/main/contracts/NestedAsset.sol#L78
Mitigation :
Title : It Cheaper to use 0 instead of empty string
Impact : change bytes32("") to bytes32(0) can save +- 3 gas, both check for zero bytes32
POC :
https://github.com/code-423n4/2022-02-nested/blob/main/contracts/NestedFactory.sol#L101
Mitigation :
Title : It cheaper to cached the operators to a memory instead use storage multiple times
Impact : In the
removeOperator
function it do the check in the loop by calling the operators storage, instead checking it with memory, multiple storage read is more expansive than doing multiple read from memory therefore saving the operator value to a memory first before checking inside a loop can make this call cheaper, just likeaddOperator
function do.POC :
https://github.com/code-423n4/2022-02-nested/blob/main/contracts/NestedFactory.sol#L111
Mitigation :
The text was updated successfully, but these errors were encountered: