Build on X Layer

X Layer overview#

X Layer is a cutting-edge Ethereum layer 2 (L2) network built by OKX and Polygon using Polygon's CDK. It offers full compatibility with the Ethereum Virtual Machine (EVM), enabling developers to deploy existing Ethereum applications and develop new, innovative projects at a fraction of the cost compared to doing so on Ethereum. X Layer also enables users to use dapps at significantly lower gas fees and faster speed compared to Ethereum.

X Layer's underlying architecture is that of a zkEVM validium, which means that transactions are secured via ZK proofs. This architecture is a close sibling of ZK rollup, but it offers the following advantages over rollups:

  • Significantly lower fees, since they don't consume expensive Ethereum gas, i.e., blockspace to store transaction data.
  • Significantly higher scalability, since rollups’ throughput is bounded by the amount of transaction data that can be published to Ethereum.

For more detailed information, you can check out the X Layer architecture below.

X Layer architecture#

The major components of X Layer are:

  • Virtual Machine: zkEVM
  • Mode: Validium
  • Data Availability: Data Availability Committee (DAC)
  • Consensus: X Layer PoE contract (ZkEVM.sol)
  • Sequencer: Trusted
  • Gas token: OKB

X Layer Architecture

X Layer Validium#

X Layer is built with Polygon CDK, an advanced open-source framework designed for the rapid deployment of ZK-powered layer 2 (L2) blockchains on Ethereum.

X Layer adopts the validium mode, and implements a dedicated committee of sequencers, to maintain seamless interoperability with all other Polygon chains, delivering a high performance L2 scaling solution.

Since transaction data is not stored on the Ethereum mainnet, it is both executed and stored off-chain, which can lead to a massive enhancement in scalability. In the premise of ensuring security, Validium can reduce L1 gas storage costs, hence reducing transaction costs for users on L2, with a prominent enhancement in user privacy and user experience.

Similar to zero-knowledge rollups (ZK-rollups), X Layer confirms off-chain transactions on the Ethereum network. This approach prevents incorrect state changes and boosts the security of the X Layer network.

ZKValidium vs. ZKRollups#

zkValidiums differ from rollups and sidechains because they only share the proof of validity, which confirms the results of the transactions with Ethereum, not the actual transaction data of the executed transactions. Here is how it operates: a verifier smart contract is deployed on Ethereum, and validium submits proof of validity to this contract. These proofs are zero knowledge in nature and contain transaction outcomes but not the specific transaction data.

The verifier smart contract assesses the validity of the proof. If it is found to be invalid, any batch submitted by the validium is rejected and not stored on Ethereum.

ZKValidium vs. ZKRollup

Consensus contract#

ZkEVM.sol is the underlying protocol that guarantees the correctness of state changes through the use of validity proof. To confirm that specific predefined rules have been adhered to for permitting state transitions, the Consensus contract (ZkEVM.sol, deployed on Ethereum layer 1) comes into play.

ZkEVM.sol is responsible for verifying validity proofs to confirm that each transition has been executed correctly, utilizing ZK-SNARK circuits for verification. To make this system work, two key processes are involved: transaction batching and transaction validation. To perform these procedures, X Layer involves two types of participants: sequencers and aggregators.

Sequencer: it is responsible for proposing transaction batches to the network, essentially grouping transaction requests and adding them to the ZkEVM.sol.

Aggregator: it is responsible for reviewing the transaction batches’ validity and providing the necessary proofs of validity. Any permissionless aggregator can submit these proofs to demonstrate the accuracy of the state transition computation.

Consensus Contract Flow

Data Availability#

X Layer operates in validium mode, where it integrates a secure data availability layer managed by a DAC. Below are the functionalities of DAC:

  • Verifies the availability of data associated with specific blockchain blocks
  • Ensures data robustness and computational efficiency of X Layer

Advantages of the DAC provided by Polygon CDK#

The DAC primarily provides:

  • Lower transaction fees: less computations leads to lower fees
  • State privacy: maintaining a secure state change record to ensure data integrity

ZKNode#

ZKNode is a client used to sync with the state of X Layer. Trusted sequencer and trusted aggregator are responsible for managing the L2 state and its finality on L1. The following ZKNode architecture shows the flow of state updates.

ZKNode Architecture

Note
For more information on ZKNode, you can visit Polygon ZKNode.

ZKProver#

As an Ethereum scaling solution, X Layer simulates the Ethereum Virtual Machine to provide users with the same Ethereum experience while inheriting the security of the Ethereum mainnet.

X Layer employs a zero-knowledge prover component called ZKProver to generate validity proofs for ZKRollup. The ZKProver is expected to leverage accelerators such as GPU, FPGA, and ASIC to reduce proof time and cost significantly.

The general operational process is as follows: ZKProver receives a batch of many transactions from nodes and generates a concise zero-knowledge proof using state-of-the-art ZK tools and technology. This not only substantially reduces the time for final transaction confirmation but also significantly lowers users’ Gas consumption costs. The specific interaction flow can be referred to in the following diagram:

ZKProver Control Flow

  1. ZKNode sends the content of the Merkle tree to the database for storage.
  2. Then, ZK nodes send a batch of many transactions to the ZKProver component.
  3. ZKProver accesses the database and retrieves the necessary information to generate verifiable proofs for the transactions sent by the nodes. This information includes Merkle roots, the keys and hashes of relevant siblings, and more.
  4. Finally, ZKProver generates proofs for the transactions and sends them back to the ZK node.
Note
For more information on how ZKProver creates verifiable transaction proofs, you can visit Polygon ZKProver Overview.

Tokenomics#

There are two main actors on X Layer that earn OKB as reward and pay OKB token as Gas fee for transactions at the same time.

Sequencers#

  • Each sequencer is required to pay a fee in OKB tokens to have the privilege of creating and suggesting batches.
  • When a sequencer successfully proposes valid batches containing valid transactions, they are rewarded with the fees paid by transaction requestors or network users.

Aggregators#

  • Aggregators validate transactions proposed and batched by sequencers.
  • Aggregators need to run on X Layer’s ZKNode software, and create zero-knowledge validity proofs utilizing ZKProver.
  • For each validity proof submitted, aggregators earn the OKB fee, which is paid by the sequencer(s) of the batch(es).
  • Aggregators compete to produce validity proofs based on their strategies and intentions to validate transactions.

Transactions on X Layer#

Before making any transactions on layer 2, users need to have some OKB token on X Layer to perform any layer 2 transaction. To get OKB on layer 2, users need to transfer some OKB from L1 to L2 through X Layer bridge.

  1. Visit Bridge user guide for detailed steps to transfer OKB from L1 to layer 2.
  2. Layer 2 transactions:
  • The user starts a transaction from their wallet (e.g., MetaMask) and sends it to a sequencer.
  • Once the sequencer commits to adding the transaction, it becomes finalized on layer 2.
  • At this point, the transaction is settled on layer 2, but its state has not yet propagated to L1. This state is known as the trusted state.
  • The sequencer transmits the batch data to a smart contract on L1, permitting any node to synchronize its state from L1 in a secure, trustless manner. This state is referred to as the virtual state.
  • The aggregator gathers pending transactions for verification and constructs a proof to attain finality on L1.
  • After the proof undergoes validation, the user’s transactions gain finality on L1, a crucial step for actions like withdrawals. This state is called the verified state.

To get a sense of the complete transaction life cycle on X Layer, we recommend you to take a look at the Transactions and data flow document.

Note
For more EVM and zkEVM related questions, you can visit Polygon’s EVM Equivalence FAQ and General FAQ for more info.