You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Motivation**
<!-- Why does this pull request exist? What are its goals? -->
We want the L1 contracts to be upgradeable so it's possible to fix bugs
and introduce new features.
**Description**
<!-- A clear and concise general description of the changes this PR
introduces -->
Changed the contracts to follow the UUPS proxy pattern (from
OpenZeppelin's library). The deployer binary now deploys both the
implementation and the proxy.
<!-- Link to issues: Resolves#111, Resolves#222 -->
There are two L1 contracts: OnChainProposer and CommonBridge. Both contracts are deployed using UUPS proxies, so they are upgradeables.
4
+
5
+
### Upgrade the contracts
6
+
7
+
To upgrade a contract, you have to create the new contract and, as the original one, inherit from OpenZeppelin's `UUPSUpgradeable`. Make sure to implement the `_authorizeUpgrade` function and follow the [proxy pattern restrictions](https://docs.openzeppelin.com/upgrades-plugins/writing-upgradeable).
8
+
9
+
Once you have the new contract, you need to do the following two steps:
10
+
11
+
1. Deploy the new contract
12
+
```sh
13
+
rex deploy <NEW_IMPLEMENTATION_BYTECODE> 0 <DEPLOYER_PRIVATE_KEY>
14
+
```
15
+
2. Upgrade the proxy by calling the method `upgradeToAndCall(address newImplementation, bytes memory data)`. The `data` parameter is the calldata to call on the new implementation as an initialization, you can pass an empty stream.
16
+
```sh
17
+
rex send <PROXY_ADDRESS> 0 <PRIVATE_KEY> -- 'upgradeToAndCall(address,bytes)' 0 <NEW_IMPLEMENTATION_ADDRESS><INITIALIZATION_CALLDATA>
18
+
```
19
+
3. Check the proxy updated the pointed address to the new implementation. It should return the address of the new implementation:
0 commit comments