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
Rank: 41/109
Findings: 2
Award: $123.86
π Selected for report: 0
π Solo Findings: 0
π Selected for report: IllIllI
Also found by: 0x1f8b, 0x4non, 0x52, 0x5rings, 0xNazgul, 0xRobocop, 0xSmartContract, 0xdeadbeef, 0xsanson, 8olidity, Amithuddar, Aymen0909, B2, B353N, CertoraInc, Ch_301, Chom, CodingNameKiki, Deivitto, ElKu, Funen, JC, JohnnyTime, Kresh, Lambda, Noah3o6, RaymondFam, ReyAdmirado, RockingMiles, Rolezn, Sm4rty, SuldaanBeegsi, Tadashi, TomJ, Tomio, V_B, Waze, __141345__, a12jmx, ak1, arcoun, asutorufos, aviggiano, berndartmueller, bharg4v, bin2chen, brgltd, bulej93, c3phas, catchup, cccz, ch0bu, cryptonue, cryptphi, csanuragjain, delfin454000, devtooligan, djxploit, durianSausage, eighty, erictee, exd0tpy, fatherOfBlocks, giovannidisiena, hansfriese, ignacio, joestakey, ladboy233, lukris02, m9800, malinariy, martin, minhtrng, obront, oyc_109, pedr02b2, pedroais, pfapostol, philogy, prasantgupta52, rbserver, ronnyx2017, rotcivegaf, rvierdiiev, sach1r0, shung, simon135, throttle, tnevler, tonisives, wagmi, yixxas, zkhorse, zzykxx, zzzitron
55.1985 USDC - $55.20
Severity Low
Context: ArtGobblers.sol#L260
, ArtGobblers.sol#L736
Description:
On #L260 there is error Cannibalism();
leading to that Gobblers should not eat other Gobblers. However, Gobblers can be wrapped into a new token and be force feed to other Gobblers.
Proof of Concept:
Recommendation: No real way to stop a user from doing this. Should however be outlined in the documentation so that users/developers can know that this can still happen.
Severity Low
Context: Owned.sol#L39
Description: This function transfers the ownership of the contract in a single step. There is no way to reverse a one-step transfer of ownership to an address without an owner. This would not be the case if ownership were transferred through a two-step process in which an owner proposed a transfer and the prospective recipient accepted it.
Recommendation: Consider using a two-step process for ownership transfers.
Severity: Low
Context: Owned.sol#L39
, ArtGobblers.sol#L560
Description: Setter functions are missing checks to validate if the new value being set is the same as the current value already set in the contract. Such checks will showcase mismatches between on-chain and off-chain states.
Recommendation: This may hinder detecting discrepancies between on-chain and off-chain states leading to flawed assumptions of on-chain state and protocol behavior.
Severity: Low
Context: Owned.sol#L39
Description: When critical parameters of systems need to be changed, it is required to broadcast the change via event emission and recommended to enforce the changes after a time-delay. This is to allow system users to be aware of such critical changes and give them an opportunity to exit or adjust their engagement with the system accordingly. None of the onlyOwner functions that change critical protocol addresses/parameters have a timelock for a time-delayed change to alert: (1) users and give them a chance to engage/exit protocol if they are not agreeable to the changes (2) team in case of compromised owner(s) and give them a chance to perform incident response.
Recommendation: Users may be surprised when critical parameters are changed. Furthermore, it can erode users' trust since they canβt be sure the protocol rules wonβt be changed later on. Compromised owner keys may be used to change protocol addresses/parameters to benefit attackers. Without a time-delay, authorized owners have no time for any planned incident response.
Severity: Low
Context: Owned.sol#L39
, ArtGobblers.sol#L292-L296
, ArtGobblers.sol#L560
, PagesERC721.sol#L37
, Pages.sol#L160-L162
, ChainlinkV1RandProvider.sol#L49-L51
, Goo.sol#L82
, GobblerReserve.sol#L23
Description: Lack of zero-address validation on address parameters may lead to transaction reverts, waste gas, require resubmission of transactions and may even force contract redeployments in certain cases within the protocol.
Recommendation: Consider adding explicit zero-address validation on input parameters of address type.
Severity: Informational
Context: DeployRinkeby.s.sol#L13-L15
, MerkleProofLib.sol#L23
, LibString.sol#L30
Description: It's best practice that when there is an empty block, to add a comment in the block explaining why it's empty.
Recommendation:
Consider adding /* Comment on why */
to the empty blocks.
Severity: Informational
Context: ArtGobblers.sol#L475-L476
, ArtGobblers.sol#L499
Description: Max line length must be no more than 120 but many lines are extended past this length.
Recommendation: Consider cutting down the line length below 120.
Severity Informational
Context: ArtGobblers.sol#L136-L139
, ArtGobblers.sol#L813
, Pages.sol#L96
, Pages.sol#L122
, Pages.sol#L128
, ChainlinkV1RandProvider.sol#L27-L30
, ChainlinkV1RandProvider.sol#L73
, DeployBase.s.sol#L18-L27
, DeployRinkeby.s.sol#L13-L15
, LogisticToLinearVRGDA.sol#L20-L28
, LogisticVRGDA.sol#L30
, VRGDA.sol#L21
, LinearVRGDA.sol#L19
, FixedPointMathLib.sol#L12
Description:
The linked variables do not conform to the standard naming convention of Solidity whereby functions and variable names(local and state) utilize the mixedCase
format unless variables are declared as constant
in which case they utilize the UPPER_CASE_WITH_UNDERSCORES
format. Private variables and functions should lead with an _underscore
.
Recommendation: Consider naming conventions utilized by the linked statements are adjusted to reflect the correct type of declaration according to the Solidity style guide.
Severity: Informational
Context: ArtGobblers.sol#L187
, ArtGobblers.sol#L804
, GobblersERC1155B.sol#L37
, GobblersERC721.sol#L23-L25
, PagesERC721.sol#L24-L26
, Owned.sol#L17
, ERC721.sol#L21-L23
Description: The best-practice layout for a contract should follow the following order: state variables, events, modifiers, constructor and functions. Function ordering helps readers identify which functions they can call and find constructor and fallback functions easier. Functions should be grouped according to their visibility and ordered as: constructor, receive function (if exists), fallback function (if exists), external, public, internal, private. Functions should then further be ordered with view functions coming after the non-view labeled ones.
Recommendation: Consider adopting recommended best-practice for code structure and layout.
Severity: Informational
Context: ArtGobblers.sol#L112
, ArtGobblers.sol#L115
Description: There are multiple occasions where certain numbers have been hardcoded, either in variables or in the code itself. Large numbers can become hard to read.
Recommendation: Consider using underscores for number literals to improve its readability.
mul
Severity: Informational
Context: ArtGobblers.sol#L844
Description: It will increase readability for future developers and users.
Recommendation:
Consider using mul
instead of the left shift
Severity: Informational
Context: ArtGobblers.sol#L441
Description: There is an inconsistent use of inline delete in the event. It will increase readability for future developers and users if done outside the event.
Recommendation: Consider Moving the inline delete outside of the event.
Severity: Informational
Context: All Contracts
Description: Some functions are missing @notice/@dev NatSpec comments for the function, @param for all/some of their parameters and @return for return values. Given that NatSpec is an important part of code documentation, this affects code comprehension, auditability and usability.
Recommendation: Consider adding in full NatSpec comments for all functions to have complete code documentation for future use.
#0 - GalloDaSballo
2022-10-04T21:44:37Z
NC
NC
NC
Disputed per rulebook
L
Will not consider, given the specific instances which are heavily optimized, you'd have to explain why this is an issue
NC
NC, some of these are false positives
Not sold on this one in lack of detail
Disagree for the specific instances given, 10k is fine as literal
R
Disagree for the specific instance
I must disagree, the code is well commented, specific instances would have helped more imo
All in all good report but I really can feel the automated text which would benefit by having some re-elaboration to tailor it for the Sponsor
#1 - GalloDaSballo
2022-10-04T21:44:53Z
1L 1R 5NC
π Selected for report: IllIllI
Also found by: 0x1f8b, 0xNazgul, 0xSmartContract, Atarpara, CertoraInc, Deathstore, Deivitto, ElKu, MiloTruck, ReyAdmirado, SnowMan, Tadashi, V_B, __141345__, aviggiano, catchup, djxploit, gogo, pfapostol, philogy, shung
68.6605 USDC - $68.66
Context: ArtGobblers.sol#L202
Description: Currently in the struct there are 248 bits being used and this is a was of gas when the struct is read from as a whole. It would be cheaper to fill the struct to 256 bits.
Recommendation: Consider filling in the extra bits left in the struct.
_batchMint
for Page Reserve MintingContext: Pages.sol#L251
Description:
There are benefits to using _batchMint()
as such:
Recommendation:
Consider using _batchMint()
for page reserve minting to save gas.
++index
instead of index++
to increment a loop counterContext: Pages.sol#L251
, GobblerReserve.sol#L37
Description:
Due to reduced stack operations, using ++index
saves 5 gas per iteration.
Recommendation:
Use ++index
to increment a loop counter.
++index
instead of index++
to increment a loop counterContext: Pages.sol#L251
, GobblerReserve.sol#L37
Description:
Due to reduced stack operations, using ++index
saves 5 gas per iteration.
Recommendation:
Use ++index
to increment a loop counter.
Context: ArtGobblers.sol
, GobblersERC1155B.sol
, GobblersERC721.sol
, PagesERC721.sol
, VRGDA.sol
Description: To save some gas the use of custom errors leads to cheaper deploy time cost and run time cost. The run time cost is only relevant when the revert condition is met.
Recommendation: Use Custom Errors instead of strings.
Context: All Contracts
Description:
You can cut out 10 opcodes in the creation-time EVM bytecode if you declare a constructor payable. Making the constructor payable eliminates the need for an initial check of msg.value == 0
and saves 21 gas on deployment with no security risks.
Recommendation: Set the constructor to payable.
Context: All Contracts
Description:
Contracts most called functions could simply save gas by function ordering via Method ID. Calling a function at runtime will be cheaper if the function is positioned earlier in the order (has a relatively lower Method ID) because 22 gas are added to the cost of a function for every position that came before it. The caller can save on gas if you prioritize most called functions. One could use This tool
to help find alternative function names with lower Method IDs while keeping the original name intact.
Recommendation:
Find a lower method ID name for the most called functions for example mostCalled()
vs. mostCalled_41q()
is cheaper by 44 gas.
#0 - GalloDaSballo
2022-10-04T23:08:56Z
50 gas on rest
200 gas for batchMint as the idea is neat but as you prob know there's no code for it
#1 - GalloDaSballo
2022-10-04T23:09:10Z
250
#2 - GalloDaSballo
2022-10-04T23:09:31Z
Please stop posting the methodId finding, I've marked this as invalid for months now
#3 - GalloDaSballo
2022-10-16T16:37:17Z
Chosing not to mark as unsatisfactory because of the uniqueness of the _batchMint advice, despite what I've rated as low savings