Juicebox V2 contest - Randyyy's results

The decentralized fundraising and treasury protocol.

General Information

Platform: Code4rena

Start Date: 01/07/2022

Pot Size: $75,000 USDC

Total HM: 17

Participants: 105

Period: 7 days

Judge: Jack the Pug

Total Solo HM: 5

Id: 143

League: ETH

Juicebox

Findings Distribution

Researcher Performance

Rank: 92/105

Findings: 1

Award: $38.23

🌟 Selected for report: 0

🚀 Solo Findings: 0

  1. Cached array.

POC

https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/733810a0339a5c0cb608345e6fc66a6edeac13cc/contracts/JBController.sol#L1013-L1014 https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/733810a0339a5c0cb608345e6fc66a6edeac13cc/contracts/JBSingleTokenPaymentTerminalStore.sol#L861-L862

Impact

Reading array length at each iteration of the loop takes 6 gas (3 for mload and 3 to place memory_offset) in the stack.Caching the array length in the stack saves around 3 gas per iteration.

  1. x > 0 --> x != 0

POC

https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/c363abb67302314c2e061a01f76eb5e5dce2c935/contracts/JBTokenStore.sol#L356

Impact

A small gas optimization is possible by replacing x > 0 with x != 0 provide x is an unsigned integer.

  1. ++i -->> ++i

POC

https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/733810a0339a5c0cb608345e6fc66a6edeac13cc/contracts/JBSingleTokenPaymentTerminalStore.sol#L862

Impact

++i cost less gas than i++, especially when its used in for-loops.

  1. uint zero defaut value is zero.

POC

https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/733810a0339a5c0cb608345e6fc66a6edeac13cc/contracts/JBSingleTokenPaymentTerminalStore.sol#L862

Impact

Setting a variable to the default value is unnecessary. Removing lines of code where variables are initialized to zero can save gas.

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