|
| 1 | +## Set up |
| 2 | + |
| 3 | +1. Create some working directories. |
| 4 | + |
| 5 | + !!! info |
| 6 | + The following commands take care of directory placements where non-obvious. |
| 7 | + |
| 8 | + ```sh |
| 9 | + mkdir -p ~/zkevm/data/{statedb,pooldb} ~/zkevm/zkevm-config ~/zkevm/zkevm-node |
| 10 | + ``` |
| 11 | + |
| 12 | +2. Populate the directories by fetching data from latest mainnet node release. |
| 13 | + |
| 14 | + ```sh |
| 15 | + export ZKEVM_NET="mainnet" |
| 16 | + export ZKEVM_DIR="zkevm" |
| 17 | + curl -L https://github.com/0xPolygonHermez/zkevm-node/releases/latest/download/$ZKEVM_NET.zip > $ZKEVM_NET.zip && unzip -o $ZKEVM_NET.zip -d $ZKEVM_DIR && rm $ZKEVM_NET.zip |
| 18 | + ``` |
| 19 | + |
| 20 | +3. Go to the `zkevm/zkevm-config` directory and create an `.env` file and open it for editing. |
| 21 | + |
| 22 | + ```sh |
| 23 | + cd ../zkevm-config/ |
| 24 | + nano .env |
| 25 | + ``` |
| 26 | + |
| 27 | +4. In the `.env` file, set the following: |
| 28 | + |
| 29 | + ```sh |
| 30 | + ZKEVM_NODE_ETHERMAN_URL = "" # set valid Goerli RPC endpoint |
| 31 | + ZKEVM_NODE_STATEDB_DATA_DIR = "~/zkevm/data/statedb" |
| 32 | + ZKEVM_NODE_POOLDB_DATA_DIR = "~/zkevm/data/pooldb" |
| 33 | + ``` |
| 34 | + |
| 35 | + !!! warning |
| 36 | + - You may have to hardcode these variables into the `mainnet/docker-compose.yaml` file. |
| 37 | + - Also, the `ZKEVM_NETWORK` variable which you can set to `mainnet`. |
| 38 | + - Note, there are more than one references to hardcode in. |
| 39 | + |
| 40 | +## Approve MATIC token for sequencer |
| 41 | + |
| 42 | +1. Launch a Hardhat console connected to the Goerli network. |
| 43 | + |
| 44 | + ```sh |
| 45 | + cd ~/zkevm-contracts |
| 46 | + npx hardhat console --network goerli |
| 47 | + ``` |
| 48 | + |
| 49 | +2. Add the missing data as directed and copy/paste the following code into the open console. |
| 50 | + |
| 51 | + ```js |
| 52 | + const provider = ethers.getDefaultProvider("<GOERLI_RPC_NODE>"); // set Goerli RPC node |
| 53 | + const privateKey = "<TRUSTED_SEQUENCER_PK>"; // from wallets.txt |
| 54 | + const wallet = new ethers.Wallet(privateKey, provider); |
| 55 | +
|
| 56 | + const maticTokenFactory = await ethers.getContractFactory( |
| 57 | + "ERC20PermitMock", |
| 58 | + provider |
| 59 | + ); |
| 60 | + maticTokenContract = maticTokenFactory.attach("<maticTokenAddress>"); // from ~/zkevm-contracts/deployments/deploy_output.json |
| 61 | + maticTokenContractWallet = maticTokenContract.connect(wallet); |
| 62 | + await maticTokenContractWallet.approve("<polygonZkEVMAddress>", ethers.utils.parseEther("100.0")); // from ~/zkevm-contracts/deployments/deploy_output.json |
| 63 | + ``` |
| 64 | + |
| 65 | +## Configure genesis |
| 66 | + |
| 67 | +1. Copy the `genesis.json` file into the appropriate location. |
| 68 | + |
| 69 | + ```sh |
| 70 | + cp ~/zkevm-contracts/deployment/genesis.json ~/zkevm/mainnet/config/environments/mainnet/public.genesis.config.json |
| 71 | + ``` |
| 72 | + |
| 73 | +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`. |
| 74 | + |
| 75 | + !!! important |
| 76 | + The `genesisBlockNumber` is called `deploymentBlockNumber` in `deploy_output.json`. |
| 77 | + |
| 78 | + ```json |
| 79 | + "l1Config" : { |
| 80 | + "chainId": 5, |
| 81 | + "polygonZkEVMAddress": "", |
| 82 | + "maticTokenAddress": "", |
| 83 | + "polygonZkEVMGlobalExitRootAddress": "" |
| 84 | + }, |
| 85 | + "genesisBlockNumber": <number-here>, |
| 86 | + ``` |
| 87 | + |
| 88 | +## Update node config |
| 89 | + |
| 90 | +Add the missing parameters in the `~/zkevm/mainnet/config/environments/mainnet/public.node.config.toml` file. |
| 91 | + |
| 92 | +!!! warning |
| 93 | + Rename the file if necessary. |
| 94 | + |
| 95 | +- `ApiKey` # for Etherscan |
| 96 | +- `URL` # for Goerli node, under [ETHERMAN] |
| 97 | + |
| 98 | +## Add wallet keystores |
| 99 | + |
| 100 | +Copy/paste the keystore value from `wallets.txt` for the sequencer and aggregator respectively into the following files. |
| 101 | + |
| 102 | +```sh |
| 103 | +# paste only the keystore value from wallets.txt in each respective file |
| 104 | +nano ~/zkevm/zkevm-config/sequencer.keystore |
| 105 | +nano ~/zkevm/zkevm-config/aggregator.keystore |
| 106 | +``` |
0 commit comments