I am trying to deploy this governance contract, created using OpenZeppelin Template and it gives me the ERROR: Warning: Contract code size is 29977 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries.
How can a contract made by Openzeppelin be oversized?
Am I doing something wrong ? Any Tips on how to make this contract deployable/smaller?
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "./Governance.sol";
/*
The GovernanceProtocol Contract has all the voting and proposal's logic
used in the system. Users interact with the GovernanceProtocol because
it is the only Proposer trusted by the TimeLock, but proposals are only
operated by the TimeLock. It is this relation between the GovernanceProtocol
and TimeLock that makes this system a DAO.
*/
contract GovernanceProtocol is
GovernorVotes,
GovernorVotesQuorumFraction,
GovernorTimelockControl,
GovernorSettings,
GovernorCountingSimple,
AccessControl
{
constructor(
IVotes _token,
TimelockController _timelock,
uint256 _quorumPercentage,
uint256 _votingPeriod,
uint256 _votingDelay
)
Governor("GovernanceProtocol")
GovernorSettings(
_votingDelay, /* 1 block */ // votind delay
_votingPeriod, // 45818, /* 1 week */ // voting period
0 // proposal threshold
)
GovernorVotes(_token)
GovernorVotesQuorumFraction(_quorumPercentage)
GovernorTimelockControl(_timelock)
{}
// The following functions are overrides required by Solidity
function votingDelay()
public
view
override(IGovernor, GovernorSettings)
returns (uint256)
{
return super.votingDelay();
}
function votingPeriod()
public
view
override(IGovernor, GovernorSettings)
returns (uint256)
{
return super.votingPeriod();
}
function quorum(uint256 blockNumber)
public
view
override(IGovernor, GovernorVotesQuorumFraction)
returns (uint256)
{
return super.quorum(blockNumber);
}
function state(uint256 proposalId)
public
view
override(Governor, GovernorTimelockControl)
returns (ProposalState)
{
return super.state(proposalId);
}
function proposalThreshold()
public
view
override(Governor, GovernorSettings)
returns (uint256)
{
return super.proposalThreshold();
}
function _execute(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockControl) {
super._execute(proposalId, targets, values, calldatas, descriptionHash);
}
function _cancel(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockControl) returns (uint256) {
return super._cancel(targets, values, calldatas, descriptionHash);
}
function _executor()
internal
view
override(Governor, GovernorTimelockControl)
returns (address)
{
return super._executor();
}
function supportsInterface(bytes4 interfaceId)
public
view
override(Governor, GovernorTimelockControl, AccessControl)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}