Consider changing the _deployData
architecture
#114
Labels
bug
Warden finding
G (Gas Optimization)
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Handle
hrkrshnn
Vulnerability details
Consider changing the
_deployData
architectureCurrently, the factory contracts implements deployment in the following
fashion:
bytes memory
.abi.decode(deploydata, args)
Example
Consider directly specifying the parameters.
Advantages
_deployData
instead of(address, address, uint256, uint256)
needs larger calldata size. This is because thebytes
also needs to store the length.
is first copied from
calldata
tomemory
(note: soliditycurrently does this in an inefficient for loop, instead of using
calldatacopy
; so if you really want to keep the architecture,writing it in assembly using
calldatacopy
would be even moreefficient.) Effectively, this saves the cost to store in memory, as
well as memory expansion costs. Since the function call does a
contract deployment, the savings from memory expansion costs can be
reasonably high, assuming that the quadratic pricing is reached.
This pattern seems to be used in several other places. All of them can
be better optimized.
The text was updated successfully, but these errors were encountered: