You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HomeFi.sol never utilizes the onlyInitializing modifier from the initializable.sol openzeppelin contract. Therefore the initializer modifier is gas inefficient, as it unnecessarily performs logic for _initializing.
Potentially inherit from another more gas-efficient initializable implementation or implement a simpler initializable functionality that avoids such gas inefficiencies.
Variables should not be initialized to defaults (uint256 default is 0):
contracts/Community.sol::624 => for (uint256 i = 0; i < _communities[_communityID].memberCount; i++) {
contracts/HomeFiProxy.sol::87 => for (uint256 i = 0; i < _length; i++) {
contracts/HomeFiProxy.sol::136 => for (uint256 i = 0; i < _length; i++) {
contracts/Project.sol::248 => for (uint256 i = 0; i < _length; i++) {
contracts/Project.sol::311 => for (uint256 i = 0; i < _length; i++) {
contracts/Project.sol::322 => for (uint256 i = 0; i < _length; i++) {
contracts/libraries/Tasks.sol::181 => for (uint256 i = 0; i < _length; i++) _alerts[i] = _self.alerts[i];
Length of array should be computed outside of for-loop:
contracts/Community.sol::618 => // Initiate empty equal equal to member count length
contracts/HomeFiProxy.sol::78 => uint256 _length = allContractNames.length;
contracts/HomeFiProxy.sol::80 => // Revert if _implementations length is wrong. Indicating wrong set of _implementations.
contracts/HomeFiProxy.sol::81 => require(_length == _implementations.length, "Proxy::Lengths !match");
contracts/HomeFiProxy.sol::87 => for (uint256 i = 0; i < _length; i++) {
contracts/HomeFiProxy.sol::130 => uint256 _length = _contractNames.length;
contracts/HomeFiProxy.sol::132 => // Revert if _contractNames and _contractAddresses length mismatch
contracts/HomeFiProxy.sol::133 => require(_length == _contractAddresses.length, "Proxy::Lengths !match");
contracts/HomeFiProxy.sol::136 => for (uint256 i = 0; i < _length; i++) {
contracts/Project.sol::243 => // Revert if IPFS hash array length is not equal to task cost array length.
contracts/Project.sol::244 => uint256 _length = _hash.length;
contracts/Project.sol::245 => require(_length == _taskCosts.length, "Project::Lengths !match");
contracts/Project.sol::248 => for (uint256 i = 0; i < _length; i++) {
contracts/Project.sol::306 => // Revert if taskList array length not equal to scList array length.
contracts/Project.sol::307 => uint256 _length = _taskList.length;
contracts/Project.sol::308 => require(_length == _scList.length, "Project::Lengths !match");
contracts/Project.sol::311 => for (uint256 i = 0; i < _length; i++) {
contracts/Project.sol::321 => uint256 _length = _taskList.length;
contracts/Project.sol::322 => for (uint256 i = 0; i < _length; i++) {
contracts/Project.sol::367 => uint256 _length = taskCount;
contracts/Project.sol::368 => for (uint256 _taskID = 1; _taskID <= _length; _taskID++) {
contracts/Project.sol::592 => taskCount - j + _changeOrderedTask.length - i
contracts/Project.sol::601 => if (_changeOrderedTask.length > 0) {
contracts/Project.sol::602 => // Loop from lastAllocatedChangeOrderTask to _changeOrderedTask length (until _maxLoop)
contracts/Project.sol::603 => for (; i < _changeOrderedTask.length; i++) {
contracts/Project.sol::635 => if (i == _changeOrderedTask.length) {
contracts/Project.sol::707 => uint256 _length = taskCount;
contracts/Project.sol::710 => for (uint256 _taskID = 1; _taskID <= _length; _taskID++) {
contracts/libraries/SignatureDecoder.sol::25 => if (messageSignatures.length % 65 != 0) {
contracts/libraries/Tasks.sol::180 => uint256 _length = _alerts.length;
contracts/libraries/Tasks.sol::181 => for (uint256 i = 0; i < _length; i++) _alerts[i] = _self.alerts[i];
!= is more efficient than > 0 for uint comparisons:
contracts/Community.sol::261 => if (projectPublished[_project] > 0) {
contracts/Community.sol::425 => // First claim interest if principal lent > 0
contracts/Community.sol::427 => _communities[_communityID].projectDetails[_project].lentAmount > 0
contracts/Community.sol::764 => require(_repayAmount > 0, "Community::!repay");
contracts/Community.sol::840 => if (_interestEarned > 0) {
contracts/Disputes.sol::107 => _actionType > 0 && _actionType <= uint8(ActionType.TaskPay),
contracts/HomeFi.sol::245 => return projectTokenId[_project] > 0;
contracts/Project.sol::195 => require(_cost > 0, "Project::!value>0");
contracts/Project.sol::380 => if (_leftOutTokens > 0) {
contracts/Project.sol::601 => if (_changeOrderedTask.length > 0) {
contracts/Project.sol::691 => if (_loopCount > 0) emit TaskAllocated(_tasksAllocated);
Switching from division/multiplication to right-shift/left-shift can save gas:
onlyInitializing
modifier from theinitializable.sol
openzeppelin contract. Therefore the initializer modifier is gas inefficient, as it unnecessarily performs logic for_initializing
.Potentially inherit from another more gas-efficient initializable implementation or implement a simpler initializable functionality that avoids such gas inefficiencies.
The text was updated successfully, but these errors were encountered: