You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
G-01: ++i/i++ should be placed in unchecked blocks to save gas as it is impossible for them to overflow in for and while loops
Unchecked keyword is available in solidity version 0.8.0 or higher and can be applied to iterator variables to save gas.
Saves more than 30 gas per loop.
src/governance/treasury/Treasury.sol
162: for (uint256 i =0; i < numTargets; ++i) {
G-05: Using uints/ints smaller than 256 bits increases overhead
Gas usage becomes higher with uint/int smaller than 256 bits because EVM operates on 32 bytes and uses additional operations to reduce the size from 32 bytes to the target size.
Gas Optimizations
G-01:
++i/i++
should be placed in unchecked blocks to save gas as it is impossible for them to overflow in for and while loopsUnchecked keyword is available in solidity version
0.8.0
or higher and can be applied to iterator variables to save gas.Saves more than
30 gas
per loop.Total instances of this issue: 2
instance #1
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/metadata/MetadataRenderer.sol#L133
instance #2
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/metadata/MetadataRenderer.sol#L229
G-02:
x += y
costs more gas thanx = x + y
for state variablesTotal instances of this issue: 6
instance #1
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/Token.sol#L88
instance #2
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/Token.sol#L118
instance #3
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/metadata/MetadataRenderer.sol#L140
instance #4
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/Governor.sol#L280
instance #5
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/Governor.sol#L285
instance #6
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/Governor.sol#L290
G-03: Adding
payable
to functions which are only meant to be called by specific actors likeonlyOwner
will save gas costMarking functions payable removes additional checks for whether a payment was provided, hence reducing gas cost
Total instances of this issue: 24
instance #1
Permalink: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/metadata/MetadataRenderer.sol#L91-L95
instance #2
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/metadata/MetadataRenderer.sol#L347
instance #3
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/metadata/MetadataRenderer.sol#L355
instance #4
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/metadata/MetadataRenderer.sol#L363
instance #5
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/metadata/MetadataRenderer.sol#L376
instance #6
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/auction/Auction.sol#L244
instance #7
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/auction/Auction.sol#L263
instance #8
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/auction/Auction.sol#L307
instance #9
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/auction/Auction.sol#L315
instance #10
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/auction/Auction.sol#L323
instance #11
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/auction/Auction.sol#L331
instance #12
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/auction/Auction.sol#L374
instance #13
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/manager/Manager.sol#L187
instance #14
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/manager/Manager.sol#L196
instance #15
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/manager/Manager.sol#L209
instance #16
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/Governor.sol#L564
instance #17
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/Governor.sol#L572
instance #18
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/Governor.sol#L580
instance #19
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/Governor.sol#L588
instance #20
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/Governor.sol#L596
instance #21
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/Governor.sol#L605
instance #22
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/Governor.sol#L618
instance #23
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/treasury/Treasury.sol#L116
instance #24
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/treasury/Treasury.sol#L180
G-04: No need to initialize non-constant/non-immutable variables to zero
Since the default value is already zero, overwriting is not required.
Saves
8 gas
per instance.Total instances of this issue: 5
instance #1
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/metadata/MetadataRenderer.sol#L119
instance #2
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/metadata/MetadataRenderer.sol#L133
instance #3
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/metadata/MetadataRenderer.sol#L189
instance #4
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/metadata/MetadataRenderer.sol#L229
instance #5
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/treasury/Treasury.sol#L162
G-05: Using uints/ints smaller than 256 bits increases overhead
Gas usage becomes higher with uint/int smaller than 256 bits because EVM operates on 32 bytes and uses additional operations to reduce the size from 32 bytes to the target size.
Total instances of this issue: 28
instance #1
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/types/TokenTypesV1.sol#L18
instance #2
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/types/TokenTypesV1.sol#L20
instance #3
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/types/TokenTypesV1.sol#L21
instance #4
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/types/TokenTypesV1.sol#L30
instance #5
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/types/TokenTypesV1.sol#L31
instance #6
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/metadata/types/MetadataRendererTypesV1.sol#L20
instance #7
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/auction/types/AuctionTypesV1.sol#L16
instance #8
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/auction/types/AuctionTypesV1.sol#L17
instance #9
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/auction/types/AuctionTypesV1.sol#L18
instance #10
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/auction/types/AuctionTypesV1.sol#L33
instance #11
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/auction/types/AuctionTypesV1.sol#L34
instance #12
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/types/GovernorTypesV1.sol#L21
instance #13
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/types/GovernorTypesV1.sol#L22
instance #14
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/types/GovernorTypesV1.sol#L24
instance #15
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/types/GovernorTypesV1.sol#L25
instance #16
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/types/GovernorTypesV1.sol#L44
instance #17
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/types/GovernorTypesV1.sol#L45
instance #18
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/types/GovernorTypesV1.sol#L46
instance #19
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/types/GovernorTypesV1.sol#L47
instance #20
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/types/GovernorTypesV1.sol#L48
instance #21
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/types/GovernorTypesV1.sol#L49
instance #22
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/types/GovernorTypesV1.sol#L50
instance #23
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/types/GovernorTypesV1.sol#L51
instance #24
Permalink: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/Governor.sol#L208-L216
instance #25
Permalink: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/IGovernor.sol#L176-L184
instance #26
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/treasury/types/TreasuryTypesV1.sol#L12
instance #27
Link: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/treasury/types/TreasuryTypesV1.sol#L13
instance #28
Permalink: https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/lib/token/ERC721Votes.sol#L144-L151
The text was updated successfully, but these errors were encountered: