-
Notifications
You must be signed in to change notification settings - Fork 10
docs: misc docusaurus improvements #478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
eb8d4aa
chore: update OpenAPI specification and documentation visual improvem…
linconvidal 5c8fb34
chore: update OpenAPI specification for java implementation
linconvidal df86ed3
chore: update Docusaurus configuration and CSS for improved documenta…
linconvidal 70dc5a1
chore: update dependencies in package.json and yarn.lock
linconvidal b419ccc
chore: restore SearchTransactionsResponse schema to specs
linconvidal f6610f9
fix: remove schema 'examples' breaking CI validation
linconvidal 84a331a
chore: update OpenAPI generator plugin version and refine example val…
linconvidal 560ad05
chore: drop API spec and pom edits from PR 456
linconvidal 78bf58d
chore: update Docker compose command and version in documentation
linconvidal b76c5a8
refactor: update documentation for spent UTXO pruning
linconvidal 9e05c10
docs: enhance documentation for queryng stake addresses and rename mu…
linconvidal 9ab932c
docs: update performance measurement documentation and environment va…
linconvidal 6622029
docs: update storage requirements and pruning notes in documentation
linconvidal b632cb1
Merge branch 'main' into docs/misc-improvements
linconvidal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,134 @@ | ||
--- | ||
sidebar_position: 1 | ||
title: Remove Spent UTXOs | ||
description: Optimizing disk usage with removal of spent UTxOs | ||
title: Spent UTXO Pruning | ||
description: Optimizing disk usage with spent UTXO pruning | ||
--- | ||
|
||
# Remove Spent UTXOs | ||
# Spent UTXO Pruning | ||
|
||
This guide explains how to optimize disk usage in **cardano-rosetta-java** through removal of spent utxo (a special rosetta-java specific form of pruning). | ||
This guide explains how to optimize disk usage in **cardano-rosetta-java** through spent UTXO pruning, including its impact on Rosetta API endpoints and configuration options. | ||
|
||
## What is UTxO Spent Pruning (removal of spent UTxOs)? | ||
## Understanding Spent UTXO Pruning | ||
|
||
UTxO Spent Pruning removes spent (consumed) UTXOs from local storage, keeping only unspent UTXOs. This can reduce on-disk storage from ~1TB down to ~400GB, but discards historical transaction data. | ||
Spent UTXO pruning is a disk optimization mechanism in `cardano-rosetta-java`, powered by its underlying indexer, Yaci-Store. This feature selectively removes data related to spent UTXOs from the local database. | ||
|
||
- Only unspent outputs are preserved. | ||
- You can still validate the chain's current state (and spend tokens), since active UTXOs remain. | ||
- You should be able to build transaction because only spent UTxOs are removed (unspent stay) | ||
**Core Principles:** | ||
|
||
- **Targeted Deletion**: Only _spent_ UTXOs are removed. All _current, unspent_ UTXOs are preserved, ensuring the accuracy of the present blockchain state and balances. | ||
- **Distinction from Other Pruning**: This mechanism differs from what is commonly understood as 'pruning' in some other blockchain contexts, including certain descriptions in the Coinbase Mesh API (formerly Rosetta). Unlike methods such as Bitcoin's pruning (which removes entire historical blocks), our approach retains full block history but selectively trims the UTXO set by removing only spent outputs. | ||
|
||
**How it Works:** | ||
When enabled, the pruning process operates as follows: | ||
|
||
1. New UTXOs are indexed as transactions occur. | ||
2. UTXOs are marked as spent when consumed in subsequent transactions. | ||
3. A background job periodically permanently deletes spent UTXOs that are older than a configurable safety margin (default: 2,160 blocks, ~12 hours on mainnet). This buffer safeguards data integrity against chain rollbacks within Cardano's finality window. | ||
|
||
**Impact Summary:** | ||
| Aspect | Effect | | ||
| :------------------------- | :----------------------------------------------------------- | | ||
| **Disk Storage** | ✅ Significantly reduced (e.g., mainnet from ~1TB to ~500GB) | | ||
| **Current UTXO Set** | ✅ Fully preserved; current balances remain accurate | | ||
| **Historical Spent UTXOs** | ⚠️ Permanently deleted beyond the safety margin | | ||
| **Query Performance** | ✅ Improved for queries against the current UTXO set | | ||
|
||
## Impact on Rosetta API Endpoints | ||
|
||
Spent UTXO pruning affects Rosetta API endpoints differently based on their reliance on historical transaction data. The table below summarizes the impact. Note that "Recent" refers to data within the safety margin (default ~12 hours). | ||
|
||
:::info Oldest Block Identifier | ||
When pruning is enabled, the `/network/status` endpoint includes an additional `oldest_block_identifier` object in its response. This identifier corresponds to the latest fully queryable block with complete data. Below this block index, blocks might have missing data due to pruning, making historical queries unreliable. | ||
::: | ||
|
||
| **Endpoint** | **Current State** | **Historical Queries** | **Impact & Notes** | | ||
| ---------------------- | ----------------- | ---------------------- | ---------------------------------------------------------------------------- | | ||
| `/account/balance` | ✅ Works | ⚠️ Limited | **Low** - Current balances unaffected | | ||
| `/account/coins` | ✅ Works | ⚠️ Limited | **Low** - Current UTXO lists complete | | ||
| `/block` | ✅ Recent only | ❌ Incomplete | **High** - Missing old transaction inputs | | ||
| `/block/transaction` | ✅ Recent only | ❌ Incomplete | **High** - Missing spent UTXOs operation details | | ||
| `/search/transactions` | ⚠️ Recent only | ❌ Limited | **Medium** - Hash search works, address limited | | ||
| `/network/status` | ✅ Works | ✅ Works | **None** - Returns additional `oldest_block_identifier` when pruning enabled | | ||
| `/network/*` | ✅ Works | ✅ Works | **None** - Independent of UTXO data | | ||
| `/construction/*` | ✅ Works | ✅ Works | **None** - Uses current UTXOs only | | ||
|
||
After enabling pruning, searching for transactions by their hash will always work, because transaction records themselves are never pruned. However, searching by address is limited: address-based searches rely on the UTXO set, and once spent UTXOs older than the pruning window are deleted, only transactions involving current or recently spent UTXOs can be found by address. Older history is not returned once pruned. | ||
|
||
**Enable Spent UTxO removal **: Set `REMOVE_SPENT_UTXOS=true` in your environment (e.g., in `.env.dockerfile` or `.env.docker-compose`). | ||
**Disable Spent UTxO removal ** (default): Set `REMOVE_SPENT_UTXOS=false`. | ||
|
||
## When Spent UTxO Removal should be enabled? | ||
|
||
- **Low Disk Environments**: If you need to minimize disk usage and only require UTXO data for current balances. | ||
- **Exploratory / Dev Environments**: If historical queries are not critical. | ||
- **Performance**: if you are running into performance / scalability issues, i.e. especially on /account/balance when working with large addresses | ||
:::tip Recommended Use Cases | ||
Pruning is beneficial in scenarios where optimizing disk space and focusing on current data is prioritized over maintaining a complete historical record. Consider enabling pruning if your use case aligns with the following: | ||
|
||
- **Exchange Integrations & Wallet Services**: Primarily for tracking current balances, processing recent deposits/withdrawals, and validating recent transactions. | ||
- **Resource-Constrained Environments**: Ideal when disk space is a significant limitation (e.g., under 1TB available for mainnet data). | ||
- **Tip-of-Chain Operations**: For applications focused on the latest blockchain state rather than deep historical analysis. | ||
- **Development and Testing**: Useful when a full historical dataset is not essential for development or testing purposes. | ||
::: | ||
|
||
## When to avoid setting UtxO Removal feature? | ||
|
||
- **Full Historical Data Requirements**: If you need the complete transaction history—whether for exchange operations, audit trails, or compliance mandates—do not enable pruning. Pruning discards spent UTXOs, which removes older transaction data and prevents certain types of historical lookups or reporting. | ||
:::warning Not Suitable For | ||
Avoid pruning if your operational or regulatory requirements necessitate access to complete and auditable historical blockchain data. Pruning is generally not suitable if you need: | ||
|
||
- **Complete Historical Data & Deep Queries**: For comprehensive auditing, compliance, data analytics, or block explorer-like functionality that requires querying full transaction history from any point in time. | ||
- **Strict Compliance and Audit Trails**: If regulatory mandates demand immutable, complete historical records. Pruned data cannot be recovered without a full resync, and historical queries for `/block` and `/block/transaction` become unreliable beyond the safety window. | ||
::: | ||
|
||
:::danger Data Loss Warning | ||
Once data is pruned, it cannot be recovered without a full blockchain resynchronization. Assess your historical data needs carefully before enabling pruning. | ||
::: | ||
|
||
## Example Configuration | ||
## Configuration | ||
|
||
Below is a snippet of how you might configure `.env.dockerfile` or `.env.docker-compose` for pruning: | ||
Spent UTXO pruning is configured via environment variables, typically set in your `.env.dockerfile` or `.env.docker-compose` file. Below is an example demonstrating the available settings and their default values: | ||
|
||
```bash | ||
# --- Remove Spent UTxOs Toggle --- | ||
# --- Spent UTXO Pruning Configuration --- | ||
|
||
# Enable or disable spent UTXO pruning. | ||
# Default: false (Pruning is disabled by default) | ||
# To enable, set to: true | ||
REMOVE_SPENT_UTXOS=true | ||
|
||
# Safety margin: Number of recent blocks for which spent UTXOs are retained. | ||
# Default: 2160 (approximately 12 hours of blocks on mainnet) | ||
# This value balances safety for rollbacks against storage savings. | ||
# Example: To keep ~24 hours of spent UTXOs, set to 4320. | ||
# Note: Larger REMOVE_SPENT_UTXOS_LAST_BLOCKS_GRACE_COUNT values provide longer historical query support | ||
# but use more disk space and delay the realization of storage benefits. | ||
REMOVE_SPENT_UTXOS_LAST_BLOCKS_GRACE_COUNT=2160 | ||
``` | ||
|
||
:::note Configuration Guidelines | ||
|
||
- Start with the default settings (`REMOVE_SPENT_UTXOS=false` means pruning is initially off). | ||
- If enabling, the provided defaults (`REMOVE_SPENT_UTXOS_LAST_BLOCKS_GRACE_COUNT=2160`) are sensible starting points. | ||
- Adjust `REMOVE_SPENT_UTXOS_LAST_BLOCKS_GRACE_COUNT` based on your specific needs for recent historical data access. A larger value offers a longer window for historical queries but increases storage. | ||
::: | ||
|
||
## Migration and Operational Notes | ||
|
||
This section outlines key considerations when changing pruning settings or managing a system with pruning enabled. | ||
|
||
### Enabling Pruning on an Existing Deployment | ||
|
||
1. **Configuration**: Update the necessary environment variables (e.g., `REMOVE_SPENT_UTXOS=true`) and restart your cardano-rosetta-java services. | ||
2. **Initial Monitoring**: After enabling, closely monitor your application for any errors. Disk usage benefits will typically appear after the first pruning cycle completes. | ||
|
||
### Disabling Pruning | ||
|
||
:::caution Important Considerations | ||
|
||
- **Halts Deletion, No Restoration**: Setting `REMOVE_SPENT_UTXOS=false` and restarting services will stop further deletion of spent UTXOs. However, this action **does not restore** any data already pruned. | ||
- **Full Resync for Complete History**: To regain a complete historical dataset after pruning has been active, a full resynchronization of the blockchain data is required. | ||
- **Storage Growth Resumes**: Once pruning is disabled, expect storage usage to gradually increase again as new UTXOs (both spent and unspent) accumulate. | ||
::: | ||
|
||
## Further Reading | ||
|
||
- [Rosetta API Reference](https://docs.cdp.coinbase.com/mesh/docs/api-reference/) | ||
- [Environment Variables Reference](../install-and-deploy/env-vars.md) | ||
- [Yaci-Store Repository](https://github.com/bloxbean/yaci-store) | ||
- [Coinbase Mesh (formerly Rosetta) API Specification](https://docs.cdp.coinbase.com/mesh/docs/api-reference/) | ||
- [Cardano UTXO Model Documentation](https://docs.cardano.org/learn/eutxo-explainer/) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
docs/docs/development/test-results/1.2.6-dev_2025-04-16/docker-compose.md
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we cann this pruning again? :)