Configure node deployment
## Set up 1. Create some working directories. The following commands take care of directory placements where non-obvious. 2. Populate the directories by fetchin
Set up
- Create some working directories.
The following commands take care of directory placements where non-obvious.
mkdir -p ~/zkevm/data/{statedb,pooldb} ~/zkevm/zkevm-config ~/zkevm/zkevm-node-
Populate the directories by fetching data from latest mainnet node release.
export ZKEVM_NET="mainnet" export ZKEVM_DIR="zkevm" 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 -
Go to the
zkevm/zkevm-configdirectory and create an.envfile and open it for editing.cd ~/zkevm/zkevm-config/ nano .env -
In the
.envfile, set the following:ZKEVM_NODE_ETHERMAN_URL = "" # set valid Sepolia RPC endpoint ZKEVM_NODE_STATEDB_DATA_DIR = "~/zkevm/data/statedb" ZKEVM_NODE_POOLDB_DATA_DIR = "~/zkevm/data/pooldb"
Workaround if you have configuration issues
- You may have to hardcode these variables into the
mainnet/docker-compose.yamlfile.- Also, the
ZKEVM_NETWORKvariable which you can set tomainnet. - Note, there is more than one reference to hardcode in.
- Also, the
Approve POL token for sequencer
-
Launch a Hardhat console connected to the Sepolia network.
cd ~/zkevm-contracts npx hardhat console --network sepolia -
Add the missing data as directed and copy/paste the following code into the open console.
const provider = ethers.getDefaultProvider("<SEPOLIA_RPC_NODE>"); // set Sepolia RPC node const privateKey = "<TRUSTED_SEQUENCER_PK>"; // from wallets.txt const wallet = new ethers.Wallet(privateKey, provider); const polTokenFactory = await ethers.getContractFactory( "ERC20PermitMock", provider ); polTokenContract = polTokenFactory.attach("<polTokenAddress>"); // from ~/zkevm-contracts/deployments/deploy_output.json polTokenContractWallet = polTokenContract.connect(wallet); await polTokenContractWallet.approve("<polygonZkEVMAddress>", ethers.parseEther("100.0")); // from ~/zkevm-contracts/deployments/deploy_output.json
Configure genesis
-
Copy the
genesis.jsonfile into the appropriate location.cp ~/zkevm-contracts/deployment/v2/genesis.json ~/zkevm/mainnet/config/environments/mainnet/public.genesis.config.json -
Copy/paste the json below to the head of the
public.genesis.config.jsonfile inputting the data from~/zkevm-contracts/deployments/v2/deploy_output.json.
The genesisBlockNumber is called deploymentBlockNumber in deploy_output.json.
"l1Config" : {
"chainId": 11155111,
"polygonZkEVMAddress": "",
"polTokenAddress": "",
"polygonZkEVMGlobalExitRootAddress": ""
},
"genesisBlockNumber": <number-here>, Update node config
Add the following missing parameters to the ~/zkevm/mainnet/config/environments/mainnet/public.node.config.toml file.
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.
ApiKey# for EtherscanURL# for Sepolia node, under [ETHERMAN]
Add wallet keystores
Copy/paste the keystore value from wallets.txt for the sequencer and aggregator respectively into the following files.
nano ~/zkevm/zkevm-config/sequencer.keystore
nano ~/zkevm/zkevm-config/aggregator.keystoreLast updated on
Create wallets
## Set up wallet contracts Clone the wallet contracts from the and install the libraries. ## Create wallets 1. Create a file. 2. Copy/paste the JavaScript code
Configure prover
## Configure prover DB 1. Copy/paste the following script into to replace what's there. 2. Save and exit the file. ## Configure the prover 1. Create a file call