Omniscia MetaSoccer Audit

EntropyStorage Code Style Findings

EntropyStorage Code Style Findings

ESE-01C: Struct Mutability Optimization

Description:

The gas cost of the setEntropy function can be optimized by setting its struct pointer from memory to storage and omitting the last assignment.

Example:

contracts/EntropyStorage.sol
45function setEntropy(uint256 _tokenId, uint256 _index, uint256 _randomness) external onlyRole(SET_ENTROPY_ROLE) {
46 Entropy memory entropy = entropyStorage[_tokenId][_index];
47 ///@notice Once set, entropy can't be changed
48 require(!entropy.finished, "Setting existent entropy");
49 entropy.value = _randomness;
50 entropy.finished = true;
51 entropyStorage[_tokenId][_index] = entropy;
52}

Recommendation:

We advise this to be done so, optimizing the mapping lookup operations.

Alleviation:

The pointer is now properly specified as storage optimizing the codebase.