Polygon zkEVM Protocol
Various Layer 2 solutions aimed at improving the scalability of the Ethereum network, primarily transaction throughput, have been developed over the past years. The ultimate and intended benefit for Ethereum network users is a reduction in gas fees, while maintaining decentralisation and security.
Polygon zkEVM is a Layer 2 Rollup solution that combines data availability and execution verification in Layer 1 of the Ethereum blockchain to ensure L2 state transition security and reliability.
This section will describe the infrastructure that Polygon designed and implemented for its zkEVM, with a focus on providing an overview of the components used in the development of the zkEVM Protocol.
This section describes the components used in the Polygon zkEVM to enable transaction finality while ensuring the correctness of state transitions.
The three main components of zkEVM protocol are:
- Trusted Sequencer
- Trusted Aggregator, and
- Consensus Contract (PolygonZkEVM.sol, deployed on L1)
The Trusted Sequencer component is in charge of receiving L2 transactions from users, ordering them, generating batches, and submitting them to the Consensus contract's storage slots in the form of sequences.
The Sequencer executes and broadcasts batches of transactions to L2 network nodes in order to achieve fast finality and reduce costs associated with high network usage. That's before even submitting them to L1.
The Trusted Sequencer must run a zkEVM node in Sequencer mode and be in control of a Consensus Contract-enforced Ethereum account.
The Trusted Aggregator component can compute the L2 State based on batches of L2 transactions executed by the Trusted Sequencer.
The main role of the Trusted Aggregator, on the other hand, is to take the L2 batches committed by the Trusted Sequencer and generate Zero-Knowledge proofs attesting to the batches' computational integrity. These ZK proofs are generated by the Aggregator using a special off-chain EVM interpreter.
The Consensus Contract's logic validates the Zero-Knowledge proofs, resulting in the zkEVM inheriting the L1 security. Verification is required before committing new L2 State roots to the Consensus Contract. A verified proof is an irrefutable evidence that a given sequence of batches led to a specific L2 State.
The Trusted Aggregator should run a zkEVM node in Aggregator mode and must control a specific Ethereum account enforced in a Consensus Contract.
The Consensus Contract used by both the Trusted Sequencer and the Trusted Aggregator in their interactions with L1 is the PolygonZkEVM.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.
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 the proper execution of transaction batches.
zkEVM Node Execution Modes
zkEVM node is a software package containing all components needed to run zkEVM network. It can be run in three different modes; as a Sequencer, an Aggregator, or RPC.
In the Sequencer mode, the node holds an instance of L2 State, manages batch broadcasting to other L2 network nodes, and has a built-in API to handle L2 user interactions (transaction requests and L2 State queries).
There is also a database to temporarily store transactions that have not yet been ordered and executed (pending transactions pool), as well as all the components required to interact with L1 in order to sequence transaction batches and keep its local L2 State up to date.
In the Aggregator mode, the node has all the components needed to execute transaction batches, compute the resulting L2 State and generate the Zero-Knowledge proofs of computational integrity.
Also, has all the components needed to fetch transaction batches committed in L1 by the Trusted Sequencer and call the functions to publicly verify the L2 State transitions on L1.
In the RPC mode, the zKEVM node has a limited functionality. It primarily maintains an up-to-date instance of L2 State, initially with respect to batches broadcast by the Trusted Sequencer, and later with sequences of batches fetched from the Consensus Contract.
The node continuously interacts with L1 in order to keep the local L2 State up to date, as well as to check the synchronization of L2 State roots. The default syncing rate for the synchroniser is every 2 seconds, unless stipulated otherwise in the configuration.