# Storage and snapshots

State persistence is provided by the `mazze-storage` crate. It combines a Merkle Patricia Trie (MPT) with snapshotting and delta layers to balance performance and history retention.

## Storage layers

* Delta MPTs: append-only changes between snapshots.
* Snapshot MPTs: compact state snapshots at selected epochs.
* State DB backend: MDBX by default, configurable via `MdbxConfig`.

## StorageManager and state access

`StorageManager` and `StateManager` provide:

* Read/write access to the current state.
* Snapshot creation and pruning.
* Proof generation and state sync support.

## Snapshot policy

`StorageConfiguration` controls:

* `snapshot_epoch_count` and `era_epoch_count`.
* Extra snapshots for sync (`ProvideExtraSnapshotSyncConfig`).
* Cache sizes and open snapshot limits.
* Directory layout under `storage_db/`.

## Interaction with consensus

`BlockDataManager` keeps a `StateAvailabilityBoundary` describing which epoch states can be read. This allows full nodes to prune old state while still serving recent queries.

## Key source files

* `crates/dbs/storage/src/lib.rs`
* `crates/dbs/storage/src/state_manager.rs`
* `crates/dbs/storage/src/impls/storage_manager/snapshot_manager.rs`
* `crates/dbs/storage/src/impls/merkle_patricia_trie/mod.rs`
* `crates/mazzecore/core/src/block_data_manager/mod.rs`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mazze.io/architecture/storage-and-snapshots.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
