Skip to content

Commit 3dbc015

Browse files
authored
feat: make contracts upgradable (#4)
1 parent 3c545c6 commit 3dbc015

16 files changed

+192
-87
lines changed

.env.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ RLC_OFT_TOKEN_NAME="RLC OFT"
1616
RLC_TOKEN_SYMBOL="RLC"
1717

1818
# Transaction Settings
19-
SENDER_ADDRESS=0x<delegate-wallet-address>
19+
OWNER_ADDRESS=0x<owner-wallet-address>
2020

2121
# API Keys
2222
ETHERSCAN_API_KEY=<your-etherscan-api-key>

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
[submodule "lib/rlc-faucet-contract"]
1111
path = lib/rlc-faucet-contract
1212
url = https://github.com/iExecBlockchainComputing/rlc-faucet-contract
13+
[submodule "lib/openzeppelin-contracts-upgradeable"]
14+
path = lib/openzeppelin-contracts-upgradeable
15+
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
16+
[submodule "lib/openzeppelin-foundry-upgrades"]
17+
path = lib/openzeppelin-foundry-upgrades
18+
url = https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades
1319
[submodule "lib/openzeppelin-contracts"]
1420
path = lib/openzeppelin-contracts
1521
url = https://github.com/OpenZeppelin/openzeppelin-contracts

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ deploy-oft:
2929

3030
configure-adapter:
3131
@echo "Configuring RLCAdapter on SEPOLIA..."
32-
forge script script/ConfigureRLCAdapter.s.sol:Configure \
32+
forge script script/RLCAdapter.s.sol:Configure \
3333
--rpc-url $(SEPOLIA_RPC_URL) \
3434
--account $(ACCOUNT) \
3535
--broadcast \
3636
-vvv
3737
configure-oft:
3838
@echo "Configuring RLCOFT on Arbitrum SEPOLIA..."
39-
forge script script/ConfigureRLCOFT.s.sol:Configure \
39+
forge script script/RLCOFT.s.sol:Configure \
4040
--rpc-url $(ARBITRUM_SEPOLIA_RPC_URL) \
4141
--account $(ACCOUNT) \
4242
--broadcast \
@@ -64,7 +64,7 @@ verify-adapter:
6464
forge verify-contract \
6565
--chain-id 11155111 \
6666
--watch \
67-
--constructor-args $(shell cast abi-encode "constructor(address,address,address)" $(RLC_SEPOLIA_ADDRESS) $(LAYER_ZERO_SEPOLIA_ENDPOINT_ADDRESS) $(SENDER_ADDRESS)) \
67+
--constructor-args $(shell cast abi-encode "constructor(address,address,address)" $(RLC_SEPOLIA_ADDRESS) $(LAYER_ZERO_SEPOLIA_ENDPOINT_ADDRESS) $(OWNER_ADDRESS)) \
6868
--etherscan-api-key $(ETHERSCAN_API_KEY) \
6969
$(RLC_SEPOLIA_ADAPTER_ADDRESS) \
7070
src/RLCAdapter.sol:RLCAdapter
@@ -74,7 +74,7 @@ verify-oft:
7474
forge verify-contract \
7575
--chain-id 421614 \
7676
--watch \
77-
--constructor-args $(shell cast abi-encode "constructor(string,string,address,address)" $(RLC_OFT_TOKEN_NAME) $(RLC_TOKEN_SYMBOL) $(LAYER_ZERO_ARBITRUM_SEPOLIA_ENDPOINT_ADDRESS) $(SENDER_ADDRESS)) \
77+
--constructor-args $(shell cast abi-encode "constructor(string,string,address,address)" $(RLC_OFT_TOKEN_NAME) $(RLC_TOKEN_SYMBOL) $(LAYER_ZERO_ARBITRUM_SEPOLIA_ENDPOINT_ADDRESS) $(OWNER_ADDRESS)) \
7878
--etherscan-api-key $(ARBISCAN_API_KEY) \
7979
$(RLC_ARBITRUM_SEPOLIA_OFT_ADDRESS) \
8080
src/RLCOFT.sol:RLCOFT

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,32 @@ The system consists of two main components:
2020
## Installation
2121

2222
1. Clone the repository
23+
2324
```bash
2425
git clone https://github.com/iExecBlockchainComputing/rlc-multichain.git
2526
cd rlc-multichain
2627
```
2728

2829
2. Install dependencies
30+
2931
```bash
3032
forge install
3133
```
3234

3335
3. Create a `.env` file
36+
3437
```sh
3538
cp .env.template .env # and edit .env content
3639
```
3740

41+
**Note:** To run scripts, you must save a wallet in the Foundry keystore. Use the following command to import a wallet with a raw private key:
42+
43+
```bash
44+
cast wallet import --private-key <RAW_PRIVATE_KEY> <ACCOUNT_NAME>
45+
```
46+
47+
Alternatively, you can use a mnemonic by specifying the `--mnemonic-path` option. Remember the `<ACCOUNT_NAME>` you choose, and set it in your `.env` file under the `ACCOUNT` field.
48+
3849
## Contract Overview
3950

4051
Instead of duplicating code that may become outdated, here are links to the key contracts in the repository:
@@ -47,21 +58,25 @@ Instead of duplicating code that may become outdated, here are links to the key
4758
The deployment process involves four steps:
4859

4960
1. Deploy the RLCAdapter on Ethereum Sepolia:
61+
5062
```bash
5163
make deploy-adapter
5264
```
5365

5466
2. Deploy the RLCOFT on Arbitrum Sepolia:
67+
5568
```bash
5669
make deploy-oft
5770
```
5871

5972
3. Configure the RLCAdapter to trust the RLCOFT contract:
73+
6074
```bash
6175
make configure-adapter
6276
```
6377

6478
4. Configure the RLCOFT to trust the RLCAdapter contract:
79+
6580
```bash
6681
make configure-oft
6782
```
@@ -79,6 +94,7 @@ make send-tokens-to-arbitrum-sepolia
7994
```
8095

8196
This will:
97+
8298
1. Approve the RLCAdapter to spend your RLC tokens
8399
2. Initiate the cross-chain transfer through LayerZero
84100
3. Lock tokens in the adapter and mint equivalent tokens on Arbitrum
@@ -90,6 +106,7 @@ make send-tokens-to-sepolia
90106
```
91107

92108
This will:
109+
93110
1. Burn RLCOFT tokens on Arbitrum
94111
2. Send a cross-chain message to the adapter
95112
3. Release the original RLC tokens on Ethereum
@@ -118,6 +135,7 @@ This will:
118135
## Gas Costs and Fees
119136
120137
LayerZero transactions require fees to cover:
138+
121139
1. Gas on the source chain
122140
2. Gas on the destination chain (prepaid)
123141
3. LayerZero relayer fees
@@ -126,9 +144,8 @@ The scripts automatically calculate these fees and include them in the transacti
126144
127145
## Troubleshooting
128146
129-
130147
## References
131148
132149
- [LayerZero Documentation](https://layerzero.gitbook.io/docs/)
133150
- [OFT Contracts](https://github.com/LayerZero-Labs/solidity-examples/tree/main/contracts/token/oft)
134-
- [iExec Platform Documentation](https://docs.iex.ec/)
151+
- [iExec Platform Documentation](https://docs.iex.ec/)

foundry.toml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,26 @@ src = "src"
33
out = "out"
44
libs = ["lib"]
55
fs_permissions = [{ access = "read-write", path = "./" }]
6+
optimizer = true
7+
optimizer_runs = 200
8+
via_ir = true
9+
10+
## Needed by openzepplin upgrade plugin
11+
ffi = true
12+
ast = true
13+
build_info = true
14+
extra_output = ["storageLayout"]
615

716
remappings = [
17+
'@layerzerolabs/oft-evm-upgradeable/=lib/devtools/packages/oft-evm-upgradeable/',
818
'@layerzerolabs/oft-evm/=lib/devtools/packages/oft-evm/',
19+
'@layerzerolabs/oapp-evm-upgradeable/=lib/devtools/packages/oapp-evm-upgradeable/',
920
'@layerzerolabs/oapp-evm/=lib/devtools/packages/oapp-evm/',
1021
'@layerzerolabs/lz-evm-protocol-v2/=lib/layerzero-v2/packages/layerzero-v2/evm/protocol',
22+
'@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/',
1123
'@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/',
24+
'@openzeppelin-foundry/contracts/=lib/openzeppelin-foundry-upgrades/src/',
1225
]
1326

1427

15-
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
28+
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

lib/openzeppelin-contracts

lib/openzeppelin-foundry-upgrades

script/ConfigureRLCAdapter.s.sol

Lines changed: 0 additions & 25 deletions
This file was deleted.

script/ConfigureRLCOFT.s.sol

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)