applyHarness.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. diff -ruN access/AccessControl.sol access/AccessControl.sol
  2. --- access/AccessControl.sol 2022-05-25 15:36:58.849363940 -0400
  3. +++ access/AccessControl.sol 2022-05-25 16:04:57.725255723 -0400
  4. @@ -93,7 +93,7 @@
  5. *
  6. * _Available since v4.6._
  7. */
  8. - function _checkRole(bytes32 role) internal view virtual {
  9. + function _checkRole(bytes32 role) public view virtual { // HARNESS: internal -> public
  10. _checkRole(role, _msgSender());
  11. }
  12. diff -ruN governance/extensions/GovernorPreventLateQuorum.sol governance/extensions/GovernorPreventLateQuorum.sol
  13. --- governance/extensions/GovernorPreventLateQuorum.sol 2022-05-25 15:36:58.849363940 -0400
  14. +++ governance/extensions/GovernorPreventLateQuorum.sol 2022-05-25 16:04:57.725255723 -0400
  15. @@ -21,8 +21,8 @@
  16. using SafeCast for uint256;
  17. using Timers for Timers.BlockNumber;
  18. - uint64 private _voteExtension;
  19. - mapping(uint256 => Timers.BlockNumber) private _extendedDeadlines;
  20. + uint64 internal _voteExtension;
  21. + mapping(uint256 => Timers.BlockNumber) internal _extendedDeadlines;
  22. /// @dev Emitted when a proposal deadline is pushed back due to reaching quorum late in its voting period.
  23. event ProposalExtended(uint256 indexed proposalId, uint64 extendedDeadline);
  24. diff -ruN governance/Governor.sol governance/Governor.sol
  25. --- governance/Governor.sol 2022-05-25 15:36:58.849363940 -0400
  26. +++ governance/Governor.sol 2022-05-25 16:04:57.725255723 -0400
  27. @@ -44,7 +44,7 @@
  28. string private _name;
  29. - mapping(uint256 => ProposalCore) private _proposals;
  30. + mapping(uint256 => ProposalCore) internal _proposals;
  31. // This queue keeps track of the governor operating on itself. Calls to functions protected by the
  32. // {onlyGovernance} modifier needs to be whitelisted in this queue. Whitelisting is set in {_beforeExecute},
  33. diff -ruN governance/TimelockController.sol governance/TimelockController.sol
  34. --- governance/TimelockController.sol 2022-05-25 15:36:58.849363940 -0400
  35. +++ governance/TimelockController.sol 2022-05-25 16:04:57.725255723 -0400
  36. @@ -28,10 +28,10 @@
  37. bytes32 public constant PROPOSER_ROLE = keccak256("PROPOSER_ROLE");
  38. bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE");
  39. bytes32 public constant CANCELLER_ROLE = keccak256("CANCELLER_ROLE");
  40. - uint256 internal constant _DONE_TIMESTAMP = uint256(1);
  41. + uint256 public constant _DONE_TIMESTAMP = uint256(1);
  42. mapping(bytes32 => uint256) private _timestamps;
  43. - uint256 private _minDelay;
  44. + uint256 public _minDelay;
  45. /**
  46. * @dev Emitted when a call is scheduled as part of operation `id`.
  47. diff -ruN governance/utils/Votes.sol governance/utils/Votes.sol
  48. --- governance/utils/Votes.sol 2022-05-25 15:36:58.849363940 -0400
  49. +++ governance/utils/Votes.sol 2022-05-25 16:04:57.725255723 -0400
  50. @@ -35,7 +35,25 @@
  51. bytes32 private constant _DELEGATION_TYPEHASH =
  52. keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
  53. - mapping(address => address) private _delegation;
  54. + // HARNESS : Hooks cannot access any information from Checkpoints yet, so I am also updating votes and fromBlock in this struct
  55. + struct Ckpt {
  56. + uint32 fromBlock;
  57. + uint224 votes;
  58. + }
  59. + mapping(address => Ckpt) public _checkpoints;
  60. +
  61. + // HARNESSED getters
  62. + function numCheckpoints(address account) public view returns (uint32) {
  63. + return SafeCast.toUint32(_delegateCheckpoints[account]._checkpoints.length);
  64. + }
  65. + function ckptFromBlock(address account, uint32 pos) public view returns (uint32) {
  66. + return _delegateCheckpoints[account]._checkpoints[pos]._blockNumber;
  67. + }
  68. + function ckptVotes(address account, uint32 pos) public view returns (uint224) {
  69. + return _delegateCheckpoints[account]._checkpoints[pos]._value;
  70. + }
  71. +
  72. + mapping(address => address) public _delegation;
  73. mapping(address => Checkpoints.History) private _delegateCheckpoints;
  74. Checkpoints.History private _totalCheckpoints;
  75. @@ -124,7 +142,7 @@
  76. *
  77. * Emits events {DelegateChanged} and {DelegateVotesChanged}.
  78. */
  79. - function _delegate(address account, address delegatee) internal virtual {
  80. + function _delegate(address account, address delegatee) public virtual {
  81. address oldDelegate = delegates(account);
  82. _delegation[account] = delegatee;
  83. @@ -142,10 +160,10 @@
  84. uint256 amount
  85. ) internal virtual {
  86. if (from == address(0)) {
  87. - _totalCheckpoints.push(_add, amount);
  88. + _totalCheckpoints.push(_totalCheckpoints.latest() + amount); // Harnessed to remove function pointers
  89. }
  90. if (to == address(0)) {
  91. - _totalCheckpoints.push(_subtract, amount);
  92. + _totalCheckpoints.push(_totalCheckpoints.latest() - amount); // Harnessed to remove function pointers
  93. }
  94. _moveDelegateVotes(delegates(from), delegates(to), amount);
  95. }
  96. @@ -160,11 +178,13 @@
  97. ) private {
  98. if (from != to && amount > 0) {
  99. if (from != address(0)) {
  100. - (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[from].push(_subtract, amount);
  101. + (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[from].push(_delegateCheckpoints[from].latest() - amount); // HARNESSED TO REMOVE FUNCTION POINTERS
  102. + _checkpoints[from] = Ckpt({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newValue)}); // HARNESS
  103. emit DelegateVotesChanged(from, oldValue, newValue);
  104. }
  105. if (to != address(0)) {
  106. - (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[to].push(_add, amount);
  107. + (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[to].push(_delegateCheckpoints[to].latest() + amount); // HARNESSED TO REMOVE FUNCTION POINTERS
  108. + _checkpoints[to] = Ckpt({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newValue)}); // HARNESS
  109. emit DelegateVotesChanged(to, oldValue, newValue);
  110. }
  111. }
  112. @@ -207,5 +227,5 @@
  113. /**
  114. * @dev Must return the voting units held by an account.
  115. */
  116. - function _getVotingUnits(address) internal view virtual returns (uint256);
  117. + function _getVotingUnits(address) public virtual returns (uint256); // HARNESS: internal -> public
  118. }
  119. diff -ruN token/ERC1155/ERC1155.sol token/ERC1155/ERC1155.sol
  120. --- token/ERC1155/ERC1155.sol 2022-05-25 15:36:58.853363841 -0400
  121. +++ token/ERC1155/ERC1155.sol 2022-05-25 16:04:57.725255723 -0400
  122. @@ -268,7 +268,7 @@
  123. uint256 id,
  124. uint256 amount,
  125. bytes memory data
  126. - ) internal virtual {
  127. + ) public virtual { // HARNESS: internal -> public
  128. require(to != address(0), "ERC1155: mint to the zero address");
  129. address operator = _msgSender();
  130. @@ -301,7 +301,7 @@
  131. uint256[] memory ids,
  132. uint256[] memory amounts,
  133. bytes memory data
  134. - ) internal virtual {
  135. + ) public virtual { // HARNESS: internal -> public
  136. require(to != address(0), "ERC1155: mint to the zero address");
  137. require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
  138. @@ -334,7 +334,7 @@
  139. address from,
  140. uint256 id,
  141. uint256 amount
  142. - ) internal virtual {
  143. + ) public virtual { // HARNESS: internal -> public
  144. require(from != address(0), "ERC1155: burn from the zero address");
  145. address operator = _msgSender();
  146. @@ -367,7 +367,7 @@
  147. address from,
  148. uint256[] memory ids,
  149. uint256[] memory amounts
  150. - ) internal virtual {
  151. + ) public virtual { // HARNESS: internal -> public
  152. require(from != address(0), "ERC1155: burn from the zero address");
  153. require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
  154. @@ -471,7 +471,7 @@
  155. uint256 id,
  156. uint256 amount,
  157. bytes memory data
  158. - ) private {
  159. + ) public { // HARNESS: private -> public
  160. if (to.isContract()) {
  161. try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
  162. if (response != IERC1155Receiver.onERC1155Received.selector) {
  163. @@ -492,7 +492,7 @@
  164. uint256[] memory ids,
  165. uint256[] memory amounts,
  166. bytes memory data
  167. - ) private {
  168. + ) public { // HARNESS: private -> public
  169. if (to.isContract()) {
  170. try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
  171. bytes4 response
  172. diff -ruN token/ERC20/ERC20.sol token/ERC20/ERC20.sol
  173. --- token/ERC20/ERC20.sol 2022-05-25 15:36:58.853363841 -0400
  174. +++ token/ERC20/ERC20.sol 2022-05-25 16:04:57.725255723 -0400
  175. @@ -277,7 +277,7 @@
  176. * - `account` cannot be the zero address.
  177. * - `account` must have at least `amount` tokens.
  178. */
  179. - function _burn(address account, uint256 amount) internal virtual {
  180. + function _burn(address account, uint256 amount) public virtual returns (bool) { // HARNESS: internal -> public
  181. require(account != address(0), "ERC20: burn from the zero address");
  182. _beforeTokenTransfer(account, address(0), amount);
  183. @@ -292,6 +292,8 @@
  184. emit Transfer(account, address(0), amount);
  185. _afterTokenTransfer(account, address(0), amount);
  186. +
  187. + return true;
  188. }
  189. /**
  190. diff -ruN token/ERC20/extensions/ERC20FlashMint.sol token/ERC20/extensions/ERC20FlashMint.sol
  191. --- token/ERC20/extensions/ERC20FlashMint.sol 2022-05-25 15:36:58.853363841 -0400
  192. +++ token/ERC20/extensions/ERC20FlashMint.sol 2022-05-25 16:04:57.725255723 -0400
  193. @@ -40,9 +40,11 @@
  194. require(token == address(this), "ERC20FlashMint: wrong token");
  195. // silence warning about unused variable without the addition of bytecode.
  196. amount;
  197. - return 0;
  198. + return fee; // HARNESS: made "return" nonzero
  199. }
  200. + uint256 public fee; // HARNESS: added it to simulate random fee amount
  201. +
  202. /**
  203. * @dev Returns the receiver address of the flash fee. By default this
  204. * implementation returns the address(0) which means the fee amount will be burnt.
  205. diff -ruN token/ERC20/extensions/ERC20Votes.sol token/ERC20/extensions/ERC20Votes.sol
  206. --- token/ERC20/extensions/ERC20Votes.sol 2022-03-02 13:56:14.831535075 -0500
  207. +++ token/ERC20/extensions/ERC20Votes.sol 2022-05-25 16:04:57.725255723 -0400
  208. @@ -33,8 +33,8 @@
  209. bytes32 private constant _DELEGATION_TYPEHASH =
  210. keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
  211. - mapping(address => address) private _delegates;
  212. - mapping(address => Checkpoint[]) private _checkpoints;
  213. + mapping(address => address) public _delegates;
  214. + mapping(address => Checkpoint[]) public _checkpoints;
  215. Checkpoint[] private _totalSupplyCheckpoints;
  216. /**
  217. diff -ruN token/ERC20/extensions/ERC20Wrapper.sol token/ERC20/extensions/ERC20Wrapper.sol
  218. --- token/ERC20/extensions/ERC20Wrapper.sol 2022-05-25 15:36:58.853363841 -0400
  219. +++ token/ERC20/extensions/ERC20Wrapper.sol 2022-05-25 16:04:57.733255587 -0400
  220. @@ -55,7 +55,7 @@
  221. * @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake. Internal
  222. * function that can be exposed with access control if desired.
  223. */
  224. - function _recover(address account) internal virtual returns (uint256) {
  225. + function _recover(address account) public virtual returns (uint256) { // HARNESS: internal -> public
  226. uint256 value = underlying.balanceOf(address(this)) - totalSupply();
  227. _mint(account, value);
  228. return value;
  229. diff -ruN token/ERC721/extensions/draft-ERC721Votes.sol token/ERC721/extensions/draft-ERC721Votes.sol
  230. --- token/ERC721/extensions/draft-ERC721Votes.sol 2022-05-25 15:36:58.853363841 -0400
  231. +++ token/ERC721/extensions/draft-ERC721Votes.sol 2022-05-25 16:04:57.733255587 -0400
  232. @@ -34,7 +34,7 @@
  233. /**
  234. * @dev Returns the balance of `account`.
  235. */
  236. - function _getVotingUnits(address account) internal view virtual override returns (uint256) {
  237. + function _getVotingUnits(address account) public view virtual override returns (uint256) {
  238. return balanceOf(account);
  239. }
  240. }
  241. diff -ruN utils/Address.sol utils/Address.sol
  242. --- utils/Address.sol 2022-05-25 15:36:58.853363841 -0400
  243. +++ utils/Address.sol 2022-05-25 16:04:57.733255587 -0400
  244. @@ -131,6 +131,7 @@
  245. uint256 value,
  246. string memory errorMessage
  247. ) internal returns (bytes memory) {
  248. + return ""; // external calls havoc
  249. require(address(this).balance >= value, "Address: insufficient balance for call");
  250. require(isContract(target), "Address: call to non-contract");