Validium Docs
  • Overview
  • Connect to Validium
  • Start Coding 🚀
    • Quickstart
      • Overview
      • Deploy using Validium CLI
      • Deploy using Quickstart Repository
      • Deploy your first contract
      • Create an ERC20 token
  • Tooling
    • Block Explorers
    • Hardhat-Validium
      • Overview
      • Installation
      • Guides
        • Getting started
        • Migrating Hardhat project to Validium
        • Compiling non-inlinable libraries
      • Plugins
        • hardhat-zksync
        • hardhat-zksync-solc
        • hardhat-zksync-vyper
        • hardhat-zksync-deploy
        • hardhat-zksync-upgradable
        • hardhat-zksync-verify
        • hardhat-zksync-verify-vyper
        • hardhat-zksync-ethers
        • hardhat-zksync-node
        • Hardhat Community Plugins
    • Foundary
      • Overview
      • Installation
      • Getting Started
      • Migration Guide
        • Overview
        • Compilation
        • Deployment
        • Testing
  • Test and Debug
    • Getting Started
    • Docker L1 - L2 Nodes
    • In-Memory Node
    • Continuous Integration
    • Hardhat
    • Foundry
  • API Reference
    • Overview
    • Conventions
    • ZKs JSON-RPC API
    • Debug JSON-RPC API
    • Ethereum JSON-RPC API
    • PubSub JSON-RPC API
  • Concepts
    • Transaction Lifecycle
    • Blocks and Batches
    • Validium Network Fee Mechanism
    • Finality
    • System Upgrades
    • ZK Chains
    • Data Availability
      • Overview
      • Recreating L2 state from L1 pubdata
      • Validiums
    • Account Abstraction
    • L1 <-> L2 Communication
  • Components
    • Overview
    • Smart & System Contracts
      • Smart Contracts
      • System Contracts
    • Shared Bridges
    • Sequencer / Server
    • Validium Network EVM
      • Overview
      • Bootloader
      • Precompiles
      • Virtual Machine Specification
        • ZKsync Virtual Machine primer
        • VM Formal Specification
    • Prover
      • Overview
      • ZK Terminology
      • Running the Prover
      • Circuits
        • Overview
        • Circuit Testing
        • CodeDecommitter
        • DemuxLogQueue
        • ECRecover
        • KeccakRoundFunction
        • L1MessagesHasher
        • LogSorter
        • Main VM
        • RAMPermutation
        • Sha256RoundFunction
        • StorageApplication
        • Sorting and Deduplicating
          • Overview
          • SortDecommitments
          • StorageSorter
          • LogSorter
      • Boojum Gadgets
      • Boojum Function - `check_if_satisfied`
    • Compiler
      • Compiler Toolchain Overview
        • Compiler Toolchain Overview
        • Solidity Compiler
        • Vyper Compiler
        • LLVM Framework
      • Specification
        • Overview
        • Code Separation
        • System Contracts
        • Exception Handling
        • EVM Legacy Assembly Translator
        • Instructions
          • Instruction Reference
          • EVM
            • Native EVM Instructions
            • Arithmetic
            • Bitwise
            • Block
            • Call
            • Create
            • Environment
            • Logging
            • Logical
            • Memory
            • Return
            • Sha3
            • Stack
          • Extensions
            • Overview
            • Validium Network Extension Simulation (call)
            • Validium Network Extension Simulation (verbatim)
          • EVM Legacy Assembly
          • Yul
        • EraVM Binary Layout
    • Fee Withdrawer
    • Portal - Wallet + Bridge
    • Block Explorer
    • Transaction filtering
Powered by GitBook
On this page
  • State diffs: Optimizing storage slots
  • Additional data posted to L1
  • Validiums and zkPorter: Balancing Security and Efficiency
  • Recreating L2 State From L1 Pubdata
  • Basic Flow
  • Key components for state reconstruction
  • State Diffs
  • Contract Bytecodes
  1. Concepts
  2. Data Availability

