Art Gobblers contest - ReyAdmirado'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: 26/109

Findings: 2

Award: $930.57

🌟 Selected for report: 0

🚀 Solo Findings: 0

1. typo in comments

moduloing --> modulating (maybe moduleing)

2. Contracts should be deployed with the same compiler version and flags that they have been tested with thoroughly.

3. event is missing indexed fields

Each event should use three indexed fields if there are three or more fields

4. constants should be defined rather than using magic numbers

Even assembly can benefit from using readable constants instead of hex/numeric literals

5. inconsistent use of named return variables

there is an inconsistent use of named return variables in the contract some functions return named variables, others return explicit values. consider adopting a consistent approach. this would improve both the explicitness and readability of the code, and it may also help reduce regressions during future code refactors.

#0 - GalloDaSballo

2022-10-06T00:24:29Z

Typo

Disputed it's a real word

2. Contracts should be deployed with the same compiler version and flags that they have been tested with thoroughly.

NC

5. inconsistent use of named return variables

R

Rest I disagree with

1R 1NC

Awards

875.3748 USDC - $875.37

Labels

bug
G (Gas Optimization)

External Links

1. state variables only set in the constructor should be declared immutable

2. <x> += <y> costs more gas than <x> = <x> + <y> for state variables

3. not using the named return variables when a function returns, wastes deployment gas

4. can make the variable outside the loop to save gas

5. <array>.length should not be looked up in every loop of a for-loop

This reduce gas cost as show here https://forum.openzeppelin.com/t/a-collection-of-gas-optimisation-tricks/19966/5

1- if it is a storage array, this is an extra sload operation (100 additional extra gas (EIP-2929 2) for each iteration except for the first), 2- if it is a memory array, this is an extra mload operation (3 additional gas for each iteration except for the first), 3- if it is a calldata array, this is an extra calldataload operation (3 additional gas for each iteration except for the first)

6. ++i costs less gas than i++, especially when it’s used in for-loops (--i/i-- too)

Saves 6 gas per loop

7. it costs more gas to initialize non-constant/non-immutable variables to zero than to let the default of zero be applied

8. use custom errors rather than revert()/require() strings to save deployment gas

https://blog.soliditylang.org/2021/04/21/custom-errors/

9. usage of uint/int smaller than 32 bytes (256 bits) incurs overhead

When using elements that are smaller than 32 bytes, your contract’s gas usage may be higher. This is because the EVM operates on 32 bytes at a time. Therefore, if the element is smaller than that, the EVM must use more operations in order to reduce the size of the element from 32 bytes to the desired size. https://docs.soliditylang.org/en/v0.8.11/internals/layout_in_storage.html Use a larger size then downcast where needed

10. using private rather than public for constants, saves gas

If needed, the values can be read from the verified contract source code, or if there are multiple values there can be a single getter function that returns a tuple of the values of all currently-public constants. Saves 3406-3606 gas in deployment gas due to the compiler not having to create non-payable getter functions for deployment calldata, not having to store the bytes of the value outside of where it’s used, and not adding another entry to the method ID table

11. bytes constants are more efficient than string constants

If data can fit into 32 bytes, then you should use bytes32 datatype rather than bytes or strings as it is cheaper in solidity.

#0 - GalloDaSballo

2022-10-05T22:58:07Z

6.3k from immutables 100 gas rest

Will penalize as this report is clearly automated

#1 - GalloDaSballo

2022-10-05T22:58:11Z

6.4K

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