Compare commits

..

344 Commits

Author SHA1 Message Date
37991642dc nightly 2023-03-01 00:46:18 +01:00
1038b7f2c7 wip GovernorPreventLateQuorum 2023-02-28 23:33:12 +01:00
7dc201fce9 fix some specs 2023-02-28 22:57:43 +01:00
bf73fb4013 fix GovernorPreventLateQuorum.spec 2023-02-28 18:35:03 +01:00
6c4ffe783f cleanup accesscontrol specs 2023-02-28 17:12:15 +01:00
f21f86c3c1 fixing certora/specs/GovernorCountingSimple.spec 2023-02-28 16:09:35 +01:00
2e7bca424a cleanup GovernorBase.spec 2023-02-28 14:05:30 +01:00
d4e9d8d54d fix error in one of the governor rules 2023-02-28 12:18:04 +01:00
baf71582b9 improve helperFunctionsWithRevert 2023-02-28 11:10:36 +01:00
ecebc5688d add --optimistic_hashing to governor scripts 2023-02-28 09:55:41 +01:00
3c58e4e3d3 isOperationReady NOT envfree 2023-02-27 17:21:06 +01:00
4242fdace4 isOperationReady envfree 2023-02-27 16:19:18 +01:00
14b40eddcb add --optimistic_hashing 2023-02-27 15:25:04 +01:00
c8c8ca39d7 cleanup 2023-02-27 15:19:07 +01:00
150edce57b fix timelockcontroller 2023-02-27 15:13:25 +01:00
9f2d511d20 fix2 2023-02-27 14:01:59 +01:00
b50d9980be fix 2023-02-27 13:48:48 +01:00
423a808748 fix harness 2023-02-27 11:59:16 +01:00
5c859049e6 latest compiler 2023-02-27 11:18:16 +01:00
cad49af31e minimize diff 2023-02-27 11:02:36 +01:00
e0fa84a6b7 Merge branch 'master' into formal-verification 2023-02-27 11:00:16 +01:00
e04f7ded94 Fixed GPLQ spec, all rules passing (#3822)
Co-authored-by: Michael George <michael@certora.com>
Co-authored-by: Nick Armstrong <nick@certora.com>
Co-authored-by: Michael George <mdgeorge@cs.cornell.edu>
Co-authored-by: Aleksander Kryukov <firealexkryukov@gmail.com>
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
2022-11-27 20:41:50 -03:00
2c5194f3f1 Clean and fix formal verification (#3798)
Co-authored-by: Michael George <michael@certora.com>
Co-authored-by: Nick Armstrong <nick@certora.com>
Co-authored-by: Michael George <mdgeorge@cs.cornell.edu>
Co-authored-by: Aleksander Kryukov <firealexkryukov@gmail.com>
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
2022-11-04 18:07:39 +01:00
07ac1030e7 chmod -x certora/scripts/**/*.sh 2022-11-03 12:07:39 +01:00
a73d7ab57b get rid of certora/helpers 2022-10-05 15:30:03 +02:00
89962af163 Fix ERC20Wrapper.spec 2022-10-05 15:23:26 +02:00
c7a544d568 move passing scripts out of noCI 2022-09-29 18:40:14 +02:00
634c37becf enable ci test for some (passing) rules 2022-09-28 23:49:03 +02:00
d986bbc8e0 filter noCI on script listing 2022-09-28 11:02:50 +02:00
fed8d5c856 refactor & improve ERC20 specs 2022-09-28 10:55:39 +02:00
597202d904 finish ERC20 base specs + move all other specs to noCI for the time being 2022-09-27 23:36:58 +02:00
8f6a03204e Start working on ERC20 specs 2022-09-27 21:42:18 +02:00
d916e2edf4 further script cleanup 2022-09-23 12:47:45 +02:00
3075181276 use bash 2022-09-23 11:54:11 +02:00
8b1042371a remove some scripts from CI run 2022-09-23 11:43:33 +02:00
38d21cab86 update scripts 2022-09-22 18:56:59 +02:00
bfbf4d8398 clean applyHarness 2022-09-22 10:47:06 +02:00
49333bcc24 clean applyHarness 2022-09-22 10:44:48 +02:00
3252e54f2b use solc without version & remove send_only 2022-09-21 17:41:13 +02:00
cc7837fb46 cleanup scripts/*.sh 2022-09-21 17:30:34 +02:00
9dd0eb5e5c better wildcard 2022-09-21 17:21:26 +02:00
9ce8455ae0 run certora scripts 2022-09-21 17:12:20 +02:00
dfa0505c40 fix formal verification workflow 2022-09-21 09:18:00 +02:00
e7f770591b update harness and matrix 2022-09-20 20:12:05 +02:00
b9c7899e6c no debug 2022-09-20 16:50:37 +02:00
0f20d57771 touch to force make 2022-09-20 16:46:24 +02:00
797ef26bb6 refactor 2022-09-20 16:42:18 +02:00
9aa745e4fe try using python 3.8 2022-09-20 16:40:45 +02:00
d7c3cc758b try using python 3.10 2022-09-20 16:39:12 +02:00
3c0d926908 --debug 2022-09-20 16:28:09 +02:00
28367f8989 fix action 2022-09-20 16:23:25 +02:00
61817e055f enable formal verification by matrix 2022-09-20 16:18:56 +02:00
94f9f7ac58 test matrix 2022-09-20 16:15:33 +02:00
b2ec06aaf2 test matrix 2022-09-20 16:11:32 +02:00
0fa6aad5e5 Update certora harness 2022-09-20 15:12:26 +02:00
0c2453ba17 Automatically generate test matrix 2022-09-09 22:54:56 +02:00
0d1e919742 run check on the formal-verification branch 2022-09-09 15:47:00 +02:00
75ce9ef8e9 name 2022-09-09 13:52:59 +02:00
56c355ea8b fix 2022-09-09 13:47:16 +02:00
e9f53ebc02 run prettier --write 2022-09-09 13:33:55 +02:00
3aa0a015d1 workflow trigger 2022-09-09 13:28:49 +02:00
d98d9c03f3 Merge remote-tracking branch 'Certora/master' into formal-verification 2022-09-09 13:19:12 +02:00
2627753bfe votes solvency passing again 2022-08-12 00:32:35 -07:00
4820ed4ea8 missing erc20votes harnessing 2022-08-11 21:27:17 -07:00
4a3b0bb875 filters for skipped functions 2022-08-11 21:11:01 -07:00
3e6045155e reorganized scripts 2022-08-11 20:40:13 -07:00
b90f4d285e Merge pull request #4 from Certora/certora/erc1155ext
fix erc1155supply vacuity, change CI solc version to 8.4
2022-06-16 11:25:14 -07:00
1701b0c7fd fix erc1155supply vacuity, change CI solc version to 8.4 2022-06-15 17:05:12 -07:00
154a151518 Update verify.yml, adding master branch 2022-06-15 14:31:28 -07:00
0b99b54327 Merge pull request #3 from Certora/certora/erc1155ext
Certora/erc1155ext
2022-06-15 14:18:59 -07:00
9708bc0397 undo script changes 2022-06-15 14:13:43 -07:00
8ec6b0f56f Merge branch 'OpenZeppelin:master' into certora/erc1155ext 2022-06-15 14:07:26 -07:00
962a5023e6 remove commented code, fix some old scripts 2022-06-14 16:52:57 -07:00
6820ff8b9c Merge branch 'OpenZeppelin:master' into certora/erc1155ext 2022-06-08 16:39:13 -07:00
65ab8e9ac4 Changed rule transfersHaveSameLengthInputArrays (passing) to use _ instead of holder 2022-06-07 17:51:27 -07:00
9bbc7b7eb3 Moved three transfer rules from 1155Supply spec to base 1155 spec 2022-06-07 17:32:45 -07:00
e4492aed8a Cleaned up code for rule transfersHaveSameLengthInputArrays (passing) 2022-06-07 17:26:22 -07:00
9c45c52c4b Fix CI script name for GovernorPreventLateQuorum 2022-06-07 17:26:11 -07:00
ca034ab3df Deleted unused method from GovPreventLateQuorum 2022-06-07 17:20:50 -07:00
75a3602ba6 Modified rule transfersHaveSameLengthInputArrays (passing) to limit array size 2022-06-07 17:16:45 -07:00
7946806fb3 Commented out sanity rules for the purposes of CI 2022-06-06 17:34:11 -07:00
84b371f92c Added rule transfersHaveSameLengthInputArrays (partially passing) 2022-06-06 13:54:53 -07:00
cccd90ec83 fix typo in CI 2022-06-06 13:06:28 -07:00
ee2f0ecb68 Improved multiple token transfer batch transfer equivalence rule 2022-06-06 13:02:41 -07:00
6a4fc6acb8 set up CI for round3 scripts 2022-06-06 12:57:50 -07:00
1aa8141b14 removed a assert failure message from an invariant in Initializable spec 2022-06-06 12:56:19 -07:00
866042d6fc Added two transfer batch transfer equivalence rules 2022-06-06 12:53:13 -07:00
234b843c36 commented out failing rules and added solc version to ERC1155 2022-06-06 15:44:07 -04:00
a373d25b01 updated CI to match moving scripts to old 2022-06-06 15:35:08 -04:00
f4b2aff79e added erc1155ext branch to CI 2022-06-06 15:33:29 -04:00
371818f792 Removed reference to _burn and _mint 2022-06-06 12:26:41 -07:00
3ccaf4f6d1 Updated and cleaned up rule descriptions 2022-06-06 11:50:05 -07:00
ffa3daa5d9 Modified verification scripts and Supply spec syntax 2022-06-06 11:42:42 -07:00
990fd18c21 make ERC1155Harness, set up script, and undo munging for ERC1155 2022-06-06 11:26:58 -07:00
5a7cc50974 Modified burnable verification script to follow script naming convention 2022-06-06 11:25:48 -07:00
e3341255b2 Added rule skeletons for equivalence rules 2022-06-06 11:24:50 -07:00
69d9ebfcdf Added modified scripts to run previous ERC1155 spec 2022-06-06 11:24:50 -07:00
be18334b69 Merge branch 'OpenZeppelin:master' into certora/erc1155ext 2022-06-06 09:23:03 -07:00
5516589b88 final initializable spec modulo extra natspec style comments 2022-06-03 16:45:27 -07:00
6363deaedd Changed rule onlyHolderOrApprovedCanReduceBalance to include filtered block 2022-06-03 16:12:12 -07:00
b10a2b8cd3 Added burn and burnBatch to filtered block of unexpectedBalanceChange 2022-06-03 13:56:46 -07:00
bdb49654c5 Deleted redundant rule burnBatchAmountProportionalToBalanceReduction 2022-06-03 12:27:08 -07:00
bab9528dc1 Added rule comments re burn method rules holding for burnBatch method 2022-06-03 12:24:03 -07:00
93928e3e19 Added rule burnBatchOnEmptyArraysChangesNothing (passing) 2022-06-03 12:13:10 -07:00
f3f26e3ff3 Modified verification scripts to include --send_only flag 2022-06-02 14:25:08 -07:00
3eb67081f3 Added TODO show equivalence between batch and non-batch methods 2022-06-02 14:15:20 -07:00
d02c2ccab3 Added comments throughout regarding reasoning 2022-06-02 14:08:29 -07:00
27fa53bba9 added init_state axiom for sum of balances 2022-06-02 14:37:40 -04:00
b90d195c6c Added rule re burnBatch (not implemented) 2022-06-02 11:30:58 -07:00
a6863a059c Changed invariant total_supply_is_sum_of_balances (partially passing) 2022-06-02 11:30:58 -07:00
669a22e0ff remove duplicate initalize script 2022-06-01 17:39:39 -07:00
cab8e489b2 initializable final draft, ready for review 2022-06-01 17:38:28 -07:00
0119a187c1 Added rule multipleTokenBurnBurnBatchEquivalence (passing) 2022-06-01 10:34:03 -07:00
15e847c835 Added invariant balanceOfZeroAddressIsZero (partially passing) 2022-05-31 18:34:22 -07:00
8e283704c3 Modified 1155 Burnable scripts 2022-05-31 16:29:46 -07:00
38495a5026 Added rule singleTokenBurnBurnBatchEquivalence (passing) 2022-05-31 16:02:23 -07:00
f74e316422 Added rule sequentialBurnsEquivalentToSingleBurnOfSum (passing) 2022-05-31 15:12:48 -07:00
2a73da9f67 Added rule burnBatchAmountProportionalToBalanceReduction (unimplemented) 2022-05-31 14:13:44 -07:00
018c58219f Updated 1155 Pausable and Supply scripts to first run make munged 2022-05-31 13:59:46 -07:00
bd3427d5ff Included rule burnAmountProportionalToBalanceReduction (passing) 2022-05-31 13:57:19 -07:00
10f5d8d942 Updated verifyERC1155Burnable.sh to first run make munged 2022-05-31 13:57:19 -07:00
b2cdcc38d4 final govPreventLateQ 2022-05-28 11:01:25 -07:00
ca0d3363b8 Revised rule description to be more accurate 2022-05-27 13:34:24 -07:00
78263e2a9a Changed rule description to match phrasing of assert comment 2022-05-26 14:39:10 -07:00
4dc0ff9fe3 Added assert message 2022-05-26 14:35:27 -07:00
1dd3b7a307 Made comment changes to Burnable and Pausable spec files 2022-05-26 14:10:49 -07:00
657a051062 replaced burn with generic function 2022-05-26 14:46:14 -04:00
da1cda69bf Merge branch 'certora/erc1155ext' of github.com:Certora/openzeppelin-contracts into certora/erc1155ext 2022-05-26 11:21:55 -07:00
428197be69 Added tester rule for only burn 2022-05-26 11:20:46 -07:00
5e69b54af1 added solc version 2022-05-25 16:20:45 -04:00
04382cd1d3 fixed a munging merge problem 2022-05-25 16:20:28 -04:00
d01f3ba925 unclobbered gitignore file 2022-05-25 16:07:55 -04:00
94eba74016 removed some patch cruft 2022-05-25 16:06:34 -04:00
8ec6785cb8 Merge branch 'master' into certora/erc1155ext. Resolved conflicts in
applyHarness by manually merging.
2022-05-25 16:04:16 -04:00
0321f38054 Added remaining rules, unclear if rules_sanity is passing 2022-05-24 16:11:18 -07:00
36327ce8c5 Added script to verify ERC1155Burnable 2022-05-23 10:00:09 -07:00
39f29ec3fd Added spec for ERC1155Burnable with rule sanity 2022-05-23 09:52:25 -07:00
7a2b502b9c Added harness for ERC1155Burnable 2022-05-23 09:32:50 -07:00
46cb74f3cf held tokens should exist passing 2022-05-20 16:27:09 -04:00
fa89068f2b 8.5/10 rules finished 2022-05-19 15:37:58 -07:00
793b88efd8 finalize fist 3 rules; fix old governor spec 2022-05-16 14:26:31 -07:00
c45f34adc8 fix typos 2022-05-11 12:28:28 -07:00
6add1e7718 setup GovLateQuorum and add 3 rules for deadlines 2022-05-11 11:35:24 -07:00
0deaee1217 Added unfinished invariant regarding user token sums and totalSupply 2022-05-10 17:36:19 -07:00
2fc3a5d4b8 implemented independence rule 2022-05-09 17:54:01 -04:00
da0fdc1aa0 harness setup for ERC1155Supply 2022-05-09 17:30:57 -04:00
aafb14461b made the spec run 2022-05-06 14:12:32 -04:00
70cbfffc74 created harness and script 2022-05-06 13:23:52 -04:00
4a3cddc529 temporarily moved old projects into old directory 2022-05-06 13:21:36 -04:00
cca337f5ae Merge branch 'certora/erc20' of github.com:Certora/openzeppelin-contracts into remotes/origin/certora/erc20 2022-04-11 13:56:37 -07:00
02de598056 removed sanity 2022-04-11 13:56:34 -07:00
8fc90f6779 fix in script 2022-04-11 16:55:54 -04:00
f15308f763 added python requirements file 2022-04-11 16:37:21 -04:00
f242abbf93 starting CI integration 2022-04-11 16:35:52 -04:00
135e21f35d comment cleanup 2022-04-11 13:26:46 -07:00
6662d0556f verify all - rules passing 2022-04-11 12:46:56 -07:00
d1454932b2 Merge branch 'certora/erc20' of github.com:Certora/openzeppelin-contracts into remotes/origin/certora/erc20 2022-04-10 19:55:27 -07:00
cab9b09b7b rough contracts all finished 2022-04-10 19:55:23 -07:00
741e9a8b6d timelock function moved 2022-04-08 20:57:53 +01:00
66c72f2b5d CI preparations 2022-04-08 20:52:38 +01:00
163a76f436 Merge branch 'certora/erc20' of github.com:Certora/openzeppelin-contracts into certora/erc20 2022-04-08 15:38:32 +01:00
75417fbf9f finilized rules 2022-04-08 15:38:26 +01:00
ec8f03ee96 Merge branch 'certora/erc20' of github.com:Certora/openzeppelin-contracts into remotes/origin/certora/erc20 2022-04-07 15:50:14 -07:00
140df5b7ce everything except Alex fix for totalVotes_sums_accounts 2022-04-07 15:49:37 -07:00
da674eced1 typos and cleaning 2022-04-04 22:34:51 +01:00
479118fcd1 push to report issues 2022-04-04 21:33:31 +01:00
8c86b250bc fixed rule description 2022-04-04 21:19:54 +01:00
a0b58c3071 flashMint finished 2022-04-04 21:16:15 +01:00
fe7d42dedd Merge branch 'certora/erc20' of github.com:Certora/openzeppelin-contracts into certora/erc20 2022-04-01 17:58:48 +01:00
44fba3e2eb ERC1155 finished 2022-04-01 17:58:41 +01:00
b2b72e7783 Merge branch 'certora/erc20' of github.com:Certora/openzeppelin-contracts into remotes/origin/certora/erc20 2022-03-31 14:40:36 -07:00
22827223c0 more passing 2022-03-31 14:40:20 -07:00
033f08972f Merge branch 'certora/erc20' of github.com:Certora/openzeppelin-contracts into certora/erc20 2022-03-31 21:08:21 +01:00
ec4e77397f AccessControl verification 2022-03-31 21:08:14 +01:00
50cf82823e one more TC cleaning 2022-03-31 21:08:00 +01:00
53b6ed80bb ERC1155 verification (not finished) 2022-03-31 21:07:28 +01:00
a982bee235 TC cleaning 2022-03-31 21:07:01 +01:00
92f07bae1b typechecker error and skipped require bug 2022-03-30 17:12:30 -07:00
4c74b2951d Merge branch 'certora/erc20' of github.com:Certora/openzeppelin-contracts into
remotes/origin/certora/erc20
2022-03-28 12:07:21 -07:00
3f1ee39910 call trace error 2022-03-28 12:05:33 -07:00
4b9500cf25 Merge branch 'certora/erc20' of github.com:Certora/openzeppelin-contracts into certora/erc20 2022-03-27 16:06:49 +01:00
a35ad6dfc3 wrapper and timelockController cleaning 2022-03-27 16:04:31 +01:00
140f019155 Merge branch 'certora/erc20' of github.com:Certora/openzeppelin-contracts into remotes/origin/certora/erc20 2022-03-25 12:57:21 -07:00
6895946f41 updated rules 2022-03-25 12:57:16 -07:00
5153c462d5 wrapper counterexample to check 2022-03-23 19:42:14 +00:00
8318470cca flashMint cleaning 2022-03-23 19:12:16 +00:00
89f9878ba2 Merge branch 'certora/erc20' of github.com:Certora/openzeppelin-contracts into remotes/origin/certora/erc20 2022-03-21 11:13:36 -07:00
6c5d33ba22 run scripts 2022-03-21 11:13:24 -07:00
8d9ab176d7 Timelock hash bug, example for Alex 2022-03-21 17:58:21 +00:00
62d60a5890 Timelock, erc20Wrapper and erc20FlashMint verification 2022-03-20 22:36:48 +00:00
7caa9bbb2c TimelockController wating for hash fix 2022-03-11 00:29:03 +00:00
2be84e627b Merge branch 'certora/erc20' of github.com:Certora/openzeppelin-contracts into remotes/origin/certora/erc20 2022-03-08 18:23:38 -08:00
1900c86c99 removed unnecessary harness from the first iteration 2022-03-08 19:58:23 +00:00
56e4ae9f4a Merge branch 'certora/erc20' of github.com:Certora/openzeppelin-contracts into remotes/origin/certora/erc20 2022-03-08 11:29:12 -08:00
3cb87abec1 removed flags for erc20Votes script 2022-03-08 19:20:55 +00:00
b3845e43d8 Merge branch 'master' of github.com:Certora/openzeppelin-contracts 2022-03-08 11:16:41 -08:00
61fa061ecf erc20votes pointers workaround and preset 2022-03-08 16:38:11 +00:00
ef8013ef79 sanity for TimelockController and Votes 2022-03-03 12:42:16 -08:00
7ab95baab8 Merge branch 'OpenZeppelin:master' into certora/erc20 2022-03-02 12:53:03 -05:00
99864fd2da Merge branch 'OpenZeppelin:master' into certora/erc20 2022-03-01 14:23:25 -05:00
1c3b17826e Merge branch 'OpenZeppelin:master' into master 2022-03-01 14:21:32 -05:00
97b2e1b12a sanity passes 2021-12-17 09:43:47 -05:00
2304dd7bb1 added script for checking token sanity 2021-12-17 09:36:01 -05:00
44cedd5ea2 made scripts executable 2021-12-17 09:30:30 -05:00
7ffbf6a3c8 renamed governor sanity script 2021-12-17 09:30:04 -05:00
b5980a569c reorganized governance verification in preparation for erc20 verification 2021-12-17 09:22:06 -05:00
7912b1af7d filtered out relay, since it is havocing 2021-12-16 14:58:55 -05:00
2a75aa19bd added munging to scripts 2021-12-09 17:17:49 -05:00
d95c3eeee1 removed some spurious comments 2021-12-09 14:47:57 -05:00
22de642692 simplified README somewhat, included additional information about munging 2021-12-09 14:43:40 -05:00
6bd525fd67 Merge branch 'master' into certora/governor
Rerunning verification against current master to ensure clean PR
2021-12-03 15:24:56 -05:00
8c0684ad13 Merge branch 'OpenZeppelin:master' into master 2021-12-03 15:22:52 -05:00
3c150953ed harnessing fix 2021-12-03 14:52:53 -05:00
d64869545d did some harnessing 2021-12-02 16:47:18 -05:00
5888bee853 fixed executeOnly rule 2021-12-02 15:16:26 -05:00
ec5d501791 filtered out timeouts 2021-12-02 15:06:29 -05:00
760edf9b87 tweaked script to run quickly 2021-12-02 14:01:44 -05:00
380b87dc0c switched harnesses to use munged contracts 2021-12-01 10:13:42 -05:00
f3087407c6 created applyHarness 2021-12-01 10:08:06 -05:00
749738f2aa moved contract modifications into munged directory 2021-12-01 10:03:21 -05:00
7d0eeab6f7 HarnessCleaning 2021-12-01 12:02:15 +02:00
dae72a7e1b FixingScriptsToWorkWithNewChanges 2021-12-01 11:59:59 +02:00
96c6120609 NewFileForRulesInProgress 2021-12-01 11:59:30 +02:00
de594921cc fix script 2021-11-30 18:10:20 +02:00
f40c48a83d madeVeryfyAllMoreFlexible 2021-11-27 20:22:25 +02:00
43e37f0184 executedImplyStartAndEndDateNonZero inv fix 2021-11-25 16:25:40 +02:00
1d25a22201 runAllwithoutTypeCheckAndPolishingIt 2021-11-25 13:33:36 +02:00
73080c79d0 cleaning in process 2021-11-25 13:30:09 +02:00
37725a0f2c CleaningAndScriptForAllAndReadme 2021-11-24 19:48:39 +02:00
b3dd1e0386 RulesCleaning 2021-11-24 17:53:01 +02:00
108be781a4 RemovedUnnecessaryHarnesses 2021-11-24 17:52:25 +02:00
0894724496 all rules checked no structure organization 2021-11-23 16:57:14 +02:00
9344f697f9 removed oneUserVotesInCast 2021-11-23 16:33:28 +02:00
4c3ad9c95a GovernorCountingSimple cleaning 2021-11-23 15:27:22 +02:00
38e42f92c2 helperFunctionArgumentEnv 2021-11-23 12:52:51 +02:00
c38babecd9 helper function name change 2021-11-23 12:47:21 +02:00
e01b285780 helper function fix plus reviewing up to noExecuteOrCancelBeforeDeadline including 2021-11-23 11:48:58 +02:00
1b4fb6c758 callPropose and castVoteWithReason removed 2021-11-23 11:48:07 +02:00
95321a3516 done up to noStartBeforeCreation including 2021-11-22 17:35:13 +02:00
ff8e17ec2f removedHarnessesAnsSummariesAddedComments 2021-11-22 12:17:41 +02:00
37fe8c292a FixinigTimeoutsAndTotalVotes 2021-11-22 09:51:11 +02:00
cd703a5ee0 cleaned up to doubleVoting (not included) 2021-11-21 18:03:11 +02:00
167f175f3a harness _execute() 2021-11-21 18:02:26 +02:00
a14abd0276 hashProposal summarization removed 2021-11-20 02:06:01 +02:00
0fbf745efe noVoteForSomeoneElse fix 2021-11-20 01:52:06 +02:00
92f5f0dfbb TryingToFixRules 2021-11-19 20:13:06 +02:00
0cbb98b92c uncommenting hook for oneUserVotesInCast 2021-11-18 16:42:32 +02:00
9f2a672240 moving updateQuorumNumerator to GovernorBase 2021-11-18 15:46:56 +02:00
0ecb5fce78 fix for oneUserVotesInCast 2021-11-18 15:43:21 +02:00
65af47d90d added filters to revert if exec and revert if canceled 2021-11-18 15:39:18 +02:00
f7049de567 envfreeViolationFix 2021-11-18 10:12:13 +02:00
61b011869c AddedLinkAndFixingGhost 2021-11-17 16:00:16 +02:00
a33b9b2bb0 FixedERC20VotesIssue 2021-11-17 13:33:43 +02:00
44113d58f5 NewWizardHarness 2021-11-17 11:56:24 +02:00
eb27bdd282 MoreRulesAndFixesOfExistedRules 2021-11-16 19:53:07 +02:00
daad23b3a7 comment noVoteForSomeoneElse 2021-11-16 18:35:09 +02:00
1da0a4ae7d allFunctionsRevertIfExecuted, allFunctionsRevertIfCanceled, executedOnlyAfterExecuteFunc passing as intended 2021-11-16 18:33:49 +02:00
5833f52879 Harness of castVoteWithReason to be able to impose requirement on the proposal ID 2021-11-16 18:32:38 +02:00
a16eaebb25 ManyNonWorkingRules 2021-11-15 18:22:36 +02:00
d297280617 oneUserVoteInCast, noVotesForSomeoneElse 2021-11-15 18:00:04 +02:00
eee306acda commenting helper function, executed only after exec, func revert if canceled or executed 2021-11-15 17:58:36 +02:00
c0a257fa0c overriding castVoteWithReason 2021-11-15 17:56:30 +02:00
c6365ef868 creating new ghost for 26 b 2021-11-14 15:44:29 +02:00
54fa59f879 proposeInitialized done 2021-11-14 15:33:30 +02:00
2baa9bd801 Merge branch 'certora/governor' of https://github.com/Certora/openzeppelin-contracts into certora/governor 2021-11-12 16:42:55 +02:00
a858ed7a2a codeCleaningNumberIDontKnow 2021-11-12 16:42:22 +02:00
921c668a59 reorganization + violated rules 2021-11-12 16:42:22 +02:00
0598a3ac43 CountingSimpleMoreCleanAndAddedMoreRules 2021-11-12 16:42:22 +02:00
0d724ca892 Cleaned harness + callPropose 2021-11-12 16:42:22 +02:00
b948e70258 aesthetic 2021-11-12 16:42:22 +02:00
5267eaac81 Changed deltaWeight type from uint to uin256 2021-11-12 16:42:22 +02:00
9b4634bebe FixedTypoInEnvfreeWord 2021-11-12 16:42:22 +02:00
f8a54d2ae2 RemovedInsertedBugForSumRule 2021-11-12 16:42:21 +02:00
92744a195a specificSpecForSumRule 2021-11-12 16:42:21 +02:00
bc9bbc2431 FirstWizardHarness 2021-11-12 16:42:21 +02:00
16e101bba9 cannot set if executed and canceled as rules (not working) 2021-11-12 16:42:21 +02:00
861fab8589 ghosts and invariant unfinished 2021-11-12 16:42:21 +02:00
8ed7f965bb added ghost and counter implementation for castWithReason and castBySig 2021-11-12 16:42:21 +02:00
53d4006806 fixed function revert if executed 2021-11-12 16:42:20 +02:00
2761ec0b66 MoreRulesToTheGodOfRules 2021-11-12 16:42:20 +02:00
d5c6520e4d idea for sum of votes 2021-11-12 16:42:20 +02:00
5ea1cc7a8a added invariants if executed or canceled always revert 2021-11-12 16:42:20 +02:00
c50cb000dd fix simple vote end before start 2021-11-12 16:42:20 +02:00
d4b9e9ab80 someCleaning 2021-11-12 16:42:20 +02:00
85b65befd5 WorkInProgress 2021-11-12 16:42:20 +02:00
77efd53f0c checkingInvariantsWithoutGhosts 2021-11-12 16:42:19 +02:00
364da56ab4 quotes on var in msg 2021-11-12 16:42:19 +02:00
9298482163 scripts settings added 2021-11-12 16:42:19 +02:00
91f8919876 hooks fixed 2021-11-12 16:42:19 +02:00
6323c9a73d slight changes in scripts + disableLocalTypeChecking 2021-11-12 16:42:19 +02:00
c08a73a6ca Harness private to public 2021-11-12 16:42:19 +02:00
547e7a8308 Harness private to public 2021-11-12 16:42:19 +02:00
6307b3bb64 slight changes change for convenience + disableLocalTypeChecking flag for the hooks 2021-11-12 16:42:18 +02:00
32ab301c9d Hooks fixed 2021-11-12 16:42:18 +02:00
788d4672d7 slight script changes and ghost fix 2021-11-12 16:42:18 +02:00
1c35a7dad0 multiple inheritance is tricky x2 2021-11-12 16:42:18 +02:00
2d33674870 multiple inheritance is tricky 2021-11-12 16:42:18 +02:00
e810379262 sanity rule preparations 2021-11-12 16:42:18 +02:00
d6036f9291 ignore certora's generated files 2021-11-12 16:42:17 +02:00
ea6baf2220 rule drafts 2021-11-12 16:42:17 +02:00
a0cb8cd446 fixes 2021-11-12 16:42:17 +02:00
8494fe20bc fixes 2021-11-12 16:42:17 +02:00
4a0077d685 Back to expected pattern? 2021-11-12 16:42:17 +02:00
9a194f24b8 start work on governor 2021-11-12 16:42:17 +02:00
4337957a6b codeCleaningNumberIDontKnow 2021-11-12 14:12:03 +02:00
2ecba5326b reorganization + violated rules 2021-11-12 09:02:51 +02:00
2a0532dacc CountingSimpleMoreCleanAndAddedMoreRules 2021-11-11 17:28:22 +02:00
f2c352366a Merge pull request #1 from OpenZeppelin/master
Synced Forked Repo
2021-11-11 11:27:32 +02:00
b52832ca7f Cleaned harness + callPropose 2021-11-10 15:26:29 +02:00
eb87bb4822 aesthetic 2021-11-10 15:10:37 +02:00
52924aaec0 Changed deltaWeight type from uint to uin256 2021-11-10 15:07:34 +02:00
85855b8cc7 FixedTypoInEnvfreeWord 2021-11-09 21:09:54 +02:00
6ac85d8d15 RemovedInsertedBugForSumRule 2021-11-09 15:16:44 +02:00
96df9799c3 specificSpecForSumRule 2021-11-09 15:10:07 +02:00
07d637980c FirstWizardHarness 2021-11-09 11:18:23 +02:00
44a8fed410 cannot set if executed and canceled as rules (not working) 2021-11-08 20:16:53 +02:00
34cb4bdc9c ghosts and invariant unfinished 2021-11-08 19:00:22 +02:00
c819e0b063 added ghost and counter implementation for castWithReason and castBySig 2021-11-08 17:57:53 +02:00
37a4975544 fixed function revert if executed 2021-11-08 17:51:28 +02:00
751277a1ab MoreRulesToTheGodOfRules 2021-11-08 17:18:36 +02:00
ad7993d7d5 idea for sum of votes 2021-11-08 15:57:53 +02:00
7a5bd86ef4 added invariants if executed or canceled always revert 2021-11-08 15:57:19 +02:00
ac729e0ecf fix simple vote end before start 2021-11-08 14:57:51 +02:00
0ebc0d5844 someCleaning 2021-11-08 11:44:04 +02:00
b133fee376 WorkInProgress 2021-11-07 17:55:03 +02:00
f08ee568b9 checkingInvariantsWithoutGhosts 2021-11-04 17:54:26 +02:00
bfa1dd3756 quotes on var in msg 2021-11-04 15:03:28 +02:00
f7cc2548f3 scripts settings added 2021-11-04 12:54:23 +02:00
a2960e22b9 hooks fixed 2021-11-04 12:35:37 +02:00
21b84349d4 slight changes in scripts + disableLocalTypeChecking 2021-11-04 12:35:11 +02:00
d6e79f4366 Harness private to public 2021-11-04 12:29:04 +02:00
c00d951e06 Harness private to public 2021-11-04 11:51:14 +02:00
6876df00ae slight changes change for convenience + disableLocalTypeChecking flag for the hooks 2021-11-04 11:50:40 +02:00
e888ea4ccb Hooks fixed 2021-11-04 11:48:55 +02:00
69f87ad916 slight script changes and ghost fix 2021-11-04 11:27:44 +02:00
a710435535 multiple inheritance is tricky x2 2021-11-03 17:24:35 +02:00
72d4e9c29c multiple inheritance is tricky 2021-11-03 17:09:27 +02:00
cac49bfc2e sanity rule preparations 2021-11-03 17:05:06 +02:00
6776cc6ee4 ignore certora's generated files 2021-11-02 14:01:48 +02:00
22030f2fd3 rule drafts 2021-10-07 11:58:47 +03:00
4c1d5e01c6 fixes 2021-09-26 01:43:16 +03:00
fdc4b0cf23 fixes 2021-09-26 01:39:27 +03:00
f239fa56dd Back to expected pattern? 2021-09-26 00:25:59 +03:00
2c08f85744 start work on governor 2021-09-26 00:21:08 +03:00
865 changed files with 52849 additions and 63484 deletions

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---
`Initializable`: optimize `_disableInitializers` by using `!=` instead of `<`. ([#3787](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3787))

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`ReentrancyGuard`: Add a `_reentrancyGuardEntered` function to expose the guard status. ([#3714](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3714))

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---
`Ownable2Step`: make `acceptOwnership` public virtual to enable usecases that require overriding it. ([#3960](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3960))

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`ERC721Wrapper`: add a new extension of the `ERC721` token which wraps an underlying token. Deposit and withdraw guarantee that the ownership of each token is backed by a corresponding underlying token with the same identifier.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`Strings`: Add `parseUint`, `parseInt`, `parseHexUint` and `parseAddress` to parse strings into numbers and addresses. Also provide variants of these functions that parse substrings, and `tryXxx` variants that do not revert on invalid input.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`EnumerableMap`: add a `keys()` function that returns an array containing all the keys. ([#3920](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3920))

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---
`UUPSUpgradeable.sol`: Change visibility to the functions `upgradeTo ` and `upgradeToAndCall ` from `external` to `public`.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---
`TimelockController`: Add the `CallSalt` event to emit on operation schedule.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`Governor`: add a public `cancel(uint256)` function.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`Governor`: Enable timestamp operation for blockchains without a stable block time. This is achieved by connecting a Governor's internal clock to match a voting token's EIP-6372 interface.

View File

@ -1,5 +0,0 @@
---
"openzeppelin-solidity": minor
---
`Clones`: Add `cloneWithImmutableArgs` and `cloneDeterministicWithImmutableArgs` variants that create clones with per-instance immutable arguments. The immutable arguments can be retrieved using `fetchCloneArgs`. The corresponding `predictDeterministicWithImmutableArgs` function is also included.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---
Reformatted codebase with latest version of Prettier Solidity. ([#3898](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3898))

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`Strings`: add `equal` method. ([#3774](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3774))

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': patch
---
`VotesExtended`: Create an extension of `Votes` which checkpoints balances and delegates.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`IERC5313`: Add an interface for EIP-5313 that is now final.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`CAIP2` and `CAIP10`: Add libraries for formatting and parsing CAIP-2 and CAIP-10 identifiers.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---
`Math`: optimize `log256` rounding check. ([#3745](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3745))

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`Packing`: Add variants for packing `bytes10` and `bytes22`

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---
`ERC20Votes`: optimize by using unchecked arithmetic. ([#3748](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3748))

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---
`Multicall`: annotate `multicall` function as upgrade safe to not raise a flag for its delegatecall. ([#3961](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3961))

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`NoncesKeyed`: Add a variant of `Nonces` that implements the ERC-4337 entrypoint nonce system.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`IERC4906`: Add an interface for ERC-4906 that is now Final.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`TransparentUpgradeableProxy`: support value passthrough for all ifAdmin function.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`StorageSlot`: Add support for `string` and `bytes`.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---
`ERC20Pausable`, `ERC721Pausable`, `ERC1155Pausable`: Add note regarding missing public pausing functionality

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`Votes`, `ERC20Votes`, `ERC721Votes`: support timestamp checkpointing using EIP-6372.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`ERC4626`: Add mitigation to the inflation attack through virtual shares and assets.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': patch
---
`GovernorCountingOverridable`: Add a governor counting module that enables token holders to override the vote of their delegate.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`Strings`: add `toString` method for signed integers. ([#3773](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3773))

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`ERC20Wrapper`: Make the `underlying` variable private and add a public accessor.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`Bytes`: Add a library of common operations that operate on `bytes` objects.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': patch
---
Update some pragma directives to ensure that all file requirements match that of the files they import.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`EIP712`: add EIP-5267 support for better domain discovery.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`AccessControlDefaultAdminRules`: Add an extension of `AccessControl` with additional security rules for the `DEFAULT_ADMIN_ROLE`.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`SignatureChecker`: Add `isValidERC1271SignatureNow` for checking a signature directly against a smart contract using ERC-1271.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---
`ECDSA`: Add a function `toDataWithIntendedValidatorHash` that encodes data with version 0x00 following EIP-191.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`ERC7579Utils`: Add a reusable library to interact with ERC-7579 modular accounts

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`SafeERC20`: Add a `forceApprove` function to improve compatibility with tokens behaving like USDT.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`ERC1967Upgrade`: removed contract-wide `oz-upgrades-unsafe-allow delegatecall` annotation, replaced by granular annotation in `UUPSUpgradeable`.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---
`MerkleProof`: optimize by using unchecked arithmetic. ([#3745](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3745))

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`ECDSA`: optimize bytes32 computation by using assembly instead of `abi.encodePacked`.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`ERC721URIStorage`: Emit ERC-4906 `MetadataUpdate` in `_setTokenURI`.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`ERC1363Utils`: Add helper similar to the existing `ERC721Utils` and `ERC1155Utils`

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`ShortStrings`: Added a library for handling short strings in a gas efficient way, with fallback to storage for longer strings.

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`SignatureChecker`: Allow return data length greater than 32 from EIP-1271 signers.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`ERC4337Utils`: Add a reusable library to manipulate user operations and interact with ERC-4337 contracts

View File

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`UUPSUpgradeable`: added granular `oz-upgrades-unsafe-allow-reachable` annotation to improve upgrade safety checks on latest version of the Upgrades Plugins (starting with `@openzeppelin/upgrades-core@1.21.0`).

View File

@ -10,7 +10,3 @@ coverage:
project:
default:
threshold: 1%
ignore:
- "test"
- "contracts/mocks"
- "contracts/vendor"

20
.eslintrc Normal file
View File

@ -0,0 +1,20 @@
{
"root": true,
"extends" : [
"eslint:recommended",
"prettier",
],
"env": {
"es2022": true,
"browser": true,
"node": true,
"mocha": true,
},
"globals" : {
"artifacts": "readonly",
"contract": "readonly",
"web3": "readonly",
"extendEnvironment": "readonly",
"expect": "readonly",
}
}

View File

@ -1,8 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
if [ "${CI:-"false"}" != "true" ]; then
npm run test:generation
npm run lint
fi

View File

@ -10,7 +10,7 @@ about: Report a bug in OpenZeppelin Contracts
**💻 Environment**
<!-- Tell us what version of OpenZeppelin Contracts you're using, and how you're using it: Hardhat, Remix, etc. -->
<!-- Tell us what version of OpenZeppelin Contracts you're using, and how you're using it: Truffle, Remix, etc. -->
**📝 Details**

View File

@ -1,5 +1,4 @@
name: Compare gas costs
description: Compare gas costs between branches
inputs:
token:
description: github token

View File

@ -1,13 +1,12 @@
name: Setup
description: Common environment setup
runs:
using: composite
steps:
- uses: actions/setup-node@v4
- uses: actions/setup-node@v3
with:
node-version: 20.x
- uses: actions/cache@v4
node-version: 14.x
- uses: actions/cache@v3
id: cache
with:
path: '**/node_modules'
@ -16,7 +15,5 @@ runs:
run: npm ci
shell: bash
if: steps.cache.outputs.cache-hit != 'true'
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
env:
SKIP_COMPILE: true

View File

@ -1,5 +1,4 @@
name: Compare storage layouts
description: Compare storage layouts between branches
inputs:
token:
description: github token

View File

@ -9,7 +9,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Add problem matchers
run: |
# https://github.com/rhysd/actionlint/blob/3a2f2c7/docs/usage.md#problem-matchers

View File

@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'ignore-changeset') }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Include history so Changesets finds merge-base
- name: Set up environment

View File

@ -4,7 +4,6 @@ on:
push:
branches:
- master
- next-v*
- release-v*
pull_request: {}
workflow_dispatch: {}
@ -13,14 +12,12 @@ concurrency:
group: checks-${{ github.ref }}
cancel-in-progress: true
env:
NODE_OPTIONS: --max_old_space_size=8192
jobs:
lint:
if: github.repository != 'OpenZeppelin/openzeppelin-contracts-upgradeable'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- run: npm run lint
@ -29,108 +26,71 @@ jobs:
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
# Needed for "eth-gas-reporter" to produce a "gasReporterOutput.json" as documented in
# https://github.com/cgewecke/eth-gas-reporter/blob/v0.2.27/docs/gasReporterOutput.md
CI: true
NODE_OPTIONS: --max_old_space_size=4096
GAS: true
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- name: Run tests and generate gas report
run: npm run test
- name: Check linearisation of the inheritance graph
run: npm run test:inheritance
- name: Check pragma consistency between files
run: npm run test:pragma
- name: Check proceduraly generated contracts are up-to-date
if: github.repository != 'OpenZeppelin/openzeppelin-contracts-upgradeable'
run: npm run test:generation
- name: Compare gas costs
uses: ./.github/actions/gas-compare
with:
token: ${{ github.token }}
tests-upgradeable:
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Include history so patch conflicts are resolved automatically
- name: Set up environment
uses: ./.github/actions/setup
- name: Copy non-upgradeable contracts as dependency
run: |
mkdir -p lib/openzeppelin-contracts
cp -rnT contracts lib/openzeppelin-contracts/contracts
- name: Transpile to upgradeable
run: bash scripts/upgradeable/transpile.sh
- name: Run tests
run: npm run test
- name: Check linearisation of the inheritance graph
run: npm run test:inheritance
- name: Check pragma consistency between files
run: npm run test:pragma
- name: Check storage layout
uses: ./.github/actions/storage-layout
continue-on-error: ${{ contains(github.event.pull_request.labels.*.name, 'breaking change') }}
with:
token: ${{ github.token }}
tests-foundry:
foundry-tests:
if: github.repository != 'OpenZeppelin/openzeppelin-contracts-upgradeable'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up environment
uses: ./.github/actions/setup
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run tests
run: forge test -vv
coverage:
if: github.repository != 'OpenZeppelin/openzeppelin-contracts-upgradeable'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- name: Run coverage
run: npm run coverage
- uses: codecov/codecov-action@v4
- run: npm run coverage
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
harnesses:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up environment
uses: ./.github/actions/setup
- name: Compile harnesses
run: |
make -C certora apply
npm run compile:harnesses
NODE_OPTIONS: --max_old_space_size=4096
- uses: codecov/codecov-action@v3
slither:
if: github.repository != 'OpenZeppelin/openzeppelin-contracts-upgradeable'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- run: rm foundry.toml
- uses: crytic/slither-action@v0.4.0
with:
node-version: 18.15
slither-version: 0.10.1
- uses: crytic/slither-action@v0.3.0
codespell:
if: github.repository != 'OpenZeppelin/openzeppelin-contracts-upgradeable'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Run CodeSpell
uses: codespell-project/actions-codespell@v2.1
uses: codespell-project/actions-codespell@v1.0
with:
check_hidden: true
check_filenames: true
skip: package-lock.json,*.pdf,vendor
skip: package-lock.json,*.pdf

View File

@ -11,7 +11,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- run: bash scripts/git-user-config.sh

View File

@ -0,0 +1,55 @@
name: Formal verification
on:
push:
branches:
- master
- release-v*
- formal-verification
pull_request: {}
workflow_dispatch: {}
jobs:
list-scripts:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- id: set-matrix
run: echo ::set-output name=matrix::$(ls certora/scripts/{,**}/*.sh | grep -v '\WnoCI\W' | jq -Rsc 'split("\n")[:-1]')
verify:
runs-on: ubuntu-latest
needs: list-scripts
steps:
- uses: actions/checkout@v2
- name: Install python
uses: actions/setup-python@v2
with:
python-version: '3.10'
cache: 'pip'
- name: Install java
uses: actions/setup-java@v1
with:
java-version: '11'
java-package: 'jre'
- name: Install certora
run: pip install certora-cli
- name: Install solc
run: |
wget https://github.com/ethereum/solidity/releases/download/v0.8.19/solc-static-linux
sudo mv solc-static-linux /usr/local/bin/solc
chmod +x /usr/local/bin/solc
- name: Verify rule ${{ matrix.params }}
run: |
touch certora/applyHarness.patch
make -C certora munged
bash ${{ matrix.params }}
env:
CERTORAKEY: ${{ secrets.CERTORAKEY }}
strategy:
fail-fast: false
max-parallel: 4
matrix:
params: ${{ fromJson(needs.list-scripts.outputs.matrix) }}

View File

@ -1,86 +0,0 @@
name: formal verification
on:
pull_request:
types:
- opened
- reopened
- synchronize
- labeled
workflow_dispatch: {}
env:
PIP_VERSION: '3.11'
JAVA_VERSION: '11'
SOLC_VERSION: '0.8.20'
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
apply-diff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Apply patches
run: make -C certora apply
verify:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'formal-verification')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up environment
uses: ./.github/actions/setup
- name: identify specs that need to be run
id: arguments
run: |
if [[ ${{ github.event_name }} = 'pull_request' ]];
then
RESULT=$(git diff ${{ github.event.pull_request.head.sha }}..${{ github.event.pull_request.base.sha }} --name-only certora/specs/*.spec | while IFS= read -r file; do [[ -f $file ]] && basename "${file%.spec}"; done | tr "\n" " ")
else
RESULT='--all'
fi
echo "result=$RESULT" >> "$GITHUB_OUTPUT"
- name: Install python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PIP_VERSION }}
cache: 'pip'
cache-dependency-path: 'fv-requirements.txt'
- name: Install python packages
run: pip install -r fv-requirements.txt
- name: Install java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
- name: Install solc
run: |
wget https://github.com/ethereum/solidity/releases/download/v${{ env.SOLC_VERSION }}/solc-static-linux
sudo mv solc-static-linux /usr/local/bin/solc
chmod +x /usr/local/bin/solc
- name: Verify specification
run: |
make -C certora apply
node certora/run.js ${{ steps.arguments.outputs.result }} >> "$GITHUB_STEP_SUMMARY"
env:
CERTORAKEY: ${{ secrets.CERTORAKEY }}
halmos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up environment
uses: ./.github/actions/setup
- name: Install python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PIP_VERSION }}
cache: 'pip'
cache-dependency-path: 'fv-requirements.txt'
- name: Install python packages
run: pip install -r fv-requirements.txt
- name: Run Halmos
run: halmos --match-test '^symbolic|^testSymbolic' -vv

View File

@ -27,12 +27,12 @@ jobs:
pull-requests: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- id: state
name: Get state
uses: actions/github-script@v7
uses: actions/github-script@v6
env:
TRIGGERING_ACTOR: ${{ github.triggering_actor }}
with:
@ -58,7 +58,7 @@ jobs:
if: needs.state.outputs.start == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- run: bash scripts/git-user-config.sh
@ -66,7 +66,7 @@ jobs:
name: Create branch with release candidate
run: bash scripts/release/workflow/start.sh
- name: Re-run workflow
uses: actions/github-script@v7
uses: actions/github-script@v6
env:
REF: ${{ steps.start.outputs.branch }}
with:
@ -81,7 +81,7 @@ jobs:
if: needs.state.outputs.promote == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- run: bash scripts/git-user-config.sh
@ -89,7 +89,7 @@ jobs:
if: needs.state.outputs.is_prerelease == 'true'
run: bash scripts/release/workflow/exit-prerelease.sh
- name: Re-run workflow
uses: actions/github-script@v7
uses: actions/github-script@v6
with:
script: await require('./scripts/release/workflow/rerun.js')({ github, context })
@ -102,13 +102,13 @@ jobs:
if: needs.state.outputs.changesets == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
with:
fetch-depth: 0 # To get all tags
- name: Set up environment
uses: ./.github/actions/setup
- name: Set release title
uses: actions/github-script@v7
uses: actions/github-script@v6
with:
result-encoding: string
script: await require('./scripts/release/workflow/set-changesets-pr-title.js')({ core })
@ -134,7 +134,7 @@ jobs:
if: needs.state.outputs.publish == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- id: pack
@ -143,18 +143,22 @@ jobs:
env:
PRERELEASE: ${{ needs.state.outputs.is_prerelease }}
- name: Upload tarball artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: ${{ github.ref_name }}
path: ${{ steps.pack.outputs.tarball }}
- name: Tag
run: npx changeset tag
- name: Publish
run: bash scripts/release/workflow/publish.sh
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
TARBALL: ${{ steps.pack.outputs.tarball }}
TAG: ${{ steps.pack.outputs.tag }}
- name: Push tags
run: git push --tags
- name: Create Github Release
uses: actions/github-script@v7
uses: actions/github-script@v6
env:
PRERELEASE: ${{ needs.state.outputs.is_prerelease }}
with:
@ -167,10 +171,12 @@ jobs:
name: Tarball Integrity Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Download tarball artifact
id: artifact
uses: actions/download-artifact@v4
# Replace with actions/upload-artifact@v3 when
# https://github.com/actions/download-artifact/pull/194 gets released
uses: actions/download-artifact@e9ef242655d12993efdcda9058dee2db83a2cb9b
with:
name: ${{ github.ref_name }}
- name: Check integrity
@ -186,27 +192,23 @@ jobs:
pull-requests: write
if: needs.state.outputs.merge == 'true'
runs-on: ubuntu-latest
env:
MERGE_BRANCH: merge/${{ github.ref_name }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
with:
fetch-depth: 0 # All branches
- name: Set up environment
uses: ./.github/actions/setup
- run: bash scripts/git-user-config.sh
- name: Create branch to merge
run: |
git checkout -B "$MERGE_BRANCH" "$GITHUB_REF_NAME"
git push -f origin "$MERGE_BRANCH"
run: bash scripts/release/workflow/prepare-release-merge.sh
- name: Create PR back to master
uses: actions/github-script@v7
uses: actions/github-script@v6
with:
script: |
await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
head: process.env.MERGE_BRANCH,
head: 'merge/${{ github.ref_name }}',
base: 'master',
title: '${{ format('Merge {0} branch', github.ref_name) }}'
});

View File

@ -1,4 +1,4 @@
name: transpile upgradeable
name: Upgradeable Trigger
on:
push:
@ -7,28 +7,17 @@ on:
- release-v*
jobs:
transpile:
environment: push-upgradeable
trigger:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: app
uses: getsentry/action-github-app-token@v2
with:
repository: OpenZeppelin/openzeppelin-contracts-upgradeable
fetch-depth: 0
token: ${{ secrets.GH_TOKEN_UPGRADEABLE }}
- name: Fetch current non-upgradeable branch
run: |
git fetch "$REMOTE" master # Fetch default branch first for patch to apply cleanly
git fetch "$REMOTE" "$REF"
git checkout FETCH_HEAD
env:
REF: ${{ github.ref }}
REMOTE: https://github.com/${{ github.repository }}.git
- name: Set up environment
uses: ./.github/actions/setup
- run: bash scripts/git-user-config.sh
- name: Transpile to upgradeable
run: bash scripts/upgradeable/transpile-onto.sh ${{ github.ref_name }} origin/${{ github.ref_name }}
env:
SUBMODULE_REMOTE: https://github.com/${{ github.repository }}.git
- run: git push origin ${{ github.ref_name }}
app_id: ${{ secrets.UPGRADEABLE_APP_ID }}
private_key: ${{ secrets.UPGRADEABLE_APP_PK }}
- run: |
curl -X POST \
https://api.github.com/repos/OpenZeppelin/openzeppelin-contracts-upgradeable/dispatches \
-H 'Accept: application/vnd.github.v3+json' \
-H 'Authorization: token ${{ steps.app.outputs.token }}' \
-d '{ "event_type": "Update", "client_payload": { "ref": "${{ github.ref }}" } }'

9
.gitignore vendored
View File

@ -29,9 +29,15 @@ npm-debug.log
# local env variables
.env
# truffle build directory
build/
# macOS
.DS_Store
# truffle
.node-xmlhttprequest-*
# IntelliJ IDE
.idea
@ -57,10 +63,9 @@ contracts-exposed
# Foundry
/out
/cache_forge
# Certora
.certora*
.last_confs
certora_*
.zip-output-url.txt
resource_errors.json

4
.gitmodules vendored
View File

@ -1,10 +1,6 @@
[submodule "lib/forge-std"]
branch = v1
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/erc4626-tests"]
path = lib/erc4626-tests
url = https://github.com/a16z/erc4626-tests.git
[submodule "lib/halmos-cheatcodes"]
path = lib/halmos-cheatcodes
url = https://github.com/a16z/halmos-cheatcodes

View File

@ -10,6 +10,5 @@
"singleQuote": false
}
}
],
"plugins": ["prettier-plugin-solidity"]
]
}

View File

@ -10,12 +10,4 @@ module.exports = {
fgrep: '[skip-on-coverage]',
invert: true,
},
// Work around stack too deep for coverage
configureYulOptimizer: true,
solcOptimizerDetails: {
yul: true,
yulDetails: {
optimizerSteps: '',
},
},
};

14
.solhint.json Normal file
View File

@ -0,0 +1,14 @@
{
"rules": {
"no-unused-vars": "error",
"const-name-snakecase": "error",
"contract-name-camelcase": "error",
"event-name-camelcase": "error",
"func-name-mixedcase": "error",
"func-param-name-mixedcase": "error",
"modifier-name-mixedcase": "error",
"private-vars-leading-underscore": "error",
"var-name-mixedcase": "error",
"imports-on-top": "error"
}
}

View File

@ -1,443 +1,5 @@
# Changelog
## 5.1.0 (2024-10-17)
### Breaking changes
- `ERC1967Utils`: Removed duplicate declaration of the `Upgraded`, `AdminChanged` and `BeaconUpgraded` events. These events are still available through the `IERC1967` interface located under the `contracts/interfaces/` directory. Minimum pragma version is now 0.8.21.
- `Governor`, `GovernorCountingSimple`: The `_countVote` virtual function now returns an `uint256` with the total votes casted. This change allows for more flexibility for partial and fractional voting. Upgrading users may get a compilation error that can be fixed by adding a return statement to the `_countVote` function.
#### Custom error changes
This version comes with changes to the custom error identifiers. Contracts previously depending on the following errors should be replaced accordingly:
- Replace `Address.FailedInnerCall` with `Errors.FailedCall`
- Replace `Address.AddressInsufficientBalance` with `Errors.InsufficientBalance`
- Replace `Clones.Create2InsufficientBalance` with `Errors.InsufficientBalance`
- Replace `Clones.ERC1167FailedCreateClone` with `Errors.FailedDeployment`
- Replace `Clones.Create2FailedDeployment` with `Errors.FailedDeployment`
- `SafeERC20`: Replace `Address.AddressEmptyCode` with `SafeERC20FailedOperation` if there is no code at the token's address.
- `SafeERC20`: Replace generic `Error(string)` with `SafeERC20FailedOperation` if the returned data can't be decoded as `bool`.
- `SafeERC20`: Replace generic `SafeERC20FailedOperation` with the revert message from the contract call if it fails.
### Changes by category
#### General
- `AccessManager`, `VestingWallet`, `TimelockController` and `ERC2771Forwarder`: Added a public `initializer` function in their corresponding upgradeable variants. ([#5008](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5008))
#### Access
- `AccessControlEnumerable`: Add a `getRoleMembers` method to return all accounts that have `role`. ([#4546](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4546))
- `AccessManager`: Allow the `onlyAuthorized` modifier to restrict functions added to the manager. ([#5014](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5014))
#### Finance
- `VestingWalletCliff`: Add an extension of the `VestingWallet` contract with an added cliff. ([#4870](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4870))
#### Governance
- `GovernorCountingFractional`: Add a governor counting module that allows distributing voting power amongst 3 options (For, Against, Abstain). ([#5045](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5045))
- `Votes`: Set `_moveDelegateVotes` visibility to internal instead of private. ([#5007](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5007))
#### Proxy
- `Clones`: Add version of `clone` and `cloneDeterministic` that support sending value at creation. ([#4936](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4936))
- `TransparentUpgradeableProxy`: Make internal `_proxyAdmin()` getter have `view` visibility. ([#4688](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4688))
- `ProxyAdmin`: Fixed documentation for `UPGRADE_INTERFACE_VERSION` getter. ([#5031](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5031))
#### Tokens
- `ERC1363`: Add implementation of the token payable standard allowing execution of contract code after transfers and approvals. ([#4631](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4631))
- `ERC20TemporaryApproval`: Add an ERC-20 extension that implements temporary approval using transient storage, based on ERC7674 (draft). ([#5071](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5071))
- `SafeERC20`: Add "relaxed" function for interacting with ERC-1363 functions in a way that is compatible with EOAs. ([#4631](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4631))
- `SafeERC20`: Document risks of `safeIncreaseAllowance` and `safeDecreaseAllowance` when associated with ERC-7674. ([#5262](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5262))
- `ERC721Utils` and `ERC1155Utils`: Add reusable libraries with functions to perform acceptance checks on `IERC721Receiver` and `IERC1155Receiver` implementers. ([#4845](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4845))
- `ERC1363Utils`: Add helper similar to the existing ERC721Utils and ERC1155Utils. ([#5133](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5133))
#### Utils
- `Arrays`: add a `sort` functions for `address[]`, `bytes32[]` and `uint256[]` memory arrays. ([#4846](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4846))
- `Arrays`: add new functions `lowerBound`, `upperBound`, `lowerBoundMemory` and `upperBoundMemory` for lookups in sorted arrays with potential duplicates. ([#4842](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4842))
- `Arrays`: deprecate `findUpperBound` in favor of the new `lowerBound`. ([#4842](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4842))
- `Base64`: Add `encodeURL` following section 5 of RFC4648 for URL encoding ([#4822](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4822))
- `Comparator`: A library of comparator functions, useful for customizing the behavior of the Heap structure. ([#5084](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5084))
- `Create2`: Bubbles up returndata from a deployed contract that reverted during construction. ([#5052](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5052))
- `Create2`, `Clones`: Mask `computeAddress` and `cloneDeterministic` outputs to produce a clean value for an `address` type (i.e. only use 20 bytes) ([#4941](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4941))
- `Errors`: New library of common custom errors. ([#4936](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4936))
- `Hashes`: A library with commonly used hash functions. ([#3617](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3617))
- `Packing`: Added a new utility for packing, extracting and replacing bytesXX values. ([#4992](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4992))
- `Panic`: Add a library for reverting with panic codes. ([#3298](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3298))
- `ReentrancyGuardTransient`: Added a variant of `ReentrancyGuard` that uses transient storage. ([#4988](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4988))
- `Strings`: Added a utility function for converting an address to checksummed string. ([#5067](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5067))
- `SlotDerivation`: Add a library of methods for derivating common storage slots. ([#4975](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4975))
- `TransientSlot`: Add primitives for operating on the transient storage space using a typed-slot representation. ([#4980](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4980))
##### Cryptography
- `SignatureChecker`: refactor `isValidSignatureNow` to avoid validating ECDSA signatures if there is code deployed at the signer's address. ([#4951](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4951))
- `MerkleProof`: Add variations of `verify`, `processProof`, `multiProofVerify` and `processMultiProof` (and equivalent calldata version) with support for custom hashing functions. ([#4887](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4887))
- `P256`: Library for verification and public key recovery of P256 (aka secp256r1) signatures. ([#4881](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4881))
- `RSA`: Library to verify signatures according to RFC 8017 Signature Verification Operation ([#4952](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4952))
#### Math
- `Math`: add an `invMod` function to get the modular multiplicative inverse of a number in Z/nZ. ([#4839](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4839))
- `Math`: Add `modExp` function that exposes the `EIP-198` precompile. Includes `uint256` and `bytes memory` versions. ([#3298](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3298))
- `Math`: Custom errors replaced with native panic codes. ([#3298](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3298))
- `Math`, `SignedMath`: Add a branchless `ternary` function that computes`cond ? a : b` in constant gas cost. ([#4976](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4976))
- `SafeCast`: Add `toUint(bool)` for operating on `bool` values as `uint256`. ([#4878](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4878))
#### Structures
- `CircularBuffer`: Add a data structure that stores the last `N` values pushed to it. ([#4913](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4913))
- `DoubleEndedQueue`: Custom errors replaced with native panic codes. ([#4872](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4872))
- `EnumerableMap`: add `UintToBytes32Map`, `AddressToAddressMap`, `AddressToBytes32Map` and `Bytes32ToAddressMap`. ([#4843](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4843))
- `Heap`: A data structure that implements a heap-based priority queue. ([#5084](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5084))
- `MerkleTree`: A data structure that allows inserting elements into a merkle tree and updating its root hash. ([#3617](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3617))
## 5.0.2 (2024-02-29)
- `Base64`: Fix issue where dirty memory located just after the input buffer is affecting the result. ([#4926](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4926))
## 5.0.1 (2023-12-07)
- `ERC2771Context` and `Context`: Introduce a `_contextPrefixLength()` getter, used to trim extra information appended to `msg.data`.
- `Multicall`: Make aware of non-canonical context (i.e. `msg.sender` is not `_msgSender()`), allowing compatibility with `ERC2771Context`.
## 5.0.0 (2023-10-05)
### Additions Summary
The following contracts and libraries were added:
- `AccessManager`: A consolidated system for managing access control in complex systems.
- `AccessManaged`: A module for connecting a contract to an authority in charge of its access control.
- `GovernorTimelockAccess`: An adapter for time-locking governance proposals using an `AccessManager`.
- `AuthorityUtils`: A library of utilities for interacting with authority contracts.
- `GovernorStorage`: A Governor module that stores proposal details in storage.
- `ERC2771Forwarder`: An ERC2771 forwarder for meta transactions.
- `ERC1967Utils`: A library with ERC1967 events, errors and getters.
- `Nonces`: An abstraction for managing account nonces.
- `MessageHashUtils`: A library for producing digests for ECDSA operations.
- `Time`: A library with helpers for manipulating time-related objects.
### Removals Summary
The following contracts, libraries, and functions were removed:
- `Address.isContract` (because of its ambiguous nature and potential for misuse)
- `Checkpoints.History`
- `Counters`
- `ERC20Snapshot`
- `ERC20VotesComp`
- `ERC165Storage` (in favor of inheritance based approach)
- `ERC777`
- `ERC1820Implementer`
- `GovernorVotesComp`
- `GovernorProposalThreshold` (deprecated since 4.4)
- `PaymentSplitter`
- `PullPayment`
- `SafeMath`
- `SignedSafeMath`
- `Timers`
- `TokenTimelock` (in favor of `VestingWallet`)
- All escrow contracts (`Escrow`, `ConditionalEscrow` and `RefundEscrow`)
- All cross-chain contracts, including `AccessControlCrossChain` and all the vendored bridge interfaces
- All presets in favor of [OpenZeppelin Contracts Wizard](https://wizard.openzeppelin.com/)
These removals were implemented in the following PRs: [#3637](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3637), [#3880](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3880), [#3945](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3945), [#4258](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4258), [#4276](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4276), [#4289](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4289)
### Changes by category
#### General
- Replaced revert strings and require statements with custom errors. ([#4261](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4261))
- Bumped minimum compiler version required to 0.8.20 ([#4288](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4288), [#4489](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4489))
- Use of `abi.encodeCall` in place of `abi.encodeWithSelector` and `abi.encodeWithSignature` for improved type-checking of parameters ([#4293](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4293))
- Replaced some uses of `abi.encodePacked` with clearer alternatives (e.g. `bytes.concat`, `string.concat`). ([#4504](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4504)) ([#4296](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4296))
- Overrides are now used internally for a number of functions that were previously hardcoded to their default implementation in certain locations: `ERC1155Supply.totalSupply`, `ERC721.ownerOf`, `ERC721.balanceOf` and `ERC721.totalSupply` in `ERC721Enumerable`, `ERC20.totalSupply` in `ERC20FlashMint`, and `ERC1967._getImplementation` in `ERC1967Proxy`. ([#4299](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4299))
- Removed the `override` specifier from functions that only override a single interface function. ([#4315](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4315))
- Switched to using explicit Solidity import statements. Some previously available symbols may now have to be separately imported. ([#4399](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4399))
- `Governor`, `Initializable`, and `UUPSUpgradeable`: Use internal functions in modifiers to optimize bytecode size. ([#4472](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4472))
- Upgradeable contracts now use namespaced storage (EIP-7201). ([#4534](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4534))
- Upgradeable contracts no longer transpile interfaces and libraries. ([#4628](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4628))
#### Access
- `Ownable`: Added an `initialOwner` parameter to the constructor, making the ownership initialization explicit. ([#4267](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4267))
- `Ownable`: Prevent using address(0) as the initial owner. ([#4531](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4531))
- `AccessControl`: Added a boolean return value to the internal `_grantRole` and `_revokeRole` functions indicating whether the role was granted or revoked. ([#4241](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4241))
- `access`: Moved `AccessControl` extensions to a dedicated directory. ([#4359](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4359))
- `AccessManager`: Added a new contract for managing access control of complex systems in a consolidated location. ([#4121](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4121))
- `AccessManager`, `AccessManaged`, `GovernorTimelockAccess`: Ensure that calldata shorter than 4 bytes is not padded to 4 bytes. ([#4624](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4624))
- `AccessManager`: Use named return parameters in functions that return multiple values. ([#4624](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4624))
- `AccessManager`: Make `schedule` and `execute` more conservative when delay is 0. ([#4644](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4644))
#### Finance
- `VestingWallet`: Fixed revert during 1 second time window when duration is 0. ([#4502](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4502))
- `VestingWallet`: Use `Ownable` instead of an immutable `beneficiary`. ([#4508](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4508))
#### Governance
- `Governor`: Optimized use of storage for proposal data ([#4268](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4268))
- `Governor`: Added validation in ERC1155 and ERC721 receiver hooks to ensure Governor is the executor. ([#4314](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4314))
- `Governor`: Refactored internals to implement common queuing logic in the core module of the Governor. Added `queue` and `_queueOperations` functions that act at different levels. Modules that implement queuing via timelocks are expected to override `_queueOperations` to implement the timelock-specific logic. Added `_executeOperations` as the equivalent for execution. ([#4360](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4360))
- `Governor`: Added `voter` and `nonce` parameters in signed ballots, to avoid forging signatures for random addresses, prevent signature replay, and allow invalidating signatures. Add `voter` as a new parameter in the `castVoteBySig` and `castVoteWithReasonAndParamsBySig` functions. ([#4378](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4378))
- `Governor`: Added support for casting votes with ERC-1271 signatures by using a `bytes memory signature` instead of `r`, `s` and `v` arguments in the `castVoteBySig` and `castVoteWithReasonAndParamsBySig` functions. ([#4418](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4418))
- `Governor`: Added a mechanism to restrict the address of the proposer using a suffix in the description.
- `GovernorStorage`: Added a new governor extension that stores the proposal details in storage, with an interface that operates on `proposalId`, as well as proposal enumerability. This replaces the old `GovernorCompatibilityBravo` module. ([#4360](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4360))
- `GovernorTimelockAccess`: Added a module to connect a governor with an instance of `AccessManager`, allowing the governor to make calls that are delay-restricted by the manager using the normal `queue` workflow. ([#4523](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4523))
- `GovernorTimelockControl`: Clean up timelock id on execution for gas refund. ([#4118](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4118))
- `GovernorTimelockControl`: Added the Governor instance address as part of the TimelockController operation `salt` to avoid operation id collisions between governors using the same TimelockController. ([#4432](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4432))
- `TimelockController`: Changed the role architecture to use `DEFAULT_ADMIN_ROLE` as the admin for all roles, instead of the bespoke `TIMELOCK_ADMIN_ROLE` that was used previously. This aligns with the general recommendation for `AccessControl` and makes the addition of new roles easier. Accordingly, the `admin` parameter and timelock will now be granted `DEFAULT_ADMIN_ROLE` instead of `TIMELOCK_ADMIN_ROLE`. ([#3799](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3799))
- `TimelockController`: Added a state getter that returns an `OperationState` enum. ([#4358](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4358))
- `Votes`: Use Trace208 for checkpoints. This enables EIP-6372 clock support for keys but reduces the max supported voting power to uint208. ([#4539](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4539))
#### Metatx
- `ERC2771Forwarder`: Added `deadline` for expiring transactions, batching, and more secure handling of `msg.value`. ([#4346](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4346))
- `ERC2771Context`: Return the forwarder address whenever the `msg.data` of a call originating from a trusted forwarder is not long enough to contain the request signer address (i.e. `msg.data.length` is less than 20 bytes), as specified by ERC-2771. ([#4481](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4481))
- `ERC2771Context`: Prevent revert in `_msgData()` when a call originating from a trusted forwarder is not long enough to contain the request signer address (i.e. `msg.data.length` is less than 20 bytes). Return the full calldata in that case. ([#4484](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4484))
#### Proxy
- `ProxyAdmin`: Removed `getProxyAdmin` and `getProxyImplementation` getters. ([#3820](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3820))
- `TransparentUpgradeableProxy`: Removed `admin` and `implementation` getters, which were only callable by the proxy owner and thus not very useful. ([#3820](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3820))
- `ERC1967Utils`: Refactored the `ERC1967Upgrade` abstract contract as a library. ([#4325](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4325))
- `TransparentUpgradeableProxy`: Admin is now stored in an immutable variable (set during construction) to avoid unnecessary storage reads on every proxy call. This removed the ability to ever change the admin. Transfer of the upgrade capability is exclusively handled through the ownership of the `ProxyAdmin`. ([#4354](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4354))
- Moved the logic to validate ERC-1822 during an upgrade from `ERC1967Utils` to `UUPSUpgradeable`. ([#4356](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4356))
- `UUPSUpgradeable`, `TransparentUpgradeableProxy` and `ProxyAdmin`: Removed `upgradeTo` and `upgrade` functions, and made `upgradeToAndCall` and `upgradeAndCall` ignore the data argument if it is empty. It is no longer possible to invoke the receive function (or send value with empty data) along with an upgrade. ([#4382](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4382))
- `BeaconProxy`: Reject value in initialization unless a payable function is explicitly invoked. ([#4382](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4382))
- `Proxy`: Removed redundant `receive` function. ([#4434](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4434))
- `BeaconProxy`: Use an immutable variable to store the address of the beacon. It is no longer possible for a `BeaconProxy` to upgrade by changing to another beacon. ([#4435](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4435))
- `Initializable`: Use the namespaced storage pattern to avoid putting critical variables in slot 0. Allow reinitializer versions greater than 256. ([#4460](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4460))
- `Initializable`: Use intermediate variables to improve readability. ([#4576](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4576))
#### Token
- `ERC20`, `ERC721`, `ERC1155`: Deleted `_beforeTokenTransfer` and `_afterTokenTransfer` hooks, added a new internal `_update` function for customizations, and refactored all extensions using those hooks to use `_update` instead. ([#3838](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3838), [#3876](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3876), [#4377](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4377))
- `ERC20`: Removed `Approval` event previously emitted in `transferFrom` to indicate that part of the allowance was consumed. With this change, allowances are no longer reconstructible from events. See the code for guidelines on how to re-enable this event if needed. ([#4370](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4370))
- `ERC20`: Removed the non-standard `increaseAllowance` and `decreaseAllowance` functions. ([#4585](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4585))
- `ERC20Votes`: Changed internal vote accounting to reusable `Votes` module previously used by `ERC721Votes`. Removed implicit `ERC20Permit` inheritance. Note that the `DOMAIN_SEPARATOR` getter was previously guaranteed to be available for `ERC20Votes` contracts, but is no longer available unless `ERC20Permit` is explicitly used; ERC-5267 support is included in `ERC20Votes` with `EIP712` and is recommended as an alternative. ([#3816](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3816))
- `SafeERC20`: Refactored `safeDecreaseAllowance` and `safeIncreaseAllowance` to support USDT-like tokens. ([#4260](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4260))
- `SafeERC20`: Removed `safePermit` in favor of documentation-only `permit` recommendations. Based on recommendations from @trust1995 ([#4582](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4582))
- `ERC721`: `_approve` no longer allows approving the owner of the tokenId. ([#4377](https://github.com/OpenZeppelin/openzeppelin-contracts/issues/4377)) `_setApprovalForAll` no longer allows setting address(0) as an operator. ([#4377](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4377))
- `ERC721`: Renamed `_requireMinted` to `_requireOwned` and added a return value with the current owner. Implemented `ownerOf` in terms of `_requireOwned`. ([#4566](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4566))
- `ERC721Consecutive`: Added a `_firstConsecutiveId` internal function that can be overridden to change the id of the first token minted through `_mintConsecutive`. ([#4097](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4097))
- `ERC721URIStorage`: Allow setting the token URI prior to minting. ([#4559](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4559))
- `ERC721URIStorage`, `ERC721Royalty`: Stop resetting token-specific URI and royalties when burning. ([#4561](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4561))
- `ERC1155`: Optimized array allocation. ([#4196](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4196))
- `ERC1155`: Removed check for address zero in `balanceOf`. ([#4263](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4263))
- `ERC1155`: Optimized array accesses by skipping bounds checking when unnecessary. ([#4300](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4300))
- `ERC1155`: Bubble errors triggered in the `onERC1155Received` and `onERC1155BatchReceived` hooks. ([#4314](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4314))
- `ERC1155Supply`: Added a `totalSupply()` function that returns the total amount of token circulating, this change will restrict the total tokens minted across all ids to 2\*\*256-1 . ([#3962](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3962))
- `ERC1155Receiver`: Removed in favor of `ERC1155Holder`. ([#4450](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4450))
#### Utils
- `Address`: Removed the ability to customize error messages. A common custom error is always used if the underlying revert reason cannot be bubbled up. ([#4502](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4502))
- `Arrays`: Added `unsafeMemoryAccess` helpers to read from a memory array without checking the length. ([#4300](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4300))
- `Arrays`: Optimized `findUpperBound` by removing redundant SLOAD. ([#4442](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4442))
- `Checkpoints`: Library moved from `utils` to `utils/structs` ([#4275](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4275))
- `DoubleEndedQueue`: Refactored internal structure to use `uint128` instead of `int128`. This has no effect on the library interface. ([#4150](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4150))
- `ECDSA`: Use unchecked arithmetic for the `tryRecover` function that receives the `r` and `vs` short-signature fields separately. ([#4301](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4301))
- `EIP712`: Added internal getters for the name and version strings ([#4303](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4303))
- `Math`: Makes `ceilDiv` to revert on 0 division even if the numerator is 0 ([#4348](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4348))
- `Math`: Optimized stack operations in `mulDiv`. ([#4494](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4494))
- `Math`: Renamed members of `Rounding` enum, and added a new rounding mode for "away from zero". ([#4455](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4455))
- `MerkleProof`: Use custom error to report invalid multiproof instead of reverting with overflow panic. ([#4564](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4564))
- `MessageHashUtils`: Added a new library for creating message digest to be used along with signing or recovery such as ECDSA or ERC-1271. These functions are moved from the `ECDSA` library. ([#4430](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4430))
- `Nonces`: Added a new contract to keep track of user nonces. Used for signatures in `ERC20Permit`, `ERC20Votes`, and `ERC721Votes`. ([#3816](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3816))
- `ReentrancyGuard`, `Pausable`: Moved to `utils` directory. ([#4551](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4551))
- `Strings`: Renamed `toString(int256)` to `toStringSigned(int256)`. ([#4330](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4330))
- Optimized `Strings.equal` ([#4262](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4262))
### How to migrate from 4.x
#### ERC20, ERC721, and ERC1155
These breaking changes will require modifications to ERC20, ERC721, and ERC1155 contracts, since the `_afterTokenTransfer` and `_beforeTokenTransfer` functions were removed. Thus, any customization made through those hooks should now be done overriding the new `_update` function instead.
Minting and burning are implemented by `_update` and customizations should be done by overriding this function as well. `_transfer`, `_mint` and `_burn` are no longer virtual (meaning they are not overridable) to guard against possible inconsistencies.
For example, a contract using `ERC20`'s `_beforeTokenTransfer` hook would have to be changed in the following way.
```diff
-function _beforeTokenTransfer(
+function _update(
address from,
address to,
uint256 amount
) internal virtual override {
- super._beforeTokenTransfer(from, to, amount);
require(!condition(), "ERC20: wrong condition");
+ super._update(from, to, amount);
}
```
#### More about ERC721
In the case of `ERC721`, the `_update` function does not include a `from` parameter, as the sender is implicitly the previous owner of the `tokenId`. The address of this previous owner is returned by the `_update` function, so it can be used for a posteriori checks. In addition to `to` and `tokenId`, a third parameter (`auth`) is present in this function. This parameter enabled an optional check that the caller/spender is approved to do the transfer. This check cannot be performed after the transfer (because the transfer resets the approval), and doing it before `_update` would require a duplicate call to `_ownerOf`.
In this logic of removing hidden SLOADs, the `_isApprovedOrOwner` function was removed in favor of a new `_isAuthorized` function. Overrides that used to target the `_isApprovedOrOwner` should now be performed on the `_isAuthorized` function. Calls to `_isApprovedOrOwner` that preceded a call to `_transfer`, `_burn` or `_approve` should be removed in favor of using the `auth` argument in `_update` and `_approve`. This is showcased in `ERC721Burnable.burn` and in `ERC721Wrapper.withdrawTo`.
The `_exists` function was removed. Calls to this function can be replaced by `_ownerOf(tokenId) != address(0)`.
#### More about ERC1155
Batch transfers will now emit `TransferSingle` if the batch consists of a single token, while in previous versions the `TransferBatch` event would be used for all transfers initiated through `safeBatchTransferFrom`. Both behaviors are compliant with the ERC-1155 specification.
#### ERC165Storage
Users that were registering EIP-165 interfaces with `_registerInterface` from `ERC165Storage` should instead do so by overriding the `supportsInterface` function as seen below:
```solidity
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
}
```
#### SafeMath
Methods in SafeMath superseded by native overflow checks in Solidity 0.8.0 were removed along with operations providing an interface for revert strings. The remaining methods were moved to `utils/Math.sol`.
```diff
- import "@openzeppelin/contracts/utils/math/SafeMath.sol";
+ import "@openzeppelin/contracts/utils/math/Math.sol";
function tryOperations(uint256 x, uint256 y) external view {
- (bool overflowsAdd, uint256 resultAdd) = SafeMath.tryAdd(x, y);
+ (bool overflowsAdd, uint256 resultAdd) = Math.tryAdd(x, y);
- (bool overflowsSub, uint256 resultSub) = SafeMath.trySub(x, y);
+ (bool overflowsSub, uint256 resultSub) = Math.trySub(x, y);
- (bool overflowsMul, uint256 resultMul) = SafeMath.tryMul(x, y);
+ (bool overflowsMul, uint256 resultMul) = Math.tryMul(x, y);
- (bool overflowsDiv, uint256 resultDiv) = SafeMath.tryDiv(x, y);
+ (bool overflowsDiv, uint256 resultDiv) = Math.tryDiv(x, y);
// ...
}
```
#### Adapting Governor modules
Custom Governor modules that override internal functions may require modifications if migrated to v5. In particular, the new internal functions `_queueOperations` and `_executeOperations` may need to be used. If assistance with this migration is needed reach out via the [OpenZeppelin Support Forum](https://forum.openzeppelin.com/c/support/contracts/18).
#### ECDSA and MessageHashUtils
The `ECDSA` library is now focused on signer recovery. Previously it also included utility methods for producing digests to be used with signing or recovery. These utilities have been moved to the `MessageHashUtils` library and should be imported if needed:
```diff
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
+import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
contract Verifier {
using ECDSA for bytes32;
+ using MessageHashUtils for bytes32;
function _verify(bytes32 data, bytes memory signature, address account) internal pure returns (bool) {
return data
.toEthSignedMessageHash()
.recover(signature) == account;
}
}
```
#### Interfaces and libraries in upgradeable contracts
The upgradeable version of the contracts library used to include a variant suffixed with `Upgradeable` for every contract. These variants, which are produced automatically, mainly include changes for dealing with storage that don't apply to libraries and interfaces.
The upgradeable library no longer includes upgradeable variants for libraries and interfaces. Projects migrating to 5.0 should replace their library and interface imports with their corresponding non-upgradeable version:
```diff
// Libraries
-import {AddressUpgradeable} from '@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol';
+import {Address} from '@openzeppelin/contracts/utils/Address.sol';
// Interfaces
-import {IERC20Upgradeable} from '@openzeppelin/contracts-upgradeable/interfaces/IERC20.sol';
+import {IERC20} from '@openzeppelin/contracts/interfaces/IERC20.sol';
```
#### Offchain Considerations
Some changes may affect offchain systems if they rely on assumptions that are changed along with these new breaking changes. These cases are:
##### Relying on revert strings for processing errors
A concrete example is AccessControl, where it was previously advised to catch revert reasons using the following regex:
```
/^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
```
Instead, contracts now revert with custom errors. Systems that interact with smart contracts outside of the network should consider reliance on revert strings and possibly support the new custom errors.
##### Relying on storage locations for retrieving data
After 5.0, the storage location of some variables were changed. This is the case for `Initializable` and all the upgradeable contracts since they now use namespaced storaged locations. Any system relying on storage locations for retrieving data or detecting capabilities should be updated to support these new locations.
## 4.9.6 (2024-02-29)
- `Base64`: Fix issue where dirty memory located just after the input buffer is affecting the result. ([#4929](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4929))
## 4.9.5 (2023-12-08)
- `Multicall`: Make aware of non-canonical context (i.e. `msg.sender` is not `_msgSender()`), allowing compatibility with `ERC2771Context`. Patch duplicated `Address.functionDelegateCall` in v4.9.4 (removed).
## 4.9.3 (2023-07-28)
- `ERC2771Context`: Return the forwarder address whenever the `msg.data` of a call originating from a trusted forwarder is not long enough to contain the request signer address (i.e. `msg.data.length` is less than 20 bytes), as specified by ERC-2771. ([#4481](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4481))
- `ERC2771Context`: Prevent revert in `_msgData()` when a call originating from a trusted forwarder is not long enough to contain the request signer address (i.e. `msg.data.length` is less than 20 bytes). Return the full calldata in that case. ([#4484](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4484))
## 4.9.2 (2023-06-16)
- `MerkleProof`: Fix a bug in `processMultiProof` and `processMultiProofCalldata` that allows proving arbitrary leaves if the tree contains a node with value 0 at depth 1.
## 4.9.1 (2023-06-07)
- `Governor`: Add a mechanism to restrict the address of the proposer using a suffix in the description.
## 4.9.0 (2023-05-23)
- `ReentrancyGuard`: Add a `_reentrancyGuardEntered` function to expose the guard status. ([#3714](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3714))
- `ERC721Wrapper`: add a new extension of the `ERC721` token which wraps an underlying token. Deposit and withdraw guarantee that the ownership of each token is backed by a corresponding underlying token with the same identifier. ([#3863](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3863))
- `EnumerableMap`: add a `keys()` function that returns an array containing all the keys. ([#3920](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3920))
- `Governor`: add a public `cancel(uint256)` function. ([#3983](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3983))
- `Governor`: Enable timestamp operation for blockchains without a stable block time. This is achieved by connecting a Governor's internal clock to match a voting token's EIP-6372 interface. ([#3934](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3934))
- `Strings`: add `equal` method. ([#3774](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3774))
- `IERC5313`: Add an interface for EIP-5313 that is now final. ([#4013](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4013))
- `IERC4906`: Add an interface for ERC-4906 that is now Final. ([#4012](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4012))
- `StorageSlot`: Add support for `string` and `bytes`. ([#4008](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4008))
- `Votes`, `ERC20Votes`, `ERC721Votes`: support timestamp checkpointing using EIP-6372. ([#3934](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3934))
- `ERC4626`: Add mitigation to the inflation attack through virtual shares and assets. ([#3979](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3979))
- `Strings`: add `toString` method for signed integers. ([#3773](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3773))
- `ERC20Wrapper`: Make the `underlying` variable private and add a public accessor. ([#4029](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4029))
- `EIP712`: add EIP-5267 support for better domain discovery. ([#3969](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3969))
- `AccessControlDefaultAdminRules`: Add an extension of `AccessControl` with additional security rules for the `DEFAULT_ADMIN_ROLE`. ([#4009](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4009))
- `SignatureChecker`: Add `isValidERC1271SignatureNow` for checking a signature directly against a smart contract using ERC-1271. ([#3932](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3932))
- `SafeERC20`: Add a `forceApprove` function to improve compatibility with tokens behaving like USDT. ([#4067](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4067))
- `ERC1967Upgrade`: removed contract-wide `oz-upgrades-unsafe-allow delegatecall` annotation, replaced by granular annotation in `UUPSUpgradeable`. ([#3971](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3971))
- `ERC20Wrapper`: self wrapping and deposit by the wrapper itself are now explicitly forbidden. ([#4100](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4100))
- `ECDSA`: optimize bytes32 computation by using assembly instead of `abi.encodePacked`. ([#3853](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3853))
- `ERC721URIStorage`: Emit ERC-4906 `MetadataUpdate` in `_setTokenURI`. ([#4012](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4012))
- `ShortStrings`: Added a library for handling short strings in a gas efficient way, with fallback to storage for longer strings. ([#4023](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4023))
- `SignatureChecker`: Allow return data length greater than 32 from EIP-1271 signers. ([#4038](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4038))
- `UUPSUpgradeable`: added granular `oz-upgrades-unsafe-allow-reachable` annotation to improve upgrade safety checks on latest version of the Upgrades Plugins (starting with `@openzeppelin/upgrades-core@1.21.0`). ([#3971](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3971))
- `Initializable`: optimize `_disableInitializers` by using `!=` instead of `<`. ([#3787](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3787))
- `Ownable2Step`: make `acceptOwnership` public virtual to enable usecases that require overriding it. ([#3960](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3960))
- `UUPSUpgradeable.sol`: Change visibility to the functions `upgradeTo ` and `upgradeToAndCall ` from `external` to `public`. ([#3959](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3959))
- `TimelockController`: Add the `CallSalt` event to emit on operation schedule. ([#4001](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4001))
- Reformatted codebase with latest version of Prettier Solidity. ([#3898](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3898))
- `Math`: optimize `log256` rounding check. ([#3745](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3745))
- `ERC20Votes`: optimize by using unchecked arithmetic. ([#3748](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3748))
- `Multicall`: annotate `multicall` function as upgrade safe to not raise a flag for its delegatecall. ([#3961](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3961))
- `ERC20Pausable`, `ERC721Pausable`, `ERC1155Pausable`: Add note regarding missing public pausing functionality ([#4007](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4007))
- `ECDSA`: Add a function `toDataWithIntendedValidatorHash` that encodes data with version 0x00 following EIP-191. ([#4063](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4063))
- `MerkleProof`: optimize by using unchecked arithmetic. ([#3745](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3745))
### Breaking changes
- `EIP712`: Addition of ERC5267 support requires support for user defined value types, which was released in Solidity version 0.8.8. This requires a pragma change from `^0.8.0` to `^0.8.8`.
@ -450,19 +12,6 @@ After 5.0, the storage location of some variables were changed. This is the case
- `ERC777`: The `ERC777` token standard is no longer supported by OpenZeppelin. Our implementation is now deprecated and will be removed in the next major release. The corresponding standard interfaces remain available. ([#4066](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4066))
- `ERC1820Implementer`: The `ERC1820` pseudo-introspection mechanism is no longer supported by OpenZeppelin. Our implementation is now deprecated and will be removed in the next major release. The corresponding standard interfaces remain available. ([#4066](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4066))
## 4.8.3 (2023-04-13)
- `GovernorCompatibilityBravo`: Fix encoding of proposal data when signatures are missing.
- `TransparentUpgradeableProxy`: Fix transparency in case of selector clash with non-decodable calldata or payable mutability. ([#4154](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4154))
## 4.8.2 (2023-03-02)
- `ERC721Consecutive`: Fixed a bug when `_mintConsecutive` is used for batches of size 1 that could lead to balance overflow. Refer to the breaking changes section in the changelog for a note on the behavior of `ERC721._beforeTokenTransfer`.
### Breaking changes
- `ERC721`: The internal function `_beforeTokenTransfer` no longer updates balances, which it previously did when `batchSize` was greater than 1. This change has no consequence unless a custom ERC721 extension is explicitly invoking `_beforeTokenTransfer`. Balance updates in extensions must now be done explicitly using `__unsafe_increaseBalance`, with a name that indicates that there is an invariant that has to be manually verified.
## 4.8.1 (2023-01-12)
- `ERC4626`: Use staticcall instead of call when fetching underlying ERC-20 decimals. ([#3943](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3943))
@ -763,7 +312,7 @@ It is no longer possible to call an `initializer`-protected function from within
This release includes two small breaking changes in `TimelockController`.
1. The `onlyRole` modifier in this contract was designed to let anyone through if the role was granted to `address(0)`,
allowing the possibility to make a role "open", which can be used for `EXECUTOR_ROLE`. This modifier is now
allowing the possibility to to make a role "open", which can be used for `EXECUTOR_ROLE`. This modifier is now
replaced by `AccessControl.onlyRole`, which does not have this ability. The previous behavior was moved to the
modifier `TimelockController.onlyRoleOrOpenRole`.
2. It was possible to make `PROPOSER_ROLE` an open role (as described in the previous item) if it was granted to

View File

@ -6,7 +6,7 @@ In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socioeconomic status, nationality, personal
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards

View File

@ -1,7 +0,0 @@
{
"drips": {
"ethereum": {
"ownedBy": "0xAeb37910f93486C85A1F8F994b67E8187554d664"
}
}
}

View File

@ -55,7 +55,7 @@ External contributions must be reviewed separately by multiple maintainers.
Automation should be used as much as possible to reduce the possibility of human error and forgetfulness.
Automations that make use of sensitive credentials must use secure secret management, and must be strengthened against attacks such as [those on GitHub Actions workflows](https://github.com/nikitastupin/pwnhub).
Automations that make use of sensitive credentials must use secure secret management, and must be strengthened against attacks such as [those on GitHub Actions worklows](https://github.com/nikitastupin/pwnhub).
Some other examples of automation are:
@ -95,18 +95,8 @@ In addition to the official Solidity Style Guide we have a number of other conve
}
```
* Functions should be declared virtual, with few exceptions listed below. The
contract logic should be written considering that these functions may be
overridden by developers, e.g. getting a value using an internal getter rather
than reading directly from a state variable.
If function A is an "alias" of function B, i.e. it invokes function B without
significant additional logic, then function A should not be virtual so that
any user overrides are implemented on B, preventing inconsistencies.
* Events should generally be emitted immediately after the state change that they
represent, and should be named in the past tense. Some exceptions may be made for gas
efficiency if the result doesn't affect observable ordering of events.
* Events should be emitted immediately after the state change that they
represent, and should be named in the past tense.
```solidity
function _burn(address who, uint256 value) internal {
@ -115,7 +105,7 @@ In addition to the official Solidity Style Guide we have a number of other conve
}
```
Some standards (e.g. ERC-20) use present tense, and in those cases the
Some standards (e.g. ERC20) use present tense, and in those cases the
standard specification is used.
* Interface names should have a capital I prefix.
@ -124,32 +114,4 @@ In addition to the official Solidity Style Guide we have a number of other conve
interface IERC777 {
```
* Contracts not intended to be used standalone should be marked abstract
so they are required to be inherited to other contracts.
```solidity
abstract contract AccessControl is ..., {
```
* Return values are generally not named, unless they are not immediately clear or there are multiple return values.
```solidity
function expiration() public view returns (uint256) { // Good
function hasRole() public view returns (bool isMember, uint32 currentDelay) { // Good
```
* Unchecked arithmetic blocks should contain comments explaining why overflow is guaranteed not to happen. If the reason is immediately apparent from the line above the unchecked block, the comment may be omitted.
* Custom errors should be declared following the [EIP-6093](https://eips.ethereum.org/EIPS/eip-6093) rationale whenever reasonable. Also, consider the following:
* The domain prefix should be picked in the following order:
1. Use `ERC<number>` if the error is a violation of an ERC specification.
2. Use the name of the underlying component where it belongs (eg. `Governor`, `ECDSA`, or `Timelock`).
* The location of custom errors should be decided in the following order:
1. Take the errors from their underlying ERCs if they're already defined.
2. Declare the errors in the underlying interface/library if the error makes sense in its context.
3. Declare the error in the implementation if the underlying interface/library is not suitable to do so (eg. interface/library already specified in an ERC).
4. Declare the error in an extension if the error only happens in such extension or child contracts.
* Custom error names should not be declared twice along the library to avoid duplicated identifier declarations when inheriting from multiple contracts.

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2016-2024 Zeppelin Group Ltd
Copyright (c) 2016-2023 zOS Global Limited and contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

View File

@ -14,43 +14,28 @@
:mage: **Not sure how to get started?** Check out [Contracts Wizard](https://wizard.openzeppelin.com/) — an interactive smart contract generator.
:building_construction: **Want to scale your decentralized application?** Check out [OpenZeppelin Defender](https://openzeppelin.com/defender) — a mission-critical developer security platform to code, audit, deploy, monitor, and operate with confidence.
> [!IMPORTANT]
> OpenZeppelin Contracts uses semantic versioning to communicate backwards compatibility of its API and storage layout. For upgradeable contracts, the storage layout of different major versions should be assumed incompatible, for example, it is unsafe to upgrade from 4.9.3 to 5.0.0. Learn more at [Backwards Compatibility](https://docs.openzeppelin.com/contracts/backwards-compatibility).
:building_construction: **Want to scale your decentralized application?** Check out [OpenZeppelin Defender](https://openzeppelin.com/defender) — a secure platform for automating and monitoring your operations.
## Overview
### Installation
#### Hardhat (npm)
```
$ npm install @openzeppelin/contracts
```
#### Foundry (git)
OpenZeppelin Contracts features a [stable API](https://docs.openzeppelin.com/contracts/releases-stability#api-stability), which means that your contracts won't break unexpectedly when upgrading to a newer minor version.
> [!WARNING]
> When installing via git, it is a common error to use the `master` branch. This is a development branch that should be avoided in favor of tagged releases. The release process involves security measures that the `master` branch does not guarantee.
> [!WARNING]
> Foundry installs the latest version initially, but subsequent `forge update` commands will use the `master` branch.
```
$ forge install OpenZeppelin/openzeppelin-contracts
```
Add `@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/` in `remappings.txt.`
An alternative to npm is to use the GitHub repository (`openzeppelin/openzeppelin-contracts`) to retrieve the contracts. When doing this, make sure to specify the tag for a release such as `v4.5.0`, instead of using the `master` branch.
### Usage
Once installed, you can use the contracts in the library by importing them:
```solidity
pragma solidity ^0.8.20;
pragma solidity ^0.8.0;
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
contract MyCollectible is ERC721 {
constructor() ERC721("MyCollectible", "MCO") {
@ -72,7 +57,7 @@ The guides in the [documentation site](https://docs.openzeppelin.com/contracts)
The [full API](https://docs.openzeppelin.com/contracts/api/token/ERC20) is also thoroughly documented, and serves as a great reference when developing your smart contract application. You can also ask for help or follow Contracts's development in the [community forum](https://forum.openzeppelin.com).
Finally, you may want to take a look at the [guides on our blog](https://blog.openzeppelin.com/), which cover several common use cases and good practices. The following articles provide great background reading, though please note that some of the referenced tools have changed, as the tooling in the ecosystem continues to rapidly evolve.
Finally, you may want to take a look at the [guides on our blog](https://blog.openzeppelin.com/guides), which cover several common use cases and good practices. The following articles provide great background reading, though please note that some of the referenced tools have changed, as the tooling in the ecosystem continues to rapidly evolve.
* [The Hitchhikers Guide to Smart Contracts in Ethereum](https://blog.openzeppelin.com/the-hitchhikers-guide-to-smart-contracts-in-ethereum-848f08001f05) will help you get an overview of the various tools available for smart contract development, and help you set up your environment.
* [A Gentle Introduction to Ethereum Programming, Part 1](https://blog.openzeppelin.com/a-gentle-introduction-to-ethereum-programming-part-1-783cc7796094) provides very useful information on an introductory level, including many basic concepts from the Ethereum platform.
@ -82,15 +67,13 @@ Finally, you may want to take a look at the [guides on our blog](https://blog.op
This project is maintained by [OpenZeppelin](https://openzeppelin.com) with the goal of providing a secure and reliable library of smart contract components for the ecosystem. We address security through risk management in various areas such as engineering and open source best practices, scoping and API design, multi-layered review processes, and incident response preparedness.
The [OpenZeppelin Contracts Security Center](https://contracts.openzeppelin.com/security) contains more details about the secure development process.
The security policy is detailed in [`SECURITY.md`](./SECURITY.md) as well, and specifies how you can report security vulnerabilities, which versions will receive security patches, and how to stay informed about them. We run a [bug bounty program on Immunefi](https://immunefi.com/bounty/openzeppelin) to reward the responsible disclosure of vulnerabilities.
The security policy is detailed in [`SECURITY.md`](./SECURITY.md), and specifies how you can report security vulnerabilities, which versions will receive security patches, and how to stay informed about them. We run a [bug bounty program on Immunefi](https://immunefi.com/bounty/openzeppelin) to reward the responsible disclosure of vulnerabilities.
The engineering guidelines we follow to promote project quality can be found in [`GUIDELINES.md`](./GUIDELINES.md).
Past audits can be found in [`audits/`](./audits).
Smart contracts are a nascent technology and carry a high level of technical risk and uncertainty. Although OpenZeppelin is well known for its security audits, using OpenZeppelin Contracts is not a substitute for a security audit.
Smart contracts are a nascent techology and carry a high level of technical risk and uncertainty. Although OpenZeppelin is well known for its security audits, using OpenZeppelin Contracts is not a substitute for a security audit.
OpenZeppelin Contracts is made available under the MIT License, which disclaims all warranties in relation to the project and which limits the liability of those that contribute and maintain the project, including OpenZeppelin. As set out further in the Terms, you acknowledge that you are solely responsible for any use of OpenZeppelin Contracts and you assume all risks associated with any such use.

View File

@ -1,5 +1,7 @@
# Releasing
> Visit the documentation for [details about release schedule](https://docs.openzeppelin.com/contracts/releases-stability).
OpenZeppelin Contracts uses a fully automated release process that takes care of compiling, packaging, and publishing the library, all of which is carried out in a clean CI environment (GitHub Actions), implemented in the ([`release-cycle`](.github/workflows/release-cycle.yml)) workflow. This helps to reduce the potential for human error and inconsistencies, and ensures that the release process is ongoing and reliable.
## Changesets

View File

@ -8,7 +8,7 @@ Security vulnerabilities should be disclosed to the project maintainers through
Responsible disclosure of security vulnerabilities is rewarded through a bug bounty program on [Immunefi].
There is a bonus reward for issues introduced in release candidates that are reported before making it into a stable release. Learn more about release candidates at [`RELEASING.md`](./RELEASING.md).
There is a bonus reward for issues introduced in release candidates that are reported before making it into a stable release.
## Security Patches
@ -30,14 +30,13 @@ Only critical severity bug fixes will be backported to past major releases.
| Version | Critical security fixes | Other security fixes |
| ------- | ----------------------- | -------------------- |
| 5.x | :white_check_mark: | :white_check_mark: |
| 4.9 | :white_check_mark: | :x: |
| 4.x | :white_check_mark: | :white_check_mark: |
| 3.4 | :white_check_mark: | :x: |
| 2.5 | :x: | :x: |
| 2.5 | :white_check_mark: | :x: |
| < 2.0 | :x: | :x: |
Note as well that the Solidity language itself only guarantees security updates for the latest release.
## Legal
Smart contracts are a nascent technology and carry a high level of technical risk and uncertainty. OpenZeppelin Contracts is made available under the MIT License, which disclaims all warranties in relation to the project and which limits the liability of those that contribute and maintain the project, including OpenZeppelin. Your use of the project is also governed by the terms found at www.openzeppelin.com/tos (the "Terms"). As set out in the Terms, you are solely responsible for any use of OpenZeppelin Contracts and you assume all risks associated with any such use. This Security Policy in no way evidences or represents an on-going duty by any contributor, including OpenZeppelin, to correct any flaws or alert you to all or any of the potential risks of utilizing the project.
Smart contracts are a nascent techology and carry a high level of technical risk and uncertainty. OpenZeppelin Contracts is made available under the MIT License, which disclaims all warranties in relation to the project and which limits the liability of those that contribute and maintain the project, including OpenZeppelin. Your use of the project is also governed by the terms found at www.openzeppelin.com/tos (the "Terms"). As set out in the Terms, you are solely responsible for any use of OpenZeppelin Contracts and you assume all risks associated with any such use. This Security Policy in no way evidences or represents an on-going duty by any contributor, including OpenZeppelin, to correct any flaws or alert you to all or any of the potential risks of utilizing the project.

BIN
audit/2020-10-certora.pdf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,9 +2,6 @@
| Date | Version | Commit | Auditor | Scope | Links |
| ------------ | ------- | --------- | ------------ | -------------------- | ----------------------------------------------------------- |
| October 2024 | v5.1.0 | TBD | OpenZeppelin | v5.1 Changes | [🔗](./2024-10-v5.1.pdf) |
| October 2023 | v5.0.0 | `b5a3e69` | OpenZeppelin | v5.0 Changes | [🔗](./2023-10-v5.0.pdf) |
| May 2023 | v4.9.0 | `91df66c` | OpenZeppelin | v4.9 Changes | [🔗](./2023-05-v4.9.pdf) |
| October 2022 | v4.8.0 | `14f98db` | OpenZeppelin | ERC4626, Checkpoints | [🔗](./2022-10-ERC4626.pdf) [🔗](./2022-10-Checkpoints.pdf) |
| October 2018 | v2.0.0 | `dac5bcc` | LevelK | Everything | [🔗](./2018-10.pdf) |
| March 2017 | v1.0.4 | `9c5975a` | New Alchemy | Everything | [🔗](./2017-03.md) |

2
certora/.gitignore vendored
View File

@ -1 +1 @@
patched
munged

View File

@ -1,54 +1,25 @@
default: help
SRC := ../contracts
DST := patched
DIFF := diff
SRCS := $(shell find $(SRC) -type f)
DSTS := $(shell find $(DST) -type f)
DIFFS := $(shell find $(DIFF) -type f)
PATCH = applyHarness.patch
CONTRACTS_DIR = ../contracts
MUNGED_DIR = munged
###############################################################################
# Apply all patches in the $DIFF folder to the $DST folder
apply: $(DST) $(patsubst $(DIFF)/%.patch,$(DST)/%,$(subst _,/,$(DIFFS)))
# Reset the $DST folder
$(DST): FORCE
@rm -rf $@
@cp -r $(SRC) $@
# Update a solidity file in the $DST directory using the corresponding patch
$(DST)/%.sol: FORCE | $(DST)
@echo Applying patch to $@
@patch -p0 -d $(DST) < $(patsubst $(DST)_%,$(DIFF)/%.patch,$(subst /,_,$@))
###############################################################################
# Record all difference between $SRC and $DST in patches
record: $(DIFF) $(patsubst %,$(DIFF)/%.patch,$(subst /,_,$(subst $(SRC)/,,$(SRCS)) $(subst $(DST)/,,$(DSTS))))
# Create the $DIFF folder
$(DIFF): FORCE
@rm -rf $@
@mkdir $@
# Create the patch file by comparing the source and the destination
$(DIFF)/%.patch: FORCE | $(DIFF)
@echo Generating patch $@
@diff -ruN \
$(patsubst $(DIFF)/%.patch,$(SRC)/%,$(subst _,/,$@)) \
$(patsubst $(DIFF)/%.patch,$(DST)/%,$(subst _,/,$@)) \
| sed 's+$(SRC)/++g' \
| sed 's+$(DST)/++g' \
> $@
@[ -s $@ ] || rm $@
###############################################################################
help:
@echo "usage:"
@echo " make apply: create $(DST) directory by applying the patches to $(SRC)"
@echo " make record: record the patches capturing the differences between $(SRC) and $(DST)"
@echo " make clean: remove all generated files (those ignored by git)"
@echo " make $(MUNGED_DIR): create $(MUNGED_DIR) directory by applying the patch file to $(CONTRACTS_DIR)"
@echo " make record: record a new patch file capturing the differences between $(CONTRACTS_DIR) and $(MUNGED_DIR)"
munged: $(wildcard $(CONTRACTS_DIR)/*.sol) $(PATCH)
rm -rf $@
cp -r $(CONTRACTS_DIR) $@
patch -p0 -d $@ < $(PATCH)
record:
diff -druN $(CONTRACTS_DIR) $(MUNGED_DIR) | sed 's+../contracts/++g' | sed 's+munged/++g' > $(PATCH)
refresh: munged record
clean:
git clean -fdX
FORCE: ;
touch $(PATCH)

View File

@ -1,60 +1,56 @@
# Running the certora verification tool
These instructions detail the process for running Certora Verification Tool on OpenZeppelin Contracts.
These instructions detail the process for running CVT on the OpenZeppelin (Wizard/Governor) contracts.
Documentation for CVT and the specification language are available [here](https://certora.atlassian.net/wiki/spaces/CPD/overview).
## Prerequisites
Follow the [Certora installation guide](https://docs.certora.com/en/latest/docs/user-guide/getting-started/install.html) in order to get the Certora Prover Package and the `solc` executable folder in your path.
> **Note**
> An API Key is required for local testing. Although the prover will run on a Github Actions' CI environment on selected Pull Requests.
Documentation for CVT and the specification language are available
[here](https://certora.atlassian.net/wiki/spaces/CPD/overview)
## Running the verification
The Certora Verification Tool proves specs for contracts, which are defined by the `./specs.json` file along with their pre-configured options.
The scripts in the `certora/scripts` directory are used to submit verification
jobs to the Certora verification service. After the job is complete, the results will be available on
[the Certora portal](https://vaas-stg.certora.com/).
The verification script `./run.js` is used to submit verification jobs to the Certora Verification service.
These scripts should be run from the root directory; for example by running
You can run it from the root of the repository with the following command:
```bash
node certora/run.js [[CONTRACT_NAME:]SPEC_NAME] [OPTIONS...]
```
sh certora/scripts/verifyAll.sh <meaningful comment>
```
Where:
The most important of these is `verifyAll.sh`, which checks
all of the harnessed contracts (`certora/harness/Wizard*.sol`) against all of
the specifications (`certora/spec/*.spec`).
- `CONTRACT_NAME` matches the `contract` key in the `./spec.json` file and may be empty. It will run all matching contracts if not provided.
- `SPEC_NAME` refers to a `spec` key from the `./specs.json` file. It will run every spec if not provided.
- `OPTIONS` extend the [Certora Prover CLI options](https://docs.certora.com/en/latest/docs/prover/cli/options.html#certora-prover-cli-options) and will respect the preconfigured options in the `specs.json` file.
The other scripts run a subset of the specifications or the contracts. You can
verify different contracts or specifications by changing the `--verify` option,
and you can run a single rule or method with the `--rule` or `--method` option.
> **Note**
> A single spec may be configured to run for multiple contracts, whereas a single contract may run multiple specs.
For example, to verify the `WizardFirstPriority` contract against the
`GovernorCountingSimple` specification, you could change the `--verify` line of
the `WizardControlFirstPriortity.sh` script to:
Example usage:
```bash
node certora/run.js AccessControl # Run the AccessControl spec against every contract implementing it
```
--verify WizardFirstPriority:certora/specs/GovernorCountingSimple.spec \
```
## Adapting to changes in the contracts
Some of our rules require the code to be simplified in various ways. Our primary tool for performing these simplifications is to run verification on a contract that extends the original contracts and overrides some of the methods. These "harness" contracts can be found in the `certora/harness` directory.
Some of our rules require the code to be simplified in various ways. Our
primary tool for performing these simplifications is to run verification on a
contract that extends the original contracts and overrides some of the methods.
These "harness" contracts can be found in the `certora/harness` directory.
This pattern does require some modifications to the original code: some methods need to be made virtual or public, for example. These changes are handled by applying a patch
to the code before verification by running:
This pattern does require some modifications to the original code: some methods
need to be made virtual or public, for example. These changes are handled by
applying a patch to the code before verification.
```bash
make -C certora apply
```
When one of the `verify` scripts is executed, it first applies the patch file
`certora/applyHarness.patch` to the `contracts` directory, placing the output
in the `certora/munged` directory. We then verify the contracts in the
`certora/munged` directory.
Before running the `certora/run.js` script, it's required to apply the corresponding patches to the `contracts` directory, placing the output in the `certora/patched` directory. Then, the contracts are verified by running the verification for the `certora/patched` directory.
If the original contracts change, it is possible to create a conflict with the patch. In this case, the verify scripts will report an error message and output rejected changes in the `patched` directory. After merging the changes, run `make record` in the `certora` directory; this will regenerate the patch file, which can then be checked into git.
For more information about the `make` scripts available, run:
```bash
make -C certora help
```
If the original contracts change, it is possible to create a conflict with the
patch. In this case, the verify scripts will report an error message and output
rejected changes in the `munged` directory. After merging the changes, run
`make record` in the `certora` directory; this will regenerate the patch file,
which can then be checked into git.

408
certora/applyHarness.patch Normal file
View File

@ -0,0 +1,408 @@
diff -druN governance/extensions/GovernorCountingSimple.sol governance/extensions/GovernorCountingSimple.sol
--- governance/extensions/GovernorCountingSimple.sol 2023-02-27 10:59:32.652558153 +0100
+++ governance/extensions/GovernorCountingSimple.sol 2023-02-28 16:49:10.417726143 +0100
@@ -27,7 +27,7 @@
mapping(address => bool) hasVoted;
}
- mapping(uint256 => ProposalVote) private _proposalVotes;
+ mapping(uint256 => ProposalVote) internal _proposalVotes; // HARNESS: private -> internal
/**
* @dev See {IGovernor-COUNTING_MODE}.
diff -druN governance/extensions/GovernorPreventLateQuorum.sol governance/extensions/GovernorPreventLateQuorum.sol
--- governance/extensions/GovernorPreventLateQuorum.sol 2023-02-27 10:59:32.652558153 +0100
+++ governance/extensions/GovernorPreventLateQuorum.sol 2023-02-28 16:49:10.417726143 +0100
@@ -20,10 +20,10 @@
abstract contract GovernorPreventLateQuorum is Governor {
using SafeCast for uint256;
- uint64 private _voteExtension;
+ uint64 internal _voteExtension; // HARNESS: private -> internal
/// @custom:oz-retyped-from mapping(uint256 => Timers.BlockNumber)
- mapping(uint256 => uint64) private _extendedDeadlines;
+ mapping(uint256 => uint64) internal _extendedDeadlines; // HARNESS: private -> internal
/// @dev Emitted when a proposal deadline is pushed back due to reaching quorum late in its voting period.
event ProposalExtended(uint256 indexed proposalId, uint64 extendedDeadline);
diff -druN governance/extensions/GovernorVotesQuorumFraction.sol governance/extensions/GovernorVotesQuorumFraction.sol
--- governance/extensions/GovernorVotesQuorumFraction.sol 2023-02-27 10:59:32.655891529 +0100
+++ governance/extensions/GovernorVotesQuorumFraction.sol 2023-02-28 16:49:10.417726143 +0100
@@ -17,10 +17,10 @@
using SafeCast for *;
using Checkpoints for Checkpoints.Trace224;
- uint256 private _quorumNumerator; // DEPRECATED in favor of _quorumNumeratorHistory
+ uint256 internal _quorumNumerator; // DEPRECATED // MUNGED private => internal
/// @custom:oz-retyped-from Checkpoints.History
- Checkpoints.Trace224 private _quorumNumeratorHistory;
+ Checkpoints.Trace224 internal _quorumNumeratorHistory; // MUNGED private => internal
event QuorumNumeratorUpdated(uint256 oldQuorumNumerator, uint256 newQuorumNumerator);
diff -druN governance/Governor.sol governance/Governor.sol
--- governance/Governor.sol 2023-02-27 10:59:32.652558153 +0100
+++ governance/Governor.sol 2023-02-28 16:49:10.421059488 +0100
@@ -51,7 +51,7 @@
string private _name;
/// @custom:oz-retyped-from mapping(uint256 => Governor.ProposalCore)
- mapping(uint256 => ProposalCore) private _proposals;
+ mapping(uint256 => ProposalCore) internal _proposals; // HARNESS: private -> internal
// This queue keeps track of the governor operating on itself. Calls to functions protected by the
// {onlyGovernance} modifier needs to be whitelisted in this queue. Whitelisting is set in {_beforeExecute},
diff -druN governance/TimelockController.sol governance/TimelockController.sol
--- governance/TimelockController.sol 2023-02-27 10:59:32.652558153 +0100
+++ governance/TimelockController.sol 2023-02-28 16:49:10.421059488 +0100
@@ -28,10 +28,10 @@
bytes32 public constant PROPOSER_ROLE = keccak256("PROPOSER_ROLE");
bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE");
bytes32 public constant CANCELLER_ROLE = keccak256("CANCELLER_ROLE");
- uint256 internal constant _DONE_TIMESTAMP = uint256(1);
+ uint256 public constant _DONE_TIMESTAMP = uint256(1); // HARNESS: internal -> public
mapping(bytes32 => uint256) private _timestamps;
- uint256 private _minDelay;
+ uint256 public _minDelay; // HARNESS: private -> public
/**
* @dev Emitted when a call is scheduled as part of operation `id`.
diff -druN governance/utils/Votes.sol governance/utils/Votes.sol
--- governance/utils/Votes.sol 2023-02-27 10:59:32.655891529 +0100
+++ governance/utils/Votes.sol 2023-02-28 16:49:10.421059488 +0100
@@ -35,7 +35,25 @@
bytes32 private constant _DELEGATION_TYPEHASH =
keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
- mapping(address => address) private _delegation;
+ // HARNESS : Hooks cannot access any information from Checkpoints yet, so I am also updating votes and fromBlock in this struct
+ struct Ckpt {
+ uint32 fromBlock;
+ uint224 votes;
+ }
+ mapping(address => Ckpt) public _checkpoints;
+
+ // HARNESSED getters
+ function numCheckpoints(address account) public view returns (uint32) {
+ return SafeCast.toUint32(_delegateCheckpoints[account]._checkpoints.length);
+ }
+ function ckptFromBlock(address account, uint32 pos) public view returns (uint32) {
+ return _delegateCheckpoints[account]._checkpoints[pos]._key;
+ }
+ function ckptVotes(address account, uint32 pos) public view returns (uint224) {
+ return _delegateCheckpoints[account]._checkpoints[pos]._value;
+ }
+
+ mapping(address => address) public _delegation; // HARNESS: private -> public
/// @custom:oz-retyped-from mapping(address => Checkpoints.History)
mapping(address => Checkpoints.Trace224) private _delegateCheckpoints;
@@ -240,5 +258,5 @@
/**
* @dev Must return the voting units held by an account.
*/
- function _getVotingUnits(address) internal view virtual returns (uint256);
+ function _getVotingUnits(address) public view virtual returns (uint256); // HARNESS: internal -> public
}
diff -druN proxy/utils/Initializable.sol proxy/utils/Initializable.sol
--- proxy/utils/Initializable.sol 2023-02-27 10:59:32.655891529 +0100
+++ proxy/utils/Initializable.sol 2023-02-28 16:49:10.421059488 +0100
@@ -60,12 +60,12 @@
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
- uint8 private _initialized;
+ uint8 internal _initialized; // HARNESS: private -> internal
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
- bool private _initializing;
+ bool internal _initializing; // HARNESS: private -> internal
/**
* @dev Triggered when the contract has been initialized or reinitialized.
diff -druN token/ERC1155/ERC1155.sol token/ERC1155/ERC1155.sol
--- token/ERC1155/ERC1155.sol 2023-02-27 10:59:32.655891529 +0100
+++ token/ERC1155/ERC1155.sol 2023-02-28 16:49:10.421059488 +0100
@@ -21,7 +21,7 @@
using Address for address;
// Mapping from token ID to account balances
- mapping(uint256 => mapping(address => uint256)) private _balances;
+ mapping(uint256 => mapping(address => uint256)) internal _balances; // HARNESS: private -> internal
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
@@ -451,7 +451,7 @@
uint256 id,
uint256 amount,
bytes memory data
- ) private {
+ ) public { // HARNESS: private -> public
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
@@ -472,7 +472,7 @@
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
- ) private {
+ ) public { // HARNESS: private -> public
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
diff -druN token/ERC20/ERC20.sol token/ERC20/ERC20.sol
--- token/ERC20/ERC20.sol 2023-02-27 10:59:32.655891529 +0100
+++ token/ERC20/ERC20.sol 2023-02-28 16:49:10.421059488 +0100
@@ -248,7 +248,7 @@
*
* - `account` cannot be the zero address.
*/
- function _mint(address account, uint256 amount) internal virtual {
+ function _mint(address account, uint256 amount) public virtual { // HARNESS: internal -> public
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
@@ -274,7 +274,7 @@
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
- function _burn(address account, uint256 amount) internal virtual {
+ function _burn(address account, uint256 amount) public virtual { // HARNESS: internal -> public
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
diff -druN token/ERC20/extensions/ERC20Capped.sol token/ERC20/extensions/ERC20Capped.sol
--- token/ERC20/extensions/ERC20Capped.sol 2023-02-22 15:43:36.624717708 +0100
+++ token/ERC20/extensions/ERC20Capped.sol 2023-02-28 16:49:10.421059488 +0100
@@ -30,7 +30,7 @@
/**
* @dev See {ERC20-_mint}.
*/
- function _mint(address account, uint256 amount) internal virtual override {
+ function _mint(address account, uint256 amount) public virtual override { // HARNESS: internal -> public
require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded");
super._mint(account, amount);
}
diff -druN token/ERC20/extensions/ERC20FlashMint.sol token/ERC20/extensions/ERC20FlashMint.sol
--- token/ERC20/extensions/ERC20FlashMint.sol 2023-02-27 10:59:32.655891529 +0100
+++ token/ERC20/extensions/ERC20FlashMint.sol 2023-02-28 16:49:10.421059488 +0100
@@ -53,9 +53,11 @@
// silence warning about unused variable without the addition of bytecode.
token;
amount;
- return 0;
+ return fee; // HARNESS: made "return" nonzero
}
+ uint256 public fee; // HARNESS: added it to simulate random fee amount
+
/**
* @dev Returns the receiver address of the flash fee. By default this
* implementation returns the address(0) which means the fee amount will be burnt.
diff -druN token/ERC20/extensions/ERC20Votes.sol token/ERC20/extensions/ERC20Votes.sol
--- token/ERC20/extensions/ERC20Votes.sol 2023-02-27 10:59:32.655891529 +0100
+++ token/ERC20/extensions/ERC20Votes.sol 2023-02-28 16:49:10.421059488 +0100
@@ -33,8 +33,8 @@
bytes32 private constant _DELEGATION_TYPEHASH =
keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
- mapping(address => address) private _delegates;
- mapping(address => Checkpoint[]) private _checkpoints;
+ mapping(address => address) public _delegates; // HARNESS: private -> public
+ mapping(address => Checkpoint[]) public _checkpoints; // HARNESS: private -> public
Checkpoint[] private _totalSupplyCheckpoints;
/**
@@ -186,27 +186,27 @@
/**
* @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1).
*/
- function _maxSupply() internal view virtual returns (uint224) {
+ function _maxSupply() public view virtual returns (uint224) { // HARNESS: internal -> public
return type(uint224).max;
}
/**
* @dev Snapshots the totalSupply after it has been increased.
*/
- function _mint(address account, uint256 amount) internal virtual override {
+ function _mint(address account, uint256 amount) public virtual override { // HARNESS: internal -> public
super._mint(account, amount);
require(totalSupply() <= _maxSupply(), "ERC20Votes: total supply risks overflowing votes");
- _writeCheckpoint(_totalSupplyCheckpoints, _add, amount);
+ _writeCheckpointAdd(_totalSupplyCheckpoints, amount); // HARNESS: new version without pointer
}
/**
* @dev Snapshots the totalSupply after it has been decreased.
*/
- function _burn(address account, uint256 amount) internal virtual override {
+ function _burn(address account, uint256 amount) public virtual override { // HARNESS: internal -> public (to comply with the ERC20 harness)
super._burn(account, amount);
- _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount);
+ _writeCheckpointSub(_totalSupplyCheckpoints, amount); // HARNESS: new version without pointer
}
/**
@@ -225,7 +225,7 @@
*
* Emits events {IVotes-DelegateChanged} and {IVotes-DelegateVotesChanged}.
*/
- function _delegate(address delegator, address delegatee) internal virtual {
+ function _delegate(address delegator, address delegatee) public virtual { // HARNESS: internal -> public
address currentDelegate = delegates(delegator);
uint256 delegatorBalance = balanceOf(delegator);
_delegates[delegator] = delegatee;
@@ -238,35 +238,60 @@
function _moveVotingPower(address src, address dst, uint256 amount) private {
if (src != dst && amount > 0) {
if (src != address(0)) {
- (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], _subtract, amount);
+ (uint256 oldWeight, uint256 newWeight) = _writeCheckpointSub(_checkpoints[src], amount); // HARNESS: new version without pointer
emit DelegateVotesChanged(src, oldWeight, newWeight);
}
if (dst != address(0)) {
- (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount);
+ (uint256 oldWeight, uint256 newWeight) = _writeCheckpointAdd(_checkpoints[dst], amount); // HARNESS: new version without pointer
emit DelegateVotesChanged(dst, oldWeight, newWeight);
}
}
}
- function _writeCheckpoint(
- Checkpoint[] storage ckpts,
- function(uint256, uint256) view returns (uint256) op,
- uint256 delta
- ) private returns (uint256 oldWeight, uint256 newWeight) {
+ // HARNESS: split _writeCheckpoint() to two functions as a workaround for function pointers that cannot be managed by the tool
+ // function _writeCheckpoint(
+ // Checkpoint[] storage ckpts,
+ // function(uint256, uint256) view returns (uint256) op,
+ // uint256 delta
+ // ) private returns (uint256 oldWeight, uint256 newWeight) {
+ // uint256 pos = ckpts.length;
+
+ // unchecked {
+ // Checkpoint memory oldCkpt = pos == 0 ? Checkpoint(0, 0) : _unsafeAccess(ckpts, pos - 1);
+
+ // oldWeight = oldCkpt.votes;
+ // newWeight = op(oldWeight, delta);
+
+ // if (pos > 0 && oldCkpt.fromBlock == clock()) {
+ // _unsafeAccess(ckpts, pos - 1).votes = SafeCast.toUint224(newWeight);
+ // } else {
+ // ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(clock()), votes: SafeCast.toUint224(newWeight)}));
+ // }
+ // }
+ // }
+
+ function _writeCheckpointAdd(Checkpoint[] storage ckpts, uint256 delta) private returns (uint256 oldWeight, uint256 newWeight) {
uint256 pos = ckpts.length;
+ oldWeight = pos == 0 ? 0 : ckpts[pos - 1].votes;
+ newWeight = _add(oldWeight, delta);
- unchecked {
- Checkpoint memory oldCkpt = pos == 0 ? Checkpoint(0, 0) : _unsafeAccess(ckpts, pos - 1);
+ if (pos > 0 && ckpts[pos - 1].fromBlock == clock()) {
+ ckpts[pos - 1].votes = SafeCast.toUint224(newWeight);
+ } else {
+ ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(clock()), votes: SafeCast.toUint224(newWeight)}));
+ }
+ }
- oldWeight = oldCkpt.votes;
- newWeight = op(oldWeight, delta);
+ function _writeCheckpointSub(Checkpoint[] storage ckpts, uint256 delta) private returns (uint256 oldWeight, uint256 newWeight) {
+ uint256 pos = ckpts.length;
+ oldWeight = pos == 0 ? 0 : ckpts[pos - 1].votes;
+ newWeight = _subtract(oldWeight, delta);
- if (pos > 0 && oldCkpt.fromBlock == clock()) {
- _unsafeAccess(ckpts, pos - 1).votes = SafeCast.toUint224(newWeight);
- } else {
- ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(clock()), votes: SafeCast.toUint224(newWeight)}));
- }
+ if (pos > 0 && ckpts[pos - 1].fromBlock == clock()) {
+ ckpts[pos - 1].votes = SafeCast.toUint224(newWeight);
+ } else {
+ ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(clock()), votes: SafeCast.toUint224(newWeight)}));
}
}
diff -druN token/ERC20/extensions/ERC20Wrapper.sol token/ERC20/extensions/ERC20Wrapper.sol
--- token/ERC20/extensions/ERC20Wrapper.sol 2023-02-27 10:59:32.655891529 +0100
+++ token/ERC20/extensions/ERC20Wrapper.sol 2023-02-28 16:49:10.421059488 +0100
@@ -62,7 +62,7 @@
* @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake. Internal
* function that can be exposed with access control if desired.
*/
- function _recover(address account) internal virtual returns (uint256) {
+ function _recover(address account) public virtual returns (uint256) { // HARNESS: internal -> public
uint256 value = _underlying.balanceOf(address(this)) - totalSupply();
_mint(account, value);
return value;
diff -druN token/ERC721/extensions/ERC721Votes.sol token/ERC721/extensions/ERC721Votes.sol
--- token/ERC721/extensions/ERC721Votes.sol 2023-02-27 10:59:32.655891529 +0100
+++ token/ERC721/extensions/ERC721Votes.sol 2023-02-28 16:49:10.421059488 +0100
@@ -35,7 +35,7 @@
/**
* @dev Returns the balance of `account`.
*/
- function _getVotingUnits(address account) internal view virtual override returns (uint256) {
+ function _getVotingUnits(address account) public view virtual override returns (uint256) { // HARNESS: internal -> public
return balanceOf(account);
}
}
diff -druN utils/Address.sol utils/Address.sol
--- utils/Address.sol 2023-02-27 10:59:32.659224903 +0100
+++ utils/Address.sol 2023-02-28 16:49:10.421059488 +0100
@@ -197,7 +197,7 @@
bool success,
bytes memory returndata,
string memory errorMessage
- ) internal view returns (bytes memory) {
+ ) internal view returns (bytes memory val) { // MUNGED undeterministic return causes error for Prover
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
@@ -220,7 +220,7 @@
bool success,
bytes memory returndata,
string memory errorMessage
- ) internal pure returns (bytes memory) {
+ ) internal pure returns (bytes memory val) { // MUNGED undeterministic return causes error for Prover
if (success) {
return returndata;
} else {
diff -druN utils/Checkpoints.sol utils/Checkpoints.sol
--- utils/Checkpoints.sol 2023-02-27 10:59:32.659224903 +0100
+++ utils/Checkpoints.sol 2023-02-28 16:49:10.424392833 +0100
@@ -84,13 +84,13 @@
*
* Returns previous value and new value.
*/
- function push(
- History storage self,
- function(uint256, uint256) view returns (uint256) op,
- uint256 delta
- ) internal returns (uint256, uint256) {
- return push(self, op(latest(self), delta));
- }
+ // function push(
+ // History storage self,
+ // function(uint256, uint256) view returns (uint256) op,
+ // uint256 delta
+ // ) internal returns (uint256, uint256) {
+ // return push(self, op(latest(self), delta));
+ // }
/**
* @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.

View File

@ -1,97 +0,0 @@
--- access/manager/AccessManager.sol 2023-10-05 12:17:09.694051809 -0300
+++ access/manager/AccessManager.sol 2023-10-05 12:26:18.498688718 -0300
@@ -6,7 +6,6 @@
import {IAccessManaged} from "./IAccessManaged.sol";
import {Address} from "../../utils/Address.sol";
import {Context} from "../../utils/Context.sol";
-import {Multicall} from "../../utils/Multicall.sol";
import {Math} from "../../utils/math/Math.sol";
import {Time} from "../../utils/types/Time.sol";
@@ -57,7 +56,8 @@
* mindful of the danger associated with functions such as {{Ownable-renounceOwnership}} or
* {{AccessControl-renounceRole}}.
*/
-contract AccessManager is Context, Multicall, IAccessManager {
+// NOTE: The FV version of this contract doesn't include Multicall because CVL HAVOCs on any `delegatecall`.
+contract AccessManager is Context, IAccessManager {
using Time for *;
// Structure that stores the details for a target contract.
@@ -105,7 +105,7 @@
// Used to identify operations that are currently being executed via {execute}.
// This should be transient storage when supported by the EVM.
- bytes32 private _executionId;
+ bytes32 internal _executionId; // private → internal for FV
/**
* @dev Check that the caller is authorized to perform the operation, following the restrictions encoded in
@@ -253,6 +253,11 @@
_setGrantDelay(roleId, newDelay);
}
+ // Exposed for FV
+ function _getTargetAdminDelayFull(address target) internal view virtual returns (uint32, uint32, uint48) {
+ return _targets[target].adminDelay.getFull();
+ }
+
/**
* @dev Internal version of {grantRole} without access control. Returns true if the role was newly granted.
*
@@ -287,6 +292,11 @@
return newMember;
}
+ // Exposed for FV
+ function _getRoleGrantDelayFull(uint64 roleId) internal view virtual returns (uint32, uint32, uint48) {
+ return _roles[roleId].grantDelay.getFull();
+ }
+
/**
* @dev Internal version of {revokeRole} without access control. This logic is also used by {renounceRole}.
* Returns true if the role was previously granted.
@@ -586,7 +596,7 @@
/**
* @dev Check if the current call is authorized according to admin logic.
*/
- function _checkAuthorized() private {
+ function _checkAuthorized() internal virtual { // private → internal virtual for FV
address caller = _msgSender();
(bool immediate, uint32 delay) = _canCallSelf(caller, _msgData());
if (!immediate) {
@@ -609,7 +619,7 @@
*/
function _getAdminRestrictions(
bytes calldata data
- ) private view returns (bool adminRestricted, uint64 roleAdminId, uint32 executionDelay) {
+ ) internal view returns (bool adminRestricted, uint64 roleAdminId, uint32 executionDelay) { // private → internal for FV
if (data.length < 4) {
return (false, 0, 0);
}
@@ -662,7 +672,7 @@
address caller,
address target,
bytes calldata data
- ) private view returns (bool immediate, uint32 delay) {
+ ) internal view returns (bool immediate, uint32 delay) { // private → internal for FV
if (target == address(this)) {
return _canCallSelf(caller, data);
} else {
@@ -716,14 +726,14 @@
/**
* @dev Extracts the selector from calldata. Panics if data is not at least 4 bytes
*/
- function _checkSelector(bytes calldata data) private pure returns (bytes4) {
+ function _checkSelector(bytes calldata data) internal pure returns (bytes4) { // private → internal for FV
return bytes4(data[0:4]);
}
/**
* @dev Hashing function for execute protection
*/
- function _hashExecutionId(address target, bytes4 selector) private pure returns (bytes32) {
+ function _hashExecutionId(address target, bytes4 selector) internal pure returns (bytes32) { // private → internal for FV
return keccak256(abi.encode(target, selector));
}
}

View File

@ -1,46 +0,0 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {AccessControlDefaultAdminRules} from "../patched/access/extensions/AccessControlDefaultAdminRules.sol";
contract AccessControlDefaultAdminRulesHarness is AccessControlDefaultAdminRules {
uint48 private _delayIncreaseWait;
constructor(
uint48 initialDelay,
address initialDefaultAdmin,
uint48 delayIncreaseWait
) AccessControlDefaultAdminRules(initialDelay, initialDefaultAdmin) {
_delayIncreaseWait = delayIncreaseWait;
}
// FV
function pendingDefaultAdmin_() external view returns (address) {
(address newAdmin, ) = pendingDefaultAdmin();
return newAdmin;
}
function pendingDefaultAdminSchedule_() external view returns (uint48) {
(, uint48 schedule) = pendingDefaultAdmin();
return schedule;
}
function pendingDelay_() external view returns (uint48) {
(uint48 newDelay, ) = pendingDefaultAdminDelay();
return newDelay;
}
function pendingDelaySchedule_() external view returns (uint48) {
(, uint48 schedule) = pendingDefaultAdminDelay();
return schedule;
}
function delayChangeWait_(uint48 newDelay) external view returns (uint48) {
return _delayChangeWait(newDelay);
}
// Overrides
function defaultAdminDelayIncreaseWait() public view override returns (uint48) {
return _delayIncreaseWait;
}
}

View File

@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol)
import {AccessControl} from "../patched/access/AccessControl.sol";
pragma solidity ^0.8.0;
import "../munged/access/AccessControl.sol";
contract AccessControlHarness is AccessControl {}

View File

@ -1,36 +0,0 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "../patched/access/manager/IAccessManager.sol";
import "../patched/access/manager/AccessManaged.sol";
contract AccessManagedHarness is AccessManaged {
bytes internal SOME_FUNCTION_CALLDATA = abi.encodeCall(this.someFunction, ());
constructor(address initialAuthority) AccessManaged(initialAuthority) {}
function someFunction() public restricted() {
// Sanity for FV: the msg.data when calling this function should be the same as the data used when checking
// the schedule. This is a reformulation of `msg.data == SOME_FUNCTION_CALLDATA` that focuses on the operation
// hash for this call.
require(
IAccessManager(authority()).hashOperation(_msgSender(), address(this), msg.data)
==
IAccessManager(authority()).hashOperation(_msgSender(), address(this), SOME_FUNCTION_CALLDATA)
);
}
function authority_canCall_immediate(address caller) public view returns (bool result) {
(result,) = AuthorityUtils.canCallWithDelay(authority(), caller, address(this), this.someFunction.selector);
}
function authority_canCall_delay(address caller) public view returns (uint32 result) {
(,result) = AuthorityUtils.canCallWithDelay(authority(), caller, address(this), this.someFunction.selector);
}
function authority_getSchedule(address caller) public view returns (uint48) {
IAccessManager manager = IAccessManager(authority());
return manager.getSchedule(manager.hashOperation(caller, address(this), SOME_FUNCTION_CALLDATA));
}
}

View File

@ -1,116 +0,0 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "../patched/access/manager/AccessManager.sol";
contract AccessManagerHarness is AccessManager {
// override with a storage slot that can basically take any value.
uint32 private _minSetback;
constructor(address initialAdmin) AccessManager(initialAdmin) {}
// FV
function minSetback() public view override returns (uint32) {
return _minSetback;
}
function canCall_immediate(address caller, address target, bytes4 selector) external view returns (bool result) {
(result,) = canCall(caller, target, selector);
}
function canCall_delay(address caller, address target, bytes4 selector) external view returns (uint32 result) {
(,result) = canCall(caller, target, selector);
}
function canCallExtended(address caller, address target, bytes calldata data) external view returns (bool, uint32) {
return _canCallExtended(caller, target, data);
}
function canCallExtended_immediate(address caller, address target, bytes calldata data) external view returns (bool result) {
(result,) = _canCallExtended(caller, target, data);
}
function canCallExtended_delay(address caller, address target, bytes calldata data) external view returns (uint32 result) {
(,result) = _canCallExtended(caller, target, data);
}
function getAdminRestrictions_restricted(bytes calldata data) external view returns (bool result) {
(result,,) = _getAdminRestrictions(data);
}
function getAdminRestrictions_roleAdminId(bytes calldata data) external view returns (uint64 result) {
(,result,) = _getAdminRestrictions(data);
}
function getAdminRestrictions_executionDelay(bytes calldata data) external view returns (uint32 result) {
(,,result) = _getAdminRestrictions(data);
}
function hasRole_isMember(uint64 roleId, address account) external view returns (bool result) {
(result,) = hasRole(roleId, account);
}
function hasRole_executionDelay(uint64 roleId, address account) external view returns (uint32 result) {
(,result) = hasRole(roleId, account);
}
function getAccess_since(uint64 roleId, address account) external view returns (uint48 result) {
(result,,,) = getAccess(roleId, account);
}
function getAccess_currentDelay(uint64 roleId, address account) external view returns (uint32 result) {
(,result,,) = getAccess(roleId, account);
}
function getAccess_pendingDelay(uint64 roleId, address account) external view returns (uint32 result) {
(,,result,) = getAccess(roleId, account);
}
function getAccess_effect(uint64 roleId, address account) external view returns (uint48 result) {
(,,,result) = getAccess(roleId, account);
}
function getTargetAdminDelay_after(address target) public view virtual returns (uint32 result) {
(,result,) = _getTargetAdminDelayFull(target);
}
function getTargetAdminDelay_effect(address target) public view virtual returns (uint48 result) {
(,,result) = _getTargetAdminDelayFull(target);
}
function getRoleGrantDelay_after(uint64 roleId) public view virtual returns (uint32 result) {
(,result,) = _getRoleGrantDelayFull(roleId);
}
function getRoleGrantDelay_effect(uint64 roleId) public view virtual returns (uint48 result) {
(,,result) = _getRoleGrantDelayFull(roleId);
}
function hashExecutionId(address target, bytes4 selector) external pure returns (bytes32) {
return _hashExecutionId(target, selector);
}
function executionId() external view returns (bytes32) {
return _executionId;
}
// Pad with zeros (and don't revert) if data is too short.
function getSelector(bytes calldata data) external pure returns (bytes4) {
return bytes4(data);
}
function getFirstArgumentAsAddress(bytes calldata data) external pure returns (address) {
return abi.decode(data[0x04:0x24], (address));
}
function getFirstArgumentAsUint64(bytes calldata data) external pure returns (uint64) {
return abi.decode(data[0x04:0x24], (uint64));
}
function _checkAuthorized() internal override {
// We need this hack otherwise certora will assume _checkSelector(_msgData()) can return anything :/
require(msg.sig == _checkSelector(_msgData()));
super._checkAuthorized();
}
}

View File

@ -1,58 +0,0 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {DoubleEndedQueue} from "../patched/utils/structs/DoubleEndedQueue.sol";
contract DoubleEndedQueueHarness {
using DoubleEndedQueue for DoubleEndedQueue.Bytes32Deque;
DoubleEndedQueue.Bytes32Deque private _deque;
function pushFront(bytes32 value) external {
_deque.pushFront(value);
}
function pushBack(bytes32 value) external {
_deque.pushBack(value);
}
function popFront() external returns (bytes32 value) {
return _deque.popFront();
}
function popBack() external returns (bytes32 value) {
return _deque.popBack();
}
function clear() external {
_deque.clear();
}
function begin() external view returns (uint128) {
return _deque._begin;
}
function end() external view returns (uint128) {
return _deque._end;
}
function length() external view returns (uint256) {
return _deque.length();
}
function empty() external view returns (bool) {
return _deque.empty();
}
function front() external view returns (bytes32 value) {
return _deque.front();
}
function back() external view returns (bytes32 value) {
return _deque.back();
}
function at_(uint256 index) external view returns (bytes32 value) {
return _deque.at(index);
}
}

View File

@ -0,0 +1,5 @@
import "../../munged/token/ERC1155/extensions/ERC1155Burnable.sol";
contract ERC1155BurnableHarness is ERC1155Burnable {
constructor(string memory uri_) ERC1155(uri_) {}
}

View File

@ -0,0 +1,41 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
import "../../munged/token/ERC1155/ERC1155.sol";
contract ERC1155Harness is ERC1155 {
constructor(string memory uri_) ERC1155(uri_) {}
function burn(
address from,
uint256 id,
uint256 amount
) public virtual {
_burn(from, id, amount);
}
function burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) public virtual {
_burnBatch(from, ids, amounts);
}
function mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual {
_mint(to, id, amount, data);
}
function mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual {
_mintBatch(to, ids, amounts, data);
}
}

View File

@ -0,0 +1,17 @@
import "../../munged/token/ERC1155/extensions/ERC1155Pausable.sol";
contract ERC1155PausableHarness is ERC1155Pausable {
constructor(string memory uri_) ERC1155(uri_) {}
function pause() public {
_pause();
}
function unpause() public {
_unpause();
}
function onlyWhenPausedMethod() public whenPaused {}
function onlyWhenNotPausedMethod() public whenNotPaused {}
}

View File

@ -0,0 +1,65 @@
import "../../munged/token/ERC1155/extensions/ERC1155Supply.sol";
contract ERC1155SupplyHarness is ERC1155Supply {
address public owner;
constructor(string memory uri_) ERC1155(uri_) {
owner = msg.sender;
}
// workaround for problem caused by `exists` being a CVL keyword
function exists_wrapper(uint256 id) public view virtual returns (bool) {
return exists(id);
}
// These rules were not implemented in the base but there are changes in supply
// that are affected by the internal contracts so we implemented them. We assume
// only the owner can call any of these functions to be able to test them but also
// limit false positives.
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function burn(
address from,
uint256 id,
uint256 amount
) public virtual onlyOwner {
_burn(from, id, amount);
}
function burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) public virtual onlyOwner {
_burnBatch(from, ids, amounts);
}
function mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual onlyOwner {
_mint(to, id, amount, data);
}
function mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual onlyOwner {
_mintBatch(to, ids, amounts, data);
}
// In order to check the invariant that zero address never holds any tokens, we need to remove the require
// from this function.
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
// require(account != address(0), "ERC1155: address zero is not a valid owner");
return _balances[id][account];
}
}

View File

@ -1,36 +1,5 @@
// SPDX-License-Identifier: MIT
import "../munged/token/ERC20/extensions/ERC20FlashMint.sol";
pragma solidity ^0.8.20;
import "../patched/token/ERC20/ERC20.sol";
import "../patched/token/ERC20/extensions/ERC20Permit.sol";
import "../patched/token/ERC20/extensions/ERC20FlashMint.sol";
contract ERC20FlashMintHarness is ERC20, ERC20Permit, ERC20FlashMint {
uint256 someFee;
address someFeeReceiver;
constructor(string memory name, string memory symbol) ERC20(name, symbol) ERC20Permit(name) {}
function mint(address account, uint256 amount) external {
_mint(account, amount);
}
function burn(address account, uint256 amount) external {
_burn(account, amount);
}
// public accessor
function flashFeeReceiver() public view returns (address) {
return someFeeReceiver;
}
// internal hook
function _flashFee(address, uint256) internal view override returns (uint256) {
return someFee;
}
function _flashFeeReceiver() internal view override returns (address) {
return someFeeReceiver;
}
contract ERC20FlashMintHarness is ERC20FlashMint {
constructor(string memory name, string memory symbol) ERC20(name, symbol) {}
}

View File

@ -1,16 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "../munged/token/ERC20/extensions/draft-ERC20Permit.sol";
import {ERC20Permit, ERC20} from "../patched/token/ERC20/extensions/ERC20Permit.sol";
contract ERC20PermitHarness is ERC20Permit {
contract ERC20PermitHarness is ERC20, ERC20Permit {
constructor(string memory name, string memory symbol) ERC20(name, symbol) ERC20Permit(name) {}
function mint(address account, uint256 amount) external {
_mint(account, amount);
}
function burn(address account, uint256 amount) external {
_burn(account, amount);
}
}

View File

@ -0,0 +1,26 @@
import "../munged/token/ERC20/extensions/ERC20Votes.sol";
contract ERC20VotesHarness is ERC20Votes {
constructor(string memory name, string memory symbol) ERC20(name, symbol) ERC20Permit(name) {}
function ckptFromBlock(address account, uint32 pos) public view returns (uint32) {
return _checkpoints[account][pos].fromBlock;
}
function ckptVotes(address account, uint32 pos) public view returns (uint224) {
return _checkpoints[account][pos].fromBlock;
}
function unsafeNumCheckpoints(address account) public view returns (uint256) {
return _checkpoints[account].length;
}
function delegateBySig(
address delegatee,
uint256 nonce,
uint256 expiry,
uint8 v,
bytes32 r,
bytes32 s
) public virtual override {}
}

View File

@ -1,16 +1,11 @@
// SPDX-License-Identifier: MIT
import "../munged/token/ERC20/extensions/ERC20Wrapper.sol";
pragma solidity ^0.8.20;
import {ERC20Permit} from "../patched/token/ERC20/extensions/ERC20Permit.sol";
import {ERC20Wrapper, IERC20, ERC20} from "../patched/token/ERC20/extensions/ERC20Wrapper.sol";
contract ERC20WrapperHarness is ERC20Permit, ERC20Wrapper {
contract ERC20WrapperHarness is ERC20Wrapper {
constructor(
IERC20 _underlying,
string memory _name,
string memory _symbol
) ERC20(_name, _symbol) ERC20Permit(_name) ERC20Wrapper(_underlying) {}
) ERC20(_name, _symbol) ERC20Wrapper(_underlying) {}
function underlyingTotalSupply() public view returns (uint256) {
return underlying().totalSupply();
@ -19,16 +14,4 @@ contract ERC20WrapperHarness is ERC20Permit, ERC20Wrapper {
function underlyingBalanceOf(address account) public view returns (uint256) {
return underlying().balanceOf(account);
}
function underlyingAllowanceToThis(address account) public view returns (uint256) {
return underlying().allowance(account, address(this));
}
function recover(address account) public returns (uint256) {
return _recover(account);
}
function decimals() public view override(ERC20Wrapper, ERC20) returns (uint8) {
return super.decimals();
}
}

View File

@ -1,13 +0,0 @@
// SPDX-License-Identifier: MIT
import {IERC3156FlashBorrower} from "../patched/interfaces/IERC3156FlashBorrower.sol";
pragma solidity ^0.8.20;
contract ERC3156FlashBorrowerHarness is IERC3156FlashBorrower {
bytes32 somethingToReturn;
function onFlashLoan(address, address, uint256, uint256, bytes calldata) external view override returns (bytes32) {
return somethingToReturn;
}
}

View File

@ -1,33 +0,0 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {ERC721} from "../patched/token/ERC721/ERC721.sol";
contract ERC721Harness is ERC721 {
constructor(string memory name, string memory symbol) ERC721(name, symbol) {}
function mint(address account, uint256 tokenId) external {
_mint(account, tokenId);
}
function safeMint(address to, uint256 tokenId) external {
_safeMint(to, tokenId);
}
function safeMint(address to, uint256 tokenId, bytes memory data) external {
_safeMint(to, tokenId, data);
}
function burn(uint256 tokenId) external {
_burn(tokenId);
}
function unsafeOwnerOf(uint256 tokenId) external view returns (address) {
return _ownerOf(tokenId);
}
function unsafeGetApproved(uint256 tokenId) external view returns (address) {
return _getApproved(tokenId);
}
}

Some files were not shown because too many files have changed in this diff Show More