Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCS-01C: Inefficient Hash Constants #29

Open
JayWelsh opened this issue Dec 16, 2021 · 2 comments
Open

SCS-01C: Inefficient Hash Constants #29

JayWelsh opened this issue Dec 16, 2021 · 2 comments

Comments

@JayWelsh
Copy link
Contributor

SCS-01C: Inefficient Hash Constants

Type Severity Location
Gas Optimization Informational SeenConstants.sol:L17-L22

Description:

The linked constant declarations are meant to be assigned to the result of a keccak256 instruction. Contrary to the expected, constant variables are evaluated as expressions and as such the gas optimization of caching the result of the keccak256 instruction is actually not achieved here.

Example:

bytes32 internal constant ADMIN = keccak256("ADMIN");                   // Deployer and any other admins as needed
bytes32 internal constant SELLER = keccak256("SELLER");                 // Approved sellers amd Seen.Haus reps
bytes32 internal constant MINTER = keccak256("MINTER");                 // Approved artists and Seen.Haus reps
bytes32 internal constant ESCROW_AGENT = keccak256("ESCROW_AGENT");     // Seen.Haus Physical Item Escrow Agent
bytes32 internal constant MARKET_HANDLER = keccak256("MARKET_HANDLER"); // Market Handler contracts
bytes32 internal constant UPGRADER = keccak256("UPGRADER");             // Performs contract upgrades

Recommendation:

We advise the immutable keyword to be utilized instead to actually take advantage of the gas benefit of pre-calculating the keccak256 hash. For more information, consult this issue in the Solidity compiler.

@JayWelsh
Copy link
Contributor Author

Resolved by #36

@JayWelsh
Copy link
Contributor Author

Reverted by #39

Appeal:

Change reverted due to immutable values not being able to be read in contract constructors

147928503-59d859bf-cae3-48e1-8c30-5d3c18de1d89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant