Art Gobblers contest - Tadashi's results

Experimental Decentralized Art Factory By Justin Roiland and Paradigm.

General Information

Platform: Code4rena

Start Date: 20/09/2022

Pot Size: $100,000 USDC

Total HM: 4

Participants: 109

Period: 7 days

Judge: GalloDaSballo

Id: 163

League: ETH

Art Gobblers

Findings Distribution

Researcher Performance

Rank: 48/109

Findings: 2

Award: $123.86

🌟 Selected for report: 0

🚀 Solo Findings: 0

Left shift could be replaced by multiplication without losing gas

Summary: << 1 can be replaced by *2 without losing gas and increasing readability.

Details: L844 of ArtGobblers.sol contains a left shift which is equivalent to multiplication by 2. While representing a multiplication by a power of 2 by left shifts can save gas, this do not occur here. Hence, consider changing the left shift by an explicit multiplication by 2.

Impact: Code QA

Suggestion: Consider changing the left shift by a multiplication by 2.

#0 - GalloDaSballo

2022-10-06T00:33:34Z

1R

Awards

68.6605 USDC - $68.66

Labels

bug
G (Gas Optimization)

External Links

Computation of Goo balance can be optimized

Summary: Pre-computing the square root of 1e18 in computeGOOBalance saves gas.

Details: Perform this change in L38 of LibGoo.sol:

-(emissionMultiple * lastBalanceWad * 1e18).sqrt()
+(emissionMultiple * lastBalanceWad).sqrt() * 1e9

⛽ Profiling: Computed using forge snapshot --diff:

testCanMintPageFromVirtualBalance() (gas: -24 (-0.008%)) 
testGooAddition() (gas: -20 (-0.008%)) 
testGooRemoval() (gas: -24 (-0.009%)) 
testMintFromGooBalance() (gas: -24 (-0.009%)) 
testSnapshotDoesNotAffectBalance() (gas: -96 (-0.024%)) 
Overall gas change: -188 (-0.059%)

Notes: - The comments in the previous lines should be rewritten if this change is made - The resolution of the operation will decrease if this change is made

Block of code can be made unchecked

Summary: part of tokenURI can be made unchecked

Details: Since there will be only 10 legendary Globbers, L707-L709 of ArtGobblers.sol can be changed to

unchecked {
	if (gobblerId < FIRST_LEGENDARY_GOBBLER_ID + legendaryGobblerAuctionData.numSold)
	  return string.concat(BASE_URI, gobblerId.toString());
}

⛽ Profiling: Computed using forge snapshot --diff:

testMintedLegendaryURI() (gas: -161 (-0.000%)) 
testUnmintedLegendaryUri() (gas: -402 (-1.588%)) 
Overall gas change: -563 (-1.589%)

Post-increments that can be replaced by pre-increments

Summary: Pre-incrementing a variable is cheaper than post-incrementing it. For more information, see G012 of c4-common-issues.

Details: Consider the following changes:

  1. L37 of ArtGobblers.sol

    -for (uint256 i = 0; i < ids.length; i++) {
    +for (uint256 i = 0; i < ids.length; ++i) {
  2. L251 of Pages.sol

    -for (uint256 i = 0; i < numPages; i++) _mint(community, ++lastMintedPageId);
    +for (uint256 i = 0; i < numPages; ++i) _mint(community, ++lastMintedPageId);

⛽ Profiling: Computed using forge snapshot --diff:

testCanWithdraw() (gas: -6 (-0.001%)) 
testFeedingArt() (gas: -224 (-0.087%)) 
testPagePricingPricingBeforeSwitch() (gas: -820505 (-0.365%)) 
testPagePricingPricingAfterSwitch() (gas: -2685499 (-0.743%)) 
testCantMintTooFastCommunityOneByOne() (gas: -57520 (-0.970%)) 
testCantMintTooFastCommunity() (gas: -21566 (-1.835%)) 
testCanMintMultipleCommunity() (gas: -39536 (-3.196%)) 
testCanMintCommunity() (gas: -37288 (-5.721%)) 
testCanMintPageFromVirtualBalance() (gas: -22181 (-7.406%)) 
testCantFeed721As1155() (gas: -17745 (-7.541%)) 
testMintPage() (gas: -5081 (-8.639%)) 
testMintPageUsingVirtualBalance() (gas: -5081 (-8.782%)) 
testCantgobbleToUnownedGobbler() (gas: -17745 (-15.405%)) 
testRegularMint() (gas: -17745 (-16.310%)) 
testMintCommunityPages() (gas: -22181 (-37.596%)) 
Overall gas change: -3769903 (-114.598%)

#0 - GalloDaSballo

2022-10-05T00:24:33Z

Can't argue with Benchmarks

751 from first 2 findings will give 25 for the 3rd 776

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