The Factory.sol contract made use of a number of public variables that were set only in the constructor and would remain constant. These variables were consuming storage slots, which unnecessarily increased the deployment and runtime gas costs of the contract.
By removing the public keyword from all variables that are not required (which are only used in the unit tests), the deployment costs can be further reduced.
Handle
bw
Vulnerability details
Impact
The
Factory.sol
contract made use of a number ofpublic
variables that were set only in the constructor and would remain constant. These variables were consuming storage slots, which unnecessarily increased the deployment and runtime gas costs of the contract.For more information regarding the
immutable
keyword: https://blog.soliditylang.org/2020/05/13/immutable-keyword/Proof of Concept
Code Diff
Gas Improvement
By removing the
public
keyword from all variables that are not required (which are only used in the unit tests), the deployment costs can be further reduced.Tools Used
https://www.npmjs.com/package/hardhat-gas-reporter
Recommended Mitigation Steps
Add the immutable key word to all variables that are only set during the constructor.