Category: Code Maturity
Redundant assignment
Informational Impact
Informational Severity
N/A Likelihood
Description
The initialize function in DealManager sets corp and dealRegistry twice — directly through LexScrowStorage.set* and again within __LexScroWLite_init.
function initialize(address _auth, address _corp, address _dealRegistry, address _issuanceManager, address _upgradeFactory) public initializer {
// [...]
LexScrowStorage.setCorp(_corp);
LexScrowStorage.setDealRegistry(_dealRegistry);
// [...]
// [...]
__LexScroWLite_init(_corp, _dealRegistry);
// [...]
}
function __LexScroWLite_init(address _corp, address _dealRegistry) internal onlyInitializing {
LexScrowStorage.setCorp(_corp);
LexScrowStorage.setDealRegistry(_dealRegistry);
}These redundant assignments waste gas by writing the same values to storage twice.
Impact
The function consumes additional gas for redundant storage writes.
Recommendations
Remove the direct setCorp and setDealRegistry calls from initialize. Rely solely on __LexScroWLite_init to set these values.
Remediation
This issue has been acknowledged by MetaLex, and a fix was implemented in commit 291e723d↗.