What Is DA Compression in Fuel Core? Architecture and Implementation Guide
DA compression in Fuel Core is a configurable storage optimization that compresses historic block data into a compact representation containing only headers and transaction IDs, storing full transaction payloads off-chain while maintaining data-availability guarantees through a dedicated compression service.
DA compression (Data‑Availability compression) is a first‑class feature of the FuelLabs/fuel-core repository designed to reduce on‑chain storage requirements. When enabled, the node maintains a temporal registry of compressed blocks in a separate RocksDB column family, allowing operators to specify retention periods for historic data while keeping essential metadata accessible via the GraphQL API.
How DA Compression Works in Fuel Core
The DaCompressionMode Configuration Enum
At the heart of the feature lies the DaCompressionMode enum defined in crates/fuel-core/src/service/config.rs. This enum controls whether compression is active and configures retention policies via the DaCompressionConfig struct.
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum DaCompressionMode {
#[default]
Disabled,
Enabled(DaCompressionConfig),
}
Source: [crates/fuel-core/src/service/config.rs (lines 440‑447)](https://github.com/FuelLabs/fuel-core/blob/master/crates/fuel-core/src/service/config.rs#L440-L447)
The Compression Service Architecture
When the node starts, sub_services.rs inspects the configuration variant. If enabled, it spawns the CompressionService from crates/services/compression. This background task watches the block production pipeline, compresses completed blocks, and maintains a temporal registry mapping block‑level keys (addresses, contract IDs, script code) to their compressed values.
let compression_service = match &config.da_compression {
DaCompressionMode::Disabled => None,
DaCompressionMode::Enabled(cfg) => Some(CompressionService::new(cfg.clone())),
};
Source: [crates/fuel-core/src/service/sub_services.rs (lines 452‑456)](https://github.com/FuelLabs/fuel-core/blob/master/crates/fuel-core/src/service/sub_services.rs#L452-L456)
VersionedCompressedBlock and Storage Format
The core data structure VersionedCompressedBlock lives in crates/compression/src/lib.rs. It stores the block header and a list of transaction IDs without the full transaction payloads, dramatically reducing the storage footprint while preserving data‑availability proofs.
Enabling DA Compression: Code Examples
CLI Parsing in the Fuel Core Binary
The fuel-core binary accepts the --da-compression flag in bin/fuel-core/src/cli/run.rs, converting the retention duration into the enabled mode.
let da_compression = match da_compression {
Some(retention) => DaCompressionMode::Enabled(DaCompressionConfig {
retention_duration: retention,
..Default::default()
}),
None => DaCompressionMode::Disabled,
};
Source: [bin/fuel-core/src/cli/run.rs (lines 595‑607)](https://github.com/FuelLabs/fuel-core/blob/master/bin/fuel-core/src/cli/run.rs#L595-L607)
Config Struct Integration
The top‑level Config struct holds the compression mode alongside other node settings.
pub struct Config {
// ...
pub da_compression: DaCompressionMode,
// ...
}
Source: [crates/fuel-core/src/service/config.rs (lines 101‑106)](https://github.com/FuelLabs/fuel-core/blob/master/crates/fuel-core/src/service/config.rs#L101-L106)
Accessing Compressed Blocks via GraphQL
Schema and Resolver Implementation
The GraphQL layer exposes compressed blocks through crates/fuel-core/src/schema/da_compressed.rs. The resolver obtains the DaCompressionProvider from the context to fetch VersionedCompressedBlock data from the off‑chain store.
let da_compression_provider = ctx.data_unchecked::<DaCompressionProvider>();
Source: [crates/fuel-core/src/schema/da_compressed.rs (lines 42‑44)](https://github.com/FuelLabs/fuel-core/blob/master/crates/fuel-core/src/schema/da_compressed.rs#L42-L44)
GraphQL queries use the daCompressedBlock field:
type Query {
daCompressedBlock(height: UInt32!): DaCompressedBlock
}
Testing DA Compression
Integration Test Validation
The test suite in tests/tests/da_compression.rs verifies the full pipeline, ensuring that nodes can start, produce blocks, restart with compression enabled, and correctly populate the compression database.
#[tokio::test]
async fn da_compression__starts_and_compresses_blocks_correctly_from_empty_database() {
// 1. Start node without compression.
// 2. Produce a few blocks.
// 3. Restart node with `--da-compression 7d`.
// 4. Ensure compressed blocks appear in the compression DB.
}
Source: [tests/tests/da_compression.rs (lines 214‑236)](https://github.com/FuelLabs/fuel-core/blob/master/tests/tests/da_compression.rs#L214-L236)
Key Source Files in the Fuel Core Repository
Understanding DA compression requires familiarity with these specific files:
crates/fuel-core/src/service/config.rs– DefinesDaCompressionMode,DaCompressionConfig, and the top‑levelConfigstruct.crates/fuel-core/src/service/sub_services.rs– Wires theCompressionServiceinto the node’s service graph based on the configuration variant.crates/fuel-core/src/schema/da_compressed.rs– Implements the GraphQL resolver andDaCompressionProviderinterface.crates/services/compression/src/lib.rs– Public API of the compression service, exposing the background task and configuration ports.crates/compression/src/lib.rs– Core data structures includingVersionedCompressedBlockandCompressedBlockPayload.bin/fuel-core/src/cli/run.rs– Parses the--da-compressionCLI argument and initializes the config.tests/tests/da_compression.rs– End‑to‑end integration tests exercising the compression pipeline.
Summary
- DA compression reduces on‑chain storage by retaining only block headers and transaction IDs, moving full transaction data to an off‑chain RocksDB column family.
DaCompressionModecontrols the feature via CLI flags, supporting configurable retention periods throughDaCompressionConfig.CompressionServiceruns as a background sub‑service, asynchronously compressing blocks and maintaining the temporal registry for efficient historical lookups.VersionedCompressedBlockserves as the compact, versioned storage format for compressed payloads.- GraphQL integration exposes compressed data via the
daCompressedBlockquery, backed by theDaCompressionProvidertrait. - The implementation spans the configuration layer, service architecture, compression algorithms, and public API surface of
fuel-core.
Frequently Asked Questions
What triggers DA compression in Fuel Core?
The compression service activates automatically when the node starts with DaCompressionMode::Enabled. It listens for newly produced blocks via the block production pipeline and compresses them asynchronously, writing the resulting VersionedCompressedBlock to a dedicated storage column without blocking consensus or block import.
How do I enable DA compression on my Fuel Core node?
Pass the --da-compression flag followed by a retention duration when starting the binary. For example, --da-compression 7d enables compression with a seven‑day retention window. The parser in bin/fuel-core/src/cli/run.rs converts this argument into DaCompressionMode::Enabled(DaCompressionConfig { retention_duration: ... }), which the service constructor uses to initialize the background compressor.
Does DA compression affect data availability or security?
No critical data is lost. The compressed representation preserves the block header and transaction IDs, maintaining data‑availability guarantees required for validation. Only the full transaction payloads move to off‑chain storage, remaining accessible through the node’s database or GraphQL queries via the DaCompressionProvider interface.
Can I disable DA compression after enabling it?
Yes, but changing modes requires a node restart. Setting DaCompressionMode::Disabled stops the compression service and returns the node to storing full blocks in the main database. Historical compressed blocks already written to the compression column family remain there until the configured retention period expires or manual pruning occurs.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →