Core Components
The Avail node is structured around these primary architectural layers:Runtime Layer
The runtime (runtime/src/lib.rs:103-153) is composed of specialized pallets that handle different aspects of blockchain functionality:
- Consensus Pallets: BABE (block production) and GRANDPA (finality)
- Core Substrate Pallets: System, Balances, Transaction Payment, Staking
- Data Availability:
da_controlpallet for managing DA operations - Governance & Utility: Mandate, Vector, Identity, Proxy, TxPause
- Economic Pallets: Treasury, NominationPools, ElectionProviderMultiPhase
Node Layer
The node implementation (node/src/) provides:
- Block Import: Custom DA block import verification (
da_block_import.rs:29-168) - RPC Services: JSON-RPC endpoints for interacting with the chain
- Network Layer: P2P communication and chain synchronization
- Service Orchestration: Consensus, block authoring, and finalization services
Base Layer
The base module (base/src/) contains infrastructure for:
- Header Extensions: Data structures for Kate commitments (
header_extension/) - Metrics: Avail-specific monitoring and observability
- Memory Storage: Temporary storage mechanisms for DA operations
- Post-Inherents: Transaction processing hooks
Data Flow
Transaction Submission
Users submit transactions through the
da_control::submit_data extrinsic, which accepts arbitrary data payloads up to 1 MB.Block Construction
The block author collects transactions and arranges them into a 2D matrix structure for Kate commitment generation.
Kate Commitment
The runtime generates polynomial commitments over the data matrix, creating erasure-coded proofs for data availability.
Key Design Principles
Modular Data Availability
Avail separates data availability from execution. The chain stores and guarantees data availability without executing application-specific logic on that data.Polynomial Commitments
Kate polynomial commitments enable:- Efficient data availability sampling
- Compact proofs for arbitrary data segments
- Light client verification without downloading full blocks
Application-Specific Data
TheAppId system (runtime/src/lib.rs:42) allows multiple applications to use Avail for DA, with each transaction tagged to a specific application.
Runtime Configuration
Component Interactions
Block Production Pipeline
- Transaction Collection: Transactions are collected from the mempool
- Data Matrix Construction: Transactions are arranged into rows and columns
- Erasure Coding: Kate commitments are generated with 2x extension
- Header Extension: Commitments are embedded in the block header
- Consensus: BABE produces blocks, GRANDPA finalizes them
Verification Pipeline
- Header Extension Validation: Custom block import checks Kate commitments
- Data Root Calculation: Runtime API builds data root from extrinsics
- Extension Comparison: Imported extension must match calculated extension
- Post-Inherent Check: Ensures required inherents are present
The DA block import layer (
node/src/da_block_import.rs) ensures that only blocks with valid Kate commitments can be imported, providing cryptographic guarantees of data availability.Storage Architecture
Avail uses a combination of storage mechanisms:- On-chain Storage: Block headers with Kate commitments
- Block Body Storage: Full transaction data in the node database
- State Storage: Runtime state in a Merkle-Patricia trie
- MMR (Merkle Mountain Range): For efficient historical proof generation
API Layers
The runtime exposes multiple API surfaces (runtime/src/apis.rs):
- DataAvailApi: Query block length parameters
- ExtensionBuilder: Build and verify header extensions
- KateApi: Generate data proofs and retrieve specific rows/cells
- VectorApi: Ethereum light client bridge functionality
The modular architecture allows Avail to scale data availability independently of execution, making it suitable for rollup and validium use cases.
Next Steps
Runtime Architecture
Deep dive into runtime pallets and transaction processing
Consensus Mechanisms
Learn about BABE and GRANDPA consensus
Data Availability
Explore Kate commitments and DA guarantees