GovernorHarness.sol 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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/GovernorTimelockControl.sol";
  6. import "../munged/governance/extensions/GovernorVotes.sol";
  7. import "../munged/governance/extensions/GovernorVotesQuorumFraction.sol";
  8. import "../munged/token/ERC20/extensions/ERC20Votes.sol";
  9. contract GovernorHarness is
  10. Governor,
  11. GovernorCountingSimple,
  12. GovernorVotes,
  13. GovernorVotesQuorumFraction,
  14. GovernorTimelockControl
  15. {
  16. constructor(
  17. IVotes _token,
  18. TimelockController _timelock,
  19. uint64 initialVoteExtension,
  20. uint256 quorumNumeratorValue
  21. )
  22. Governor("Harness")
  23. GovernorVotes(_token)
  24. GovernorVotesQuorumFraction(quorumNumeratorValue)
  25. GovernorTimelockControl(_timelock)
  26. {}
  27. mapping(uint256 => uint256) public ghost_sum_vote_power_by_id;
  28. // Harness from GovernorCountingSimple //
  29. function getAgainstVotes(uint256 proposalId) public view returns (uint256) {
  30. ProposalVote storage proposalvote = _proposalVotes[proposalId];
  31. return proposalvote.againstVotes;
  32. }
  33. function getAbstainVotes(uint256 proposalId) public view returns (uint256) {
  34. ProposalVote storage proposalvote = _proposalVotes[proposalId];
  35. return proposalvote.abstainVotes;
  36. }
  37. function getForVotes(uint256 proposalId) public view returns (uint256) {
  38. ProposalVote storage proposalvote = _proposalVotes[proposalId];
  39. return proposalvote.forVotes;
  40. }
  41. function quorumReached(uint256 proposalId) public view returns (bool) {
  42. return _quorumReached(proposalId);
  43. }
  44. function voteSucceeded(uint256 proposalId) public view returns (bool) {
  45. return _voteSucceeded(proposalId);
  46. }
  47. // Harness from Governor //
  48. function getExecutor() public view returns (address) {
  49. return _executor();
  50. }
  51. function proposalProposer(uint256 proposalId) public view returns (address) {
  52. return _proposalProposer(proposalId);
  53. }
  54. function isExecuted(uint256 proposalId) public view returns (bool) {
  55. return _proposals[proposalId].executed;
  56. }
  57. function isCanceled(uint256 proposalId) public view returns (bool) {
  58. return _proposals[proposalId].canceled;
  59. }
  60. // The following functions are overrides required by Solidity added by Certora. //
  61. function _castVote(
  62. uint256 proposalId,
  63. address account,
  64. uint8 support,
  65. string memory reason,
  66. bytes memory params
  67. ) internal virtual override returns (uint256) {
  68. // added to run GovernorCountingSimple.spec
  69. uint256 deltaWeight = super._castVote(proposalId, account, support, reason, params);
  70. ghost_sum_vote_power_by_id[proposalId] += deltaWeight;
  71. return deltaWeight;
  72. }
  73. // The following functions are overrides required by Solidity added by OZ Wizard. //
  74. function votingDelay() public pure override returns (uint256) {
  75. return 1; // 1 block
  76. }
  77. function votingPeriod() public pure override returns (uint256) {
  78. return 45818; // 1 week
  79. }
  80. function quorum(uint256 blockNumber)
  81. public
  82. view
  83. override(IGovernor, GovernorVotesQuorumFraction)
  84. returns (uint256)
  85. {
  86. return super.quorum(blockNumber);
  87. }
  88. function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState) {
  89. return super.state(proposalId);
  90. }
  91. function propose(
  92. address[] memory targets,
  93. uint256[] memory values,
  94. bytes[] memory calldatas,
  95. string memory description
  96. ) public override(Governor, IGovernor) returns (uint256) {
  97. return super.propose(targets, values, calldatas, description);
  98. }
  99. function _execute(
  100. uint256 proposalId,
  101. address[] memory targets,
  102. uint256[] memory values,
  103. bytes[] memory calldatas,
  104. bytes32 descriptionHash
  105. ) internal override(Governor, GovernorTimelockControl) {
  106. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  107. }
  108. function _cancel(
  109. address[] memory targets,
  110. uint256[] memory values,
  111. bytes[] memory calldatas,
  112. bytes32 descriptionHash
  113. ) internal override(Governor, GovernorTimelockControl) returns (uint256) {
  114. return super._cancel(targets, values, calldatas, descriptionHash);
  115. }
  116. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  117. return super._executor();
  118. }
  119. function supportsInterface(bytes4 interfaceId)
  120. public
  121. view
  122. override(Governor, GovernorTimelockControl)
  123. returns (bool)
  124. {
  125. return super.supportsInterface(interfaceId);
  126. }
  127. }