Architecture / protocol economics / security research

ZKsync OS

A first-principles map of how value moves through ZKsync OS, how execution becomes a RISC-V trace, how Airbender proves that execution, and where accounting or semantic mismatches could become protocol-security bugs.

ZKsync OS Airbender Architecture RISC-V STARK / FRI Rust
01 / First principles

What are we actually proving?

The most useful mental model is not “a blockchain that happens to use ZK.” It is a state-transition machine whose execution is turned into a proof of correct computation.

Old protocol statebalances · storage · nonces · roots
Transaction / program inputauthenticated request + execution parameters
ZKsync OS executionRISC-V program executes the state transition
New protocol statestate writes + receipts + commitments
Airbender proofproves that the transition was executed correctly
Core security equation:
Old State + Valid Inputs + Correct Execution = New State
The prover must not be able to produce an accepted proof when the execution engine and the circuit disagree about that equation.
02 / Economics

How money flows in ZKsync OS

Separate the user's fee, the operator's costs, and the assets represented by the rollup state. They are related, but they are not the same accounting object.

User pays transaction fee
Transaction fee accounting execution / pubdata / settlement components
ExecutionVM computation + resources
Pubdatadata/state-diff publication costs
L1 settlementEthereum transaction / proof settlement costs
Operator / protocol economics revenue minus proving, L1 and infrastructure costs
Important distinction: “operator profit = user fees − costs” is an economic model, not a claim that every fee component is literally transferred to one operator account at that exact point in the execution code. Audit the actual fee-credit/debit paths before treating a balance movement as protocol revenue.

Pubdata is not “just gas”

Pubdata is the information needed to make the rollup's state transition reconstructible/verifiable on L1. Depending on the protocol design and era, this can include compressed transaction/state-diff information and commitments. The security question is: does the data committed on L1 correspond to the state transition actually proven?

03 / Settlement

Sequencer → Ethereum

ZKsync OSexecute transactions and produce a new state
Batch / state transitionstate root + public data + proof inputs
Airbenderprove RISC-V execution
Final proof / wrappercompress/wrap the proof for settlement
EthereumL1 publication + verification / settlement

The operator therefore has an economic stack underneath execution: L1 publication costs, proving costs, infrastructure, storage, networking and operational overhead. The exact fee schedule and who bears each cost must be read from the current ZKsync protocol implementation rather than inferred only from the diagram.

04 / Proving

Execution → witness → proof

RISC-V executionCPU simulator / ZKsync OS program
Execution trace / witnessregisters, memory interactions, timestamps and auxiliary data
Stage 1witness LDEs + trace commitments
Stage 2lookup + memory arguments
Stage 3primary STARK quotient polynomial
Stage 4DEEP / batched FRI polynomial
Stage 5FRI / IOPP proof
Recursionconnect chunks and compress proofs
Final proofwrapped into a compact proof suitable for verification

Airbender's current architecture uses a RISC-V 32I+M proving machine with DEEP-STARK/FRI arguments, lookup/RAM/delegation arguments and AIR constraints. The repository describes proving in chunks, connecting chunks with global RAM and delegation arguments, and then joining them through recursion.

CPU path

A native Rust RISC-V simulator can generate the preliminary witness. CPU implementations and GPU implementations mirror the proving pipeline.

GPU path

GPU proving can accelerate the heavy circuit work. Current documentation notes that final proofs may still require CPU resources in some configurations.

05 / Asset accounting

Bridge flow

Ethereum → ZKsync

L1 escrow / canonical asset
ZKsync credit / representation

ZKsync → Ethereum

Burn / lock / withdrawal accounting
L1 release
Accounting invariant: L1 canonical assets ≥ valid outstanding L2 claims. A bridge bug is often a mismatch between the canonical asset ledger and the claim represented by the L2 state.

Historically, ZK rollups are described as holding funds in an L1 smart contract while computation and storage happen off-chain, with validity proofs used to establish correct state transitions.

06 / Codebase map

Do not confuse ZKsync OS with Airbender

These are two connected but different layers. ZKsync OS is the generalized RISC-V-based state-transition implementation. Airbender is the proving system that proves execution of RISC-V programs. The official ZKsync OS repository lists components such as zk_ee, basic_bootloader, evm_interpreter, zksync_os_runner and forward_system.

