Skip to content

Commit 13bd24d

Browse files
Jarrod Wattsjarrodwatts
authored andcommitted
Review comments from docs team
1 parent 3e8f532 commit 13bd24d

File tree

12 files changed

+557
-45
lines changed

12 files changed

+557
-45
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Admin upgradeability
2+
3+
As L2s work through the [stages of training wheels](https://medium.com/l2beat/introducing-stages-a-framework-to-evaluate-rollups-maturity-d290bb22befe) to become fully decentralized, chains that opt in to the [AggLayer](https://docs.polygon.technology/cdk/glossary/#agglayer-v1-al1) implement shared security mechanisms with other AggLayer chains including the [Polygon zkEVM](https://docs.polygon.technology/zkEVM/architecture/protocol/upgradability/) to ensure the safety of users.
4+
5+
Chains opted into the AggLayer share the following upgradeability controls:
6+
7+
1. The [security council](https://docs.polygon.technology/zkEVM/architecture/protocol/security-council/) ([contract address](https://etherscan.io/address/0x37c58Dfa7BF0A165C5AAEdDf3e2EdB475ac6Dcb6)) that can be used to trigger the [emergency state](https://docs.polygon.technology/zkEVM/architecture/protocol/malfunction-resistance/emergency-state/) which can pause bridge functionality, prevent smart contract upgrades, or stop the [sequencer](./architecture.md#sequencer) from [sequencing batches](./transaction-lifecycle.md#sequenced).
8+
9+
2. The [admin role](https://docs.polygon.technology/zkEVM/architecture/protocol/admin-role/) ([contract address](https://etherscan.io/address/0x242daE44F5d8fb54B198D03a94dA45B5a4413e21)) that can perform upgrades to patch bug fixes or add new features to the system by upgrading smart contracts with a 10-day waiting period (unless [emergency state](https://docs.polygon.technology/zkEVM/architecture/protocol/malfunction-resistance/emergency-state/) is active).
10+
11+
## Further reading
12+
13+
- [zkEVM protocol upgradability](https://docs.polygon.technology/zkEVM/architecture/protocol/upgradability/)
14+
- [zkEVM admin role and governance](https://docs.polygon.technology/zkEVM/architecture/protocol/admin-role/)
15+
- [zkEVM upgrade process](https://docs.polygon.technology/zkEVM/architecture/protocol/upgrade-process/)
16+
- [zkEVM security council](https://docs.polygon.technology/zkEVM/architecture/protocol/security-council/)
17+
- [zkEVM emergency state](https://docs.polygon.technology/zkEVM/architecture/protocol/malfunction-resistance/emergency-state/)
18+
- [L2Beat - Polygon zkEVM](https://l2beat.com/scaling/projects/polygonzkevm?selectedChart=activity)

docs/cdk/concepts/architecture.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Architecture
2+
3+
While each chain built with the CDK is unique, they all share a common high-level architecture. Before diving into the specifics of how [transactions](./transaction-lifecycle.md) are processed, it’s helpful to first understand the role of each component in the system.
4+
5+
Below is the high-level architecture of a chain built with the CDK, showing how transactions sent by users are processed and finalized on the L1:
6+
7+
![CDK Architecture](../../img/cdk/architecture-overview.png)
8+
9+
## Users
10+
11+
Chains built with the CDK are EVM-compatible by default. Although the [type of ZK-EVM](https://docs.polygon.technology/cdk/architecture/type-1-prover/intro-t1-prover/#type-definitions) you choose to implement is customizable, CDK chains are designed to be compatible with existing Ethereum tools and libraries.
12+
13+
This means both users and developers can use the same wallets (such as MetaMask) and libraries (such as Ethers.js) to interact with CDK-built chains as they do with Ethereum.
14+
15+
The process for submitting transactions is the same as on Ethereum, using the same [JSON-RPC](https://ethereum.org/en/developers/docs/apis/json-rpc/) interface. Transactions are submitted directly to the L2 and go into a pending transaction pool.
16+
17+
## Sequencer
18+
19+
The sequencer is responsible for two vital tasks in the system:
20+
21+
1. Executing transactions submitted by L2 users.
22+
2. Sending batches of transactions to the L1 smart contract.
23+
24+
The sequencer reads transactions from the pending transaction pool and executes them on the L2, effectively updating the state of the L2 and providing this information back to the user. Once this process is complete _(typically in a matter of seconds)_, users are free to continue interacting with the L2 as if the transaction was finalized.
25+
26+
In the background, the sequencer periodically creates batches of transactions and sends multiple batches of transactions to the L1 smart contract in a single transaction.
27+
28+
## L1 smart contracts
29+
30+
Multiple smart contracts, deployed on the L1 (Ethereum), work together to finalize transactions received from the L2 on the L1. Typically there is a main “rollup” smart contract that is responsible for:
31+
32+
1. Receiving and storing batches of transactions from the L2 (depending on the design of the L2, it may not use Ethereum for [data availability](https://docs.polygon.technology/cdk/glossary/#data-availability)).
33+
34+
2. Receiving and verifying ZK-proofs from the aggregator to prove the validity of the transactions.
35+
36+
## Aggregator and prover
37+
38+
The aggregator is responsible for periodically reading batches of L2 transactions that have not been verified yet, and generating ZK-proofs for them to prove their validity.
39+
40+
To do this, the aggregator sends the batches of transactions to a **prover**. The prover generates ZK proofs and sends them back to the aggregator, which then posts the proof back to the L1 smart contract.
41+
42+
## Further reading
43+
44+
- [zkEVM architecture overview](https://docs.polygon.technology/zkEVM/architecture/high-level/overview/)

docs/cdk/concepts/blocks.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Batches, blocks, and transactions
2+
3+
The following concepts are key to understanding how transactions are handled on L2s built with the CDK:
4+
5+
- Transaction: Signed instruction to perform an action on the blockchain.
6+
- Block: A group of transactions and a hash of the previous block in the chain.
7+
- Batch: A group of many transactions from multiple blocks.
8+
9+
See the figure below to best understand how these concepts relate to each other. We follow a real transaction from the Polygon zkEVM to track how it first gets included in a block on the L2, then a batch, and finally, a sequence sent to Ethereum.
10+
11+
![Batches, blocks, transactions](../../img/cdk/sequence-batch-block-transaction.png)
12+
13+
## Transaction
14+
15+
A transaction is a cryptographically signed instruction from an account to update the state of the blockchain. Users can leverage familiar tools and libraries, like MetaMask and Ethers.js, typically used for interacting with Ethereum, to send these transactions to CDK-built L2 chains.
16+
17+
Transactions are included in blocks, and these blocks fill batches. Consider a Polygon zkEVM transaction as an example, [`0xdd`](https://zkevm.polygonscan.com/tx/0xdd3f79c24886310ddf868ad1d36aadc6a3b6495048f68aad765c658c42426ef8), which performs a `Simple Swap` function call, and is included in block number [`12952601`](https://zkevm.polygonscan.com/block/12952601) on the L2.
18+
19+
![Transaction with Block Number](../../img/cdk/transaction-block.png)
20+
21+
## Block
22+
23+
To link blocks together, blocks contain multiple transactions as well as the hash of the previous block in the chain. Following the transaction example from above, the `0xdd` transaction is included in block [`12952601`](https://zkevm.polygonscan.com/block/12952601), which contains [2 transactions in total](https://zkevm.polygonscan.com/txs?block=12952601).
24+
25+
We can see this `0xdd` transaction is included in both a block and a batch, specifically, it is included in the block `12952601` and the batch `2041736`:
26+
27+
![Block and Batch](../../img/cdk/block-batch.png)
28+
29+
## Batch
30+
31+
Batches contain multiple transactions from multiple blocks. The two transactions from our example block `12952601` are included in batch [`2041736`](https://zkevm.polygonscan.com/batch/2041736), which contains [10 total transactions](https://zkevm.polygonscan.com/txs?batch=2041736).
32+
33+
This means the batch `2041736` includes the two transactions from block `12952601` as well as eight transactions from other blocks.
34+
35+
The presence of the `Sequence Tx Hash` field, associated with this batch, indicates that this batch has been sent to Ethereum along with other batches in a single transaction.
36+
37+
![Batch of transactions](../../img/cdk/batch-overview.png)
38+
39+
By inspecting the transactions in the batch, we can see:
40+
41+
- Our original transaction example is included in this batch.
42+
- The batch contains many transactions from different blocks.
43+
44+
![Transaction found inside batch](../../img/cdk/transaction-in-batch.png)
45+
46+
If the L2 is a [rollup](./layer2s.md) (meaning it uses Ethereum for it’s [data availability](https://docs.polygon.technology/cdk/glossary/#data-availability)), it sends an array of batches to Ethereum, by providing the array as an argument to the `sequenceBatches` function of a smart contract on Ethereum.
47+
48+
![Sequence Transaction](../../img/cdk/sequence-transaction.png)
49+
50+
By inspecting the `Sequence Tx Hash` transaction, we can see that the `sequenceBatches` function is called with the array of batches as an argument. One of these batches is the batch we have been following, `2041736`, which contains our original transaction example:
51+
52+
![Last Batch Sequenced](../../img/cdk/last-batch-sequenced.png)
53+
54+
## Further reading
55+
56+
- [Blocks in the zkEVM Etrog Upgrade](https://docs.polygon.technology/zkEVM/architecture/protocol/etrog-upgrade/?h=blocks#etrog-blocks)

docs/cdk/concepts/bridging.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
CDK-built chains come with a built-in bridge service and customizable UI out of the box, with the option to have a standalone [LxLy bridge](#lxly-bridge) or alternatively opt-in to the AggLayer and use the [Unified Bridge](#unified-bridge) to enable cross-chain L2-to-L2 interoperability.
66

7-
## LxLy Bridge
7+
## LxLy bridge
88

99
The LxLy bridge contracts carry out deposit and withdrawal of assets between L2 and L1.
1010

@@ -16,7 +16,7 @@ This option is suited to chains that may want to customize how the bridge is man
1616

1717
![LxLy Bridge](../../img/cdk/lxly.png)
1818

19-
## Unified Bridge
19+
## Unified bridge
2020

2121
A single, shared instance of the LxLy bridge, called the [unified bridge](https://docs.polygon.technology/cdk/architecture/staking-the-bridge/) is available to use for all CDK chains that opt-in to the AggLayer.
2222

@@ -28,7 +28,7 @@ This option is suited to chains that want a standard bridging experience and do
2828

2929
![Unified Bridge](../../img/cdk/unified-bridge.png)
3030

31-
## Further Reading
31+
## Further reading
3232

3333
- [Aggregated Blockchains: A New Thesis](https://polygon.technology/blog/aggregated-blockchains-a-new-thesis)
3434
- [Unified Bridge Overview](https://docs.polygon.technology/zkEVM/architecture/protocol/unified-LxLy/lxly-bridge/)

docs/cdk/concepts/gas-fees.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
# Gas Fees
1+
# Gas fees
22

3-
CDK-built chains have full control over how gas fees are set for users.
3+
CDK chains have full control over how gas fees are set for users, including what token to use for the native gas fees of the L2 chain, which is set to ETH by default.
44

5-
By default, gas fees on the L2 are paid in ETH and are determined by a combination of several factors, including the current gas price on Ethereum, the complexity of the submitted transaction, and the current demand on the L2 network itself.
6-
7-
However, developers can use any [ERC-20 token](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/) deployed on the L1 as their native gas token (see the [custom native gas token for a Polygon CDK chain tutorial](https://polygon.technology/blog/tutorial-launch-a-custom-native-gas-token-for-a-polygon-cdk-chain)).
85
Gas fees can also be omitted entirely, allowing users to interact with the chain without needing to pay gas fees for transactions and have the fees covered by the chain operator.
96

10-
When building your chain, common options for gas fee configuration include:
11-
- Using ETH as the native gas token for easy onboarding from L1.
12-
- Using an existing ERC-20 token as the native gas token.
13-
- Sponsoring gas fees for all transactions.
14-
15-
For more complex use cases, the CDK is also compatible with several [account abstraction providers](https://ecosystem.polygon.technology/spn/explore/?search=&competency=Wallet&chain=CDK) to provide more flexibility for users in regards to wallet support and gas fee payment.
7+
By default, gas fees on the L2 are determined by a combination of several factors, including the current gas price on Ethereum, the complexity of the submitted transaction, and the current demand on the L2 network itself.
168

17-
## Further Reading
9+
## Further reading
1810

19-
- [zkEVM gas fees documentation](https://docs.polygon.technology/zkEVM/architecture/effective-gas/)
11+
- [zkEVM gas fees documentation](https://docs.polygon.technology/zkEVM/architecture/effective-gas/)

docs/cdk/concepts/layer2s.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# What is a layer 2 blockchain?
2+
3+
Layer 2 (L2) blockchains are scaling solutions, typically built on top of Ethereum (L1) that are designed to increase transaction throughput without sacrificing decentralization or security.
4+
5+
While L2s are their own chains, they are considered "extensions" of Ethereum. Users can submit transactions directly to L2 chains, which handle them more efficiently (in terms of cost and speed) than Ethereum.
6+
7+
Under the hood, L2s create "batches" of transactions, and periodically submit many batches to Ethereum as a single transaction; potentially including information on thousands of transactions that occurred on the L2 in a single transaction on Ethereum.
8+
9+
Typically, L2s deploy smart contracts to Ethereum that handle the verification of these batches, ensuring that the transactions are valid. Since this verification process occurs on Ethereum, it is often said that L2s inherit the security of Ethereum.
10+
11+
![L2 Batching Overview](../../img/cdk/l2-overview-diagram.svg)
12+
13+
## Types of layer 2s
14+
15+
L2s come in different shapes and sizes in terms of their relationship with Ethereum: Each design decision comes with trade-offs in terms of security, scalability, or decentralization.
16+
17+
For example, some L2s, such as the [Polygon zkEVM](https://docs.polygon.technology/zkEVM/) send all transaction data to Ethereum, whereas other L2s only send information about the state differences, or choose not to send transaction data to Ethereum; instead relying on different data availability mechanisms.
18+
19+
Since storing information on Ethereum is expensive, (see [gas and fees](https://ethereum.org/en/developers/docs/gas/)), building an L2 chain means making tradeoffs between security, decentralization and scalability. The CDK provides developers with the tools to make these trade-offs and build a chain that meets their specific needs depending on their use case.
20+
21+
## Further reading
22+
23+
- [Ethereum documentation: Layer 2s](https://ethereum.org/en/layer-2/)
24+
- [Ethereum documentation: Scaling](https://ethereum.org/en/developers/docs/scaling/)

0 commit comments

Comments
 (0)