Gas Optimizations #115
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Title: Gas savings for using solidity 0.8.10
Proof of Concept:
all contract
Recommended Mitigation Steps:
Consider to upgrade pragma to at least 0.8.10.
Solidity 0.8.10 has a useful change which reduced gas costs of external calls
Reference: here
Title: abi.encode() is less efficient than abi.encodePacked()
Proof of Concept:
AxelarAuthWeighted.sol#L32
Title: Default value initialization
Impact:
If a variable is not set/initialized, it is assumed to have the default value (0, false, 0x0 etc depending on the data type). Explicitly initializing it with its default value is an anti-pattern and wastes gas.
Proof of Concept:
AxelarAuthWeighted.sol#L68-L69
AxelarAuthWeighted.sol#L94-L98
Recommended Mitigation Steps:
Remove explicit initialization for default values.
Title: Using unchecked and prefix increment is more effective for gas saving:
Proof of Concept:
AxelarAuthWeighted.sol#L69
AxelarAuthWeighted.sol#L98
AxelarDepositService.sol#L114
AxelarDepositService.sol#L168
AxelarDepositService.sol#L204
AxelarGasService.sol#L123
Recommended Mitigation Steps:
Change to:
Title: Cheaper to use
++
instead+ 1
Proof of Concept:
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L636
Recommended Mitigation Steps:
Title: Caching
length
for loop can save gasProof of Concept:
AxelarDepositService.sol#L114
AxelarDepositService.sol#L168
AxelarDepositService.sol#L204
AxelarAuthWeighted.sol#L116
AxelarGasService.sol#L123
Recommended Mitigation Steps:
Change to:
Title: Comparison operators
Proof of Concept:
AxelarAuthWeighted.sol#L117
Recommended Mitigation Steps:
Replace
<=
with<
, and>=
with>
for gas optimizationTitle: Expression for
constant
values such as a call tokeccak256()
, should useimmutable
rather thanconstant
Proof of Concept:
AxelarGateway.sol#L27-L43
Recommended Mitigation Steps:
Change from
constant
toimmutable
reference: here
The text was updated successfully, but these errors were encountered: