Juicebox contest - DimSon's results

The decentralized fundraising and treasury protocol.

General Information

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

Juicebox

Findings Distribution

Researcher Performance

Rank: 59/67

Findings: 1

Award: $25.96

Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

25.9629 USDC - $25.96

Labels

bug
G (Gas Optimization)
edited-by-warden
grade-b
G-17

External Links

Gas Report

[G-01] Using calldata instead of memory for read-only arguments in external functions saves gas

When 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)

JBTiered721Delegate#mintFor

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 {

[G-02] Using bools for storage incurs overhead

Use 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:

JBTiered721Delegate

File: contracts/JBTiered721Delegate.sol #1 543: bool _expectMintFromExtraFunds;

JBTiered721Delegate

File: contracts/JBTiered721Delegate.sol #2 546: bool _dontOverspend;

JBTiered721Delegate

File: contracts/JBTiered721Delegate.sol #3 555: bool _dontMint;

#0 - c4-judge

2022-11-04T19:42:12Z

Picodes marked the issue as grade-b

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