-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #183 from 0xPolygon/km/cdk-deploy-validium
CDK deploy validium
- Loading branch information
Showing
11 changed files
with
1,013 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
163 changes: 163 additions & 0 deletions
163
docs/cdk/get-started/deploy-validium/contracts/deploy-contracts.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
## Configure deployment parameters | ||
|
||
1. `cd` to the `deployment/` directory and create a new `deploy_parameters.json` by copying the example | ||
|
||
```bash | ||
cd deployment/ | ||
cp deploy_parameters.json.example deploy_parameters.json | ||
``` | ||
|
||
2. Run the following `jq` script to streamline the process of replacing these fields: | ||
|
||
```bash | ||
source /tmp/cdk/.env | ||
jq --arg TEST_ADDRESS "$TEST_ADDRESS" '.trustedSequencerURL = "http://127.0.0.1:8123" | .trustedSequencer = $TEST_ADDRESS | .trustedAggregator = $TEST_ADDRESS | .admin = $TEST_ADDRESS | .cdkValidiumOwner = $TEST_ADDRESS | .initialCDKValidiumDeployerOwner = $TEST_ADDRESS | .timelockAddress = $TEST_ADDRESS | .forkID = 6' ./deploy_parameters.json.example > ./deploy_parameters.json | ||
``` | ||
|
||
3. The complete `deploy_parameters.json` should look something like this, where all the addresses are equal to the generated address except for `maticTokenAddress`: | ||
|
||
```bash | ||
nano ~/cdk-validium/cdk-validium-contracts-0.0.2/deployment/deploy_parameters.json | ||
# ~/cdk-validium/cdk-validium-contracts-0.0.2/deployment/deploy_parameters.json | ||
{ | ||
"realVerifier": false, | ||
"trustedSequencerURL": "http://127.0.0.1:8123, | ||
"networkName": "cdk-validium", | ||
"version":"0.0.1", | ||
"trustedSequencer":"0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", | ||
"chainID": 1001, | ||
"trustedAggregator":"0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", | ||
"trustedAggregatorTimeout": 604799, | ||
"pendingStateTimeout": 604799, | ||
"forkID": 6, | ||
"admin":"0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", | ||
"cdkValidiumOwner": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", | ||
"timelockAddress": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", | ||
"minDelayTimelock": 3600, | ||
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"initialCDKValidiumDeployerOwner" :"0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", | ||
"maticTokenAddress":"0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", | ||
"cdkValidiumDeployerAddress":"", | ||
"deployerPvtKey": "", | ||
"maxFeePerGas":"", | ||
"maxPriorityFeePerGas":"", | ||
"multiplierGas": "", | ||
"setupEmptyCommittee": true, | ||
"committeeTimelock": false | ||
} | ||
``` | ||
## Deploy contracts | ||
### `CDKValidiumDeployer` | ||
This is a factory contract that deploys the deterministic contracts required by the system and must be deployed first. | ||
The address of the contracts it creates depends on the salt and the `initialCDKValidiumDeployerOwner` inside `deploy_parameters.json`. | ||
1. From the same `deployment` directory, run the deploy script. | ||
```bash | ||
npm run deploy:deployer:CDKValidium:sepolia | ||
``` | ||
You should see something similar to this: | ||
```bash | ||
cdkValidiumDeployer deployed on: 0x87572242776ccb6c98F4Cf1ff20f7e5a4e4142fF | ||
``` | ||
2. Now we can deploy the rest of the contract suite. | ||
```bash | ||
npm run deploy:testnet:CDKValidium:sepolia | ||
``` | ||
!!! info | ||
This may take several minutes depending on network conditions. | ||
!!! warning | ||
If you see this message, you can safely ignore it: | ||
```sh | ||
cp: cannot stat '.openzeppelin/sepolia.json': No such file or directory | ||
``` | ||
3. On successful deployment, you should see a new directory named `deployments` containing a directory storing the information about your deployment. For example: | ||
```bash | ||
# ~/cdk-validium/cdk-validium-contracts-0.0.2/deployments/sepolia_1705429054/deploy_output.json | ||
{ | ||
"cdkValidiumAddress": "0x37eEBCa90363b0952e03a64979B64AAE3b8C9631", | ||
"polygonZkEVMBridgeAddress": "0x3485bfA6F27e54a8FF9782032fdbC7C555c178E4", | ||
"polygonZkEVMGlobalExitRootAddress": "0x8330E90c82F4BDDfa038041B898DE2d900e6246C", | ||
"cdkDataCommitteeContract": "0xb49d901748c3E278a634c05E0c500b23db992fb0", | ||
"maticTokenAddress": "0x20db28Bb7C779a06E4081e55808cc5DE35cca303", | ||
"verifierAddress": "0xb01Be1534d1eF82Ba98DCd5B33A3A331B6d119D0", | ||
"cdkValidiumDeployerContract": "0x87572242776ccb6c98F4Cf1ff20f7e5a4e4142fF", | ||
"deployerAddress": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", | ||
"timelockContractAddress": "0xDa476BD0B6A660cd08239dEb620F701877688c6F", | ||
"deploymentBlockNumber": 5097689, | ||
"genesisRoot": "0xf07cd7c4f7df7092241ccb2072d9ac9e800a87513df628245657950b3af78f94", | ||
"trustedSequencer": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", | ||
"trustedSequencerURL": "http://127.0.0.1:8123", | ||
"chainID": 1001, | ||
"networkName": "cdk-validium", | ||
"admin": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", | ||
"trustedAggregator": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", | ||
"proxyAdminAddress": "0x828E55268524c13dB25FD33f2Be45D2771f1EeA4", | ||
"forkID": 6, | ||
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"version": "0.0.1" | ||
} | ||
``` | ||
4. In the `~/cdk-validium/cdk-validium-contracts-0.0.2/deployment/` folder, you should also see a `genesis.json` file. | ||
!!! info | ||
We use the info in `genesis.json` and `deploy_output.json` to configure the `cdk-validium-node` node. | ||
!!! warning "Deployment failure" | ||
- Since there are deterministic addresses, you cannot deploy twice on the same network using the same `salt` and `initialCDKValidiumDeployerOwner` inside `deploy_parameters.json`. Changing one of them is enough to make a new deployment. | ||
- It's mandatory to delete the `~/cdk-validium/cdk-validium-contracts-0.0.2/.openzeppelin` upgradability information in order to make a new deployment. | ||
## Verify contracts | ||
When deploying to Sepolia, the contracts should automatically verify based on other live deployments on the network with similar bytecode. If the contracts have not been verified on Etherscan, run the following commands from the `/cdk-validium/cdk-validium-contracts-0.0.2/deployment` directory. | ||
1. To verify the contract factory: | ||
```bash | ||
npm run verify:deployer:CDKValidium:sepolia | ||
``` | ||
2. To verify the rest of the contract suite: | ||
```bash | ||
npm run verify:CDKValidium:sepolia | ||
``` | ||
## Use a different node provider | ||
If you would rather use a different node provider than Infura, modify the contents of `~/cdk-validium/cdk-validium-contracts-0.0.2/hardhat.config.js` and `cdk-validium-contracts-0.0.2/.env` . | ||
For example, using Alchemy: | ||
```bash | ||
MNEMONIC="island debris exhaust typical clap debate exhaust little verify mean sausage entire" | ||
INFURA_PROJECT_ID="" # or blank if not using Infura | ||
ETHERSCAN_API_KEY="1234567890abcdefghijklmnopqr" # or blank if not verify contracts | ||
ALCHEMY_PROJECT_ID="dGPpsDzM9KpFTEnqMO44rvIXcc0fmgxr" # add this line | ||
``` | ||
```bash | ||
sepolia: { | ||
url: `https://eth-sepolia.g.alchemy.com/v2/${process.env.ALCHEMY_PROJECT_ID}`, # rpc value changed here | ||
accounts: { | ||
mnemonic: process.env.MNEMONIC || DEFAULT_MNEMONIC, | ||
path: "m/44'/60'/0'/0", | ||
initialIndex: 0, | ||
count: 20, | ||
}, | ||
}, | ||
``` |
50 changes: 50 additions & 0 deletions
50
docs/cdk/get-started/deploy-validium/contracts/prerequisites.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
## Hardware | ||
|
||
- A Linux-based OS (e.g., Ubuntu Server 22.04 LTS). | ||
- At least 8GB RAM with a 2-core CPU. | ||
- An AMD64 architecture system. | ||
|
||
## Software | ||
|
||
Make sure you have the following software: | ||
|
||
| Download link | Version | Check version | | ||
| --- | --- | --- | | ||
| [Node](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) | ^20 | `node --version` | | ||
| npm | ^10 | `npm --version` | | ||
| [Foundry](https://book.getfoundry.sh/getting-started/installation) | ^0.2 | `forge --version` | | ||
| [jq](https://jqlang.github.io/jq/download/) | ^1.6 | `jq -V` | | ||
|
||
## Sepolia access | ||
|
||
You will need the following: | ||
|
||
- A Sepolia node RPC URL: e.g. https://sepolia.infura.io/v3/YOUR-INFURA-API-KEY | ||
- An account holding minimum 2 Sepolia ETH that you can send to a generated address within CDK. | ||
|
||
### Faucets | ||
|
||
Use a public faucet to get Sepolia test ETH. | ||
|
||
- [Infura faucet](https://www.infura.io/faucet/sepolia). | ||
- [Chainstack faucet](https://chainstack.com/sepolia-faucet/). | ||
- [Quicknode faucet](https://faucet.quicknode.com/ethereum/sepoli). | ||
|
||
## Configuration files | ||
|
||
Create a folder `/tmp/cdk/` to store configuration files. | ||
|
||
```bash | ||
mkdir /tmp/cdk/ | ||
``` | ||
|
||
## Environment variables | ||
|
||
Create a `.env` file to store environment variables we will use later on. | ||
|
||
```bash | ||
nano /tmp/cdk/.env | ||
``` | ||
|
||
!!! danger | ||
The system removes this file on shutdown. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
## Download the validium repo | ||
|
||
1. Create a new directory and cd into it. | ||
|
||
```bash | ||
cd ~/ | ||
mkdir cdk-validium | ||
cd cdk-validium/ | ||
``` | ||
|
||
2. Download the `0.0.2` release from the [cdk-validium-contracts github repo](https://github.com/0xPolygon/cdk-validium-contracts/releases/tag/v0.0.2-RC1). | ||
|
||
!!! note | ||
The download is available in both `.tar.gz` and `.zip` formats. | ||
|
||
```bash | ||
curl -L -o cdk-validium-contracts.tar.gz https://github.com/0xPolygon/cdk-validium-contracts/archive/refs/tags/v0.0.2.tar.gz | ||
``` | ||
|
||
3. Extract the files and cd into the repo. | ||
|
||
```bash | ||
tar -xzf cdk-validium-contracts.tar.gz | ||
cd cdk-validium-contracts-0.0.2/ | ||
``` | ||
|
||
## Install the dependencies | ||
|
||
```bash | ||
npm install | ||
``` | ||
|
||
## Create the .env configuration | ||
|
||
1. Copy the environment configuration example file into a new `.env` file. | ||
|
||
```bash | ||
cp .env.example .env | ||
``` | ||
|
||
2. Generate a new mnemonic using `cast`. | ||
|
||
```bash | ||
cast wallet new-mnemonic --words 12 | ||
``` | ||
|
||
!!! tip | ||
If the command `new-mnemonic` is not found, update foundry with `foundryup` and try again. | ||
|
||
The output should look something like this: | ||
|
||
```bash | ||
Phrase: | ||
island debris exhaust typical clap debate exhaust little verify mean sausage entire | ||
Accounts: | ||
- Account 0: | ||
Address: 0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE | ||
Private key: 0x3b01870a8449ada951f59c0275670bea1fc145954ee7cb1d46f7d21533600726 | ||
``` | ||
|
||
3. Add the environment variables to the `.env` file. | ||
|
||
```bash | ||
nano .env | ||
MNEMONIC="<generated mnemonic>" # copy/paste the generated Phrase | ||
INFURA_PROJECT_ID="<INFURA_PROJECT_ID>" # Generate a project id on [Infura](https://www.infura.io/) | ||
ETHERSCAN_API_KEY="<ETHERSCAN_API_KEY>" # Generate an API key on [Etherscan](https://etherscan.io) | ||
``` | ||
|
||
!!! info | ||
Check our documentation if you want to [use a different node provider](deploy-contracts.md#use-a-different-node-provider). | ||
|
||
4. Send 2 Sepolia ETH to the generated address. | ||
|
||
5. Add the following variables to `/var/tmp/cdk/.env`. | ||
|
||
```bash | ||
nano /tmp/cdk/.env | ||
TEST_ADDRESS="<the address generated by cast>" | ||
TEST_PRIVATE_KEY="<the private key generated by cast>" | ||
L1_URL="https://sepolia.infura.io/v3/<YOUR INFURA PROJECT ID>" | ||
L1_WS_URL="wss://sepolia.infura.io/ws/v3/<YOUR INFURA PROJECT ID>" | ||
``` | ||
!!! important | ||
This step allows us to use `jq` and `tomlq` later on to setup our configuration files. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
This quick start takes you through the process of deploying a full CDK validium, EVM-compatible network on Sepolia. | ||
|
||
The process requires two separate flows with different software requirements. For this reason, these instructions have two distinct sections. | ||
|
||
1. [Deploying the contracts](contracts/prerequisites.md). | ||
2. [Deploying the node and services](node/prerequisites.md). | ||
|
||
!!! warning | ||
- The instructions are subject to frequent updates as the software remains at an early development stage. | ||
- Report any content issues on our docs repo: https://github.com/0xPolygon/polygon-docs | ||
|
||
## Git repos | ||
|
||
These are code bases we use to set everything up, and in this order. | ||
|
||
| Repo | Version | | ||
| --- | --- | | ||
| https://github.com/0xPolygon/cdk-validium-contracts/releases/tag/v0.0.2 | v0.0.2 | | ||
| https://github.com/0xPolygon/cdk-validium-node/releases/tag/v0.0.3 | v0.0.3 | | ||
| https://github.com/0xPolygonHermez/zkevm-prover | v3.0.2 | | ||
| https://github.com/0xPolygon/cdk-data-availability.git | v0.0.3 | | ||
| https://github.com/0xPolygonHermez/zkevm-bridge-service | v0.3.1 | |
Oops, something went wrong.