IntersectMBO / IntersectMBO/cardano-cli

FR - Query block

Open
#1,335 8 comments 4 reactions 0 assignees View on GitHub
Stale
Dominant language
Haskell
Stars
71
Forks
24
Avg merge
23h 40m
Merged PRs (30d)
14

Description

Problem

As cardano-node operators, we currently have no straightforward way to access the raw content of a block stored in our local ChainDB. When debugging network incidents — particularly forks and network partitions — the ability to inspect individual blocks is critical.

Proposed Solution

Add a CLI command (either as part of cardano-cli or as a standalone tool) that can retrieve a block directly from the ChainDB on disk and output its CBORHex to stdout.

### Retrieve by slot number
cardano-cli debug get-block --db /path/to/db --slot 83413505

### Retrieve by block hash
cardano-cli debug get-block --db /path/to/db --hash e60aa1eb682ac5...

### Retrieve by block number
cardano-cli debug get-block --db /path/to/db --block-number 4043212

Why

During a recent network partition, we needed to compare block contents across nodes to understand the fork. The process was painful because:

1. Debugging is time-sensitive — During incidents, you need to inspect blocks quickly. Having to restart nodes or set up special queries adds delay at the worst possible time.

Implementation Considerations

The ChainDB is split into two components:

- ImmutableDB — Stores finalized blocks (older than k slots from the tip). Blocks are stored in chunk files and indexed by slot number. This is where most historical lookups would go.
- VolatileDB — Stores recent blocks that have not yet been finalized. These are the blocks most relevant during fork investigations, since competing chains live here until one wins.

A viable approach would be to read the ChainDB directly on disk, bypassing the node process entirely. Does ouroboros-consensus library provides the storage layer types and indexing logic? The key question is which block identifiers are supported by the existing index structures: Slot number, Block hash, Block number?

The command should:
- Work offline (no running node required)
- Output raw CBORHex to stdout (composable with other tools via pipes)
- Support both ImmutableDB and VolatileDB lookups.
- Report when a block is not found, or when it exists, id it's in the Immutable or in the Volatile Db.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.