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
In Project.raiseDispute, all values are decoded from _data, but only the first two values are used. The additional logic required to decode the last three values costs significant gas without any benefit.
Remediation:
Don't decode the final three values as they're not being used to reduce gas usage from 217449 to 216464.
In Disputes.raiseDispute, _actionType is decoded from _data and casted to a uint8 type. This is unnecessary and inefficient as the necessary logic can be performed with a uint256, and when compiled, _actionType gets casted back to uint256 costing additional gas in the process.
Remediation:
Decode _actionType as a uint256 in Disputes.raiseDispute to reduce gas usage from 217449 to 217412.
Throughout Community.sol and Project.sol, there are storage variables which are reused within the same method. This should be generally avoided as it is much more efficient to save a variable locally and retrieve from the stack or memory instead of storage.
Remediation:
In Community.lendToProject, save _communities[_communityId] to a local variable to reduce gas usage from 190993 to 190425.
In Project.lendToProject, save builder to a local variable to reduce gas usage from 108069 to 107986
In Project.setComplete, save tasks[_taskId] to a local variable to reduce gas usage from 93713 to 93635
In Project.changeOrder, save tasks[_taskId] to a local variable to reduce gas usage from 75640 to 75459
Use optimal comparison operator
Severity: Gas Optimization
Context:
Throughout the contracts
Description:
Throughout the contracts, suboptimal comparison operators are used.
Remediation:
Optimal comparison operators should be used as follows:
When checking that uints are greater than 0, use value != 0 instead of value > 0 to save 44 gas
When checking that a uint is less/greater than or equal to another, use, e.g. value > otherValue - 1 instead of value >= otherValue to save 38 gas
The text was updated successfully, but these errors were encountered:
Avoid decoding unused values
Severity: Gas Optimization
Context:
Description:
In
Project.raiseDispute
, all values are decoded from_data
, but only the first two values are used. The additional logic required to decode the last three values costs significant gas without any benefit.Remediation:
Don't decode the final three values as they're not being used to reduce gas usage from 217449 to 216464.
Use
uint256
over smalleruint
types when possibleSeverity: Gas Optimization
Context:
Description:
In
Disputes.raiseDispute
,_actionType
is decoded from_data
and casted to auint8
type. This is unnecessary and inefficient as the necessary logic can be performed with auint256
, and when compiled,_actionType
gets casted back touint256
costing additional gas in the process.Remediation:
Decode
_actionType
as auint256
inDisputes.raiseDispute
to reduce gas usage from 217449 to 217412.Save storage variables locally when reused
Severity: Gas Optimization
Context:
Description:
Throughout
Community.sol
andProject.sol
, there are storage variables which are reused within the same method. This should be generally avoided as it is much more efficient to save a variable locally and retrieve from the stack or memory instead of storage.Remediation:
Community.lendToProject
, save_communities[_communityId]
to a local variable to reduce gas usage from 190993 to 190425.Project.lendToProject
, savebuilder
to a local variable to reduce gas usage from 108069 to 107986Project.setComplete
, savetasks[_taskId]
to a local variable to reduce gas usage from 93713 to 93635Project.changeOrder
, savetasks[_taskId]
to a local variable to reduce gas usage from 75640 to 75459Use optimal comparison operator
Severity: Gas Optimization
Context:
Description:
Throughout the contracts, suboptimal comparison operators are used.
Remediation:
Optimal comparison operators should be used as follows:
value != 0
instead ofvalue > 0
to save 44 gasvalue > otherValue - 1
instead ofvalue >= otherValue
to save 38 gasThe text was updated successfully, but these errors were encountered: