-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# Report | ||
## Gas Optimizations ## | ||
|
||
### [G-01]: X += Y costs more gas than X = X + Y | ||
**Context:** | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/proposals/ArbitraryCallsProposal.sol#L72 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/crowdfund/Crowdfund.sol#L243 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/crowdfund/Crowdfund.sol#L352 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/crowdfund/Crowdfund.sol#L355 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/crowdfund/Crowdfund.sol#L359 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/crowdfund/Crowdfund.sol#L374 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/crowdfund/Crowdfund.sol#L411 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/crowdfund/Crowdfund.sol#L427 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/party/PartyGovernance.sol#L595 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/party/PartyGovernance.sol#L595 | ||
|
||
**Recommendation:** | ||
|
||
Change X += Y (X -= Y) to X = X + Y (X = X - Y). | ||
|
||
### [G-02]: Don't initialize variable with its default value | ||
**Context:** | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/proposals/ArbitraryCallsProposal.sol#L52 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/proposals/ArbitraryCallsProposal.sol#L61 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/proposals/ArbitraryCallsProposal.sol#L78 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/distribution/TokenDistributor.sol#L230 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/distribution/TokenDistributor.sol#L239 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/proposals/ListOnOpenseaProposal.sol#L291 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/crowdfund/Crowdfund.sol#L180 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/crowdfund/Crowdfund.sol#L242 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/crowdfund/Crowdfund.sol#L300 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/crowdfund/Crowdfund.sol#L348 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/party/PartyGovernance.sol#L306 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/proposals/LibProposal.sol#L14 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/proposals/LibProposal.sol#L32 | ||
|
||
|
||
**Description:** | ||
|
||
Default value of uint is 0. It's unnecessary and costs more gas to initialize uint variavles to 0. | ||
|
||
**Recommendation:** | ||
|
||
Change uint256 i = 0; to uint256 i; | ||
|
||
|
||
### [G-03]: >0 costs more gas than !=0 | ||
**Context:** | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/crowdfund/Crowdfund.sol#L144 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/crowdfund/Crowdfund.sol#L471 | ||
|
||
**Description:** | ||
|
||
uint256 and uint96 type will never be less than 0. | ||
|
||
**Recommendation:** | ||
|
||
Change >0 to !=0. | ||
|
||
### [G-04]: Use new variable instead of reading array length in every loop of a for-loop ### | ||
**Context:** | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/crowdfund/CollectionBuyCrowdfund.sol#L62 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/proposals/ArbitraryCallsProposal.sol#L52 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/proposals/ArbitraryCallsProposal.sol#L61 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/proposals/ArbitraryCallsProposal.sol#L78 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/distribution/TokenDistributor.sol#L230 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/distribution/TokenDistributor.sol#L239 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/proposals/ListOnOpenseaProposal.sol#L291 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/crowdfund/Crowdfund.sol#L180 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/crowdfund/Crowdfund.sol#L180 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/party/PartyGovernance.sol#L306 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/proposals/LibProposal.sol#L14 | ||
|
||
+ https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/proposals/LibProposal.sol#L32 | ||
|
||
|
||
**Description:** | ||
|
||
If you read the length of the array at each iteration of the loop, this consumes a lot of gas. | ||
|
||
|
||
**Recommendation:** | ||
|
||
Store the array’s length in a variable before the for-loop, and use this new variable in the loop. | ||
|
||
### [G-05]: i++ costs more gas than ++i ### | ||
**Context:** | ||
|
||
``` | ||
for (uint256 i; i < hosts.length; i++) { | ||
``` | ||
|
||
https://github.com/PartyDAO/party-contracts-c4/blob/main/contracts/crowdfund/CollectionBuyCrowdfund.sol#L62 | ||
|
||
**Recommendation:** | ||
|
||
Change i++ to ++i. |