Platform: Code4rena
Start Date: 08/05/2023
Pot Size: $90,500 USDC
Total HM: 17
Participants: 102
Period: 7 days
Judge: 0xean
Total Solo HM: 4
Id: 236
League: ETH
Rank: 97/102
Findings: 1
Award: $44.94
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: JCN
Also found by: 0xAce, 0xSmartContract, Aymen0909, K42, Rageur, Raihan, ReyAdmirado, SAAJ, SM3_SS, Sathish9098, Team_Rocket, Udsen, c3phas, codeslide, descharre, fatherOfBlocks, hunter_w3b, j4ld1na, lllu_23, matrix_0wl, naman1778, petrichor, pontifex, rapha, souilos, wahedtalash77
44.9387 USDC - $44.94
Calldata arrays are more gas efficient compared to memory arrays when passed as function arguments. That is true when the following conditions have been met:
The following files are affected:
File: contracts/Comptroller.sol 154: function enterMarkets(address[] memory vTokens) external override returns (uint256[] memory) {
https://github.com/code-423n4/2023-05-venus/blob/9853f6f4fe906b635e214b22de9f627c6a17ba5b/contracts/Comptroller.sol#L154
This actually is in contrast to the extended ComptrollerInterface.sol
which implements function enterMarkets(address[] calldata)
.
File: contracts/Rewards/RewardsDistributor.sol 197: function setRewardTokenSpeeds( 198: VToken[] memory vTokens, 199: uint256[] memory supplySpeeds, 200: uint256[] memory borrowSpeeds 201: ) external {
The total gas saved will amount to 952
Change all the memory arrays received in the function arguments to calldata arrays:
File: contracts/Comptroller.sol 154: function enterMarkets(address[] calldata vTokens) external override returns (uint256[] memory) {
File: contracts/Rewards/RewardsDistributor.sol 197: function setRewardTokenSpeeds( 198: VToken[] calldata vTokens, 199: uint256[] calldata supplySpeeds, 200: uint256[] calldata borrowSpeeds 201: ) external {
#0 - c4-judge
2023-05-18T17:51:12Z
0xean marked the issue as grade-b