File tree Expand file tree Collapse file tree 4 files changed +58
-1
lines changed
CVLByExample/ExtensionContracts Expand file tree Collapse file tree 4 files changed +58
-1
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "files": [
3+ "OverrideExtended.sol:Extended",
4+ "OverrideExtended.sol:Extender",
5+ ],
6+ "solc": "solc8.25",
7+ "verify": "Extended:OverrideExtended.spec",
8+ "contract_extensions": {
9+ "Extended": [
10+ {
11+ "extension": "Extender",
12+ "exclude": [],
13+ },
14+ ],
15+ },
16+ "contract_extensions_override": true,
17+ }
Original file line number Diff line number Diff line change 1+ contract Extended {
2+ function foo () external returns (string memory ) {
3+ return "Extended.foo " ;
4+ }
5+
6+ function bar () external returns (string memory ) {
7+ return "Extended.bar " ;
8+ }
9+ }
10+
11+ contract Extender {
12+ function foo () external returns (string memory ) {
13+ return "Extender.foo " ;
14+ }
15+ }
Original file line number Diff line number Diff line change 1+ using Extended as Extended ;
2+
3+ rule overriddenReplaced {
4+ env e ;
5+ assert Extended .foo (e ) == "Extender.foo" ;
6+ }
7+
8+ rule notOverriddenNotReplaced {
9+ env e ;
10+ assert Extended .bar (e ) == "Extended.bar" ;
11+ }
12+
13+ use builtin rule sanity ;
Original file line number Diff line number Diff line change @@ -56,4 +56,16 @@ Some more details:
5656Run this example using:
5757``` certoraRun ExtensionContracts.conf ```
5858
59- [ Report of this run] ( https://vaas-stg.certora.com/output/15800/8de64e410516472cbc8f7d6317059680?anonymousKey=b4b480e8209e59136b4daa281aa5159a1fc66fd1 )
59+ [ Report of this run] ( https://vaas-stg.certora.com/output/15800/8de64e410516472cbc8f7d6317059680?anonymousKey=b4b480e8209e59136b4daa281aa5159a1fc66fd1 )
60+
61+ ## Extension Contracts Override
62+
63+ There are implementations of the proxy pattern in which the base contract actually has implementations for all the functions
64+ that are implemented by the extension contracts - all they do is delegatecall the corresponding function in the extension contract. In this case
65+ an extra flag needs to be set in order to avoid the Prover failing to "transfer" the functions from the extension contract into the
66+ base one: ` --contract_extensions_override ` .
67+
68+ You can see adn run an example of this with
69+ ``` certoraRun overrideExtended.conf ```
70+
71+ [ Report of this run] ( https://prover.certora.com/output/97560/68336a8a71aa42b2a66b512810b05b14?anonymousKey=f171bc0ba2d337fc4879f3165215904e72fb7416 )
You can’t perform that action at this time.
0 commit comments