Skip to content

Revert UTxOIdentifier to use TxHash #448

@lowhung

Description

@lowhung

Context

The tx_unpacker maintains a UTxORegistry that tracks the live UTxO set, mapping TxOutRef → TxIdentifier. This enables converting transaction inputs into UTxOIdentifier (block_number + tx_index + output_index) for downstream modules like utxo_state.

When processing a transaction, the tx_unpacker:

  1. Looks up inputs in its registry to get the TxIdentifier (to create UTxOIdentifier)
  2. Removes those inputs from the registry (they're spent)
  3. Adds the new outputs to the registry

Problem

When bootstrapping from a snapshot, we bypass tx_unpacker entirely:

  • utxo_state gets the full UTxO set from the snapshot
  • tx_unpacker's registry remains empty

When new blocks arrive post-snapshot, tx_unpacker can't resolve inputs to UTxOIdentifier because they never passed through it. The tx_unpacker doesn't crash—it silently drops unresolvable inputs and logs an error. The result is incomplete delta messages where spent UTxOs never get marked as spent in utxo_state.

We cannot bootstrap the UTxORegistry from the snapshot because it doesn't contain block_number or tx_index—only TxOutRef (tx_hash + output_index).

Options Discussed

  1. Revert to TxHash-based identifiers — Simpler and safer; removes dependency on block_number/tx_index. Need to assess memory impact on other modules (e.g., Address State)

  2. Invent synthetic serial numbers — Pass snapshot through tx_unpacker with invented identifiers. Unclear if other components construct UTxOIdentifier from block_number independently.

  3. Bootstrap the registry somehow — Not feasible without the required data in snapshots.

Additional Consideration

The /tx/utxos endpoint requires data not immediately available in the requested transaction:

  • Input UTxO values (chain_store could look these up)
  • Hash of tx that consumed outputs (currently falls through the gaps)

Acceptance Criteria

  • Snapshot bootstrap populates utxo_state directly without breaking input resolution
  • Post-snapshot blocks correctly mark spent UTxOs
  • Determine memory impact of TxHash-based approach on affected modules
  • Clarify ownership of consumed_by_tx lookup between chain_store and utxo_state

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions