Foundation Drop contest - sikorico's results

Foundation is a web3 destination.

General Information

Platform: Code4rena

Start Date: 11/08/2022

Pot Size: $40,000 USDC

Total HM: 8

Participants: 108

Period: 4 days

Judge: hickuphh3

Total Solo HM: 2

Id: 152

League: ETH

Foundation

Findings Distribution

Researcher Performance

Rank: 57/108

Findings: 2

Award: $61.80

馃専 Selected for report: 0

馃殌 Solo Findings: 0

QA REPORT

[QA 00] Timelock is missing for the following functions

Proof of concept:

[QA 01] Mismatched solidity versions

The code is compiled with more than one solidity version which can cause undesired behavior.

[QA 02] Use safeTransfer instead transfer in the following locations

Proof of concept:

[QA 03] Magic number, consider using named constant instead.

Proof of concept:

[QA 04] Avoid Floating pragma

Proof of concept:

[QA 05] Missing event indexers

Proof of concept:

[QA 06] Remove the name from the following unused function parameters

Proof of concept:

[QA 07] Not emitted event for state changes

Proof of concept:

[QA 08] Both return statement and named return

For readability purposes consider having one of the two return options (for the following functions)

Proof of concept:

#0 - HardlyDifficult

2022-08-18T20:26:28Z

[QA 00] Timelock is missing for the following functions

Invalid: this is a test file.

[QA 01] Mismatched solidity versions

Invalid - all files are compiled with 0.8.16

[QA 02] Use safeTransfer instead transfer in the following locations

Out of scope for this contest.

[QA 03] Magic number, consider using named constant instead.

FETH.sol#L209 Out of scope.

OZERC165Checker.sol#L34 OZERC165Checker.sol#L33 This file is a slightly modified clone from OpenZeppelin, we are aiming to minimize changes in this file.

FixedPriceDrop.sol#L39

We believe 24 hours is already pretty clear, a constant is not required.

Use fixed pragma

Disagree. We intentionally use a floating pragma in order to make integrating with contracts easier. Other contract developers are looking to interact with our contracts and they may be on a different version than we use. The pragma selected for our contracts is the minimum required in order to correctly compile and function. This way integration is easier if they lag a few versions behind, or if they use the latest but we don't bump our packages frequently enough, and when we do upgrade versions unless there was a breaking solidity change -- it should just swap in by incrementing our npm package version.

Missing indexed event parameters

I believe this is invalid. index should be reserved for params that are likely to be requested as a filter. In these examples those params are data not really filter candidates. And for the string specifically, indexed would prevent the full information from being communicated, requiring a second unindexed version which is a bit redundant and increases gas costs.

[QA 06] Remove the name from the following unused function parameters

Invalid, these blocks are required to avoid compile errors.

[QA 07] Not emitted event for state changes

FoundationTreasuryNode.sol#L47 We don't feel that events are required in a constructor.

FixedPriceDrop.sol#L27 This is a test file.

ContractFactory.sol#L30 We don't feel that events are required in a constructor.

Use named returns consistently

Agree, we have opted to use the named returns instead of return ... This is more consistent with other code in our repo and saves a bit of on the contract size. We also like named returns as a way of improving natspec, and typechain (particularly when a tuple is returned).

GAS REPORT

[GAS 00] Use custom error instead string error for the following require statements

Proof of concept:

[GAS 01] Unnecessary caching of msg.sender

Proof of concept:

[GAS 02] abiEncodePacked() instead abiEncode() in the following locations

Proof of concept:

[GAS 03] Use > 0 instead != 0 to check if an unsigned int is not 0

Proof of concept:

[GAS 04] Cache the array size for the following loops over array

Proof of concept:

#0 - HardlyDifficult

2022-08-17T18:55:17Z

[GAS 00] Use custom error instead string error for the following require statements

Agree but won't fix at this time. We use these in the market but not in collections. Unfortunately custom errors are still not as good of an experience for users (e.g. on etherscan). We used them in the market originally because we were nearing the max contract size limit and this was a good way to reduce the bytecode. We'll consider this in the future as tooling continues to improve.

[GAS 01] Unnecessary caching of msg.sender

Invalid. Neither of the functions linked even use msg.sender

[GAS 02] abiEncodePacked() instead abiEncode() in the following locations

Invalid... while it seems like this should help, changing to .encode makes creating collections slightly more expensive. createNFTCollection increased by 9 gas and createNFTDropCollection increased by 8-10 gas

[GAS 03] Use > 0 instead != 0 to check if an unsigned int is not 0

Invalid. We tested the recommendation and got the following results:

createNFTDropCollection gas reporter results: using > 0 (current): - 319246 路 319578 路 319361 using != 0 (recommendation): - 319252 路 319584 路 319367 impact: +6 gas

[GAS 04] Cache the array size for the following loops over array

Invalid - the contract referenced here was labeled as out of scope.

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