Nouns DAO contest - wagmi's results

A DAO-driven NFT project on Ethereum.

General Information

Platform: Code4rena

Start Date: 22/08/2022

Pot Size: $50,000 USDC

Total HM: 4

Participants: 160

Period: 5 days

Judge: gzeon

Total Solo HM: 2

Id: 155

League: ETH

Nouns DAO

Findings Distribution

Researcher Performance

Rank: 80/160

Findings: 2

Award: $52.10

🌟 Selected for report: 0

🚀 Solo Findings: 0

Summary

IdTitle
1Inconsistent coding style between safe32() and safe16()

1. Inconsistent coding style between safe32() and safe16()

In NounsDAOLogicV2, two function safe32() and safe16() even though have similar functionality but are implemented in different ways.

function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {
    require(n <= type(uint32).max, errorMessage);
    return uint32(n);
}

function safe16(uint256 n) internal pure returns (uint16) {
    if (n > type(uint16).max) {
        revert UnsafeUint16Cast();
    }
    return uint16(n);
}

It should be consistent for better code quality

Affected Codes

  • Refactor to make them consistent

Summary

IdTitle
1Should use memory variable when emiting events to save gas
2Cache length in the for loop and uncheck index

1. Should use memory variable when emiting events to save gas

In some function like _setProposalThresholdBPS(), we can use memory variable instead of storage variable with the same value when emiting events to save gas.

For example, in _setProposalThresholdBPS() function, we can use newProposalThresholdBPS instead of proposalThresholdBPS to save gas.

Affected Codes

2. Cache length in the for loop and uncheck index

At each iteration of the loop, length is read from storage. We can cache the length and save gas per iteration.

Solidity 0.8.0 check safe math in every operation. Use uncheck to increase index can save gas.

For example

uint256 length = arr.length; for (uint i; i < length; ) { // do stuff unchecked { ++i; } }

Affected Codes

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