code-423n4 / 2022-07-axelar-findings

0 stars 0 forks source link

Gas Optimizations #233

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

1.

Contract: AxelarGateway.sol

Line 207

unnecessary to initialize i in for loops
i++ costs more gas than ++i in for loops

result:

for (uint256 i; i < symbols.length; ++i)

2.

Contract: AxelarGasService.sol

Line 123

i++ costs more gas than ++i in for loops

result:

for (uint256 i; i < tokens.length; ++i)

3.

Contract: AxelarDepositService.sol

Line 168 Line 204

i++ costs more gas than ++i in for loops

Result:

for (uint256 i; i < refundTokens.length; ++i)
for (uint256 i; i < refundTokens.length; ++i)

4.

Contract: AxelarAuthWeighted.sol

Line 69 Line 98

unnecessary to initialize i in for loops

Result:

for (uint256 i; i < weightsLength; ++i)
for (uint256 i; i < signatures.length; ++i)

This will also provide consistency across the rest of the code given that all other for loops are stated as such

GalloDaSballo commented 2 years ago

50 gas at most