Omniscia Seen Haus Audit
SeenConstants Code Style Findings
SeenConstants Code Style Findings
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:
contracts/domain/SeenConstants.sol
17bytes32 internal constant ADMIN = keccak256("ADMIN"); // Deployer and any other admins as needed18bytes32 internal constant SELLER = keccak256("SELLER"); // Approved sellers amd Seen.Haus reps19bytes32 internal constant MINTER = keccak256("MINTER"); // Approved artists and Seen.Haus reps20bytes32 internal constant ESCROW_AGENT = keccak256("ESCROW_AGENT"); // Seen.Haus Physical Item Escrow Agent21bytes32 internal constant MARKET_HANDLER = keccak256("MARKET_HANDLER"); // Market Handler contracts22bytes32 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.
Alleviation:
The Seen Haus team initially applied this change but reverted it as it would significantly complicate inherited contract utilizations of the said variables within their constructor
declarations.