Skip to content

Commit 24bd319

Browse files
author
jarrodwatts
committed
Getting started guide
1 parent 7d46840 commit 24bd319

File tree

3 files changed

+161
-26
lines changed

3 files changed

+161
-26
lines changed

docs/cdk/getting-started.md

Lines changed: 145 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ To run the Polygon CDK locally, the following prerequisites are required:
1414
**Hardware Requirements:**
1515

1616
- A Linux-based Operating System (or [WSL](https://learn.microsoft.com/en-us/windows/wsl/about))
17-
- 8GB RAM with a 2-core CPU
17+
- Minimum 8GB RAM and 2-core CPU
1818
- An AMD64 architecture system
1919

2020
**Software Dependencies:**
@@ -49,14 +49,14 @@ If everything is installed correctly, you should see the following output:
4949

5050
```bash
5151
Checking that you have the necessary tools to deploy the Kurtosis CDK package...
52-
✅ kurtosis 0.89.12 is installed, meets the requirement (=0.89).
53-
✅ docker 25.0.3 is installed, meets the requirement (>=24.7).
52+
✅ kurtosis is installed, meets the requirement (=0.89).
53+
✅ docker is installed, meets the requirement (>=24.7).
5454

5555
You might as well need the following tools to interact with the environment...
56-
✅ jq 1.7.1 is installed.
57-
✅ yq 3.2.3 is installed, meets the requirement (>=3.2).
58-
✅ cast 0.2.0 is installed.
59-
✅ polycli v0.1.43-5-g73ad3f4 is installed.
56+
✅ jq is installed.
57+
✅ yq is installed, meets the requirement (>=3.2).
58+
✅ cast is installed.
59+
✅ polycli is installed.
6060

6161
🎉 You are ready to go!
6262
```
@@ -70,19 +70,22 @@ To begin understanding the codebase, there are two key files to inspect:
7070

7171
#### main.star
7272

73-
The `main.star` file defines the step-by-step process of the deployment process. It is the main "hub" of the chain setup process; orchestrating the setup of all the components in sequential order by pulling in necessary logic from other files.
73+
The `main.star` file defines the step-by-step instructions of the deployment process. It is the main "hub" of the chain setup process; orchestrating the setup of all the components in sequential order by pulling in necessary logic from other files.
7474

75-
By default, this script performs the following steps:
75+
It defines the following steps for the deployment process:
7676

77-
1. Deploy a local layer 1 devnet chain ([ethereum.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/ethereum.star))
78-
2. Deploy the zkEVM smart contracts on the L1 ([deploy_zkevm_contracts.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/deploy_zkevm_contracts.star))
79-
3. Deploy the zkEVM node and CDK peripheral databases ([databases.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/databases.star))
80-
4. Deploy the CDK central environment ([cdk_central_environment.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/cdk_central_environment.star))
81-
5. Deploy the bridge infrastructure ([cdk_bridge_infrastructure.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/cdk_bridge_infra.star))
82-
6. Deploy the permissionless node ([zkevm_permissionless_node.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/zkevm_permissionless_node.star))
83-
7. Deploy the observability stack and block explorer ([observability.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/observability.star) and [blockscout.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/blockscout.star))
84-
8. Apply a load test to the chain ([load_test.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/workload.star))
85-
9. Deploy [Blutgang](https://github.com/rainshowerLabs/blutgang) for load balancing & caching ([cdk_blutgang.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/cdk_blutgang.star))
77+
| Step Number | Deployment Step | Relevant Starlark Code | Enabled by Default |
78+
| ----------- | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------- | ------------------ |
79+
| 1 | Deploy a local layer 1 devnet chain | [ethereum.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/ethereum.star) | True |
80+
| 2 | Deploy the zkEVM smart contracts on the L1 | [deploy_zkevm_contracts.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/deploy_zkevm_contracts.star) | True |
81+
| 3 | Deploy the zkEVM node and CDK peripheral databases | [databases.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/databases.star) | True |
82+
| 4 | Deploy the CDK central environment | [cdk_central_environment.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/cdk_central_environment.star) | True |
83+
| 5 | Deploy the bridge infrastructure | [cdk_bridge_infrastructure.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/cdk_bridge_infra.star) | True |
84+
| 6 | Deploy the permissionless node | [zkevm_permissionless_node.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/zkevm_permissionless_node.star) | False |
85+
| 7 | Deploy the observability stack | [observability.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/observability.star) | True |
86+
| 8 | Deploy the block explorer | [blockscout.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/blockscout.star) | False |
87+
| 9 | Apply a load test to the chain | [load_test.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/workload.star) | False |
88+
| 10 | Deploy [Blutgang](https://github.com/rainshowerLabs/blutgang) for load balancing & caching | [cdk_blutgang.star](https://github.com/0xPolygon/kurtosis-cdk/blob/main/cdk_blutgang.star) | False |
8689

8790
You can customize (or skip) the logic for each of these steps by modifying the logic in the respective files.
8891

@@ -94,17 +97,137 @@ You can modify each of these parameters to customize the chain to your specific
9497

9598
## Running the Chain Locally
9699

97-
Use the [kurtosis clean](https://docs.kurtosis.com/clean) and [kurtosis run](https://docs.kurtosis.com/run) commands to begin the deployment process. Run the following commands to begin executing the `main.star` script and start the deployment process:
100+
First run the [kurtosis clean](https://docs.kurtosis.com/clean) to remove any existing Kurtosis environments:
98101

99102
```bash
100103
kurtosis clean --all
101-
kurtosis run --enclave cdk-v1 --args-file params.yml --image-download always .
102104
```
103105

104-
This command typically takes around 10 minutes to complete. It will output the logs of each step in the deployment process, allowing you to monitor the progress of the chain setup.
106+
Then, in the `kurtosis-cdk` directory, use the [kurtosis run](https://docs.kurtosis.com/run) command to deploy the chain on your local machine by executing the `main.star` script provided with the `params.yml` configuration file:
107+
108+
```bash
109+
kurtosis run --enclave cdk-v1 --args-file params.yml --image-download always .
110+
```
105111

106112
!!! info
107113

108-
- `--encalve cdk-v1` specifies the name of the [enclave](https://docs.kurtosis.com/advanced-concepts/enclaves/) (isolated environment) to use for the deployment process.
114+
- `--enclave cdk-v1` specifies the name of the [enclave](https://docs.kurtosis.com/advanced-concepts/enclaves/) (isolated environment) to use for the deployment process.
109115
- `--args-file params.yml` specifies the configuration file to use for the deployment process.
110116
- `--image-download always` specifies to always download the latest Docker images for the deployment process.
117+
118+
This command typically takes around 10 minutes to complete and outputs the logs of each step in the deployment process for you to monitor the progress of the chain setup. Once the command is complete, you should see the following output:
119+
120+
```bash
121+
Starlark code successfully run. No output was returned.
122+
123+
===============================================
124+
|| Created enclave: cdk-v1 ||
125+
===============================================
126+
Name: cdk-v1
127+
Status: RUNNING
128+
129+
========================================= Files Artifacts =========================================
130+
131+
... List of files generated during the deployment process ...
132+
133+
========================================== User Services ==========================================
134+
135+
... List of services with "RUNNING" status - none should be "FAILED"! ...
136+
137+
```
138+
139+
Run `kurtosis enclave inspect cdk-v1` to see the status of the enclave and the services running within it at any time.
140+
141+
## Interacting with the Chain
142+
143+
Now that your chain is running, you can explore and interact with each component!
144+
145+
Below are a few examples of how you can interact with the chain.
146+
147+
### Sending Test Transactions
148+
149+
Let’s perform some basic read and write operations on the L2 using Foundry.
150+
151+
Export the RPC URL of your L2 to an environment variable called `ETH_RPC_URL` with the following command:
152+
153+
```bash
154+
export ETH_RPC_URL="$(kurtosis port print cdk-v1 zkevm-node-rpc-001 http-rpc)"
155+
```
156+
157+
Then, use `cast` to view information about the chain, such as the latest block number:
158+
159+
```bash
160+
cast block-number
161+
```
162+
163+
View the balance of an address, such as the pre-funded admin account:
164+
165+
```bash
166+
cast balance --ether 0xE34aaF64b29273B7D567FCFc40544c014EEe9970
167+
```
168+
169+
Send simple transactions to the chain, such as a transfer of some ETH:
170+
171+
```bash
172+
cast send --legacy --value 0.01ether 0x0000000000000000000000000000000000000000 --private-key "0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625"
173+
```
174+
175+
!!! info
176+
177+
The `0xE34...9970` and `0x12d...c625` public-private key pair used in the above commands is the default admin account configured in `params.yml`.
178+
179+
### Load Testing the Chain
180+
181+
Use the [polycli loadtest](https://github.com/maticnetwork/polygon-cli/blob/main/doc/polycli_loadtest.md) command to send multiple transactions at once to the chain to test its performance:
182+
183+
```bash
184+
polycli loadtest --rpc-url "$ETH_RPC_URL" --legacy --verbosity 700 --requests 500 --rate-limit 5 --mode t --private-key "0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625"
185+
```
186+
187+
### Viewing Transaction Finality
188+
189+
A common way to check the status of the system is to ensure that batches are being sent and verified on the L1 chain.
190+
191+
Use `cast` to view the progression of batches from trusted, virtual, and verified states:
192+
193+
```bash
194+
cast rpc zkevm_batchNumber # Latest batch number on the L2
195+
cast rpc zkevm_virtualBatchNumber # Latest batch received on the L1
196+
cast rpc zkevm_verifiedBatchNumber # Latest batch verified or "proven" on the L1
197+
```
198+
199+
### Opening the Bridge UI
200+
201+
To open the bridge interface and bridge tokens across the L1 and L2, run the following command:
202+
203+
```bash
204+
open $(kurtosis port print cdk-v1 zkevm-bridge-proxy-001 bridge-interface)
205+
```
206+
207+
### Viewing Chain Metrics
208+
209+
To view information such as how many transactions are being processed, the amount of gas being used, the time since a batch was last verified, how many addresses have bridged, and much more, a Grafana dashboard is included in the deployed observability stack which can be opened by running the following command:
210+
211+
```bash
212+
open $(kurtosis port print cdk-v1 grafana-001 dashboards)
213+
```
214+
215+
From the hamburger menu, navigate to `Dashboards` and select the `Panoptichain` dashboard to view all of the metrics.
216+
217+
![Panoptichain Dashboard](../img/cdk/grafana.png)
218+
219+
### Stopping the Chain
220+
221+
If you want to **stop** the chain and remove all the containers, run the following command:
222+
223+
```bash
224+
kurtosis clean --all
225+
```
226+
227+
## Going to Production
228+
229+
While it is possible to run a CDK chain on your own, we strongly recommend getting in touch with one of our [Implementation Providers](https://ecosystem.polygon.technology/spn/cdk/) for production deployments.
230+
231+
## Dive Deeper into the CDK
232+
233+
For more detailed information on the CDK’s architecture, components, and how to customize your chain, refer to the [CDK architecture documentation](https://docs.polygon.technology/cdk/architecture/cdk-zkevm/).

docs/cdk/overview.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
1-
The Polygon Chain Development Kit (CDK) is an open-source stack to build layer 2 blockchains powered by zero-knowledge (ZK) proofs.
1+
The Polygon Chain Development Kit (CDK) is an open-source stack to build sovereign layer 2 blockchains powered by zero-knowledge (ZK) proofs.
22

3-
It consists of several modular components, many of which are used to power the Polygon zkEVM in production today, that are designed to be fully composable; empowering developers to customize each component and build a chain that meets their specific needs.
3+
It consists of modular components designed to be fully composable; empowering developers to customize each aspect of their chain to meet their specific needs.
44

5-
## Why Build With the CDK?
5+
## What is the CDK?
6+
7+
## CDK Features
8+
9+
- **Scalability**: todo
10+
11+
- **Sovereignity**: todo
12+
13+
- **Modularity**: todo
14+
15+
- **Interoperability**: todo
16+
17+
## Why Use the CDK?
618

719
The CDK bootstraps the development process of creating a layer 2 blockchain. Developers can easily set up the stack and begin configuring each component’s behavior with a fast feedback loop on a local development environment.
820

921
As logic is separated into modular components, developers can easily swap out components in a "plug and play" fashion to customize their chain, for example, by replacing entire components such as the data availability layer, or making granular-level configurations to each component; such as modifying the sequencer logic to comply with legal regulations.
1022

1123
### Tap Into the AggLayer
1224

13-
By default, CDK chains are opted into the Aggregation Layer (AggLayer) which enables cross-chain transactions among other L2 chains that are also opted into the AggLayer including the Polygon zkEVM.
25+
By default, CDK chains are opted into the Aggregation Layer (AggLayer) which enables cross-chain transactions among other L2 chains that are also opted into the AggLayer, including the [Polygon zkEVM](https://docs.polygon.technology/zkEVM/).
1426

1527
This provides a powerful network effect by enabling users to interact with smart contracts on your chain without having to manually bridge assets to it. This is especially useful for developers looking to bootstrap their chain’s ecosystem and have immediate access to a large pool of users and liquidity.
1628

docs/img/cdk/grafana.png

55.4 KB
Loading

0 commit comments

Comments
 (0)