GovernorFullHarness.sol 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.2;
  3. import "../munged/governance/Governor.sol";
  4. import "../munged/governance/extensions/GovernorCountingSimple.sol";
  5. import "../munged/governance/extensions/GovernorPreventLateQuorum.sol";
  6. import "../munged/governance/extensions/GovernorTimelockControl.sol";
  7. import "../munged/governance/extensions/GovernorVotes.sol";
  8. import "../munged/governance/extensions/GovernorVotesQuorumFraction.sol";
  9. import "../munged/token/ERC20/extensions/ERC20Votes.sol";
  10. contract GovernorFullHarness is
  11. Governor,
  12. GovernorCountingSimple,
  13. GovernorTimelockControl,
  14. GovernorPreventLateQuorum,
  15. GovernorVotes,
  16. GovernorVotesQuorumFraction
  17. {
  18. using Checkpoints for Checkpoints.Trace224;
  19. constructor(
  20. IVotes _token,
  21. TimelockController _timelock,
  22. uint64 initialVoteExtension,
  23. uint256 quorumNumeratorValue
  24. )
  25. Governor("Harness")
  26. GovernorPreventLateQuorum(initialVoteExtension)
  27. GovernorTimelockControl(_timelock)
  28. GovernorVotes(_token)
  29. GovernorVotesQuorumFraction(quorumNumeratorValue)
  30. {}
  31. mapping(uint256 => uint256) public ghost_sum_vote_power_by_id;
  32. // variable added to check when _castVote is called
  33. uint256 public latestCastVoteCall;
  34. // Harness from Votes //
  35. function getPastTotalSupply(uint256 blockNumber) public view returns(uint256) {
  36. return token.getPastTotalSupply(blockNumber);
  37. }
  38. // Harness from GovernorVotesQuorumFraction //
  39. function getQuorumNumeratorLength() public view returns(uint256) {
  40. return _quorumNumeratorHistory._checkpoints.length;
  41. }
  42. function getQuorumNumeratorLatest() public view returns(uint256) {
  43. return _quorumNumeratorHistory.latest();
  44. }
  45. function getDeprecatedQuorumNumerator() public view returns(uint256) {
  46. return _quorumNumerator;
  47. }
  48. // Harness from GovernorPreventLateQuorum //
  49. function getVoteExtension() public view returns (uint64) {
  50. return _voteExtension;
  51. }
  52. function getExtendedDeadline(uint256 proposalId) public view returns (uint64) {
  53. return _extendedDeadlines[proposalId];
  54. }
  55. // Harness from GovernorCountingSimple //
  56. function getAgainstVotes(uint256 proposalId) public view returns (uint256) {
  57. ProposalVote storage proposalvote = _proposalVotes[proposalId];
  58. return proposalvote.againstVotes;
  59. }
  60. function getAbstainVotes(uint256 proposalId) public view returns (uint256) {
  61. ProposalVote storage proposalvote = _proposalVotes[proposalId];
  62. return proposalvote.abstainVotes;
  63. }
  64. function getForVotes(uint256 proposalId) public view returns (uint256) {
  65. ProposalVote storage proposalvote = _proposalVotes[proposalId];
  66. return proposalvote.forVotes;
  67. }
  68. function quorumReached(uint256 proposalId) public view returns (bool) {
  69. return _quorumReached(proposalId);
  70. }
  71. function voteSucceeded(uint256 proposalId) public view returns (bool) {
  72. return _voteSucceeded(proposalId);
  73. }
  74. // Harness from Governor //
  75. function getExecutor() public view returns (address) {
  76. return _executor();
  77. }
  78. function proposalProposer(uint256 proposalId) public view returns (address) {
  79. return _proposalProposer(proposalId);
  80. }
  81. function isExecuted(uint256 proposalId) public view returns (bool) {
  82. return _proposals[proposalId].executed;
  83. }
  84. function isCanceled(uint256 proposalId) public view returns (bool) {
  85. return _proposals[proposalId].canceled;
  86. }
  87. // The following functions are overrides required by Solidity added by Certora. //
  88. function proposalDeadline(uint256 proposalId)
  89. public
  90. view
  91. virtual
  92. override(Governor, GovernorPreventLateQuorum, IGovernor)
  93. returns (uint256)
  94. {
  95. return super.proposalDeadline(proposalId);
  96. }
  97. function _castVote(
  98. uint256 proposalId,
  99. address account,
  100. uint8 support,
  101. string memory reason,
  102. bytes memory params
  103. ) internal virtual override(Governor, GovernorPreventLateQuorum) returns (uint256) {
  104. // flag for when _castVote is called
  105. latestCastVoteCall = block.number;
  106. // added to run GovernorCountingSimple.spec
  107. uint256 deltaWeight = super._castVote(proposalId, account, support, reason, params);
  108. ghost_sum_vote_power_by_id[proposalId] += deltaWeight;
  109. return deltaWeight;
  110. }
  111. function lateQuorumVoteExtension() public view virtual override returns (uint64) {
  112. return super.lateQuorumVoteExtension();
  113. }
  114. function setLateQuorumVoteExtension(uint64 newVoteExtension) public virtual override onlyGovernance {
  115. super.setLateQuorumVoteExtension(newVoteExtension);
  116. }
  117. // The following functions are overrides required by Solidity added by OZ Wizard. //
  118. function votingDelay() public pure override returns (uint256) {
  119. return 1; // 1 block
  120. }
  121. function votingPeriod() public pure override returns (uint256) {
  122. return 45818; // 1 week
  123. }
  124. function quorum(uint256 blockNumber)
  125. public
  126. view
  127. override(IGovernor, GovernorVotesQuorumFraction)
  128. returns (uint256)
  129. {
  130. return super.quorum(blockNumber);
  131. }
  132. function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState) {
  133. return super.state(proposalId);
  134. }
  135. function propose(
  136. address[] memory targets,
  137. uint256[] memory values,
  138. bytes[] memory calldatas,
  139. string memory description
  140. ) public override(Governor, IGovernor) returns (uint256) {
  141. return super.propose(targets, values, calldatas, description);
  142. }
  143. function _execute(
  144. uint256 proposalId,
  145. address[] memory targets,
  146. uint256[] memory values,
  147. bytes[] memory calldatas,
  148. bytes32 descriptionHash
  149. ) internal override(Governor, GovernorTimelockControl) {
  150. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  151. }
  152. function _cancel(
  153. address[] memory targets,
  154. uint256[] memory values,
  155. bytes[] memory calldatas,
  156. bytes32 descriptionHash
  157. ) internal override(Governor, GovernorTimelockControl) returns (uint256) {
  158. return super._cancel(targets, values, calldatas, descriptionHash);
  159. }
  160. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  161. return super._executor();
  162. }
  163. function supportsInterface(bytes4 interfaceId)
  164. public
  165. view
  166. override(Governor, GovernorTimelockControl)
  167. returns (bool)
  168. {
  169. return super.supportsInterface(interfaceId);
  170. }
  171. }