applyHarness.patch 13 KB

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