applyHarness.patch 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. diff -druN access/AccessControl.sol access/AccessControl.sol
  2. --- access/AccessControl.sol 2022-10-31 11:08:30.540461238 +0100
  3. +++ access/AccessControl.sol 2022-11-04 16:35:52.557358427 +0100
  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 -druN governance/extensions/GovernorCountingSimple.sol governance/extensions/GovernorCountingSimple.sol
  13. --- governance/extensions/GovernorCountingSimple.sol 2022-10-31 11:08:30.540461238 +0100
  14. +++ governance/extensions/GovernorCountingSimple.sol 2022-11-04 16:35:52.557358427 +0100
  15. @@ -27,7 +27,7 @@
  16. mapping(address => bool) hasVoted;
  17. }
  18. - mapping(uint256 => ProposalVote) private _proposalVotes;
  19. + mapping(uint256 => ProposalVote) internal _proposalVotes; // HARNESS: private -> internal
  20. /**
  21. * @dev See {IGovernor-COUNTING_MODE}.
  22. diff -druN governance/extensions/GovernorPreventLateQuorum.sol governance/extensions/GovernorPreventLateQuorum.sol
  23. --- governance/extensions/GovernorPreventLateQuorum.sol 2022-08-31 13:44:36.377724869 +0200
  24. +++ governance/extensions/GovernorPreventLateQuorum.sol 2022-11-04 16:35:52.557358427 +0100
  25. @@ -21,8 +21,8 @@
  26. using SafeCast for uint256;
  27. using Timers for Timers.BlockNumber;
  28. - uint64 private _voteExtension;
  29. - mapping(uint256 => Timers.BlockNumber) private _extendedDeadlines;
  30. + uint64 internal _voteExtension; // HARNESS: private -> internal
  31. + mapping(uint256 => Timers.BlockNumber) internal _extendedDeadlines; // HARNESS: private -> internal
  32. /// @dev Emitted when a proposal deadline is pushed back due to reaching quorum late in its voting period.
  33. event ProposalExtended(uint256 indexed proposalId, uint64 extendedDeadline);
  34. diff -druN governance/extensions/GovernorVotesQuorumFraction.sol governance/extensions/GovernorVotesQuorumFraction.sol
  35. --- governance/extensions/GovernorVotesQuorumFraction.sol 2022-10-31 11:08:30.540461238 +0100
  36. +++ governance/extensions/GovernorVotesQuorumFraction.sol 2022-11-04 16:35:52.557358427 +0100
  37. @@ -16,8 +16,8 @@
  38. abstract contract GovernorVotesQuorumFraction is GovernorVotes {
  39. using Checkpoints for Checkpoints.History;
  40. - uint256 private _quorumNumerator; // DEPRECATED
  41. - Checkpoints.History private _quorumNumeratorHistory;
  42. + uint256 internal _quorumNumerator; // DEPRECATED // MUNGED private => internal
  43. + Checkpoints.History internal _quorumNumeratorHistory; // MUNGED private => internal
  44. event QuorumNumeratorUpdated(uint256 oldQuorumNumerator, uint256 newQuorumNumerator);
  45. diff -druN governance/Governor.sol governance/Governor.sol
  46. --- governance/Governor.sol 2022-11-04 16:13:34.398935222 +0100
  47. +++ governance/Governor.sol 2022-11-04 16:35:52.560691845 +0100
  48. @@ -44,7 +44,7 @@
  49. string private _name;
  50. - mapping(uint256 => ProposalCore) private _proposals;
  51. + mapping(uint256 => ProposalCore) internal _proposals; // HARNESS: private -> internal
  52. // This queue keeps track of the governor operating on itself. Calls to functions protected by the
  53. // {onlyGovernance} modifier needs to be whitelisted in this queue. Whitelisting is set in {_beforeExecute},
  54. diff -druN governance/TimelockController.sol governance/TimelockController.sol
  55. --- governance/TimelockController.sol 2022-11-03 12:06:09.356515929 +0100
  56. +++ governance/TimelockController.sol 2022-11-04 16:35:52.560691845 +0100
  57. @@ -28,10 +28,10 @@
  58. bytes32 public constant PROPOSER_ROLE = keccak256("PROPOSER_ROLE");
  59. bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE");
  60. bytes32 public constant CANCELLER_ROLE = keccak256("CANCELLER_ROLE");
  61. - uint256 internal constant _DONE_TIMESTAMP = uint256(1);
  62. + uint256 public constant _DONE_TIMESTAMP = uint256(1); // HARNESS: internal -> public
  63. mapping(bytes32 => uint256) private _timestamps;
  64. - uint256 private _minDelay;
  65. + uint256 public _minDelay; // HARNESS: private -> public
  66. /**
  67. * @dev Emitted when a call is scheduled as part of operation `id`.
  68. diff -druN governance/utils/Votes.sol governance/utils/Votes.sol
  69. --- governance/utils/Votes.sol 2022-11-03 12:06:09.356515929 +0100
  70. +++ governance/utils/Votes.sol 2022-11-04 16:35:52.560691845 +0100
  71. @@ -35,7 +35,25 @@
  72. bytes32 private constant _DELEGATION_TYPEHASH =
  73. keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
  74. - mapping(address => address) private _delegation;
  75. + // HARNESS : Hooks cannot access any information from Checkpoints yet, so I am also updating votes and fromBlock in this struct
  76. + struct Ckpt {
  77. + uint32 fromBlock;
  78. + uint224 votes;
  79. + }
  80. + mapping(address => Ckpt) public _checkpoints;
  81. +
  82. + // HARNESSED getters
  83. + function numCheckpoints(address account) public view returns (uint32) {
  84. + return SafeCast.toUint32(_delegateCheckpoints[account]._checkpoints.length);
  85. + }
  86. + function ckptFromBlock(address account, uint32 pos) public view returns (uint32) {
  87. + return _delegateCheckpoints[account]._checkpoints[pos]._blockNumber;
  88. + }
  89. + function ckptVotes(address account, uint32 pos) public view returns (uint224) {
  90. + return _delegateCheckpoints[account]._checkpoints[pos]._value;
  91. + }
  92. +
  93. + mapping(address => address) public _delegation; // HARNESS: private -> public
  94. mapping(address => Checkpoints.History) private _delegateCheckpoints;
  95. Checkpoints.History private _totalCheckpoints;
  96. @@ -124,7 +142,7 @@
  97. *
  98. * Emits events {DelegateChanged} and {DelegateVotesChanged}.
  99. */
  100. - function _delegate(address account, address delegatee) internal virtual {
  101. + function _delegate(address account, address delegatee) public virtual { // HARNESS: internal -> public
  102. address oldDelegate = delegates(account);
  103. _delegation[account] = delegatee;
  104. @@ -142,10 +160,10 @@
  105. uint256 amount
  106. ) internal virtual {
  107. if (from == address(0)) {
  108. - _totalCheckpoints.push(_add, amount);
  109. + _totalCheckpoints.push(_totalCheckpoints.latest() + amount); // Harnessed to remove function pointers
  110. }
  111. if (to == address(0)) {
  112. - _totalCheckpoints.push(_subtract, amount);
  113. + _totalCheckpoints.push(_totalCheckpoints.latest() - amount); // Harnessed to remove function pointers
  114. }
  115. _moveDelegateVotes(delegates(from), delegates(to), amount);
  116. }
  117. @@ -160,11 +178,13 @@
  118. ) private {
  119. if (from != to && amount > 0) {
  120. if (from != address(0)) {
  121. - (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[from].push(_subtract, amount);
  122. + (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[from].push(_delegateCheckpoints[from].latest() - amount); // Harnessed to remove function pointers
  123. + _checkpoints[from] = Ckpt({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newValue)}); // HARNESS
  124. emit DelegateVotesChanged(from, oldValue, newValue);
  125. }
  126. if (to != address(0)) {
  127. - (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[to].push(_add, amount);
  128. + (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[to].push(_delegateCheckpoints[to].latest() + amount); // Harnessed to remove function pointers
  129. + _checkpoints[to] = Ckpt({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newValue)}); // HARNESS
  130. emit DelegateVotesChanged(to, oldValue, newValue);
  131. }
  132. }
  133. @@ -207,5 +227,5 @@
  134. /**
  135. * @dev Must return the voting units held by an account.
  136. */
  137. - function _getVotingUnits(address) internal view virtual returns (uint256);
  138. + function _getVotingUnits(address) public virtual returns (uint256); // HARNESS: internal -> public
  139. }
  140. diff -druN mocks/SafeERC20Helper.sol mocks/SafeERC20Helper.sol
  141. --- mocks/SafeERC20Helper.sol 2022-11-02 19:02:32.463724228 +0100
  142. +++ mocks/SafeERC20Helper.sol 2022-11-04 16:35:52.560691845 +0100
  143. @@ -4,7 +4,6 @@
  144. import "../utils/Context.sol";
  145. import "../token/ERC20/IERC20.sol";
  146. -import "../token/ERC20/extensions/draft-ERC20Permit.sol";
  147. import "../token/ERC20/utils/SafeERC20.sol";
  148. contract ERC20ReturnFalseMock is Context {
  149. @@ -106,42 +105,43 @@
  150. }
  151. }
  152. -contract ERC20PermitNoRevertMock is
  153. - ERC20("ERC20PermitNoRevertMock", "ERC20PermitNoRevertMock"),
  154. - ERC20Permit("ERC20PermitNoRevertMock")
  155. -{
  156. - function getChainId() external view returns (uint256) {
  157. - return block.chainid;
  158. - }
  159. +// Harness remove ?
  160. +// contract ERC20PermitNoRevertMock is
  161. +// ERC20("ERC20PermitNoRevertMock", "ERC20PermitNoRevertMock"),
  162. +// ERC20Permit("ERC20PermitNoRevertMock")
  163. +// {
  164. +// function getChainId() external view returns (uint256) {
  165. +// return block.chainid;
  166. +// }
  167. - function permitThatMayRevert(
  168. - address owner,
  169. - address spender,
  170. - uint256 value,
  171. - uint256 deadline,
  172. - uint8 v,
  173. - bytes32 r,
  174. - bytes32 s
  175. - ) public {
  176. - super.permit(owner, spender, value, deadline, v, r, s);
  177. - }
  178. +// function permitThatMayRevert(
  179. +// address owner,
  180. +// address spender,
  181. +// uint256 value,
  182. +// uint256 deadline,
  183. +// uint8 v,
  184. +// bytes32 r,
  185. +// bytes32 s
  186. +// ) public {
  187. +// super.permit(owner, spender, value, deadline, v, r, s);
  188. +// }
  189. - function permit(
  190. - address owner,
  191. - address spender,
  192. - uint256 value,
  193. - uint256 deadline,
  194. - uint8 v,
  195. - bytes32 r,
  196. - bytes32 s
  197. - ) public override {
  198. - try this.permitThatMayRevert(owner, spender, value, deadline, v, r, s) {
  199. - // do nothing
  200. - } catch {
  201. - // do nothing
  202. - }
  203. - }
  204. -}
  205. +// function permit(
  206. +// address owner,
  207. +// address spender,
  208. +// uint256 value,
  209. +// uint256 deadline,
  210. +// uint8 v,
  211. +// bytes32 r,
  212. +// bytes32 s
  213. +// ) public override {
  214. +// try this.permitThatMayRevert(owner, spender, value, deadline, v, r, s) {
  215. +// // do nothing
  216. +// } catch {
  217. +// // do nothing
  218. +// }
  219. +// }
  220. +// }
  221. contract SafeERC20Wrapper is Context {
  222. using SafeERC20 for IERC20;
  223. diff -druN proxy/utils/Initializable.sol proxy/utils/Initializable.sol
  224. --- proxy/utils/Initializable.sol 2022-11-03 12:06:09.356515929 +0100
  225. +++ proxy/utils/Initializable.sol 2022-11-04 16:35:52.560691845 +0100
  226. @@ -59,12 +59,12 @@
  227. * @dev Indicates that the contract has been initialized.
  228. * @custom:oz-retyped-from bool
  229. */
  230. - uint8 private _initialized;
  231. + uint8 internal _initialized; // HARNESS: private -> internal
  232. /**
  233. * @dev Indicates that the contract is in the process of being initialized.
  234. */
  235. - bool private _initializing;
  236. + bool internal _initializing; // HARNESS: private -> internal
  237. /**
  238. * @dev Triggered when the contract has been initialized or reinitialized.
  239. diff -druN token/ERC1155/ERC1155.sol token/ERC1155/ERC1155.sol
  240. --- token/ERC1155/ERC1155.sol 2022-10-31 11:08:30.547127922 +0100
  241. +++ token/ERC1155/ERC1155.sol 2022-11-04 16:35:52.560691845 +0100
  242. @@ -21,7 +21,7 @@
  243. using Address for address;
  244. // Mapping from token ID to account balances
  245. - mapping(uint256 => mapping(address => uint256)) private _balances;
  246. + mapping(uint256 => mapping(address => uint256)) internal _balances; // HARNESS: private -> internal
  247. // Mapping from account to operator approvals
  248. mapping(address => mapping(address => bool)) private _operatorApprovals;
  249. @@ -471,7 +471,7 @@
  250. uint256 id,
  251. uint256 amount,
  252. bytes memory data
  253. - ) private {
  254. + ) public { // HARNESS: private -> public
  255. if (to.isContract()) {
  256. try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
  257. if (response != IERC1155Receiver.onERC1155Received.selector) {
  258. @@ -492,7 +492,7 @@
  259. uint256[] memory ids,
  260. uint256[] memory amounts,
  261. bytes memory data
  262. - ) private {
  263. + ) public { // HARNESS: private -> public
  264. if (to.isContract()) {
  265. try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
  266. bytes4 response
  267. diff -druN token/ERC20/ERC20.sol token/ERC20/ERC20.sol
  268. --- token/ERC20/ERC20.sol 2022-10-31 11:08:30.547127922 +0100
  269. +++ token/ERC20/ERC20.sol 2022-11-04 16:35:52.560691845 +0100
  270. @@ -256,7 +256,7 @@
  271. *
  272. * - `account` cannot be the zero address.
  273. */
  274. - function _mint(address account, uint256 amount) internal virtual {
  275. + function _mint(address account, uint256 amount) public virtual { // HARNESS: internal -> public
  276. require(account != address(0), "ERC20: mint to the zero address");
  277. _beforeTokenTransfer(address(0), account, amount);
  278. @@ -282,7 +282,7 @@
  279. * - `account` cannot be the zero address.
  280. * - `account` must have at least `amount` tokens.
  281. */
  282. - function _burn(address account, uint256 amount) internal virtual {
  283. + function _burn(address account, uint256 amount) public virtual { // HARNESS: internal -> public
  284. require(account != address(0), "ERC20: burn from the zero address");
  285. _beforeTokenTransfer(account, address(0), amount);
  286. diff -druN token/ERC20/extensions/ERC20Capped.sol token/ERC20/extensions/ERC20Capped.sol
  287. --- token/ERC20/extensions/ERC20Capped.sol 2022-08-31 13:44:36.381058287 +0200
  288. +++ token/ERC20/extensions/ERC20Capped.sol 2022-11-04 16:35:52.560691845 +0100
  289. @@ -30,7 +30,7 @@
  290. /**
  291. * @dev See {ERC20-_mint}.
  292. */
  293. - function _mint(address account, uint256 amount) internal virtual override {
  294. + function _mint(address account, uint256 amount) public virtual override { // HARNESS: internal -> public
  295. require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded");
  296. super._mint(account, amount);
  297. }
  298. diff -druN token/ERC20/extensions/ERC20FlashMint.sol token/ERC20/extensions/ERC20FlashMint.sol
  299. --- token/ERC20/extensions/ERC20FlashMint.sol 2022-11-03 12:06:09.356515929 +0100
  300. +++ token/ERC20/extensions/ERC20FlashMint.sol 2022-11-04 16:35:52.560691845 +0100
  301. @@ -51,9 +51,11 @@
  302. // silence warning about unused variable without the addition of bytecode.
  303. token;
  304. amount;
  305. - return 0;
  306. + return fee; // HARNESS: made "return" nonzero
  307. }
  308. + uint256 public fee; // HARNESS: added it to simulate random fee amount
  309. +
  310. /**
  311. * @dev Returns the receiver address of the flash fee. By default this
  312. * implementation returns the address(0) which means the fee amount will be burnt.
  313. diff -druN token/ERC20/extensions/ERC20Votes.sol token/ERC20/extensions/ERC20Votes.sol
  314. --- token/ERC20/extensions/ERC20Votes.sol 2022-11-03 12:06:09.356515929 +0100
  315. +++ token/ERC20/extensions/ERC20Votes.sol 2022-11-04 16:35:52.560691845 +0100
  316. @@ -33,8 +33,8 @@
  317. bytes32 private constant _DELEGATION_TYPEHASH =
  318. keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
  319. - mapping(address => address) private _delegates;
  320. - mapping(address => Checkpoint[]) private _checkpoints;
  321. + mapping(address => address) public _delegates; // HARNESS: private -> public
  322. + mapping(address => Checkpoint[]) public _checkpoints; // HARNESS: private -> public
  323. Checkpoint[] private _totalSupplyCheckpoints;
  324. /**
  325. @@ -165,27 +165,27 @@
  326. /**
  327. * @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1).
  328. */
  329. - function _maxSupply() internal view virtual returns (uint224) {
  330. + function _maxSupply() public view virtual returns (uint224) { // HARNESS: internal -> public
  331. return type(uint224).max;
  332. }
  333. /**
  334. * @dev Snapshots the totalSupply after it has been increased.
  335. */
  336. - function _mint(address account, uint256 amount) internal virtual override {
  337. + function _mint(address account, uint256 amount) public virtual override { // HARNESS: internal -> public
  338. super._mint(account, amount);
  339. require(totalSupply() <= _maxSupply(), "ERC20Votes: total supply risks overflowing votes");
  340. - _writeCheckpoint(_totalSupplyCheckpoints, _add, amount);
  341. + _writeCheckpointAdd(_totalSupplyCheckpoints, amount); // HARNESS: new version without pointer
  342. }
  343. /**
  344. * @dev Snapshots the totalSupply after it has been decreased.
  345. */
  346. - function _burn(address account, uint256 amount) internal virtual override {
  347. + function _burn(address account, uint256 amount) public virtual override { // HARNESS: internal -> public (to comply with the ERC20 harness)
  348. super._burn(account, amount);
  349. - _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount);
  350. + _writeCheckpointSub(_totalSupplyCheckpoints, amount); // HARNESS: new version without pointer
  351. }
  352. /**
  353. @@ -208,7 +208,7 @@
  354. *
  355. * Emits events {DelegateChanged} and {DelegateVotesChanged}.
  356. */
  357. - function _delegate(address delegator, address delegatee) internal virtual {
  358. + function _delegate(address delegator, address delegatee) public virtual { // HARNESS: internal -> public
  359. address currentDelegate = delegates(delegator);
  360. uint256 delegatorBalance = balanceOf(delegator);
  361. _delegates[delegator] = delegatee;
  362. @@ -225,36 +225,86 @@
  363. ) private {
  364. if (src != dst && amount > 0) {
  365. if (src != address(0)) {
  366. - (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], _subtract, amount);
  367. + (uint256 oldWeight, uint256 newWeight) = _writeCheckpointSub(_checkpoints[src], amount); // HARNESS: new version without pointer
  368. +
  369. emit DelegateVotesChanged(src, oldWeight, newWeight);
  370. }
  371. if (dst != address(0)) {
  372. - (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount);
  373. + (uint256 oldWeight, uint256 newWeight) = _writeCheckpointAdd(_checkpoints[dst], amount); // HARNESS: new version without pointer
  374. emit DelegateVotesChanged(dst, oldWeight, newWeight);
  375. }
  376. }
  377. }
  378. - function _writeCheckpoint(
  379. + // function _writeCheckpoint(
  380. + // Checkpoint[] storage ckpts,
  381. + // function(uint256, uint256) view returns (uint256) op,
  382. + // uint256 delta
  383. + // ) private returns (uint256 oldWeight, uint256 newWeight) {
  384. + // uint256 pos = ckpts.length;
  385. +
  386. + // Checkpoint memory oldCkpt = pos == 0 ? Checkpoint(0, 0) : _unsafeAccess(ckpts, pos - 1);
  387. +
  388. + // oldWeight = oldCkpt.votes;
  389. + // newWeight = op(oldWeight, delta);
  390. +
  391. + // if (pos > 0 && oldCkpt.fromBlock == block.number) {
  392. + // _unsafeAccess(ckpts, pos - 1).votes = SafeCast.toUint224(newWeight);
  393. + // } else {
  394. + // ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newWeight)}));
  395. + // }
  396. + // }
  397. +
  398. + // HARNESS: split _writeCheckpoint() to two functions as a workaround for function pointers that cannot be managed by the tool
  399. + function _writeCheckpointAdd(
  400. Checkpoint[] storage ckpts,
  401. - function(uint256, uint256) view returns (uint256) op,
  402. uint256 delta
  403. ) private returns (uint256 oldWeight, uint256 newWeight) {
  404. uint256 pos = ckpts.length;
  405. + oldWeight = pos == 0 ? 0 : ckpts[pos - 1].votes;
  406. + newWeight = _add(oldWeight, delta);
  407. - Checkpoint memory oldCkpt = pos == 0 ? Checkpoint(0, 0) : _unsafeAccess(ckpts, pos - 1);
  408. + if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) {
  409. + ckpts[pos - 1].votes = SafeCast.toUint224(newWeight);
  410. + } else {
  411. + ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newWeight)}));
  412. + }
  413. + }
  414. - oldWeight = oldCkpt.votes;
  415. - newWeight = op(oldWeight, delta);
  416. + function _writeCheckpointSub(
  417. + Checkpoint[] storage ckpts,
  418. + uint256 delta
  419. + ) private returns (uint256 oldWeight, uint256 newWeight) {
  420. + uint256 pos = ckpts.length;
  421. + oldWeight = pos == 0 ? 0 : ckpts[pos - 1].votes;
  422. + newWeight = _subtract(oldWeight, delta);
  423. - if (pos > 0 && oldCkpt.fromBlock == block.number) {
  424. - _unsafeAccess(ckpts, pos - 1).votes = SafeCast.toUint224(newWeight);
  425. + if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) {
  426. + ckpts[pos - 1].votes = SafeCast.toUint224(newWeight);
  427. } else {
  428. ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newWeight)}));
  429. }
  430. }
  431. + // backup of original function
  432. + //
  433. + // function _writeCheckpoint(
  434. + // Checkpoint[] storage ckpts,
  435. + // function(uint256, uint256) view returns (uint256) op,
  436. + // uint256 delta
  437. + // ) private returns (uint256 oldWeight, uint256 newWeight) {
  438. + // uint256 pos = ckpts.length;
  439. + // oldWeight = pos == 0 ? 0 : ckpts[pos - 1].votes;
  440. + // newWeight = op(oldWeight, delta);
  441. + //
  442. + // if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) {
  443. + // ckpts[pos - 1].votes = SafeCast.toUint224(newWeight);
  444. + // } else {
  445. + // ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newWeight)}));
  446. + // }
  447. + // }
  448. +
  449. function _add(uint256 a, uint256 b) private pure returns (uint256) {
  450. return a + b;
  451. }
  452. diff -druN token/ERC20/extensions/ERC20Wrapper.sol token/ERC20/extensions/ERC20Wrapper.sol
  453. --- token/ERC20/extensions/ERC20Wrapper.sol 2022-08-31 13:44:36.381058287 +0200
  454. +++ token/ERC20/extensions/ERC20Wrapper.sol 2022-11-04 16:35:52.560691845 +0100
  455. @@ -55,7 +55,7 @@
  456. * @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake. Internal
  457. * function that can be exposed with access control if desired.
  458. */
  459. - function _recover(address account) internal virtual returns (uint256) {
  460. + function _recover(address account) public virtual returns (uint256) { // HARNESS: internal -> public
  461. uint256 value = underlying.balanceOf(address(this)) - totalSupply();
  462. _mint(account, value);
  463. return value;
  464. diff -druN token/ERC721/extensions/draft-ERC721Votes.sol token/ERC721/extensions/draft-ERC721Votes.sol
  465. --- token/ERC721/extensions/draft-ERC721Votes.sol 2022-11-03 12:06:09.356515929 +0100
  466. +++ token/ERC721/extensions/draft-ERC721Votes.sol 2022-11-04 16:35:52.560691845 +0100
  467. @@ -49,7 +49,7 @@
  468. /**
  469. * @dev Returns the balance of `account`.
  470. */
  471. - function _getVotingUnits(address account) internal view virtual override returns (uint256) {
  472. + function _getVotingUnits(address account) public view virtual override returns (uint256) { // HARNESS: internal -> public
  473. return balanceOf(account);
  474. }
  475. }
  476. diff -druN utils/Address.sol utils/Address.sol
  477. --- utils/Address.sol 2022-11-03 12:06:09.356515929 +0100
  478. +++ utils/Address.sol 2022-11-04 16:35:52.564025262 +0100
  479. @@ -197,7 +197,7 @@
  480. bool success,
  481. bytes memory returndata,
  482. string memory errorMessage
  483. - ) internal view returns (bytes memory) {
  484. + ) internal view returns (bytes memory val) { // MUNGED undeterministic return causes error for Prover
  485. if (success) {
  486. if (returndata.length == 0) {
  487. // only check isContract if the call was successful and the return data is empty
  488. @@ -220,7 +220,7 @@
  489. bool success,
  490. bytes memory returndata,
  491. string memory errorMessage
  492. - ) internal pure returns (bytes memory) {
  493. + ) internal pure returns (bytes memory val) { // MUNGED undeterministic return causes error for Prover
  494. if (success) {
  495. return returndata;
  496. } else {
  497. diff -druN utils/Checkpoints.sol utils/Checkpoints.sol
  498. --- utils/Checkpoints.sol 2022-11-02 12:17:36.976298213 +0100
  499. +++ utils/Checkpoints.sol 2022-11-04 16:35:52.564025262 +0100
  500. @@ -83,13 +83,13 @@
  501. *
  502. * Returns previous value and new value.
  503. */
  504. - function push(
  505. - History storage self,
  506. - function(uint256, uint256) view returns (uint256) op,
  507. - uint256 delta
  508. - ) internal returns (uint256, uint256) {
  509. - return push(self, op(latest(self), delta));
  510. - }
  511. + // function push(
  512. + // History storage self,
  513. + // function(uint256, uint256) view returns (uint256) op,
  514. + // uint256 delta
  515. + // ) internal returns (uint256, uint256) {
  516. + // return push(self, op(latest(self), delta));
  517. + // }
  518. /**
  519. * @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.