GovernorPreventLateQuorumHarness.sol 6.0 KB

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