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
For loop written like thisfor (uint256 i; i < array.length; ++i) { will cost more gas than for (uint256 i; i < _lengthOfArray; ++i) { because for every iteration we use mload and memory_offset
that will cost about 6 gas
Use of bit shifting operations are more cheap than normal multiplication/division operations. MUL and DIV costs 5 gas rather than SHL and SHR that costs 3 gas. You can use them where is possible
Use defualt value rather than overwriite variable with their default value.
Overriting varibles with defualt values with their default value will waste only gas and not necessary.
There are 3 instances of this issue:
Findings:
https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/Kernel.sol#L397
https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/utils/KernelUtils.sol#L43
In for loop use outside variable for array length
For loop written like this
for (uint256 i; i < array.length; ++i) {
will cost more gas thanfor (uint256 i; i < _lengthOfArray; ++i) {
because for every iteration we use mload and memory_offsetthat will cost about 6 gas
There are 2 instances of this issue:
Findings:
https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/policies/Governance.sol#L278
https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/utils/KernelUtils.sol#L58
++i
/--i
are more cheap operations thani++
/i--
Using a
++i
/--i
operations can save about 6 gas for loop/instance because compiler will make less operationsThere are 2 instances of this issue:
https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/utils/KernelUtils.sol#L49
If you use bit shifting will save some gas
Use of bit shifting operations are more cheap than normal multiplication/division operations.
MUL
andDIV
costs 5 gas rather thanSHL
andSHR
that costs 3 gas. You can use them where is possibleThere are 3 instances of this issue:
Findings:
https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/policies/Operator.sol#L372
The text was updated successfully, but these errors were encountered: