# ZKsync

### Overview

[ZKsync](https://docs.zksync.io/zk-stack) is network of ZK rollups that communicate with each other and post their transaction data to Ethereum via ZKsync Era. [ZKsync Era](https://docs.zksync.io/build) is a ZK rollup that posts batches of transactions to Ethereum with a validity proof that is verified on mainnet. The proof system and verification contracts have gone through several iterations and each version is listed below. The ZKsync Era query can be found [here](https://dune.com/queries/3890722).

#### ZKsync Era Alpha Validator Timelock (Pre-Boojum Upgrade)

The inital proof system used for ZKsync Era's alpha version was a SNARK based system. The original Validator Timelock [contract](https://etherscan.io/address/0x3dB52cE065f728011Ac6732222270b3F2360d919) was used from March 2023 until the Boojum upgrade went live.&#x20;

#### ZKsync Era Validator Timelock 2 (Post-Boojum Upgrade)

ZKsync Era launched the [Boojum proof system](https://zksync.mirror.xyz/HJ2Pj45EJkRdt5Pau-ZXwkV2ctPx8qFL19STM5jdYhc) in December 2023. This upgrade transitioned the proof system to a STARK based system with PLONK style arithmetization. There were several other notable improvements, including verifier optimizations and larger batch sizes. The Validator Timelock 2 [contract](https://etherscan.io/address/0xa0425d71cB1D6fb80E65a5361a04096E0672De03) was used from December 2023 until the Proto-Danksharding upgrade on mainnet.

#### ZKsync Era Validator Timelock 3

The Validator Timelock contract was upgraded to handle blobs after the Proto-Danksharding upgrade (EIP-4844). The Validator Timelock 3 [contract](https://etherscan.io/address/0xa8cb082a5a689e0d594d7da1e2d72a3d63adc1bd) was used from March 2024 until the v24 protocol upgrade.

#### ZKsync Era V4:  Validator Timelock

The [v24 protocol upgrade](https://github.com/zkSync-Community-Hub/zksync-developers/discussions/519) was completed in June 2024. This upgrade launched the zkSync BridgeHub, which allows for interoperability between ZK Stack chains. A new Validator Timelock [contract](https://etherscan.io/address/0x5D8ba173Dc6C3c90C8f7C04C9288BeF5FDbAd06E) was deployed as part of the upgrade and is the current version.

### Query Structure

The queries filter transactions sent to iterations of the Validator Timelock contracts that were successful and invoke proveBlocks or proveBatches.

### Calculations

* The proof volume is the sum of proveBlocks or proveBatches function calls
* The cost is calculated using the following formula:&#x20;
  * $$\text{cost} = \sum_{\text{traces}} \left( \text{gas\_used} \times \text{gas\_price} \times \text{eth\_price} \right)$$
  * Where:
    * $$\text{gas\_used}$$ is the amount of gas consumed by a trace in one of the verifiers
    * $$\text{gas\_price}$$ is the price of gas on the day of the transaction
    * $$\text{eth\_price}$$ is the average price of ETH in USD on the day of the transaction
