Platform: Code4rena
Start Date: 18/10/2022
Pot Size: $50,000 USDC
Total HM: 13
Participants: 67
Period: 5 days
Judge: Picodes
Total Solo HM: 7
Id: 172
League: ETH
Rank: 59/67
Findings: 1
Award: $25.96
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Jeiwan
Also found by: 0x1f8b, 0x4non, 0x5rings, 0xSmartContract, Awesome, Aymen0909, Bnke0x0, CodingNameKiki, Diana, DimSon, JC, JrNet, LeoS, RaymondFam, ReyAdmirado, Saintcode_, Shinchan, __141345__, berndartmueller, bharg4v, brgltd, carlitox477, ch0bu, chaduke, cryptostellar5, emrekocak, gogo, lukris02, martin, mcwildy, sakman, trustindistrust, zishansami
25.9629 USDC - $25.96
calldata
instead of memory
for read-only arguments in external
functions saves gasWhen a function with a memory
array is called externally, the abi.decode()
step has to use a for-loop to copy each index of the calldata
to the memory
index. Each iteration of this for-loop costs at least 60 gas (i.e. 60 * <mem_array>.length
). Using calldata
directly, obliviates the need for such a loop in the contract code and runtime execution.
If the array is passed to an internal
function which passes the array to another internal
function where the array is modified and therefore memory is used in the external
call, it's still more gass-efficient to use calldata
when the external
function uses modifiers, since the modifiers may prevent the internal functions from being called. Structs have the same overhead as an array of length one
There are 7 instance(s) of this issue:
JBTiered721Delegate#mintReservesFor
File: contracts/JBTiered721Delegate.sol #1 264: function mintReservesFor(JBTiered721MintReservesForTiersData[] memory _mintReservesForTiersData)
File: contracts/JBTiered721Delegate.sol #2 290: function mintFor(JBTiered721MintForTiersData[] memory _mintForTiersData)
JBTiered721Delegate#setBaseUri
File: contracts/JBTiered721Delegate.sol #3 386: function setBaseUri(string memory _baseUri) external override onlyOwner {
JBTiered721DelegateProjectDeployer#launchProjectFor
File: contracts/JBTiered721DelegateProjectDeployer.sol #4 72: JBDeployTiered721DelegateData memory _deployTiered721DelegateData,
JBTiered721DelegateProjectDeployer#launchFundingCyclesFor
File: contracts/JBTiered721DelegateProjectDeployer.sol #5 109: JBDeployTiered721DelegateData memory _deployTiered721DelegateData,
JBTiered721DelegateProjectDeployer#reconfigureFundingCyclesOf
File: contracts/JBTiered721DelegateProjectDeployer.sol #6 152: JBDeployTiered721DelegateData memory _deployTiered721DelegateData,
JBTiered721DelegateStore#recordBurn
File: contracts/JBTiered721DelegateStore.sol #7 1091: function recordBurn(uint256[] memory _tokenIds) external override {
bool
s for storage incurs overheadUse uint256(1)
and uint256(2)
for true/false to avoid a Gwarmaccess (100 gas), and to avoid Gsset (20000 gas) when changing from 'false' to 'true', after having been 'true' in the past
There are 3 instance(s) of this issue:
File: contracts/JBTiered721Delegate.sol #1 543: bool _expectMintFromExtraFunds;
File: contracts/JBTiered721Delegate.sol #2 546: bool _dontOverspend;
File: contracts/JBTiered721Delegate.sol #3 555: bool _dontMint;
#0 - c4-judge
2022-11-04T19:42:12Z
Picodes marked the issue as grade-b