Overview

An in-depth look at how Validium Network ensures data availability through state diffs and compresses data to optimize L1 submissions, plus tools for reconstructing L2 state from L1 public data.

PreviousData AvailabilityNextRecreating L2 state from L1 pubdata

Last updated 7 months ago


Data availability is a cornerstone of Validium Network's architecture, ensuring that the entire Layer 2 (L2) state can be from the data submitted to Ethereum's Layer 1 (L1). This process not only secures the network but also optimizes cost-efficiency through innovative data management techniques.

State diffs: Optimizing storage slots

Instead of submitting detailed transaction data, Validium Network focuses on posting state diffs to L1. These diffs represent changes in the blockchain's state, enabling Validium Network to efficiently manage how data is stored and referenced:

  • Efficient Use of Storage Slots: Changes to the same storage slots across multiple transactions can be grouped, reducing the amount of data that needs to be sent to L1 and thereby lowering gas costs.

  • Compression Techniques: All data sent to L1, including state diffs, is compressed to further reduce costs. Validium Network.

Additional data posted to L1

In addition to state diffs, Validium Network also posts other crucial information to ensure comprehensive data availability:

  • L2 to L1 Logs and Messages: These ensure that communications and events are recorded and accessible.

  • Published Bytecodes: The bytecodes of deployed smart contracts are made available, crucial for contract interaction and verification.

  • Compressed State Diffs: Further optimizes data management by reducing the size of state changes posted to L1.

Validiums and zkPorter: Balancing Security and Efficiency

When a chain opts not to post its data on-chain, it operates under a model known as a validium. This approach significantly reduces costs by keeping data off-chain but introduces risks related to data accessibility and security:

  • zkPorter: A hybrid model that combines features of rollups and validiums, zkPorter segments data responsibilities, allowing some storage slots to remain off-chain while critical data is posted to L1. .

Recreating L2 State From L1 Pubdata

ZKsync provides tools to validate and reconstruct the L2 state from data available on L1. Here's how this process is typically managed:

Basic Flow

  1. First, we need to filter all of the transactions to the L1 Validium Network contract for only the commitBlocks transactions where the proposed block has been referenced by a corresponding executeBlocks call (the reason for this is that a committed or even proven block can be reverted but an executed one cannot).

  2. Once we have all the committed blocks that have been executed, we then will pull the transaction input and the relevant fields. The kinds of pubdata we’ll pull from transaction data:

    • L2 to L1 Logs

    • L2 to L1 Messages

    • Published Bytecodes

    • Compressed State Diffs

Key components for state reconstruction

State Diffs

State diffs are essential for understanding changes within the blockchain's state, represented as key-value pairs:

naive way: ( storage_slot, address, value )
actual: ( derived_key, value )
compressed: ( derived_key or enumeration index, compressed_value )
  • Format: Typically presented as (derived_key, value), where derived_key is a hash of the storage slot and address, and value represents the storage value.

  • Compression and Enumeration: After the initial post, derived_key can be replaced with an enumeration index to optimize data size. The deeper meaning is that an enumeration key is the leaf index in our storage Merkle tree.

Contract Bytecodes

The handling of contract bytecodes involves:

  • Compression and Indexing: Opcodes are chunked, indexed, and compressed by the server-side operator before being verified and sent to L1.

  • Verification and Storage: A system contract ensures the accuracy of the compression before submission, with uncompressed bytecode hashes stored in AccountStorage for reference.

This process is split into 2 different parts:

The compressed bytecode makes it way up through factoryDeps and the hash of uncompressed bytecode is stored on the AccountStorage contract so the hash of the uncompressed bytecode will be part of the state diffs

handling the compression

verifying that the compression is correct before sending to L1.

reconstructed
Read more about
's compression methods
Learn more about zkPorter
the server side operator
the system contract