Omniscia Platypus Finance Audit

GovernorAlpha Code Style Findings

GovernorAlpha Code Style Findings

GAA-01C: Inefficient Mutability Type

TypeSeverityLocation
Gas OptimizationInformationalGovernorAlpha.sol:L105-L106, L109

Description:

The linked statements are meant to represent constant values, however, the constant keyword is also applicable to expressions and as such these constant declarations do not actually optimize the codebase and replace their instances with the costly keccak256 instruction instead of its result.

Example:

contracts/GovernorAlpha.sol
104/// @notice The EIP-712 typehash for the contract's domain
105bytes32 public constant DOMAIN_TYPEHASH =
106 keccak256('EIP712Domain(string name,uint256 chainId,address verifyingContract)');
107
108/// @notice The EIP-712 typehash for the ballot struct used by the contract
109bytes32 public constant BALLOT_TYPEHASH = keccak256('Ballot(uint256 proposalId,bool support)');

Recommendation:

We advise proper optimization to be applied to the codebase by using the immutable keyword instead. For more information, consult this issue in the Solidity compiler.

Alleviation:

The Platypus team considered this exhibit but opted not to apply a remediation for it.

GAA-02C: Redundant Default Value Assignments

TypeSeverityLocation
Gas OptimizationInformationalGovernorAlpha.sol:L190, L196, L198, L199, L200, L201

Description:

The codebase implementation guarantees that the propose function will attempt to update the data located in an empty proposals declaration given that the proposalCount key is solely incremented each time the function is invoked. As a result, the newly pointed to struct will have the default zeroed-out values in place of its variables.

Example:

contracts/GovernorAlpha.sol
185proposalCount++;
186Proposal storage newProposal = proposals[proposalCount];
187
188newProposal.id = proposalCount;
189newProposal.proposer = msg.sender;
190newProposal.eta = 0;
191newProposal.targets = targets;
192newProposal.values = values;
193newProposal.signatures = signatures;
194newProposal.calldatas = calldatas;
195newProposal.startTime = startTime;
196newProposal.startBlock = 0;
197newProposal.endTime = endTime;
198newProposal.forVotes = 0;
199newProposal.againstVotes = 0;
200newProposal.canceled = false;
201newProposal.executed = false;

Recommendation:

We advise these default value assignments to be omitted from the codebase greatly optimizing its gas cost as it currently performs 6 redundant SSTORE operations to storage.

Alleviation:

The Platypus team considered this exhibit but opted not to apply a remediation for it.