Skip to content

Commit a1c3aea

Browse files
mains sequencing structure
1 parent a9ce01b commit a1c3aea

File tree

12 files changed

+96
-11
lines changed

12 files changed

+96
-11
lines changed
1.39 MB
Loading

docs/zkEVM/architecture/high-level/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ When complete, this section will include information on:
4141

4242
### Currently out of scope
4343

44-
- The bridge service.
44+
- The in-development bridge service.
4545
- AggLayer.

docs/zkEVM/architecture/high-level/smart-contracts/addresses.md

Whitespace-only changes.

docs/zkEVM/architecture/high-level/smart-contracts/exit-root-trees.md renamed to docs/zkEVM/architecture/high-level/smart-contracts/api.md

File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
How bridging works: Bridge contracts -> keeping things in sync between chains L1 L2, sequencer, state db, local/global exit roots
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Transactions flowing through the system reach the smart contract environment after one of two contract call use cases; sequencing or verifying batches.
2+
3+
This section of the docs takes a closer look at the sequencing workflow.
4+
5+
## `sequenceBatches(...)`
6+
7+
The rollup sequencer component calls the [`sequenceBatches`](https://github.com/0xPolygonHermez/zkevm-contracts/blob/1ad7089d04910c319a257ff4f3674ffd6fc6e64e/contracts/v2/lib/PolygonRollupBaseEtrog.sol#L425) function on the [`PolygonZkEVMEtrog.sol`](https://github.com/0xPolygonHermez/zkevm-contracts/blob/1ad7089d04910c319a257ff4f3674ffd6fc6e64e/contracts/v2/consensus/zkEVM/PolygonZkEVMEtrog.sol) contract which inherits the function from [PolygonRollupBaseEtrog](https://github.com/0xPolygonHermez/zkevm-contracts/blob/1ad7089d04910c319a257ff4f3674ffd6fc6e64e/contracts/v2/lib/PolygonRollupBaseEtrog.sol).
8+
9+
The function takes an array of `BatchData` structs containing transactions.
10+
11+
```solidity
12+
struct BatchData {
13+
bytes transactions;
14+
bytes32 forcedGlobalExitRoot;
15+
uint64 forcedTimestamp;
16+
bytes32 forcedBlockHashL1;
17+
}
18+
```
19+
20+
The function checks them, organizes them, and appends them to the sequence correctly, eventually emitting a `SequenceBatch` event which sends a newly sequenced batch of transactions to the `PolygonRollupManager.sol` contract via the `onSequenceBatches(...)` function.
21+
22+
### `onSequenceBatches(...)`
23+
24+
This function takes the sequenced batches and adds them to the correct stack and updates the batch count.
25+
26+
## `sequenceBatchesValidium(...)`

docs/zkEVM/architecture/high-level/smart-contracts/rollup.md renamed to docs/zkEVM/architecture/high-level/smart-contracts/consensus-verification.md

File renamed without changes.

docs/zkEVM/architecture/high-level/smart-contracts/exit-roots.md

Whitespace-only changes.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## `PolygonRollupManager.sol`
2+
3+
The [PolygonRollupManager.sol](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/v2/PolygonRollupManager.sol) contract is responsible for managing rollups and verifying batches. It creates and updates rollup stacks by storing hash-sequenced data as newly sequenced batches arrive.
4+
5+
It is responsible for the verification workflow by supplying updated exit root data to the [[PolygonZkEVMGlobalExitRootV2.sol](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/v2/PolygonZkEVMGlobalExitRootV2.sol)](#polygonzkevmglobalexitrootv2sol) contract.
6+
7+
### Key functionality
8+
9+
- Defining and adding rollup types which contains consensus implementation details and compatibility checks.
10+
- Defining the [`RollupData`](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/v2/PolygonRollupManager.sol#L70s) struct.
11+
- Initializes the trusted aggregator process for verifying multiple batches.
12+
- Gets exit root data by computing all local exit roots of all rollups.
13+
- Calculates batch rewards.
14+
15+
## `PolygonZkEVMBridgeV2.sol`
16+
17+
The [PolygonZkEVMBridgeV2.sol](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/v2/PolygonZkEVMBridgeV2.sol) is the main communication mechanism between the L1 and L2 realms. It manages bridging and claiming of assets and messages across environments.
18+
19+
### Key functionality
20+
21+
- Bridging assets with the `bridgeAsset(...)` function.
22+
- Bridging messages with a choice of `bridgeMessage(...)` functions for various scenarios.
23+
- Claiming assets with the `claimAsset(..)` function.
24+
- Claiming messages with the `claimMessage(...)` function.
25+
- Verifying state and updating the global exit root with state changes.
26+
- Providing access to the global exit root manager via the `IBasePolygonZkEVMGlobalExitRoot`.
27+
- Interacting with the `PolygonZkEVMGlobalExitRootL2.sol` contract which exists in the L2 space as part of the bridge functionality.
28+
29+
## `PolygonZkEVMGlobalExitRootV2.sol`
30+
31+
The [PolygonZkEVMGlobalExitRootV2.sol](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/v2/PolygonZkEVMGlobalExitRootV2.sol) contract manages the L1 info tree that represents the current state of the system by updating global exit roots on state changes. It does this task across multiple networks and layers.
32+
33+
### Key functionality
34+
35+
- Updating the L1 info tree by emitting the `UpdateL1InfoTree(...)` event.
36+
- Updating exit roots.
37+
- Retrieving latest exit roots and leaf values.
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
1-
!!! warning
2-
Coming soon.
1+
<!-- https://excalidraw.com/#json=JKZp9QEihifF_B7Z41Dfv,FVNhqQKi9PA1jM0kzUoCsQ" -->
2+
3+
## Polygon smart contract architecture
4+
5+
The diagram below shows the Polygon smart contract architecture and how the consensus mechanism works through sequencing and verification activity.
6+
7+
The stacks direct transaction data into the L2 and L1 realms via Solidity smart contract calls, which then record the system state in binary tree structures that store local and global exit roots of the system.
8+
9+
### Smart contracts topology
10+
11+
![Polygon Solidity smart contract architecture](../../../../img/cdk/high-level-architecture/smart-contracts-full-view.png)
12+
13+
### Rollup contracts
14+
15+
The main contracts for the zkEVM rollup stack are [PolygonRollupManager.sol](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/v2/PolygonRollupManager.sol) which is responsible for managing rollup and validium batches; the bridge contract [PolygonZkEVMBridgeV2.sol](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/v2/PolygonZkEVMBridgeV2.sol) which is responsible for bridging and claiming activity across L1 and L2 chains; and the [PolygonZkEVMGlobalExitRootV2.sol](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/v2/PolygonZkEVMGlobalExitRootV2.sol) contract which manages the exit roots across multiple networks at the Ethereum L1 level.
16+
17+
### Valdium contracts
18+
19+
The CDK validium stacks use the [cdk-validium-contracts](https://github.com/0xPolygon/cdk-validium-contracts/tree/main) which has slightly adjusted behavior to take account of validium components, such as in the [PolygonZkEVMGlobalExitRootL2.sol](https://github.com/0xPolygon/cdk-validium-contracts/blob/main/contracts/PolygonZkEVMGlobalExitRootL2.sol) contract for example.
20+
21+
The CDK repo is a fork of the zkEVM main contracts repo and all contracts, therefore, extend from common interfaces.

0 commit comments

Comments
 (0)