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.
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 State + Valid Inputs + Correct Execution = New StateThe prover must not be able to produce an accepted proof when the execution engine and the circuit disagree about that equation.
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.
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?
Sequencer → Ethereum
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.
Execution → witness → proof
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.
Bridge flow
Ethereum → ZKsync
ZKsync → Ethereum
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.
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.
zksync-os — state transition function, execution environments and system logicbasic_bootloader/, process_transaction, runner, evm_interpreter/storage_models/, state-transition code, writeback/diff handlingzksync-airbender — AIR, lookup/RAM/delegation arguments, STARK/FRI and recursionzksync-airbender-prover — FRI prover, SNARK prover and prover serviceAirbender's end-to-end documentation describes the flow from a RISC-V binary through proving, final proof generation, SNARK wrapping and verification.
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.
What happens if validation succeeds, execution partially fails, and some accounting or state-commit subsystem still progresses?
| Area | Priority | What to ask |
|---|---|---|
| Orchestration | VERY HIGH | Which phase runs after validation or failure? |
| State transition | VERY HIGH | When does state actually mutate? |
| Accounting | VERY HIGH | Does every credit have a corresponding debit? |
| Replay protection | VERY HIGH | Can a value-changing action execute twice? |
| Settlement | VERY HIGH | What exactly is committed to L1? |
| Validation | HIGH | What assumptions survive past validation? |
| Storage | HIGH | Are reads/writes and final roots consistent? |
| Execution engine | HIGH | Does the VM match the circuit? |
| Math / crypto | LOW initially | Study after protocol invariants are understood. |
Files to study first
basic_bootloader/Start here. Understand the top-level lifecycle and execution phases.
process_transaction.rsTrace validation, nonce handling, execution, fee charging and failure paths.
runner.rsUnderstand frames, reverts, execution lifecycle and what survives failure.
gas_helpers.rsFollow fee charging, refunds and accumulators precisely.
state_transition_parts/Follow operand decoding, execution effects and writeback.
devices/diffs.rsInvestigate 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.
cs/, tables and prover stagesOnly 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.
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?”
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.
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.
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.