This document provides a high-level introduction to the Aztec Protocol codebase architecture, covering the relationship between Layer 1 (Ethereum) settlement, Layer 2 execution, and the zero-knowledge proving system. It describes the major components, their interactions, and how they fit together to enable privacy-preserving smart contracts on Ethereum.
For detailed information on specific subsystems:
The Aztec Protocol follows a three-tier architecture: the Client Layer for user-facing operations, the Node Layer for L2 network coordination, and the Settlement Layer on Ethereum L1 for finality and proof verification.
Sources: yarn-project/aztec-node/src/aztec-node/server.ts136-230 yarn-project/sequencer-client/src/sequencer/sequencer.ts1-230 yarn-project/archiver/src/archiver/archiver.ts1-223
The client layer provides user-facing interfaces for interacting with the Aztec network:
| Component | Location | Purpose |
|---|---|---|
aztec.js | yarn-project/aztec.js | TypeScript SDK for contract interaction and wallet management |
PXE (Private Execution Environment) | yarn-project/pxe | Handles private transaction simulation, key management, and client-side proving |
| Wallet implementations | yarn-project/accounts | Account abstraction implementations (ECDSA, Schnorr, etc.) |
The PXE runs locally or in a trusted environment and maintains private state for users, simulating private functions before submission to the network.
Sources: yarn-project/aztec.js yarn-project/pxe yarn-project/accounts
The node layer coordinates L2 network operations. The AztecNodeService class orchestrates all major components:
| Component | Class/File | Responsibilities |
|---|---|---|
| Sequencer | SequencerClient in yarn-project/sequencer-client/src/sequencer/sequencer.ts56 | Block building, checkpoint proposal, attestation collection |
| Archiver | Archiver in yarn-project/archiver/src/archiver/archiver.ts151 | Monitors L1 for events, retrieves blob data, stores historical blockchain data |
| WorldState | WorldStateSynchronizer | Maintains Merkle trees (note hash, nullifier, public data, archive) |
| P2P | P2P interface | Handles transaction gossip, block proposals, attestations via libp2p |
| Validator | ValidatorClient in yarn-project/validator-client/src/validator.ts47 | Validates block proposals, generates attestations |
| Prover | ProverClient | Orchestrates proof generation, coordinates with Barretenberg backend |
Sources: yarn-project/aztec-node/src/aztec-node/server.ts136-526 yarn-project/sequencer-client/src/sequencer/sequencer.ts56-230 yarn-project/archiver/src/archiver/archiver.ts151-223 yarn-project/validator-client/src/validator.ts47-90
The settlement layer on Ethereum L1 provides finality and manages the validator set:
| Contract | Purpose |
|---|---|
Rollup.sol | Core rollup contract that accepts checkpoint proposals and epoch proofs |
| Verifier contracts | Verify zero-knowledge proofs submitted by provers |
Inbox.sol / Outbox.sol | Handle L1-to-L2 and L2-to-L1 message passing |
| Governance contracts | Manage validator registration, staking, slashing |
The RollupContract class in TypeScript wraps the L1 contract for read/write operations:
Sources: l1-contracts/src/core/Rollup.sol yarn-project/ethereum/src/contracts/rollup_contract.ts
Smart contracts on Aztec are written in Noir and compiled through multiple stages before execution:
Noir Compilation: Noir source code (.nr files) compiles to:
AVM Transpilation: The avm-transpiler converts Brillig bytecode to AVM bytecode for public functions that execute on-chain
Execution Environments:
Proving: Barretenberg generates zero-knowledge proofs for both private and public execution
Sources: noir-projects/aztec-nr avm-transpiler barretenberg/cpp
Protocol constants are defined once in Noir and generated for all languages:
This ensures values like MAX_NOTE_HASHES_PER_TX, AZTEC_EPOCH_DURATION, etc. stay synchronized across the entire stack.
Sources: noir-projects/noir-protocol-circuits/crates/types/src/constants.nr
A complete transaction flows through multiple stages from user submission to L1 finality:
Private Execution (PXE):
aztec.jsPXE.sendTx()P2P Propagation:
P2P.sendTx() in yarn-project/p2pSequencer Selection:
Sequencer.work() in yarn-project/sequencer-client/src/sequencer/sequencer.ts201Public Execution:
PublicProcessor executing AVM bytecodeBlock Building:
BlockBuilder in yarn-project/sequencer-clientAttestation Collection:
ValidatorClient.attestToProposal() in yarn-project/validator-client/src/validator.ts197-230Checkpoint Proposal:
Rollup contract verifies quorumSequencerPublisher.enqueueProposeCheckpoint() in yarn-project/sequencer-client/src/publisher/sequencer-publisher.tsProof Generation:
ProverClient coordinating with BarretenbergL1 Finalization:
Sources: yarn-project/pxe yarn-project/sequencer-client/src/sequencer/sequencer.ts201-229 yarn-project/validator-client/src/validator.ts197-230 yarn-project/sequencer-client/src/publisher/sequencer-publisher.ts
The protocol organizes data into a hierarchical structure:
| Abstraction | Type | Description |
|---|---|---|
| Transaction | Tx in yarn-project/stdlib/src/tx/tx.ts | Single user operation with private and public components |
| Block | L2Block / L2BlockNew in yarn-project/stdlib/src/block/l2_block.ts | Batch of transactions with header and tx effects |
| Checkpoint | Checkpoint in yarn-project/stdlib/src/checkpoint/checkpoint.ts | One or more blocks proposed together, unit of L1 submission |
| Epoch | Epoch boundaries defined by slot ranges | Period after which proofs must be submitted |
Sources: yarn-project/stdlib/src/tx/tx.ts yarn-project/stdlib/src/block/l2_block.ts yarn-project/stdlib/src/checkpoint/checkpoint.ts
The protocol maintains several Merkle trees for state commitments:
Each tree is identified by MerkleTreeId and maintained by the WorldStateSynchronizer. Trees use LMDB for persistent storage.
Sources: yarn-project/world-state yarn-project/stdlib/src/trees
| Component | Location | Storage Technology | Purpose |
|---|---|---|---|
ArchiverDataStore | yarn-project/archiver/src/archiver/archiver_store.ts24 | LMDB | Historical blocks, logs, contracts |
KVArchiverDataStore | yarn-project/archiver/src/archiver/kv_archiver_store/kv_archiver_store.ts27 | LMDB | Concrete implementation |
WorldStateSynchronizer | yarn-project/world-state | LMDB | Merkle tree state |
PXEDatabase | yarn-project/pxe | KV store | User private state |
Sources: yarn-project/archiver/src/archiver/archiver_store.ts24-50 yarn-project/archiver/src/archiver/kv_archiver_store/kv_archiver_store.ts27-35
The archiver continuously synchronizes L1 data and propagates it to other components:
The Archiver class (defined in yarn-project/archiver/src/archiver/archiver.ts151) performs:
CheckpointProposed, MessageSent, and other eventsArchiverDataStoreKey method: Archiver.sync() at yarn-project/archiver/src/archiver/archiver.ts300-450
The WorldStateSynchronizer updates Merkle trees based on archiver data:
Sources: yarn-project/archiver/src/archiver/archiver.ts151-223 yarn-project/world-state
The AztecNodeService.createAndSync() method (at yarn-project/aztec-node/src/aztec-node/server.ts186-230) initializes the full node stack:
Configuration is validated against schemas defined in *ConfigSchema objects throughout the codebase. Example from yarn-project/sequencer-client/src/config.ts:
Sources: yarn-project/aztec-node/src/aztec-node/server.ts186-526 yarn-project/sequencer-client/src/config.ts
The Aztec Protocol implements a three-tier architecture where:
The system bridges privacy and public execution through a sophisticated pipeline involving:
Key orchestration classes:
AztecNodeService coordinates all node componentsSequencer manages block building and proposalArchiver synchronizes L1 data to L2ValidatorClient participates in consensusPXE handles private user operationsThis architecture enables privacy-preserving smart contracts with public state while maintaining Ethereum-level security through zero-knowledge proofs.
Sources: yarn-project/aztec-node/src/aztec-node/server.ts136-789 yarn-project/sequencer-client/src/sequencer/sequencer.ts56-660 yarn-project/archiver/src/archiver/archiver.ts151-1100 yarn-project/validator-client/src/validator.ts47-430 yarn-project/pxe barretenberg/cpp/CMakeLists.txt1-202
Refresh this wiki
This wiki was recently refreshed. Please wait 1 day to refresh again.