Skip to content

Index Byron-era outputs and spends - #6

Merged
Jimbo4350 merged 2 commits into
masterfrom
feat/byron-outputs
Sep 9, 2026
Merged

Index Byron-era outputs and spends#6
Jimbo4350 merged 2 commits into
masterfrom
feat/byron-outputs

Conversation

@Jimbo4350

@Jimbo4350 Jimbo4350 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Context

Sieve indexed nothing from Byron. The three decode entry points discarded the era witness and went through getBlockTxs, which returns [] for a ByronBlock, and there is no Tx ByronEra. A Byron block was processed as an empty one — not even a checkpoint row — so a sync from origin had no resume point until the first Shelley match, and * meant "Shelley onwards".

Shape

outputsInBlock (BlockInMode _ block) = case block of
  ByronBlock b   -> concat (zipWith byronOutputsInTx [0 ..] (byronTxs b))
  ShelleyBlock{} -> concat (zipWith outputsInTx [0 ..] (getBlockTxs block))

byronTxs is all the new plumbing: byronBlockRaw, skip epoch boundary blocks, take the transaction payload. A Byron output is an address and an ada-only value.

Nothing downstream changes. Bootstrap addresses give NULL credentials, which is already the */* filter; an ada-only value writes no policies rows. No schema, writer or CLI change. One new library dep, cardano-ledger-byronCardano.Api.Consensus re-exports byronBlockRaw/byronIdTx, and the conversions already exist, so there is no new conversion code.

Worth reviewing

transaction_index is the block's transaction order; spending_input_index is the transaction's input order, Byron having no redeemer pointers to align to. Both are pinned by tests.

How to trust it

Clean build, no warnings, fourmolu applied, 62 tests pass (11 new).

Per transaction: address round-trips to base58, ada-only value, positional output indices, NULL credentials, no assets, * matches and */* does not, a spend's consumed reference byte-identical to the producing output's, inputs indexed in transaction order.

From real block bytes, the only way to reach the BlockInMode dispatch: mainnet block 2,160,150 (six transactions) and an epoch boundary block, vendored from cardano-rpc's golden files. 17 outputs across 2,2,2,2,7,2, 17 spends across 2,10,2,1,1,1, ids verified against mainnet.

A mainnet sync of origin..4,000,000 indexed 4,460,109 outputs; 200 sampled outputs render identically to a reference index.

@Jimbo4350
Jimbo4350 force-pushed the feat/byron-outputs branch 5 times, most recently from e1a8625 to ae70d2c Compare September 9, 2026 16:55
cardano-api exports AdaAssetId only as a constructor of AssetId, so the bare
import stopped test/Main.hs compiling.
getBlockTxs returns [] for a Byron block and there is no Tx ByronEra, so the
decode entry points indexed nothing from Byron. Read the transactions off
byronBlockRaw instead. A Byron output is an address and an ada-only value; a
bootstrap address has no credentials, which the query side already handles. The
decoder is the only thing that changes.

transaction_index is the block's transaction order and spending_input_index the
transaction's input order, Byron having no redeemer pointers to align to.

Genesis-distributed outputs are in no block, so they stay unindexed.

Tested per transaction and from real block bytes: mainnet block 2,160,150 and
an epoch boundary block, with ids verified against mainnet.
@Jimbo4350
Jimbo4350 marked this pull request as ready for review September 9, 2026 17:12
@Jimbo4350
Jimbo4350 merged commit 55640ee into master Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant