Skip to content

Commit 7b9d80a

Browse files
committed
update CDK/zkEVM: Roll up deploy tutorial from Goerli to Sepolia
1 parent 4db52dd commit 7b9d80a

File tree

7 files changed

+102
-54
lines changed

7 files changed

+102
-54
lines changed

docs/zkEVM/get-started/setup-nodes/deploy-zkevm/configure-node-deployment.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,50 +31,62 @@ comments: true
3131
4. In the `.env` file, set the following:
3232

3333
```sh
34-
ZKEVM_NODE_ETHERMAN_URL = "" # set valid Goerli RPC endpoint
34+
ZKEVM_NODE_ETHERMAN_URL = "" # set valid Sepolia RPC endpoint
3535
ZKEVM_NODE_STATEDB_DATA_DIR = "~/zkevm/data/statedb"
3636
ZKEVM_NODE_POOLDB_DATA_DIR = "~/zkevm/data/pooldb"
3737
```
3838

3939
!!! warning "Workaround if you have configuration issues"
4040
- You may have to hardcode these variables into the `mainnet/docker-compose.yaml` file.
41-
- Also, the `ZKEVM_NETWORK` variable which you can set to `mainnet`.
42-
- Note, there are more than one references to hardcode in.
41+
- Also, the `ZKEVM_NETWORK` variable which you can set to `mainnet`.
42+
- Note, there are more than one references to hardcode in.
4343

44-
## Approve MATIC token for sequencer
44+
## Approve POL token for sequencer
4545

46-
1. Launch a Hardhat console connected to the Goerli network.
46+
1. Launch a Hardhat console connected to the Sepolia network.
4747

4848
```sh
4949
cd ~/zkevm-contracts
50-
npx hardhat console --network goerli
50+
npx hardhat console --network sepolia
5151
```
5252

5353
2. Add the missing data as directed and copy/paste the following code into the open console.
5454

5555
```js
56-
const provider = ethers.getDefaultProvider("<GOERLI_RPC_NODE>"); // set Goerli RPC node
56+
const provider = ethers.getDefaultProvider("https://sepolia.drpc.org"); // set Sepolia RPC node
57+
const privateKey = "0xdd3ddb7e864207f6c11ed73348221823eccb8e872d2d6f3103df6f32b284a15a"; // from wallets.txt
58+
const wallet = new ethers.Wallet(privateKey, provider);
59+
60+
const polTokenFactory = await ethers.getContractFactory(
61+
"ERC20PermitMock",
62+
provider
63+
);
64+
polTokenContract = polTokenFactory.attach("0x2B2Ef864542EA38657221393B0A18215e5c3fc7e"); // from ~/zkevm-contracts/deployments/deploy_output.json
65+
polTokenContractWallet = polTokenContract.connect(wallet);
66+
await polTokenContractWallet.approve("0x702394d505ABC47cEd3F4D2CD04453719A9168cc", ethers.parseEther("100.0")); // from ~/zkevm-contracts/deployments/deploy_output.json
67+
68+
const provider = ethers.getDefaultProvider("<SEPOLIA_RPC_NODE>"); // set Sepolia RPC node
5769
const privateKey = "<TRUSTED_SEQUENCER_PK>"; // from wallets.txt
5870
const wallet = new ethers.Wallet(privateKey, provider);
59-
60-
const maticTokenFactory = await ethers.getContractFactory(
71+
72+
const polTokenFactory = await ethers.getContractFactory(
6173
"ERC20PermitMock",
6274
provider
6375
);
64-
maticTokenContract = maticTokenFactory.attach("<maticTokenAddress>"); // from ~/zkevm-contracts/deployments/deploy_output.json
65-
maticTokenContractWallet = maticTokenContract.connect(wallet);
66-
await maticTokenContractWallet.approve("<polygonZkEVMAddress>", ethers.utils.parseEther("100.0")); // from ~/zkevm-contracts/deployments/deploy_output.json
76+
polTokenContract = polTokenFactory.attach("<polTokenAddress>"); // from ~/zkevm-contracts/deployments/deploy_output.json
77+
polTokenContractWallet = polTokenContract.connect(wallet);
78+
await polTokenContractWallet.approve("<polygonZkEVMAddress>", ethers.parseEther("100.0")); // from ~/zkevm-contracts/deployments/deploy_output.json
6779
```
6880

6981
## Configure genesis
7082

7183
1. Copy the `genesis.json` file into the appropriate location.
7284

7385
```sh
74-
cp ~/zkevm-contracts/deployment/genesis.json ~/zkevm/mainnet/config/environments/mainnet/public.genesis.config.json
86+
cp ~/zkevm-contracts/deployment/v2/genesis.json ~/zkevm/mainnet/config/environments/mainnet/public.genesis.config.json
7587
```
7688

77-
2. Copy/paste the json below to the head of the `public.genesis.config.json` file inputting the data from `~/zkevm/zkevm-contracts/deployments/deploy_output.json`.
89+
2. Copy/paste the json below to the head of the `public.genesis.config.json` file inputting the data from `~/zkevm-contracts/deployments/v2/deploy_output.json`.
7890

7991
!!! important
8092
The `genesisBlockNumber` is called `deploymentBlockNumber` in `deploy_output.json`.
@@ -83,7 +95,7 @@ comments: true
8395
"l1Config" : {
8496
"chainId": 5,
8597
"polygonZkEVMAddress": "",
86-
"maticTokenAddress": "",
98+
"polTokenAddress": "",
8799
"polygonZkEVMGlobalExitRootAddress": ""
88100
},
89101
"genesisBlockNumber": <number-here>,
@@ -97,7 +109,7 @@ Add the following missing parameters to the `~/zkevm/mainnet/config/environments
97109
If you're having trouble locating the configuration file, try looking for `node.config.toml`, since it may exist under that name in some cases. Once you've added the missing parameters, rename the file to `public.node.config.toml`.
98110

99111
- `ApiKey` # for Etherscan
100-
- `URL` # for Goerli node, under [ETHERMAN]
112+
- `URL` # for Sepolia node, under [ETHERMAN]
101113

102114
## Add wallet keystores
103115

docs/zkEVM/get-started/setup-nodes/deploy-zkevm/create-wallets.md

Lines changed: 67 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Clone the wallet contracts from the [`zkevm-contracts` repository](https://githu
88

99
```sh
1010
git clone https://github.com/0xPolygonHermez/zkevm-contracts.git
11-
cd ~/zkevm-contracts
11+
cd zkevm-contracts
1212
npm i
1313
```
1414

@@ -17,7 +17,7 @@ npm i
1717
1. Create a `wallets.js` file.
1818

1919
```sh
20-
cd ~/zkevm-contracts
20+
cd zkevm-contracts
2121
nano wallets.js
2222
```
2323

@@ -36,8 +36,8 @@ npm i
3636
const wallet = ethers.Wallet.createRandom();
3737
console.log(arrayNames[i]);
3838
console.log(`Address: ${wallet.address}`);
39-
console.log(`PrvKey: ${wallet._signingKey().privateKey}`);
40-
console.log(`mnemonic: "${wallet._mnemonic().phrase}"`);
39+
console.log(`PrvKey: ${wallet.privateKey}`);
40+
console.log(`mnemonic: "${wallet.mnemonic.phrase}"`);
4141
4242
const keystoreJson = await wallet.encrypt("password");
4343
console.log(`keystore: ${keystoreJson}`);
@@ -73,14 +73,14 @@ npm i
7373
ETHERSCAN_API_KEY="..." # your Etherscan API key
7474
```
7575
76-
3. Send 0.5 Sepolia ETH to the deployment address wallet listed in `wallets.txt`.
76+
3. Send 1 Sepolia ETH to the deployment address wallet listed in `wallets.txt`.
7777
7878
## Edit deployment configuration
7979
8080
1. Open the `deploy-parameters.json` file.
8181
8282
```sh
83-
cd ~/zkevm-contracts/deployment
83+
cd zkevm-contracts/deployment/v2
8484
cp deploy_parameters.json.example deploy_parameters.json
8585
nano deploy_parameters.json
8686
```
@@ -94,39 +94,75 @@ npm i
9494
- `timelockAddress`: deployment address in `wallets.txt`.
9595
- `initialZkEVMDeployerAddress`: deployment address in `wallets.txt`.
9696
- `zkEVMDeployerAddress`: deployment address in `wallets.txt`.
97+
- `emergencyCouncilAddress`: deployment address in `wallets.txt`.
98+
- `deployerPvtKey`: deployment private key in `wallets.txt`.
9799
98-
## Deploy contracts
100+
3. Open the `create_rollup_parameters.json` file.
99101
100-
1. `cd` back to `zkevm-contract` root directory and run the deployment scripts.
102+
```bash
103+
cd zkevm-contracts/deployment/v2
104+
cp create_rollup_parameters.json.example create_rollup_parameters.json
105+
vim create_rollup_parameters.json
106+
```
101107
102-
!!! tip
103-
It might be helpful to run these one at a time.
108+
4. Edit the following parameters to match the rollup parameters
104109
105-
```sh
106-
cd ..
107-
npm i @openzeppelin/hardhat-upgrades
108-
npm run deploy:deployer:ZkEVM:goerli
109-
npm run verify:deployer:ZkEVM:goerli
110-
npm run prepare:testnet:ZkEVM:goerli && npm run deploy:ZkEVM:test:goerli
111-
npm run verify:ZkEVM:goerli
112-
```
110+
- `trustedSequencer`: trusted sequencer address in `wallets.txt`.
111+
- `adminZkEVM`: deployment address in `wallets.txt`.
113112
114-
You should see output that looks something like this at the start each time:
113+
## Deploy & verify contracts
115114
116-
```sh
117-
> @0xpolygonhermez/zkevm-contracts@3.0.0 deploy:deployer:ZkEVM:goerli
118-
> npx hardhat run deployment/2_deployPolygonZKEVMDeployer.js --network goerli
115+
`cd` back to `zkevm-contract` root directory and run the deployment scripts.
119116
120-
#######################
117+
1. Install Hardhat
121118
122-
polygonZkEVMDeployer deployed on: 0x8c4e69A65f84D5Ee0d83095916706Be74C133571
123-
```
119+
```
120+
cd ..
121+
npm i @openzeppelin/hardhat-upgrades
122+
```
123+
124+
2. Deploy Polygon ZKEVM Deployer
125+
126+
```bash
127+
npx hardhat run deployment/v2/2_deployPolygonZKEVMDeployer.ts --network sepolia
128+
```
129+
130+
You should see output that looks like this:
131+
132+
```bash
133+
#######################
134+
135+
polygonZkEVMDeployer deployed on: 0xB1A5BA61fBAD71Ba52d70B769d6A994c01b40983
136+
```
137+
138+
3. Verify Deployer
139+
140+
```bash
141+
npx hardhat run deployment/v2/verifyzkEVMDeployer.js --network sepolia
142+
```
143+
144+
You should see ouput that looks like this:
145+
146+
```bash
147+
The contract 0xB1A5BA61fBAD71Ba52d70B769d6A994c01b40983 has already been verified.
148+
https://sepolia.etherscan.io/address/0xB1A5BA61fBAD71Ba52d70B769d6A994c01b40983#code
149+
```
150+
151+
4. Prepare Testnet
152+
153+
```bash
154+
npx hardhat run deployment/testnet/prepareTestnet.ts --network sepolia
155+
```
156+
157+
You should see output that looks like this:
124158
125-
!!! info
126-
The scripts auto-deploy the MATIC token contract and the `zkEVMDeployer` contract if required.
159+
```bash
160+
#######################
161+
162+
pol deployed to: 0x2B2Ef864542EA38657221393B0A18215e5c3fc7e
163+
```
127164
128-
2. Check the deployment was successful on Etherscan.
165+
And now if you go to sepolia scan, you should also see that under your account, there's a new `Pol` Erc-20 token created with the balance of `19,900,000` tokens.
129166
130-
```html
131-
https://goerli.etherscan.io/address/[deployment-address] <!-- from `wallets.txt` -->
132-
```
167+
!!! info
168+
The scripts auto-deploy the MATIC token contract and the `zkEVMDeployer` contract if required.

docs/zkEVM/get-started/setup-nodes/deploy-zkevm/environment-overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ Deploying the full zkEVM stack requires installing and deploying a number of dif
2424
| zkEVM explorer | `zkevm-explorer-l2` | L2 network's block explorer. i.e., The zkRollup Etherscan [explorer](https://zkevm.polygonscan.com). |
2525
| zkEVM explorer DB | `zkevm-explorer-l2-db` | Database for the L2 network's Block explorer. i.e., Where all the zkRollup Etherscan explorer queries are made. |
2626
| Gas pricer | `zkevm-l2gaspricer` | Responsible for suggesting the gas price for the L2 network fees. |
27-
| Goërli execution | `goerli-execution` | L1 node's execution layer. |
28-
| Goërli consensus | `goerli-consensus` | L1 node's consensus layer.
27+
| Sepolia execution | `sepolia-execution` | L1 node's execution layer. |
28+
| Sepolia consensus | `sepolia-consensus` | L1 node's consensus layer.

docs/zkEVM/get-started/setup-nodes/deploy-zkevm/install-dependencies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ newgrp docker && newgrp $USER
2626
```sh
2727
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
2828
source ~/.bashrc
29-
nvm install 16
29+
nvm install 18
3030
node -v
3131
```
3232

docs/zkEVM/get-started/setup-nodes/deploy-zkevm/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
comments: true
33
---
44

5-
This tutorial takes you through the process of deploying a full zkEVM stack on Goerli.
5+
This tutorial takes you through the process of deploying a full zkEVM stack on Sepolia.
66

77
It relies on specific component versions so we have hidden most of the configuration complexity in scripts to make the process straightforward.
88

docs/zkEVM/get-started/setup-nodes/deploy-zkevm/prerequisites.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ The commands on the [install dependencies page](install-dependencies.md) fulfill
3131

3232
- `INFURA_API_KEY`: [Infura](https://infura.io/) API key
3333
- `ETHERSCAN_API_KEY`: [Etherscan](https://etherscan.io/) API key
34-
- Goërli node RPC URL: e.g. https://goerli.infura.io/v3/YOUR-INFURA-API-KEY
35-
- Goërli account address holding minimum 0.5 GoërliETH
34+
- Sepolia node RPC URL: e.g. https://sepolia.infura.io/v3/YOUR-INFURA-API-KEY
35+
- Sepolia account address holding minimum 0.5 SepoliaETH

docs/zkEVM/get-started/setup-nodes/deploy-zkevm/start-node.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ comments: true
77
From the `zkevm` root directory, run the following:
88

99
```sh
10-
docker-compose -f mainnet/docker-compose.yml up
10+
sudo docker-compose -f mainnet/docker-compose.yml up
1111
```
1212

1313
This command spins up the following services:

0 commit comments

Comments
 (0)