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
Rank: 31/75
Findings: 2
Award: $88.08
π Selected for report: 0
π Solo Findings: 0
π Selected for report: oyc_109
Also found by: 0x1f8b, 0x52, 0xNazgul, 0xSmartContract, 0xf15ers, 8olidity, Aymen0909, Bnke0x0, CertoraInc, Chom, CodingNameKiki, Deivitto, Dravee, ElKu, IllIllI, JC, Lambda, Noah3o6, NoamYakov, RedOneN, Respx, ReyAdmirado, Rohan16, Rolezn, Ruhum, Sm4rty, TomJ, Twpony, Waze, Yiko, __141345__, ajtra, apostle0x01, ashiq0x01, asutorufos, bardamu, benbaessler, berndartmueller, bharg4v, bulej93, c3phas, cccz, ch13fd357r0y3r, codexploder, cryptonue, cryptphi, defsec, djxploit, durianSausage, fatherOfBlocks, gogo, hansfriese, horsefacts, ignacio, kyteg, lucacez, mics, rbserver, robee, sashik_eth, simon135, sseefried, tofunmi, xiaoming90
56.196 USDC - $56.20
receive()
Function Should Emit An EventSeverity: Low
Context: DepositReceiver.sol#L29
, AxelarDepositServiceProxy.sol#L13
Description:
Consider emitting an event inside this function with msg.sender
and msg.value
as the parameters. This would make it easier to track incoming ether transfers.
Recommendation:
Add events to the receive()
functions.
Severity: Low
Context: AxelarDepositService.sol#L19 (both gateway && wrappedSymbol)
Description: These Variables shadow state variables. As a result, the use of them locally might be incorrect.
Recommendation: Rename the local variables that shadow another component.
Severity Informational
Context: AxelarDepositServiceProxy.sol#L13
, AxelarAuthWeighted.sol#L101
Description: It's best practice that when there is an empty block, to add a comment in the block exmplaining why it's empty.
Recommendation:
Consider adding /* Comment on why */
to the empty block.
Severity Informational
Context: AxelarGateway.sol#L45-L46
Description:
The linked variables do not conform to the standard naming convention of Solidity whereby functions and variable names(local, state and immutable) utilize the mixedCase
format unless variables are declared as constant
in which case they utilize the UPPER_CASE_WITH_UNDERSCORES
format.
Recommendation: Naming conventions utilized by the linked statements are adjusted to reflect the correcttype of declaration according to the Solidity style guide.
solhint-disable-next-line
Severity: Informational
Context:AxelarGateway.sol#L157
, AxelarGateway.sol#L229
, AxelarGateway.sol#L320
, AxelarGateway.sol#L344
, AxelarGateway.sol#L461
, AxelarGateway.sol#L615
, AxelarAuthWeighted.sol#L101
Description:
solhint-disable-next-line
is used elsewhere for small linter errors and can be used here to disable these errors.
Recommendation:
Consider adding solhint-disable-next-line
.
Severity: Informational
Context: AxelarGateway.sol#L22-L24
Description: There is commented code that makes the code messy and unneeded.
Recommendation: Remove the commented out code.
Severity: Informational
Context: IAxelarGasService.sol
, IAxelarDepositService.sol
, IAxelarAuthWeighted.sol
, IDepositBase.sol
Description: Contracts should be deployed with the same compiler version and flags that they have been tested with thoroughly. Locking the pragma helps to ensure that contracts do not accidentally get deployed using, for example, an outdated compiler version that might introduce bugs that affect the contract system negatively.
Recommendation: Lock the pragma version.
Severity: Informational
Context: All Contracts
Description: Some functions are missing @notice/@dev NatSpec comments for the function, @param for all/some of their parameters and @return for return values. Given that NatSpec is an important part of code documentation, this affects code comprehension, auditability and usability.
Recommendation: Add in full NatSpec comments for all functions to have complete code documentation for future use.
#0 - re1ro
2022-08-05T04:00:33Z
Receive is used when unwrapping WETH and that ether is processed. No need to emit anything. Dup #3
Good spot.
https://github.com/axelarnetwork/axelar-cgp-solidity/pull/138
Ack
Ack
Ack
It's intentional. We want to avoid reusing storage slots in future. So we keep deprecated prefixed commented
Floating Pragma is only for interfaces, so they can be imported by other projects
Ack
#1 - GalloDaSballo
2022-08-28T20:29:33Z
NC, also pretty random rule imo
##Β [NAZ-L2] Local Variable Shadowing Valid Refactoring since it happens in the constructor
Disagree in this case
Disputed, immutable variables are treated like contacts
R
NC
NC
NC
2R 4NC
π Selected for report: IllIllI
Also found by: 0x1f8b, 0xNazgul, 0xsam, 8olidity, Aymen0909, Bnke0x0, Chom, CodingNameKiki, Deivitto, Dravee, ElKu, Fitraldys, JC, Lambda, MiloTruck, Noah3o6, NoamYakov, RedOneN, Respx, ReyAdmirado, Rohan16, Rolezn, Ruhum, Sm4rty, TomJ, Tomio, Waze, __141345__, a12jmx, ajtra, ak1, apostle0x01, asutorufos, benbaessler, bharg4v, bulej93, c3phas, defsec, djxploit, durianSausage, erictee, fatherOfBlocks, gerdusx, gogo, kyteg, lucacez, medikko, mics, owenthurm, oyc_109, rbserver, robee, sashik_eth, simon135, tofunmi
31.8812 USDC - $31.88
++index
instead of index++
to increment a loop counterContext: AxelarGateway.sol#L207
, AxelarGasService.sol#L123
, AxelarDepositService.sol#L114
, AxelarDepositService.sol#L168
, AxelarDepositService.sol#L204
Description:
Due to reduced stack operations, using ++index
saves 5 gas per iteration.
Recommendation:
Use ++index
to increment a loop counter.
Context: AxelarGateway.sol#L195
, AxelarGateway.sol#L207
, AxelarGateway.sol#L292
, AxelarGasService.sol#L123
, AxelarDepositService.sol#L114
, AxelarDepositService.sol#L168
, AxelarDepositService.sol#L204
, AxelarAuthWeighted.sol#L17
, AxelarAuthWeighted.sol#L69
, AxelarAuthWeighted.sol#L98
, AxelarAuthWeighted.sol#L116
Description:
(This is only relevant if you are using the default solidity checked arithmetic). i++
involves checked arithmetic, which is not required. This is because the value of i
is always strictly less than length <= 2**256 - 1. Therefore, the theoretical maximum value of i
to enter the for-loop body is 2**256 - 2
. This means that the i++
in the for loop can never overflow. Regardless, the overflow checks are performed by the compiler.
Unfortunately, the Solidity optimizer is not smart enough to detect this and remove the checks. One can manually do this by:
for (uint i = 0; i < length; i = unchecked_inc(i)) { // do something that doesn't change the value of i } function unchecked_inc(uint i) returns (uint) { unchecked { return i + 1; } }
Note that itβs important that the call to unchecked_inc
is inlined. This is only possible for solidity versions starting from 0.8.2
.
Recommendation: The increment in the for loop post condition can be made unchecked.
Context: AxelarGateway.sol#L207
, AxelarGasService.sol#L123
, AxelarDepositService.sol#L114
, AxelarDepositService.sol#L168
, AxelarDepositService.sol#L204
, AxelarAuthWeighted.sol#L17
, AxelarAuthWeighted.sol#L98
, AxelarAuthWeighted.sol#L116
Description: One can save gas by caching the array length (in stack) and using that set variable in the loop. Replace state variable reads and writes within loops with local variable reads and writes. This is done by assigning state variable values to new local variables, reading and/or writing the local variables in a loop, then after the loop assigning any changed local variables to their equivalent state variables.
Recommendation:
Simply do something like so before the for loop: uint length = variable.length
. Then add length
in place of variable.length
in the for loop.
Context: All Contracts
Description:
You can cut out 10 opcodes in the creation-time EVM bytecode if you declare a constructor payable. Making the constructor payable eliminates the need for an initial check of msg.value == 0
and saves 21 gas on deployment with no security risks.
Recommendation: Set the constructor to payable.
Context: All Contracts
Description:
Contracts most called functions could simply save gas by function ordering via Method ID. Calling a function at runtime will be cheaper if the function is positioned earlier in the order (has a relatively lower Method ID) because 22 gas are added to the cost of a function for every position that came before it. The caller can save on gas if you prioritize most called functions. One could use This tool
to help find alternative function names with lower Method IDs while keeping the original name intact.
Recommendation:
Find a lower method ID name for the most called functions for example mostCalled()
vs. mostCalled_41q()
is cheaper by 44 gas.
#0 - re1ro
2022-08-05T03:42:55Z
Dup #2
Good spot
Ack
#1 - GalloDaSballo
2022-08-20T18:52:41Z
Less than 300 gas saved