|
| 1 | +1. Navigate back to the working directory we created earlier, `~/cdk-validium` |
| 2 | + |
| 3 | +```bash |
| 4 | +cd ~/cdk-validium |
| 5 | +``` |
| 6 | + |
| 7 | +For this setup, we will also need our information from `deploy_output.json` inside `~/cdk-validium/cdk-validium-contracts-0.0.2/deployment`. Navigate back to `~/cdk-validium/cdk-validium-contracts-0.0.2/deployment` and run the following script to fill the required parameters into the `/tmp/cdk/.env` we created in the previous steps: |
| 8 | + |
| 9 | +```bash |
| 10 | +cd ~/cdk-validium/cdk-validium-contracts-0.0.2/deployment |
| 11 | +echo "GEN_BLOCK_NUMBER=$(jq -r '.deploymentBlockNumber' deploy_output.json)" >> /tmp/cdk/.env |
| 12 | +echo "CDK_VALIDIUM_ADDRESS=$(jq -r '.cdkValidiumAddress' deploy_output.json)" >> /tmp/cdk/.env |
| 13 | +echo "POLYGON_ZKEVM_BRIDGE_ADDRESS=$(jq -r '.polygonZkEVMBridgeAddress' deploy_output.json)" >> /tmp/cdk/.env |
| 14 | +echo "POLYGON_ZKEVM_GLOBAL_EXIT_ROOT_ADDRESS=$(jq -r '.polygonZkEVMGlobalExitRootAddress' deploy_output.json)" >> /tmp/cdk/.env |
| 15 | +echo "CDK_DATA_COMMITTEE_CONTRACT_ADDRESS=$(jq -r '.cdkDataCommitteeContract' deploy_output.json)" >> /tmp/cdk/.env |
| 16 | +echo "MATIC_TOKEN_ADDRESS=$(jq -r '.maticTokenAddress' deploy_output.json)" >> /tmp/cdk/.env |
| 17 | +``` |
| 18 | + |
| 19 | +Source our new environment and navigate back to `~/cdk-validium`: |
| 20 | + |
| 21 | +```bash |
| 22 | +source /tmp/cdk/.env |
| 23 | +cd ~/cdk-validium |
| 24 | +``` |
| 25 | + |
| 26 | +## 1. Downloading cdk-validium-node, cdk-data-availability, and cdk-bridge-service |
| 27 | + |
| 28 | +Now clone the `0.0.3` release of `cdk-validium-node`. |
| 29 | + |
| 30 | +```bash |
| 31 | +git clone --depth 1 --branch v0.0.3 https://github.com/0xPolygon/cdk-validium-node.git |
| 32 | +``` |
| 33 | + |
| 34 | +We also must download and extract version `0.0.3` of `cdk-data-availability.` The release file is available here: |
| 35 | + |
| 36 | +[Untitled Database](https://www.notion.so/b329e3b1511943ae979cc2b4c73a35e8?pvs=21) |
| 37 | + |
| 38 | +Downloading `cdk-validium-contracts` as a ***`tar.gz`*** and extracting |
| 39 | + |
| 40 | +```bash |
| 41 | +~/cdk-validium % curl -L -o cdk-data-availability.tar.gz https://github.com/0xPolygon/cdk-data-availability/archive/refs/tags/v0.0.3.tar.gz |
| 42 | +\tar -xzf cdk-data-availability.tar.gz |
| 43 | +``` |
| 44 | + |
| 45 | +Finally, the `cdk-bridge-service` release `0.3.1`. The release file can be found here: |
| 46 | + |
| 47 | +```bash |
| 48 | +curl -L -o cdk-bridge-service.tar.gz https://github.com/0xPolygonHermez/zkevm-bridge-service/archive/refs/tags/v0.3.1.tar.gz |
| 49 | +\tar -xzf cdk-bridge-service.tar.gz |
| 50 | + |
| 51 | +``` |
| 52 | +Now we have three new directories in *`cdk-validium/`* named ***`cdk-data-availability-0.0.3`, `cdk-validium-node` and `zkevm-bridge-service-0.3.1`*** |
| 53 | + |
| 54 | +## 2. Preparing the environment |
| 55 | + |
| 56 | +We will begin our setup in the node directory. |
| 57 | + |
| 58 | +Navigate into the node directory we cloned from the previous step***`cdk-validium-node/`*** |
| 59 | + |
| 60 | +```bash |
| 61 | +~/cdk-validium % cd cdk-validium-node/ |
| 62 | +``` |
| 63 | + |
| 64 | +### Setup the database |
| 65 | + |
| 66 | +Run the docker command to start an instance of the `psql` database. The database is used for many of the services, such as the node, prover, DAC, and bridge service. |
| 67 | + |
| 68 | +```bash |
| 69 | +docker run -e POSTGRES_USER=cdk_user -e POSTGRES_PASSWORD=cdk_password -e POSTGRES_DB=postgres -p 5432:5432 postgres:15 |
| 70 | +``` |
| 71 | + |
| 72 | +*note: if you are unable to start the process because port is in use, check the processes occupying the port then kill the processes* |
| 73 | + |
| 74 | +```bash |
| 75 | +sudo lsof -t -i:5432 |
| 76 | +kill -9 <PID> |
| 77 | +``` |
| 78 | + |
| 79 | +Once you have postgres running, validate you have the following setup correctly: |
| 80 | + |
| 81 | +- an admin account called: `cdk_user` with a password of `cdk_password` |
| 82 | +- postgres server running on `localhost:5432` |
| 83 | + |
| 84 | +You can use the following command to validate the steps, `\q` to exit: |
| 85 | + |
| 86 | +```bash |
| 87 | +PGPASSWORD=cdk_password psql -h localhost -U cdk_user -d postgres -p 5432 |
| 88 | +#=> \q |
| 89 | +``` |
| 90 | + |
| 91 | +### Provision the database |
| 92 | + |
| 93 | +The `cdk-validium-node` directory contains a script called `single_db_server.sql` that provisions all the databases required for the prover, state, and pool to operate. Run the script to provision all the necessary databases and schemas that will be used for both the prover and node: |
| 94 | + |
| 95 | +```bash |
| 96 | +~/cdk-validium/cdk-validium-node % PGPASSWORD=cdk_password psql -h localhost -U cdk_user -d postgres -p 5432 -a -q -f ./db/scripts/single_db_server.sql |
| 97 | +``` |
| 98 | + |
| 99 | +In addition to the provisions required for the prover and node, another provision is needed for the Data Availability Committee (DAC). We can set this up now for use later. |
| 100 | + |
| 101 | +```bash |
| 102 | +PGPASSWORD=cdk_password psql -h localhost -U cdk_user -d postgres -p 5432 -c "CREATE DATABASE committee_db;" |
| 103 | +``` |
| 104 | + |
| 105 | +Finally, we will provision a database for our bridge service, which we will setup last in this guide. |
| 106 | + |
| 107 | +```bash |
| 108 | +PGPASSWORD=cdk_password psql -h localhost -U cdk_user -d postgres -p 5432 -c "CREATE DATABASE bridge_db;" |
| 109 | +``` |
0 commit comments