Omniscia Impact Market Audit

PACTDelegate Code Style Findings

PACTDelegate Code Style Findings

PAC-01C: Duplicate Security Check

Description:

The linked security check is performed twice redundantly.

Example:

contracts/governor/PACTDelegate.sol
69require(
70 TimelockInterface(_timelock).admin() == address(this),
71 "PACT::initialize: timelock admin is not assigned to PACTDelegate"
72);
73require(
74 _votingPeriod >= MIN_VOTING_PERIOD && _votingPeriod <= MAX_VOTING_PERIOD,
75 "PACT::initialize: invalid voting period"
76);
77require(
78 _votingDelay >= MIN_VOTING_DELAY && _votingDelay <= MAX_VOTING_DELAY,
79 "PACT::initialize: invalid voting delay"
80);
81require(
82 _proposalThreshold >= MIN_PROPOSAL_THRESHOLD &&
83 _proposalThreshold <= MAX_PROPOSAL_THRESHOLD,
84 "PACT::initialize: invalid proposal threshold"
85);
86require(_quorumVotes >= _proposalThreshold, "PACT::initialize: invalid quorum votes");
87timelock = TimelockInterface(_timelock);
88require(
89 timelock.admin() == address(this),
90 "PACT::initialize: timelock admin is not assigned to PACTDelegate"
91);

Recommendation:

We advise it to be performed once to optimize the function's execution cost.

Alleviation:

The initialize function has been updated to remove the latter of the two security checks optimizing the codebase.

PAC-02C: Event Emission Optimizations

Description:

The linked event emissions can be optimized rendering the local variables redundant.

Example:

contracts/governor/PACTDelegate.sol
539uint256 _oldProposalThreshold = proposalThreshold;
540proposalThreshold = _newProposalThreshold;
541
542emit ProposalThresholdSet(_oldProposalThreshold, _newProposalThreshold);

Recommendation:

We advise the event emissions to be performed prior to the variables being adjusted thus permitting the events to be emitted with the current state variables and input arguments no longer requiring local variables.

Alleviation:

The code has been updated to emit the events without using temporary variables for all of the linked events except for _setVotingDelay, thus we consider this as partially alleviating this exhibit.

PAC-03C: Inefficient Loop Limit Evaluations

Description:

The linked for loops evaluate their limit inefficiently on each iteration.

Example:

contracts/governor/PACTDelegate.sol
225for (uint256 i = 0; i < proposalTargets[_proposalId].length; i++) {

Recommendation:

We advise the statements within the for loop limits to be relocated outside to a local variable declaration that is consequently utilized for the evaluations to significantly reduce the codebase's gas cost. We should note the same optimization is applicable for storage reads present in those limits as they are newly read on each iteration (i.e. length members of arrays in storage).

Alleviation:

All referenced loops now store the state variable length into a local variable before the for loop thus avoiding reading it from storage for each iteration.