GovernorHarness.sol 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. // Harness from GovernorCountingSimple
  55. function getAgainstVotes(uint256 proposalId) public view returns (uint256) {
  56. (uint256 againstVotes,,) = proposalVotes(proposalId);
  57. return againstVotes;
  58. }
  59. function getForVotes(uint256 proposalId) public view returns (uint256) {
  60. (,uint256 forVotes,) = proposalVotes(proposalId);
  61. return forVotes;
  62. }
  63. function getAbstainVotes(uint256 proposalId) public view returns (uint256) {
  64. (,,uint256 abstainVotes) = proposalVotes(proposalId);
  65. return abstainVotes;
  66. }
  67. /// The following functions are overrides required by Solidity added by Certora.
  68. // mapping(uint256 => uint256) public ghost_sum_vote_power_by_id;
  69. //
  70. // function _castVote(
  71. // uint256 proposalId,
  72. // address account,
  73. // uint8 support,
  74. // string memory reason,
  75. // bytes memory params
  76. // ) internal virtual override returns (uint256) {
  77. // uint256 deltaWeight = super._castVote(proposalId, account, support, reason, params);
  78. // ghost_sum_vote_power_by_id[proposalId] += deltaWeight;
  79. // return deltaWeight;
  80. // }
  81. // The following functions are overrides required by Solidity added by OZ Wizard.
  82. function votingDelay() public pure override returns (uint256) {
  83. return 1; // 1 block
  84. }
  85. function votingPeriod() public pure override returns (uint256) {
  86. return 45818; // 1 week
  87. }
  88. function quorum(uint256 blockNumber)
  89. public
  90. view
  91. override(IGovernor, GovernorVotesQuorumFraction)
  92. returns (uint256)
  93. {
  94. return super.quorum(blockNumber);
  95. }
  96. function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState) {
  97. return super.state(proposalId);
  98. }
  99. function propose(
  100. address[] memory targets,
  101. uint256[] memory values,
  102. bytes[] memory calldatas,
  103. string memory description
  104. ) public override(Governor, IGovernor) returns (uint256) {
  105. return super.propose(targets, values, calldatas, description);
  106. }
  107. function _execute(
  108. uint256 proposalId,
  109. address[] memory targets,
  110. uint256[] memory values,
  111. bytes[] memory calldatas,
  112. bytes32 descriptionHash
  113. ) internal override(Governor, GovernorTimelockControl) {
  114. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  115. }
  116. function _cancel(
  117. address[] memory targets,
  118. uint256[] memory values,
  119. bytes[] memory calldatas,
  120. bytes32 descriptionHash
  121. ) internal override(Governor, GovernorTimelockControl) returns (uint256) {
  122. return super._cancel(targets, values, calldatas, descriptionHash);
  123. }
  124. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  125. return super._executor();
  126. }
  127. function supportsInterface(bytes4 interfaceId)
  128. public
  129. view
  130. override(Governor, GovernorTimelockControl)
  131. returns (bool)
  132. {
  133. return super.supportsInterface(interfaceId);
  134. }
  135. }