Components
It takes three main components of the Polygon zkEVM protocol to enable transaction finality while ensuring the correctness of state transitions:- The trusted sequencer.
- The trusted aggregator.
- The consensus contract (
PolygonZkEVM.sol, deployed on L1).
Trusted sequencer
The trusted sequencer receives L2 transactions from users, orders them, generates blocks of transactions, fills batches, and submits them to the consensus contract’s storage slots in the form of sequences. The trusted sequencer processes batches and distributes them to L2 network nodes to achieve immediate finality and reduce costs associated with high network usage, all before submitting them to L1. The trusted sequencer runs a zkEVM node in sequencer mode and controls an Ethereum account regulated by a consensus contract.Trusted aggregator
The trusted aggregator computes the L2 state based on batches of L2 transactions executed by the trusted sequencer. On the other hand, the primary function of the trusted aggregator is to receive the L2 batches validated by the trusted sequencer and produce zero-knowledge proofs verifying the computational integrity of these batches. The aggregator achieves this by employing a specialized off-chain EVM interpreter to generate the ZK proofs. The logic within the consensus contract verifies the zero-knowledge proofs, thereby endowing the zkEVM with the security of Layer 1. Before committing new L2 state roots to the consensus contract, verification is essential. A validated proof serves as undeniable evidence that a particular sequence of batches resulted in a specific L2 state.L2 state rootAn L2 state root is a cryptographic hash value of the L2 state. In case you want to read more about state roots, please check out this article.
Consensus contract
The consensus contract used by both the trusted sequencer and the trusted aggregator in their interactions with L1 is thePolygonZkEVM.sol contract.
The trusted sequencer can commit batch sequences to L1 and store them in the PolygonZkEVM.sol contract, creating a historical repository of sequences.
The PolygonZkEVM.sol contract also enables the aggregator to publicly verify transitions from one L2 state root to the next. The consensus contract accomplishes this by validating the aggregator’s zk-proofs, which attest to proper execution of transaction batches.