FR - Query block
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Active
- Tech stack
- haskell
- Domain
- blockchain, cli, databases
Research direction
Start by examining the cardano-cli command structure and the ouroboros-consensus storage layer, focusing on ChainDB, ImmutableDB, and VolatileDB. Determine which existing indexes support slot, hash, and block-number lookups before defining the command shape. Done means an offline command retrieves either database's block as raw CBORHex on stdout and reports missing blocks and their storage location.
Written by the indexing model from the issue text.
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:
- 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.
- Dominant language
- Haskell
- Stars
- 71
- Forks
- 24
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 9
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from IntersectMBO/cardano-cli
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
IntersectMBO/cardano-cli#1306 · 2 comments ·
Maintainers usually reply within 1 day
-
Ensure Plutus V4 scripts can be deserialised by cardano-cliPossibly taken @carbolymer claimed this 6 days ago. Open
IntersectMBO/cardano-cli#1448 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Upstream non-Leios commits from the Leios integration branch to masterMay be free again @palas claimed this 48 days ago, and no pull request is open. Openrefactor
IntersectMBO/cardano-cli#1414 · 1 assignee ·
Maintainers usually reply within 1 day
-
Add `transaction validate` command (online phase 1 + phase 2)May be free again @palas claimed this 134 days ago, and no pull request is open. Openenhancement epic
IntersectMBO/cardano-cli#1380 · 4 comments · 1 reaction · 1 assignee ·
Maintainers usually reply within 1 day
-
Investigate incorporating cquisitor-style local tx validation (phase 1 + phase 2) into cardano-cliMay be free again @palas claimed this 155 days ago, and no pull request is open. OpenStale
IntersectMBO/cardano-cli#1367 · 6 comments · 1 assignee ·
Maintainers usually reply within 1 day
All issues in IntersectMBO/cardano-cli
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
objectionary/phino#1600 ·
Maintainers usually reply within 1 day