Protocol / OS
zksync-os — state transition function, execution environments and system logic
Execution
basic_bootloader/, process_transaction, runner, evm_interpreter/
State
storage_models/, state-transition code, writeback/diff handling
Proving
zksync-airbender — AIR, lookup/RAM/delegation arguments, STARK/FRI and recursion
Prover service
zksync-airbender-prover — FRI prover, SNARK prover and prover service
Settlement
Final proof / wrapper / verifier path toward Ethereum

Airbender's end-to-end documentation describes the flow from a RISC-V binary through proving, final proof generation, SNARK wrapping and verification.

07 / Security research

Where the highest-value bugs live

The most dangerous class is a semantic mismatch: the execution engine says one thing while the proving circuit, verifier, or settlement layer accepts another.

VM semanticswhat execution actually does
AIR / constraint semanticswhat the circuit enforces
Prover assumptionswhat witness generation assumes
Verifier / settlement assumptionswhat ultimately gets accepted
Highest-value question:
What happens if validation succeeds, execution partially fails, and some accounting or state-commit subsystem still progresses?
AreaPriorityWhat to ask
OrchestrationVERY HIGHWhich phase runs after validation or failure?
State transitionVERY HIGHWhen does state actually mutate?
AccountingVERY HIGHDoes every credit have a corresponding debit?
Replay protectionVERY HIGHCan a value-changing action execute twice?
SettlementVERY HIGHWhat exactly is committed to L1?
ValidationHIGHWhat assumptions survive past validation?
StorageHIGHAre reads/writes and final roots consistent?
Execution engineHIGHDoes the VM match the circuit?
Math / cryptoLOW initiallyStudy after protocol invariants are understood.
08 / Reading order

Files to study first

basic_bootloader/
Start here. Understand the top-level lifecycle and execution phases.
process_transaction.rs
Trace validation, nonce handling, execution, fee charging and failure paths.
runner.rs
Understand frames, reverts, execution lifecycle and what survives failure.
gas_helpers.rs
Follow fee charging, refunds and accumulators precisely.
state_transition_parts/
Follow operand decoding, execution effects and writeback.
devices/diffs.rs
Investigate the representation of execution-induced changes; validate the exact current role in the repo.
storage_models/
Understand how state reads, writes and roots are represented.
evm_interpreter/
Connect EVM semantics to the generalized execution environment.
Airbender cs/, tables and prover stages
Only after you understand the state machine: learn how execution claims become constraints and proofs.

Complex math — later

Study field arithmetic, FRI folding, quotient-polynomial generation and circuit optimization after the protocol lifecycle is clear. Otherwise it is easy to understand the mathematics without understanding what security property the mathematics is protecting.

09 / Research method

Audit one invariant, not the whole repository

Pick one invariant and follow it through every layer. A strong starting point is:

fees credited == fees debited

Then search for every place that can affect it:

Money words

fee balance debit credit refund reward settle accumulator

Control words

is_valid verified authorized execute commit writeback finalize

Then draw the real execution path

validate
   ↓
execute
   ↓
update state
   ↓
accumulate fees
   ↓
refund / settle
   ↓
commit / publish

At every transition ask: “What can still happen after something important has failed?”

A powerful habit: whenever you see accumulator += x, stop and ask where x came from, whether the operation can execute twice, whether the matching debit is guaranteed, and what happens if the surrounding transaction later reverts.

Trace one boolean everywhere

Pick one control bit such as is_valid, verified, should_execute, commit or reverted. Follow its origin, transformations and consumers. Security bugs often hide where one subsystem assumes a boolean was already enforced by another subsystem.

10 / Invariants

What you should be able to prove

State conservation

old_state + valid_effects = new_state

Fee conservation

total_debits = total_credits + explicit_burn/costs

Replay safety

One authorized state-changing action cannot be applied twice.

Proof soundness

No invalid execution trace satisfies all enforced constraints.

Commitment consistency

The state/data committed for settlement corresponds to the proven transition.

Failure atomicity

A failed or reverted operation cannot leave behind an unauthorized value change.

11 / Primary sources

Read the implementation, not just the diagram

The current Airbender documentation describes the system as a RISC-V prover with AIR, lookup/RAM/delegation arguments, chunked proving and recursion. The separate prover-service repository provides FRI and SNARK prover services.