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
1004 changed files with 56544 additions and 80782 deletions

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': patch
---
Add constructors to the different signers.

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

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`AccountERC7579`: Extension of `Account` that implements support for ERC-7579 modules of type executor, validator, and fallback handler.

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

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`Memory`: Add library with utilities to manipulate memory

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
---
`Checkpoints`: Add a new checkpoint variant `Checkpoint256` using `uint256` type for the value and key.

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

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`EnumerableMap`: Add `keys(uint256,uint256)` that returns a subset (slice) of the keys in the map.

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
---
`EIP7702Utils`: Add a library for checking if an address has an EIP-7702 delegation in place.

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

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`Account`: Added a simple ERC-4337 account implementation with minimal logic to process user operations.

View File

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

View File

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

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
---
`EnumerableSet`: Add `values(uint256,uint256)` that returns a subset (slice) of the values in the set.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`SignerERC7702`: Implementation of `AbstractSigner` for Externally Owned Accounts (EOAs). Useful with ERC-7702.

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
---
`EnumerableMap`: Add support for `BytesToBytesMap` type.

View File

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

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`ERC7739`: An abstract contract to validate signatures following the rehashing scheme from `ERC7739Utils`.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`Bytes`: Add `reverseBytes32`, `reverseBytes16`, `reverseBytes8`, `reverseBytes4`, and `reverseBytes2` functions to reverse byte order for converting between little-endian and big-endian representations.

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

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`Strings`: Add `toHexString(bytes)`.

View File

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

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`ERC7913P256Verifier` and `ERC7913RSAVerifier`: Ready to use ERC-7913 verifiers that implement key verification for P256 (secp256r1) and RSA keys.

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': minor
---
`EnumerableSet`: Add support for `StringSet` and `BytesSet` types.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`GovernorNoncesKeyed`: Extension of `Governor` that adds support for keyed nonces when voting by sig.

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
---
`ERC7739Utils`: Add a library that implements a defensive rehashing mechanism to prevent replayability of smart contract signatures based on the ERC-7739.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`MultiSignerERC7913Weighted`: Extension of `MultiSignerERC7913` that supports assigning different weights to each signer, enabling more flexible governance schemes.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`SignerERC7913`: Abstract signer that verifies signatures using the ERC-7913 workflow.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`Arrays`: Add `unsafeAccess`, `unsafeMemoryAccess` and `unsafeSetLength` for `bytes[]` and `string[]`.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`InteroperableAddress`: Add a library for formatting and parsing ERC-7930 interoperable addresses.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`ERC20Bridgeable`: Implementation of ERC-7802 that makes an ERC-20 compatible with crosschain bridges.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`IERC7821`, `ERC7821`: Interface and logic for minimal batch execution. No support for additional `opData` is included.

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

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

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`MultiSignerERC7913`: Implementation of `AbstractSigner` that supports multiple ERC-7913 signers with a threshold-based signature verification system.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`SignatureChecker`: Add support for ERC-7913 signatures alongside existing ECDSA and ERC-1271 signature verification.

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

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`AccountERC7579Hooked`: Extension of `AccountERC7579` that implements support for ERC-7579 hook modules.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`AbstractSigner`, `SignerECDSA`, `SignerP256`, and `SignerRSA`: Add an abstract contract and various implementations for contracts that deal with signature verification.

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

@ -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

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`ECDSA`: Add `recoverCalldata` and `tryRecoverCalldata`, variants of `recover` and `tryRecover` that are more efficient when signatures are in calldata.

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
---
`Blockhash`: Add a library that provides access to historical block hashes using EIP-2935's history storage, extending the standard 256-block limit to 8191 blocks.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`SignatureChecker`: Add `isValidSignatureNowCalldata(address,bytes32,bytes calldata)` for efficient processing of calldata signatures.

View File

@ -1,5 +0,0 @@
---
'openzeppelin-solidity': minor
---
`IERC7786`: Add the (draft) interface for ERC-7786 "Cross-Chain Messaging Gateway"

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",
}
}

10
.github/CODEOWNERS vendored
View File

@ -1,10 +0,0 @@
# List of approvers/reviewers for OpenZeppelin Contracts
#
# Get in touch with us via the OpenZeppelin Forum
# https://forum.openzeppelin.com/
#
# Learn about CODEOWNERS file format:
# https://help.github.com/en/articles/about-code-owners
# These owners will be the default owners for everything in the repo.
* @OpenZeppelin/contracts

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,19 +1,18 @@
name: Compare gas costs
description: Compare gas costs between branches
inputs:
token:
description: GitHub token, required to access GitHub API
description: github token
required: true
report:
description: Path to the report to compare
description: report to read from
required: false
default: gasReporterOutput.json
out_report:
description: Path to save the output report
description: report to read
required: false
default: ${{ github.ref_name }}.gasreport.json
ref_report:
description: Path to the reference report for comparison
description: report to read from
required: false
default: ${{ github.base_ref }}.gasreport.json
@ -44,8 +43,7 @@ runs:
shell: bash
- name: Save report
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: gasreport
overwrite: true
path: ${{ inputs.out_report }}

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: 22.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: stable
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
@ -50,8 +49,7 @@ runs:
shell: bash
- name: Save artifacts
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: layout
overwrite: true
path: ${{ inputs.out_layout }}

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,104 +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 validity
run: npm run test:pragma -- --concurrency 1
- name: Check procedurally generated contracts are up-to-date
- 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 validity
run: npm run test:pragma -- --concurrency 1
- 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 -vvv
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@v5
- 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
- uses: crytic/slither-action@v0.4.1
- run: rm foundry.toml
- 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@v4
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 })
@ -131,11 +131,10 @@ jobs:
environment: npm
permissions:
contents: write
id-token: write
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
@ -144,19 +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 }}
NPM_CONFIG_PROVENANCE: true
- 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:
@ -169,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
@ -188,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 }}" } }'

10
.gitignore vendored
View File

@ -29,15 +29,20 @@ npm-debug.log
# local env variables
.env
# truffle build directory
build/
# macOS
.DS_Store
# truffle
.node-xmlhttprequest-*
# IntelliJ IDE
.idea
# docs artifacts
docs/modules/api
build/site
# only used to package @openzeppelin/contracts
contracts/build/
@ -58,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

@ -1,2 +0,0 @@
npm run test:generation
npx lint-staged

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

@ -2,548 +2,6 @@
### Breaking changes
- Update minimum pragma to 0.8.24 in `SignatureChecker`, `Governor` and Governor's extensions. ([#5716](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5716)).
## 5.3.0 (2025-04-09)
### Breaking Changes
- Replace `GovernorCountingOverridable.VoteReceipt` struct parameter member names `hasOverriden` and `overridenWeight` for `hasOverridden` and `overriddenWeight` respectively.
#### Custom error changes
- Replace `GovernorAlreadyOverridenVote` with `GovernorAlreadyOverriddenVote`.
- Replace `GovernorOnlyProposer` with `GovernorUnableToCancel`.
### Changes by category
#### Account
- `ERC4337Utils`: Update the `hash` function to call `getUserOpHash` on the specified entrypoint and add an `ENTRYPOINT_V08` constant. ([#5614](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5614))
- `ERC7579Utils`: Add ABI decoding checks on calldata bounds within `decodeBatch`. ([#5371](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5371))
- `ERC7579Utils`: Replace `address(0)` with `address(this)` during execution for calldata compression efficiency. ([#5614](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5614))
#### Governance
- `IGovernor`: Add the `getProposalId` function to the governor interface. ([#5290](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5290))
- `GovernorProposalGuardian`: Add a governance extension that defines a proposal guardian who can cancel proposals at any stage in their lifecycle. ([#5303](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5303))
- `GovernorSequentialProposalId`: Adds a `Governor` extension that sequentially numbers proposal ids instead of using the hash. ([#5290](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5290))
- `GovernorSuperQuorum`: Add a governance extension to support a super quorum. Proposals that meet the super quorum (and have a majority of for votes) advance to the `Succeeded` state before the proposal deadline. ([#5526](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5526))
- `GovernorVotesSuperQuorumFraction`: Add a variant of the `GovernorSuperQuorum` extensions where the super quorum is expressed as a fraction of the total supply. ([#5526](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5526))
- `TimelockController`: Receive function is now virtual. ([#5509](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5509))
#### Structures
- `EnumerableSet`: Add `clear` function to EnumerableSets which deletes all values in the set. ([#5486](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5486))
- `EnumerableMap`: Add `clear` function to EnumerableMaps which deletes all entries in the map. ([#5486](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5486))
- `MerkleTree`: Add an update function that replaces a previously inserted leaf with a new value, updating the tree root along the way. ([#5526](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5526))
#### Tokens
- `ERC4626`: Use the `asset` getter in `totalAssets`, `_deposit` and `_withdraw`. ([#5322](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5322))
- `IERC6909`: Add the interface for ERC-6909. ([#5343](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5343))
- `ERC6909`: Add a standard implementation of ERC6909. ([#5394](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5394))
- `ERC6909TokenSupply`: Add an extension of ERC6909 which tracks total supply for each token id. ([#5394](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5394))
- `ERC6909Metadata`: Add an extension of ERC6909 which adds metadata functionality. ([#5394](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5394))
- `ERC6909ContentURI`: Add an extension of ERC6909 which adds content URI functionality. ([#5394](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5394))
- `SafeERC20`: Add `trySafeTransfer` and `trySafeTransferFrom` that do not revert and return false if the transfer is not successful. ([#5483](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5483))
#### Other
- `Address`: bubble up revert data on `sendValue` failed call. ([#5379](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5379))
- `Calldata`: Library with `emptyBytes` and `emptyString` functions to generate empty `bytes` and `string` calldata types. ([#5422](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5422))
- `ERC2771Forwarder`: Expose the `_isTrustedByTarget` internal function to check whether a target trusts the forwarder. ([#5416](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5416))
- `Hashes`: Expose `efficientKeccak256` for hashing non-commutative pairs of bytes32 without allocating extra memory. ([#5442](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5442))
- `Initializable`: Add `_initializableStorageSlot` function that returns a pointer to the storage struct. The function allows customizing with a custom storage slot with an `override`. ([#5526](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5526))
- `Math`: Add `add512`, `mul512` and `mulShr`. ([#5526](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5526))
- `Math`: Add saturating arithmetic operations `saturatingAdd`, `saturatingSub` and `saturatingMul`. ([#5526](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5526))
- `MessageHashUtils`: Add `toDataWithIntendedValidatorHash(address, bytes32)`. ([#5526](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5526))
- `P256`: Adjust precompile detection in `verifyNative` to consider empty `returndata` on invalid verification. Previously, invalid signatures would've reverted with a `MissingPrecompile` error in chains with RIP-7212 support. ([#5620](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5620))
- `Pausable`: Stop explicitly setting `paused` to `false` during construction. ([#5448](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5448))
- `Strings`: Add `espaceJSON` that escapes special characters in JSON strings. ([#5526](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5526))
## 5.2.0 (2025-01-08)
### Breaking Changes
#### 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 `Errors.FailedCall` with a bubbled-up revert reason in `Address.sendValue`.
### Changes by category
#### General
- Update some pragma directives to ensure that all file requirements match that of the files they import. ([#5273](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5273))
#### Account
- `ERC4337Utils`: Add a reusable library to manipulate user operations and interact with ERC-4337 contracts ([#5274](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5274))
- `ERC7579Utils`: Add a reusable library to interact with ERC-7579 modular accounts ([#5274](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5274))
#### Governance
- `GovernorCountingOverridable`: Add a governor counting module that enables token holders to override the vote of their delegate. ([#5192](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5192))
- `VotesExtended`: Create an extension of `Votes` which checkpoints balances and delegates. ([#5192](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5192))
### Proxy
- `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. ([#5109](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5109))
### Tokens
- `ERC1363Utils`: Add helper similar to the existing `ERC721Utils` and `ERC1155Utils` ([#5133](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5133))
### Utils
- `Address`: bubble up revert data on `sendValue` failed call ([#5418](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5418))
- `Bytes`: Add a library of common operations that operate on `bytes` objects. ([#5252](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5252))
- `CAIP2` and `CAIP10`: Add libraries for formatting and parsing CAIP-2 and CAIP-10 identifiers. ([#5252](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5252))
- `NoncesKeyed`: Add a variant of `Nonces` that implements the ERC-4337 entrypoint nonce system. ([#5272](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5272))
- `Packing`: Add variants for packing `bytes10` and `bytes22` ([#5274](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5274))
- `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. ([#5166](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5166))
## 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 cast. 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 was changed. This is the case for `Initializable` and all the upgradeable contracts since they now use namespaced storage 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`.
- `EIP712`: Optimization of the cache for the upgradeable version affects the way `name` and `version` are set. This is no longer done through an initializer, and is instead part of the implementation's constructor. As a consequence, all proxies using the same implementation will necessarily share the same `name` and `version`. Additionally, an implementation upgrade risks changing the EIP712 domain unless the same `name` and `version` are used when deploying the new implementation contract.
@ -554,19 +12,6 @@ After 5.0, the storage location of some variables was 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))
@ -867,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,10 +0,0 @@
{
"drips": {
"ethereum": {
"ownedBy": "0xAeb37910f93486C85A1F8F994b67E8187554d664"
}
},
"opRetro": {
"projectId": "0x939241afa4c4b9e1dda6b8250baa8f04fa8b0debce738cfd324c0b18f9926d25"
}
}

View File

@ -6,7 +6,7 @@ Code must be thoroughly tested with quality unit tests.
We defer to the [Moloch Testing Guide](https://github.com/MolochVentures/moloch/tree/master/test#readme) for specific recommendations, though not all of it is relevant here. Note the introduction:
> Tests should be written, not only to verify correctness of the target code, but to be comprehensively reviewed by other programmers. Therefore, for mission critical Solidity code, the quality of the tests is just as important (if not more so) than the code itself, and should be written to the highest standards of clarity and elegance.
> Tests should be written, not only to verify correctness of the target code, but to be comprehensively reviewed by other programmers. Therefore, for mission critical Solidity code, the quality of the tests are just as important (if not more so) than the code itself, and should be written with the highest standards of clarity and elegance.
Every addition or change to the code must come with relevant and comprehensive tests.
@ -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-2025 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

@ -1,11 +1,10 @@
# <img src="logo.svg" alt="OpenZeppelin" height="40px">
[![Github Release](https://img.shields.io/github/v/tag/OpenZeppelin/openzeppelin-contracts.svg?filter=v*&sort=semver&label=github)](https://github.com/OpenZeppelin/openzeppelin-contracts/releases/latest)
[![NPM Package](https://img.shields.io/npm/v/@openzeppelin/contracts.svg)](https://www.npmjs.org/package/@openzeppelin/contracts)
[![Coverage Status](https://codecov.io/gh/OpenZeppelin/openzeppelin-contracts/graph/badge.svg)](https://codecov.io/gh/OpenZeppelin/openzeppelin-contracts)
[![GitPOAPs](https://public-api.gitpoap.io/v1/repo/OpenZeppelin/openzeppelin-contracts/badge)](https://www.gitpoap.io/gh/OpenZeppelin/openzeppelin-contracts)
[![Docs](https://img.shields.io/badge/docs-%F0%9F%93%84-yellow)](https://docs.openzeppelin.com/contracts)
[![Forum](https://img.shields.io/badge/forum-%F0%9F%92%AC-yellow)](https://forum.openzeppelin.com/)
[![Forum](https://img.shields.io/badge/forum-%F0%9F%92%AC-yellow)](https://docs.openzeppelin.com/contracts)
**A library for secure smart contract development.** Build on a solid foundation of community-vetted code.
@ -15,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") {
@ -71,9 +55,9 @@ The guides in the [documentation site](https://docs.openzeppelin.com/contracts)
* [Tokens](https://docs.openzeppelin.com/contracts/tokens): create tradeable assets or collectives, and distribute them via [Crowdsales](https://docs.openzeppelin.com/contracts/crowdsales).
* [Utilities](https://docs.openzeppelin.com/contracts/utilities): generic useful tools including non-overflowing math, signature verification, and trustless paying systems.
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' development in the [community forum](https://forum.openzeppelin.com).
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.
@ -83,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,10 +1,12 @@
# Releasing
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 consistent and reliable.
> 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
[Changesets](https://github.com/changesets/changesets/) are used as part of our release process for `CHANGELOG.md` management. Each change that is relevant for the codebase is expected to include a changeset.
[Changesets](https://github.com/changesets/changesets/) is used as part of our release process for `CHANGELOG.md` management. Each change that is relevant for the codebase is expected to include a changeset.
## Branching model

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
Blockchain is a nascent technology and carries a high level of risk and uncertainty. OpenZeppelin makes certain software available under open source licenses, which disclaim all warranties in relation to the project and which limits the liability of OpenZeppelin. Subject to any particular licensing terms, your use of the project is governed by the terms found at [www.openzeppelin.com/tos](https://www.openzeppelin.com/tos) (the "Terms"). As set out in the Terms, you are solely responsible for any use of the project and you assume all risks associated with any such use. This Security Policy in no way evidences or represents an ongoing duty by any contributor, including OpenZeppelin, to correct any issues or vulnerabilities or alert you to all or any of the 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.

View File

@ -20,7 +20,7 @@ The git commit hash we evaluated is:
# Disclaimer
The audit makes no statements or warranties about utility of the code, safety of the code, suitability of the business model, regulatory regime for the business model, or any other statements about fitness of the contracts to purpose, or their bug free status. The audit documentation is for discussion purposes only.
The audit makes no statements or warrantees about utility of the code, safety of the code, suitability of the business model, regulatory regime for the business model, or any other statements about fitness of the contracts to purpose, or their bugfree status. The audit documentation is for discussion purposes only.
# Executive Summary
@ -90,7 +90,7 @@ We are still working through the confirmation protocol in `Shareable.sol`, but w
This bug has a number of causes that need to be addressed:
1. `resetSpentToday` and `confirm` together do not limit the days on which the function can be called or (it appears) the number of times it can be called.
1. Once a call has been confirmed and executed it appears that it can be re-executed. This is not good.
1. Once a call has been confirmed and `execute`d it appears that it can be re-executed. This is not good.
3. `confirmandCheck` doesn't seem to have logic about whether or not the function in question has been called.
4. Even if it did, `revoke` would need updates and logic to deal with revocation requests after a function call had been completed.
@ -109,7 +109,7 @@ It would be nice to see how many payments are pending. This would imply a bit of
## Shareable Contract
We do not believe the `Shareable.sol` contract is ready for prime time. It is missing functions, and as written may be vulnerable to a reordering attack -- an attack in which a miner or other party "racing" with a smart contract participant inserts their own information into a list or mapping.
We do not believe the `Shareable.sol` contract is ready for primetime. It is missing functions, and as written may be vulnerable to a reordering attack -- an attack in which a miner or other party "racing" with a smart contract participant inserts their own information into a list or mapping.
The confirmation and revocation code needs to be looked over with a very careful eye imagining extraordinarily bad behavior by shared owners before this contract can be called safe.
@ -159,7 +159,7 @@ Allows owner to set a public string of contract information. No issues.
This needs some work. Doesn't check if `_required <= len(_owners)` for instance, that would be a bummer. What if _required were like `MAX - 1`?
I have a general concern about the difference between `owners`, `_owners`, and `owner` in `Ownable.sol`. I recommend "Owners" be renamed. In general we do not recommend single character differences in variable names, although a preceding underscore is not uncommon in Solidity code.
I have a general concern about the difference between `owners`, `_owners`, and `owner` in `Ownable.sol`. I recommend "Owners" be renamed. In general we do not recomment single character differences in variable names, although a preceding underscore is not uncommon in Solidity code.
Line 34: "this contract only has six types of events"...actually only two.
@ -224,7 +224,7 @@ Transfer() and transferFrom() use SafeMath functions, which will cause them to t
### SimpleToken
Sample instantiation of StandardToken. Note that in this sample, decimals is 18 and supply is only 10,000, so the supply is a small fraction of a single nominal token.
Sample instantiation of StandardToken. Note that in this sample, decimals is 18 and supply only 10,000, so the supply is a small fraction of a single nominal token.
### CrowdsaleToken

Binary file not shown.

Binary file not shown.

Binary file not shown.

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