DataAvailApi runtime API provides methods to query block-level data availability parameters, primarily the block matrix dimensions that determine how transaction data is arranged for erasure coding and Kate commitments.
Overview
Runtime APIs are different from RPC endpoints:Runtime APIs vs RPC Endpoints
Runtime APIs vs RPC Endpoints
Runtime APIs execute inside the runtime (WebAssembly) and have direct access to the blockchain state. They are:
- Compiled into the runtime binary
- Execute deterministically on-chain
- Access runtime storage directly
- Called by the node client or RPC layer
- Versioned with the runtime
- Network communication interfaces
- State queries and transaction submission
- May call runtime APIs internally
- Not part of consensus
API Definition
Defined inruntime/src/apis.rs:43-47:
Methods
block_length
Returns the current block matrix dimensions and constraints.Block length configuration containing matrix dimensions and dispatch ratios.
Return Type: BlockLength
TheBlockLength structure contains:
Maximum block length per dispatch class.
Number of rows in the data matrix. Must be a power of 2 between 32 and 1024.Default: 256 rows
Number of columns in the data matrix. Must be a power of 2 between 32 and 1024.Default: 256 columns
Size of each matrix cell in bytes.Always: 32 bytes (31 bytes usable for data to fit in scalar field)
Implementation
The implementation delegates to the frame system (runtime/src/apis.rs:392-396):
Usage Context
When to Use
Callblock_length() when you need to:
- Calculate Matrix Space: Determine how much data fits in a block
- Validate Data Submissions: Check if data exceeds block capacity
- Generate Kate Proofs: Build the erasure-coded matrix
- Query Block Dimensions: Display current block configuration
Matrix Dimensions
The block matrix dimensions determine the data availability capacity:DA Dispatch Ratio: Only 90% of matrix space is allocated for data availability transactions (
submit_data). The remaining 10% is reserved for normal transactions to prevent DA transactions from blocking critical operations.Example Calculations
- Default (256×256)
- Maximum (1024×1024)
- Minimum (32×32)
Dynamic Block Length
Block dimensions can be adjusted via governance using theda_control::submit_block_length_proposal dispatchable function.
Adjustment Process
Validate Dimensions
Ensures dimensions are:
- Powers of 2
- Within bounds (32-1024 for both rows and cols)
- Supported by the Kate commitment system
Constraints
Code Example
Calling the runtime API from Rust client code:Related APIs
KateApi
Generate Kate commitments and data availability proofs using block dimensions.
Kate RPC
RPC endpoints for querying Kate proofs and data availability information.
Data Availability
Learn how the matrix dimensions relate to erasure coding and Kate commitments.
Runtime Architecture
Understanding the da_control pallet and block length configuration.
API Version History
Version 2 (Current)
Version 2 (Current)
Current version: 2
- No changes from version 1
- Marked with
#[api_version(2)]in source
The API version is incremented when the runtime API signature changes. Clients should check the API version to ensure compatibility.