Axelar Network v2 contest - djxploit's results

Decentralized interoperability network.

General Information

Platform: Code4rena

Start Date: 29/07/2022

Pot Size: $50,000 USDC

Total HM: 6

Participants: 75

Period: 5 days

Judge: GalloDaSballo

Total Solo HM: 3

Id: 149

League: ETH

Axelar Network

Findings Distribution

Researcher Performance

Rank: 36/75

Findings: 2

Award: $88.01

🌟 Selected for report: 0

🚀 Solo Findings: 0

#0 - GalloDaSballo

2022-08-31T23:24:19Z

Missing 0 address check in constructor :

L

Dependence on block.timestamp, they can be manipulated

Disagree without backing

Dependence on block.chainId , they can be manipulated

I'm unable to verify that statement and for this reason will dispute, please add explanations to your reports in the future

## Use safetransfer instead of transfer Invalid, those are payable.transfer, used to transfer ETH not ERC20s

1L

Awards

31.8812 USDC - $31.88

Labels

bug
G (Gas Optimization)
sponsor acknowledged
old-submission-method

External Links

For loop gas optimizations :

In line https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/auth/AxelarAuthWeighted.sol#L69, the for loop can be optimized as :

for (uint256 i ; i < weightsLength;) { totalWeight += newWeights[i]; unchecked { ++i; } }
  • removing unnecessary initialization
  • Using unchecked , as it will not overflow , because there is a check going on.

Such for loop optimizations can be found at below line also : https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/auth/AxelarAuthWeighted.sol#L98 https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/AxelarGateway.sol#L207 Also in line : https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/auth/AxelarAuthWeighted.sol#L116 accounts.length - 1 should be pre-calculated, so that the calculation doesn't happen at every loop the for loop runs.

Also in line https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/deposit-service/AxelarDepositService.sol#L114, https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/deposit-service/AxelarDepositService.sol#L168, https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/deposit-service/AxelarDepositService.sol#L204, https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/gas-service/AxelarGasService.sol#L123, the for loop can be optimized by using ++i instead of i++ and also using unchecked.

Unnecessary initialization to default value:

In line https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/auth/AxelarAuthWeighted.sol#L68 uint256 totalWeight = 0; is not required, because totalWeight's default value is 0. Such other optimizations can be found at : https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/auth/AxelarAuthWeighted.sol#L94 https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/auth/AxelarAuthWeighted.sol#L95

If-else optimizations

In line https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/auth/AxelarAuthWeighted.sol#L76, epochForHash[newOperatorsHash] will always be greater or equal to 0, as it's an uint, so the if statement can be simplified to as : if (epochForHash[newOperatorsHash]) revert SameOperators();

Similarly in line : https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/deposit-service/AxelarDepositService.sol#L165 https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/gas-service/AxelarGasService.sol#L128 https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/gas-service/AxelarGasService.sol#L131 https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/AxelarGateway.sol#L255 https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/AxelarGateway.sol#L613 https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/AxelarGateway.sol#L228 https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/deposit-service/ReceiverImplementation.sol#L23 https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/deposit-service/ReceiverImplementation.sol#L51 https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/deposit-service/ReceiverImplementation.sol#L71

<= or >= is cheaper than > or < , so use them if possible:

https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/auth/AxelarAuthWeighted.sol#L72 https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/deposit-service/DepositBase.sol#L32 https://github.com/code-423n4/2022-07-axelar/blob/main/xc20/contracts/XC20Wrapper.sol#L85

#0 - re1ro

2022-08-05T10:11:13Z

If-else optimizations

Good spot

Rest

Dup #2 #28

#1 - GalloDaSballo

2022-08-23T00:14:50Z

Less than 300 gas saved

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter