Skip to content

Commit

Permalink
Add running docs
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaubennassar committed Dec 4, 2023
1 parent e69a225 commit 3e9812f
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# CDK Data Availability

### Data Availability Layer for CDK Validium

The cdk-data-availability project is a specialized Data Availability Node (DA Node) that is part of Polygon's CDK (Chain Development Kit) Validium.
Expand Down Expand Up @@ -32,6 +33,10 @@ To learn more about how the data availability layer works in the validium, pleas

The off-chain data is stored in a distributed manner and managed by a data availability committee, ensuring that it is available for validation. The data availability committee is defined as a core smart contract, available [here](https://github.com/0xPolygon/cdk-validium-contracts/blob/main/contracts/CDKDataCommittee.sol). This is crucial for the Validium model, where data computation happens off-chain but needs to be verifiable on-chain.

### Running

Instructions on how to run this software can be found [here](./docs/running.md)

## License

The cdk-validium-node project is licensed under the [GNU Affero General Public License](LICENSE) free software license.
110 changes: 110 additions & 0 deletions docs/running.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Running a Data Availability node

In order to run this service, the following components are needed:

1. Postgres DB
2. Ethereum node (L1)
3. The Data Availability node (DAN) itself

This three components can be run in many different ways, for reference, this guide will provide instructions using the following setup:

- L1 node is provided by a 3rd party, and so just the URL of it is needed
- The Postgres instance and the DAN run in docker containers, configured using `docker-compose`

Note that this is just an opinionated way of running things. It's possible for instance to run the DAN using the binnary, and Postgres in managed instance by a cloud provider (an many more configurations).

```yml
version: "3.5"
networks:
default:
name: cdk-data-availability

services:

cdk-data-availability:
container_name: cdk-data-availability
restart: unless-stopped
depends_on:
cdk-data-availability-db:
condition: service_healthy
image: hermeznetwork/cdk-data-availability:v0.0.2
deploy:
resources:
limits:
memory: 1G
reservations:
memory: 512M
ports:
- 8444:8444
volumes:
- ./config.toml:/app/config.toml
- ./private.keystore:/pk/test-member.keystore
command:
- "/bin/sh"
- "-c"
- "/app/cdk-data-availability run --cfg /app/config.toml"

cdk-data-availability-db:
container_name: cdk-data-availability-db
restart: unless-stopped
image: postgres:15
healthcheck:
test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
interval: 10s
timeout: 5s
retries: 5
ports:
- 5434:5432
environment:
- POSTGRES_USER=committee_user # CHANGE THIS: use your prefered user name
- POSTGRES_PASSWORD=committee_password # CHANGE THIS: use a safe and strong password
- POSTGRES_DB=committee_db
command:
- "postgres"
- "-N"
- "500"
```
1. Copy/paste this into a new directory, name the file `docker-compose.yml`
2. In the same directory, create a file named `config.toml`, in that file, copy/paste the following:

```toml
PrivateKey = {Path = "/pk/test-member.keystore", Password = "testonly"} # CHANGE THIS (the password): according to the private key file password
[L1]
WsURL = "ws://URLofYourL1Node:8546" # CHANGE THIS: use the URL of your L1 node
RpcURL = "http://URLofYourL1Node:8545" # CHANGE THIS: use the URL of your L1 node
CDKValidiumAddress = "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82" # CHANGE THIS: Address of the Validium smart contract
DataCommitteeAddress = "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6" # CHANGE THIS: Address of the data availability committee smart contract
Timeout = "3m"
RetryPeriod = "5s"
BlockBatchSize = 32
[Log]
Environment = "development" # "production" or "development"
Level = "debug"
Outputs = ["stderr"]
[DB]
User = "committee_user" # CHANGE THIS: according to the POSTGRES_USER in docker-compose.yml
Password = "committee_password" # CHANGE THIS: according to the POSTGRES_PASSWORD in docker-compose.yml
Name = "committee_db"
Host = "cdk-data-availability-db"
Port = "5432"
EnableLog = false
MaxConns = 200
[RPC]
Host = "0.0.0.0"
Port = 8444
ReadTimeout = "60s"
WriteTimeout = "60s"
MaxRequestsPerIPAndSecond = 500
```

3. Next step is to generate a file for the Ethereum private key of the committee member. Note that this private key should be representing one of the address of the committee. To generate the private key, run: `docker run -d -v .:/key hermeznetwork/zkevm-node /app/zkevm-node encryptKey --pk **** --pw **** -o /key`. Replace the **** for your actual private key and a password of your choice. After running the command, a file named `UTC--...` will be generated. Rename it to `private.keystore`
4. Change all the fields marked with `CHNAGE THIS` on both the `docker-compsoe.yml` and `config.toml`
5. Run it: `docker compose up -d`
6. Check the logs to see if everything is going fine: `docker compose logs`

Note that the DAN endpoint (in this example using the port 8444) should be reachable in the URL indicated on the data availability smart contract

0 comments on commit 3e9812f

Please sign in to comment.