Runtime Composition
The Avail runtime (runtime/src/lib.rs:103-153) consists of 20+ pallets organized into functional categories:
Core Pallets
System & Utility Pallets
System & Utility Pallets
- System (index 0): Core blockchain functionality, block management
- Utility (index 1): Batch transactions and multi-signature operations
- Timestamp (index 3): Block timestamp management
- Indices (index 5): Account index lookup system
- Multisig (index 34): Multi-signature account operations
- Proxy (index 40): Proxy account delegation
Consensus & Block Production
Consensus & Block Production
- Babe (index 2): Block production using BABE (Blind Assignment for Blockchain Extension)
- Grandpa (index 17): Block finality using GRANDPA consensus
- Authorship (index 4): Block authorship tracking and uncle rewards
- ImOnline (index 20): Validator heartbeat mechanism
- AuthorityDiscovery (index 21): P2P authority node discovery
Economic & Governance
Economic & Governance
- Balances (index 6): Account balances and transfers
- TransactionPayment (index 7): Transaction fee calculation and payment
- Staking (index 10): Proof-of-Stake validator economics
- Session (index 11): Validator session management
- Treasury (index 18): On-chain treasury for protocol funds
- NominationPools (index 36): Pooled staking for nominators
Data Availability
Data Availability
- DataAvailability (da_control) (index 29): Core DA functionality, application keys, data submission
- Mmr (index 27): Merkle Mountain Range for efficient proofs
- Preimage (index 33): Storage for large preimages
Avail-Specific Features
Avail-Specific Features
- Vector (index 39): Ethereum light client bridge integration
- Mandate (index 38): Technical committee privileged calls
- Identity (index 37): On-chain identity management
- TxPause (index 41): Circuit breaker for pausing transactions
Transaction Flow
Transaction Processing Pipeline
Application ID Check
The
CheckAppId extension (pallets/dactr/src/extensions/check_app_id.rs) validates that the AppId exists if specified.Fee Calculation
TransactionPayment pallet calculates fees based on:
- Extrinsic weight
- Data length
- Dynamic fee multiplier
- For
submit_data: special weight calculation based on matrix space
da_control::weight_helper::submit_data (pallets/dactr/src/lib.rs:416-463)Data Availability Pallet
Theda_control pallet (pallets/dactr/src/lib.rs) is the core of Avail’s data availability functionality.
Key Data Structures
Dispatchable Functions
- create_application_key
- submit_data
- submit_block_length_proposal
- set_submit_data_fee_modifier
Creates a new application key and assigns an AppId.
pallets/dactr/src/lib.rs:158-178
- Ensures key doesn’t already exist
- Increments NextAppId
- Stores key-to-AppId mapping
- Emits
ApplicationKeyCreatedevent
Weight Calculation for Data Submission
Avail uses a sophisticated weight model forsubmit_data that accounts for data availability matrix space:
pallets/dactr/src/lib.rs:421-463
This weight model ensures that transactions consuming more matrix space pay proportionally higher fees, preventing block space spam.
Vector Pallet (Ethereum Bridge)
The Vector pallet (pallets/vector/src/lib.rs) implements an Ethereum light client bridge using zero-knowledge proofs.
Key Features
- Light Client Verification: Verifies Ethereum consensus using SP1 Groth16 proofs
- Message Passing: Enables cross-chain messaging between Avail and Ethereum
- Sync Committee Tracking: Maintains Ethereum beacon chain sync committee state
pallets/vector/src/lib.rs:35-48
Mandate Pallet
The Mandate pallet (pallets/mandate/src/lib.rs) provides a governance mechanism for the Technical Committee to execute privileged operations.
pallets/mandate/src/lib.rs:55-68
Runtime APIs
The runtime exposes several custom APIs for client-side operations (runtime/src/apis.rs:43-74):
DataAvailApi
ExtensionBuilder
KateApi
VectorApi
Configuration Parameters
Key runtime parameters defined inruntime/src/constants.rs and runtime/src/impls.rs:
Call Size Constraints
The runtime enforces strict size limits on calls to prevent DoS (runtime/src/lib.rs:326-343):
Box<T> to keep enum variants small.
Next Steps
Consensus
Learn how BABE and GRANDPA work together
Data Availability
Deep dive into Kate commitments