Skip to content

Commit ee7aed8

Browse files
Merge branch 'main' of https://github.com/0xPolygon/polygon-docs into cdk/native-gas-token
2 parents 88cc5ff + 05f1429 commit ee7aed8

File tree

172 files changed

+2217
-10421
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+2217
-10421
lines changed

README.md

Lines changed: 36 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,44 @@
11
# Polygon Knowledge Layer
22

3-
Welcome to the Polygon Knowledge Layer! This documentation is built using [the Material theme for MkDocs](https://squidfunk.github.io/mkdocs-material/). Our goal is to establish a high-quality, curated, and comprehensive "source of truth" for technical knowledge surrounding Polygon's main technology. This includes detailed sections on:
3+
Welcome to the Polygon Knowledge Layer.
4+
5+
These docs use [the Material theme for MkDocs](https://squidfunk.github.io/mkdocs-material/). Our goal is to establish a high-quality, curated, and comprehensive "source of truth" for Polygon's technology.
6+
7+
This includes sections on:
48

59
- Polygon CDK
610
- Polygon zkEVM
711
- Polygon PoS
812
- Polygon Miden
9-
- Dev Tools
13+
- Developer tools
14+
15+
## Run locally
16+
17+
### Prerequisites
18+
19+
1. [Python 3.12](https://www.python.org/downloads/).
20+
2. [`virtualenv`](https://pypi.org/project/virtualenv/): Install using `pip3 install virtualenv`.
21+
22+
### Setup
23+
24+
1. Clone the repository.
25+
2. `cd` to the root.
26+
3. Run the `run.sh` script. You may need to make the script executable: `chmod +x run.sh`
27+
28+
```sh
29+
./run.sh
30+
```
31+
32+
The site comes up at http://127.0.0.1:8000/
33+
34+
### Docker
1035

11-
In addition, we include top-level sections for Tools and Tutorials to support developers in their journey with Polygon technology.
36+
If you prefer Docker, you can build and run the site using the following commands:
37+
38+
```sh
39+
docker build -t polygon-docs .
40+
docker compose up
41+
```
1242

1343
## Contributing
1444

@@ -34,58 +64,12 @@ In addition, we include top-level sections for Tools and Tutorials to support de
3464
- **Engage with the community**: Participate in discussions and provide feedback on other contributions.
3565
- **Stay consistent**: Ensure your contributions are coherent with the rest of the documentation and do not overlap or contradict existing content.
3666

37-
38-
## Running locally
39-
40-
### Prerequisites
41-
42-
Before running the site locally, you need to have the following installed:
43-
44-
1. [Python 3](https://www.python.org/downloads/).
45-
2. [`virtualenv`](https://pypi.org/project/virtualenv/): Install using `pip3 install virtualenv`.
46-
47-
### Setup
48-
49-
1. **Clone repository**: Clone the Polygon Knowledge Layer repository to your local machine.
50-
2. **Create a virtual environment**: Run `virtualenv venv; source venv/bin/activate` in the root directory.
51-
3. **Install dependencies**: Install required Python packages with `pip3 install -r requirements.txt`.
52-
53-
### Running the website
54-
55-
Before running the website, you'll need to first load the Python virtual environment in your current shell. To do this, type the following (depending on your shell):
56-
57-
- **Bash**, **zsh** (most common): `virtualenv venv; source venv/bin/activate`
58-
- **Fish**: `virtualenv venv; source venv/bin/activate.fish`
59-
- **Nu**: `virtualenv venv; source venv/bin/activate.nu`
60-
61-
You only need to do the above once per shell session. Then, pick one of the following:
62-
63-
1. **MkDocs in strict mode**: Use `mkdocs serve --strict` for a production-like environment.
64-
2. **MkDocs in normal mode**: Use `mkdocs serve` for a less strict, more forgiving environment, suitable for debugging.
65-
66-
### Docker alternative
67-
68-
If you prefer Docker, you can build and run the site using the following commands:
69-
70-
```sh
71-
docker build -t polygon-docs .
72-
docker compose up
73-
```
74-
75-
## Automated deployments
76-
77-
This repository uses GitHub Actions to automate some deployments from certain branches, which is useful for testing:
78-
79-
- **`main`**: Staging branch. Changes are deployed per-commit to https://docs-staging.polygon.technology.
80-
- **`dev`**: Experimental branch. Updates with `main` every 24 hours. Changes are deployed per-commit to https://docs-dev.polygon.technology.
81-
82-
Whenever we are happy with `main`, a trigger can be manually done through GitHub Actions which deploys staging to production at https://docs.polygon.technology.
83-
8467
## Contact and support
8568

86-
For any queries or support, please open a ticket at https://support.polygon.technology/support/home.
69+
- For docs issues (technical or language) open an issue here.
70+
- For technical issues with the software, either raise an issue here and we will follow up, or check https://support.polygon.technology/support/home.
8771

88-
## Current Technical Knowledge Documentation (TKD) team members
72+
## The team
8973

9074
- Anthony Matlala (@EmpieichO)
9175
- Katharine Murphy (@kmurphypolygon)

docs/_site_essentials/stylesheets/extra.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
.md-icon {
7373
color: var(--gray);
7474
}
75+
.flex-card-item:hover {
76+
background-color: var(--gray);
77+
}
7578
}
7679
/** END OF COLOR SCHEMES **/
7780

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
The Polygon CDK validium is one of two configuration options of the Polygon CDK, the other being the Polygon zkEVM rollup.
2+
3+
As per [the definition](https://ethereum.org/developers/docs/scaling/validium), the Polygon CDK validium uses validity proofs to enforce integrity of state transitions, but it does not store transaction data on the Ethereum network.
4+
5+
The Polygon CDK validium is in fact a _zero-knowledge validium_ (zkValidium) because it utilises the Polygon zkEVM's off-chain prover to produce zero-knowledge proofs, which are published as _validity proofs_.
6+
7+
The use of the above-mentioned prover, to a certain extent, adds trustlessness to the Polygon CDK validium.
8+
9+
The validium mode inherits, not just the prover, but all the Polygon zkEVM's components and their functionalities, except that it does not publish transaction data on L1.
10+
11+
The validium configuration has one major advantage over the zkEVM rollup option: And that is, reduced gas fees due to the off-chain storage of transaction data, where only a hash of the transaction data gets stored on the Ethereum network.
12+
13+
## Data availability committee (DAC)
14+
15+
In relation to storing transaction data off-chain, the CDK validium comes with the requirement to manage the data.
16+
17+
- First of all, the transaction data is not published to the L1 but only the hash of the data.
18+
- Secondly, a trusted-sequencer collects transactions from the pool DB, puts them into batches and computes the hash of the transaction data.
19+
20+
It is due to the above two points that the Polygon CDK validium has to have a set of _trusted actors_, who can monitor and even authenticate the hash values that the sequencer proposes to be published on the L1.
21+
22+
The hash values need to be verified as true _footprints_ of the transaction data corresponding to all transactions in the sequenced batches.
23+
24+
These _trusted actors_ are collectively called the Data Availability Committee (DAC).
25+
26+
After verifying the proposed hash values individually, each DAC member signs them and sends the signature to the sequencer.
27+
28+
The sequencer uses a _multi-sig_, which is a custom-specified _m-out-of-n multi-party protocol_, to attach the required _m_ signatures to the hash of the transaction data. The _multi-sig_ contract lives on the L1 network.
29+
30+
Architecturally speaking, the Polygon CDK validium is therefore nothing but a zkEVM with a DAC. That is, **Polygon CDK validium = Polygon zkEVM + DAC**.
31+
32+
## Validium data flow
33+
34+
The DAC works together with the sequencer to control the flow of data and state changes.
35+
36+
The diagram below depicts a simplified outline of the Polygon CDK validium architecture. It particularly shows how the DAC and the sequencer relate in the overall data flow.
37+
38+
![CDK validium data availability dataflow](../../img/cdk/cdk-val-dac-02.png)
39+
40+
The entire process can be broken down as follows:
41+
42+
1. **Batch formation**: The sequencer collects user transactions, adds them to blocks, and puts the blocks in batches while recursively computing their hash values.
43+
2. **Batch authentication**: Once the batches are assembled, and their hash values computed, they need to be authenticated by the DAC. The sequencer therefore forwards the batch data, and their corresponding hash values to the DAC, as a way to request for signatures.
44+
3. **Data validation and storage**: The DAC nodes independently validate the batch data against the hash values received from the sequencer. Once validated, each hash value is stored in each DAC node's local database for future reference.
45+
4. **Signature generation**: Each DAC node generates a signature for each batch hash. This serves as an endorsement of the batch's integrity and authenticity.
46+
5. **Communication with Ethereum**: The sequencer collects the DAC members' signatures and the original batch hash, and submits them to the Ethereum network for verification.
47+
6. **Verification on Ethereum**: A designated _multi-sig_ smart contract on Ethereum verifies the submitted signatures against each DAC member's known signatures, and confirms that sufficient approval has been provided for the batch hash.
48+
7. **Final settlement with zero-knowledge proof**: The aggregator prepares a proof for the batch via the prover and submits it to the Ethereum network. This proof confirms the validity of the transactions in the batch without revealing transaction details. The chain's state gets updated on Ethereum.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Polygon zkEVM is a zero-knowledge rollup (or zk-rollup) designed to emulate the Ethereum Virtual Machine.
2+
3+
It is a scaling-solution to Ethereum as it rolls up many transactions into one batch.
4+
5+
These batches are submitted to the L1, where their integrity is proved and verified before being included in the L1 state.
6+
7+
Proving, verification of batches, and state changes are all controlled by smart contracts.
8+
9+
Most important to understand is the primary path taken by transactions from when users submit these transactions to the zkEVM network up until they are finalized and incorporated in the L1 State.
10+
11+
Polygon zkEVM achieves this by utilizing several actors. The diagram below depicts the various actors and how they interact.
12+
13+
![zkEVM option architecture](../../img/cdk/cdk-zkevm-arch-overview.png)
14+
15+
Here is an outline of the most prominent rollup components:
16+
17+
- The **users**, who connect to the zkEVM network by means of an RPC node (e.g., Infura or Alchemy), submit their transactions to a database called the pool DB.
18+
- The **pool DB** is the storage for transactions submitted by users. These are kept in the pool waiting to be put in a batch by the sequencer.
19+
- The **sequencer** is a node responsible for fetching transactions from the pool DB, checking if the transactions are valid, then putting valid ones into a batch. The sequencer submits all batches to the L1 and then sequences the batches. This process proposes the sequence of batches to be included in the L1 state.
20+
- The **state DB** is a database for permanently storing state data (but not the Merkle trees).
21+
- The **synchronizer** is the component that updates the state DB by fetching data from Ethereum through the Etherman.
22+
- The **Etherman** is a low-level component that implements methods for all interactions with the L1 network and smart contracts.
23+
- The **aggregator** is another node whose role is to produce proofs attesting to the integrity of the sequencer's proposed state-change. These proofs are zero-knowledge proofs (or ZK-proofs) and the aggregator employs a cryptographic component called the prover for this purpose.
24+
- The **prover** is a complex cryptographic tool capable of producing ZK-proofs of hundreds of batches, and aggregating these into a single ZK-proof which is published as the validity proof.

docs/cdk/architecture/dac.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

docs/cdk/get-started/connect-testnet.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
comments: true
3+
---
4+
15
## Stavanger
26

37
The [CDK Stavanger testnet](https://polygon.technology/cdk-stavanger-testnet) is a validium testnet based on Sepolia.

docs/cdk/get-started/deploy-validium/contracts/deploy-contracts.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
---
2+
comments: true
3+
---
4+
15
## Configure deployment parameters
26

3-
1. `cd` to the `deployment/` directory and create a new `deploy_parameters.json` by copying the example
7+
1. Navigate to the contracts deployment directory.
48

5-
```bash
6-
cd deployment/
7-
cp deploy_parameters.json.example deploy_parameters.json
9+
```sh
10+
cd ~/cdk-validium/cdk-validium-contracts-0.0.2/deployment
811
```
912

10-
2. Run the following `jq` script to streamline the process of replacing these fields:
13+
2. Run the following `jq` script to streamline the process of replacing the fields with the `/tmp/cdk/.env` data:
1114

1215
```bash
1316
source /tmp/cdk/.env
@@ -55,7 +58,7 @@ This is a factory contract that deploys the deterministic contracts required by
5558
5659
The address of the contracts it creates depends on the salt and the `initialCDKValidiumDeployerOwner` inside `deploy_parameters.json`.
5760
58-
1. From the same `deployment` directory, run the deploy script.
61+
1. From the same `deployment` directory you were already in, run the deploy script.
5962
6063
```bash
6164
npm run deploy:deployer:CDKValidium:sepolia
@@ -144,10 +147,10 @@ If you would rather use a different node provider than Infura, modify the conten
144147
For example, using Alchemy:
145148
146149
```bash
147-
MNEMONIC="island debris exhaust typical clap debate exhaust little verify mean sausage entire"
148-
INFURA_PROJECT_ID="" # or blank if not using Infura
149-
ETHERSCAN_API_KEY="1234567890abcdefghijklmnopqr" # or blank if not verify contracts
150-
ALCHEMY_PROJECT_ID="dGPpsDzM9KpFTEnqMO44rvIXcc0fmgxr" # add this line
150+
MNEMONIC="test test test test test test test test test test test junk"
151+
INFURA_PROJECT_ID="" # leave blank when not using Infura
152+
ETHERSCAN_API_KEY="" # or blank if not verifying contracts
153+
ALCHEMY_PROJECT_ID="" # add the Alchemy data here
151154
```
152155
153156
```bash
Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
comments: true
3+
---
4+
15
## Hardware
26

37
Make sure you have the following minimum hardware requirements.
@@ -17,10 +21,12 @@ Make sure you have the following minimum software requirements.
1721
| [Foundry](https://book.getfoundry.sh/getting-started/installation) | ^0.2 | `forge --version` |
1822
| [jq](https://jqlang.github.io/jq/download/) | ^1.6 | `jq -V` |
1923

20-
## Sepolia access
24+
## Access to a Sepolia node
25+
26+
Use a node provider like Infura or Alchemy. We use Infura throughout but you can [use a different node provider](deploy-contracts.md#use-a-different-node-provider) if you want.
2127

22-
!!! info
23-
You can run your own Sepolia node if you wish and we recommend this for a production set up. However, for simplicity and brevity, we demonstrate by using a node provider.
28+
!!! important
29+
We recommend running your own Sepolia node for a production set up.
2430

2531
You will need the following:
2632

@@ -35,32 +41,13 @@ Use a public faucet to get Sepolia test ETH.
3541
- [Chainstack faucet](https://chainstack.com/sepolia-faucet/).
3642
- [Quicknode faucet](https://faucet.quicknode.com/ethereum/sepoli).
3743

38-
## Configuration files
39-
40-
We will be working with two separate `.env` files.
44+
## Configuration with environment variables
4145

42-
- One `.env` file resides in the contracts project directory. We will set this up in the [contract set up](set-up.md#create-the-contracts-env-configuration) section.
43-
- Another `.env` resides in a shared system directory so that it is accessible to the node and all running processes.
46+
We will be working with two separate `.env` files to manage the contracts and node configurations.
4447

45-
Create a folder `/tmp/cdk/` to store the shared `.env` file which will be used by all running processes.
46-
47-
```bash
48-
mkdir /tmp/cdk/
49-
```
48+
- One `.env` file resides in the contracts project directory. We will set this up in the [contracts environment variables set up](set-up.md#create-the-contracts-env-configuration) section.
49+
- Another `.env` resides in a shared system directory, `/tmp/cdk/`, which is accessible to the node and all running processes. We set this up in the [system-wide environment variables set up](set-up.md#create-the-shared-system-env-configuration) section. This shared `.env` file allows us to use `jq` and `tomlq` to easily setup the configuration for the node and running processes.
5050

5151
!!! danger
5252
- Any files in the `tmp/` directory are deleted on shutdown.
53-
- For this reason, we recommend that you save this folder in your home directory once the shared configuration set up is complete.
54-
55-
### Shared environment variables
56-
57-
Create a `.env` file to store the environment variables that all running processes will share. This shared `.env` file allows us to use `jq` and `tomlq` to easily setup the configuration for the node and running processes.
58-
59-
After adding a few variables to this file in the next [set up section](set-up.md#create-the-shared-system-env-configuration), this file is populated with more environment variables during the [node set up step](../node/set-up.md) and is then accessed by the system throughout the [deploy node configuration step](../node/configure-deployment.md) and [node and services run step](../node/run-node-services.md).
60-
61-
```bash
62-
nano /tmp/cdk/.env
63-
```
64-
65-
!!! danger
66-
Don't forget: The system removes this file on shutdown.
53+
- For this reason, we recommend that you copy this folder and paste it into your home directory once the shared configuration set up is complete. That way, you can just add it back when you need to.

0 commit comments

Comments
 (0)