GovernorHarness.sol 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.2;
  3. import "../patched/governance/Governor.sol";
  4. import "../patched/governance/extensions/GovernorCountingSimple.sol";
  5. import "../patched/governance/extensions/GovernorTimelockControl.sol";
  6. import "../patched/governance/extensions/GovernorVotes.sol";
  7. import "../patched/governance/extensions/GovernorVotesQuorumFraction.sol";
  8. import "../patched/token/ERC20/extensions/ERC20Votes.sol";
  9. contract GovernorHarness is
  10. Governor,
  11. GovernorCountingSimple,
  12. GovernorTimelockControl,
  13. GovernorVotes,
  14. GovernorVotesQuorumFraction
  15. {
  16. constructor(IVotes _token, TimelockController _timelock, uint256 _quorumNumeratorValue)
  17. Governor("Harness")
  18. GovernorTimelockControl(_timelock)
  19. GovernorVotes(_token)
  20. GovernorVotesQuorumFraction(_quorumNumeratorValue)
  21. {}
  22. // Harness from Votes
  23. function token_getPastTotalSupply(uint256 blockNumber) public view returns(uint256) {
  24. return token.getPastTotalSupply(blockNumber);
  25. }
  26. function token_getPastVotes(address account, uint256 blockNumber) public view returns(uint256) {
  27. return token.getPastVotes(account, blockNumber);
  28. }
  29. function token_clock() public view returns (uint48) {
  30. return token.clock();
  31. }
  32. function token_CLOCK_MODE() public view returns (string memory) {
  33. return token.CLOCK_MODE();
  34. }
  35. // Harness from Governor
  36. function getExecutor() public view returns (address) {
  37. return _executor();
  38. }
  39. function proposalProposer(uint256 proposalId) public view returns (address) {
  40. return _proposalProposer(proposalId);
  41. }
  42. function quorumReached(uint256 proposalId) public view returns (bool) {
  43. return _quorumReached(proposalId);
  44. }
  45. function voteSucceeded(uint256 proposalId) public view returns (bool) {
  46. return _voteSucceeded(proposalId);
  47. }
  48. function isExecuted(uint256 proposalId) public view returns (bool) {
  49. return _isExecuted(proposalId);
  50. }
  51. function isCanceled(uint256 proposalId) public view returns (bool) {
  52. return _isCanceled(proposalId);
  53. }
  54. function governanceCallLength() public view returns (uint256) {
  55. return _governanceCallLength();
  56. }
  57. // Harness from GovernorCountingSimple
  58. function getAgainstVotes(uint256 proposalId) public view returns (uint256) {
  59. (uint256 againstVotes,,) = proposalVotes(proposalId);
  60. return againstVotes;
  61. }
  62. function getForVotes(uint256 proposalId) public view returns (uint256) {
  63. (,uint256 forVotes,) = proposalVotes(proposalId);
  64. return forVotes;
  65. }
  66. function getAbstainVotes(uint256 proposalId) public view returns (uint256) {
  67. (,,uint256 abstainVotes) = proposalVotes(proposalId);
  68. return abstainVotes;
  69. }
  70. /// The following functions are overrides required by Solidity added by Certora.
  71. // mapping(uint256 => uint256) public ghost_sum_vote_power_by_id;
  72. //
  73. // function _castVote(
  74. // uint256 proposalId,
  75. // address account,
  76. // uint8 support,
  77. // string memory reason,
  78. // bytes memory params
  79. // ) internal virtual override returns (uint256) {
  80. // uint256 deltaWeight = super._castVote(proposalId, account, support, reason, params);
  81. // ghost_sum_vote_power_by_id[proposalId] += deltaWeight;
  82. // return deltaWeight;
  83. // }
  84. // The following functions are overrides required by Solidity added by OZ Wizard.
  85. function votingDelay() public pure override returns (uint256) {
  86. return 1; // 1 block
  87. }
  88. function votingPeriod() public pure override returns (uint256) {
  89. return 45818; // 1 week
  90. }
  91. function quorum(uint256 blockNumber)
  92. public
  93. view
  94. override(IGovernor, GovernorVotesQuorumFraction)
  95. returns (uint256)
  96. {
  97. return super.quorum(blockNumber);
  98. }
  99. function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState) {
  100. return super.state(proposalId);
  101. }
  102. function propose(
  103. address[] memory targets,
  104. uint256[] memory values,
  105. bytes[] memory calldatas,
  106. string memory description
  107. ) public override(Governor, IGovernor) returns (uint256) {
  108. return super.propose(targets, values, calldatas, description);
  109. }
  110. function _execute(
  111. uint256 proposalId,
  112. address[] memory targets,
  113. uint256[] memory values,
  114. bytes[] memory calldatas,
  115. bytes32 descriptionHash
  116. ) internal override(Governor, GovernorTimelockControl) {
  117. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  118. }
  119. function _cancel(
  120. address[] memory targets,
  121. uint256[] memory values,
  122. bytes[] memory calldatas,
  123. bytes32 descriptionHash
  124. ) internal override(Governor, GovernorTimelockControl) returns (uint256) {
  125. return super._cancel(targets, values, calldatas, descriptionHash);
  126. }
  127. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  128. return super._executor();
  129. }
  130. function supportsInterface(bytes4 interfaceId)
  131. public
  132. view
  133. override(Governor, GovernorTimelockControl)
  134. returns (bool)
  135. {
  136. return super.supportsInterface(interfaceId);
  137. }
  138. }