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
* add UpgradeV1V2Test: fails
* annotate V2 as an upgrade to V1
* chore: uppercase constants in test
* upgrade v1 v2 fails: InvalidInitialization
* UpgradeV1V2 works
* add test_postUpgrade basic steps
* all AnlogTokenV2 tests also to run after upgrade
* add script/01_Upgrade.V1.V2.s.sol
* neat readme
* better title
Copy file name to clipboardExpand all lines: README.md
+47-63Lines changed: 47 additions & 63 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
> While this upgradeable token smart contract is built using [audited OZ libraries](https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/tree/v5.2.0/audits),
4
4
> **this particular implementation has not yet underwent any security audits. Use at your own risk.**
5
5
6
-
# $ANLOG ERC20 Token
6
+
# `$WANLOG`: Wrapped `ANLOG` ERC20 Token
7
7
8
8
## Initial Requirements
9
9
@@ -49,16 +49,8 @@ This project is built with the [Foundry](https://book.getfoundry.sh/) framework.
49
49
50
50
## Testing
51
51
52
-
If changed some contract, run this first:
53
-
54
-
```sh
55
-
forge fmt && forge clean && forge build
56
-
```
57
-
58
-
Then run tests:
59
-
60
52
```sh
61
-
forge test
53
+
forge fmt && forge clean && forge tests
62
54
```
63
55
64
56
## Deployment
@@ -68,54 +60,37 @@ forge test
68
60
<details>
69
61
<summary>Expand me</summary>
70
62
71
-
Spin out a default [Anvil](https://book.getfoundry.sh/anvil/) node:
63
+
Load environment variables:
72
64
73
65
```sh
74
-
anvil -p 9545
66
+
source .env.anvil
75
67
```
76
68
77
-
Load environment variables and run the deployment script:
69
+
Spin out an [Anvil](https://book.getfoundry.sh/anvil/) fork of Sepolia:
It will ask you to enter the private key. As we're using Anvil's default `account (0)` as the deployer (specified in the [`.env.anvil`](./.env.anvil)), use its (**!well-known!**) key here (can be found in Anvil logs).
85
82
86
83
</details>
87
84
88
-
### To Sepolia testnet
85
+
### To Sepolia
89
86
90
-
> [!IMPORTANT]
91
-
> You need to setup environment first, see [`.env.sepolia.example`](./.env.sepolia.example)
Figure out `solc` version used to compile the contracts:
135
110
@@ -153,37 +128,46 @@ forge v --verifier etherscan --compiler-version=<solc_version> \
153
128
src/AnlogTokenV1.sol:AnlogTokenV1
154
129
```
155
130
156
-
###Upgrade instructions
131
+
## Upgrade
157
132
158
133
> [!NOTE]
159
-
> Commands below are given for the setting when you upgrade from `V0` to `V1Upgrade`. See [`Upgrade.V0.V1.t.sol`](test/Upgrade.V0.V1.t.sol) for the reference.
134
+
> Commands below are given for the setting when you upgrade from `V1` to `V2`.
135
+
> Also see [`Upgrade.V1.V2.t.sol` test](test/Upgrade.V0.V1.t.sol) for the reference.
136
+
137
+
*Prerequisites*: you have `V1` deployed.
138
+
139
+
### Locally to Anvil
140
+
141
+
<details>
142
+
<summary>Expand me</summary>
160
143
144
+
Load environment variables:
161
145
162
-
Let say you have deployed proxy and `V0` implementation contract for it.
163
-
To upgrade the implementation contract to `V1Upgrade`:
146
+
```sh
147
+
source .env.anvil
148
+
```
149
+
150
+
First spin out a local anvil and deploy `V1` to it by following instructions above.
151
+
152
+
Then set `PROXY` environment variable to the address of the deployed proxy.
It will ask you to enter the private key. As we're using Anvil's default `account (2)` as the `UPGRADER` (specified in the [`.env.anvil`](./.env.anvil)), use its (**!well-known!**) key here (can be found in Anvil logs).
161
+
162
+
</details>
174
163
175
-
**NOTE** that we provided `0x,0x,0x,0x` to the constructor args. That is because we don't care on the values of the implementation contract storage. The proxy storage will be updated in the following `initialize()` call right after the upgrade.
176
164
177
-
2. Prepare `calldata` for `V1Upgrade` initializer:
You should get hex-encoded `calldata` as the result.
167
+
In a live network, most probably a multisig is used for the `UPGRADER` account. Thus for doing an upgrade,
184
168
185
-
3. Dispatch the call to [`upgradeToAndCall(address,bytes)`](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/332bcb5f4d9cf0ae0f98fe91c77d9c1fb9951506/contracts/proxy/ERC1967/ERC1967Utils.sol#L67), providing the following args:
169
+
dispatch the call to [`upgradeToAndCall(address,bytes)`](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/332bcb5f4d9cf0ae0f98fe91c77d9c1fb9951506/contracts/proxy/ERC1967/ERC1967Utils.sol#L67), providing the following args:
186
170
187
-
-**address**: current (`V0`) implementation contract address;
188
-
-**bytes**: `calldata` for the `V1Upgrade` implementation contract initializer
189
-
(the one you've got on the previous step).
171
+
- **address**: current (`V1`) implementation contract address;
172
+
- **bytes**: (empty) (this is `calldata` for the `V2` implementation contract initializer, which we don't need for this upgrade).
173
+
**note** for the cases when you need it, look at this [commit](https://github.com/Analog-Labs/erc20-token/blob/2c6025e8099966194ed006c25f1a79b5cabfa0df/README.md#upgrade-instructions) for the instructions of how to calculate it.
0 commit comments