lightninglabs / lightninglabs/taproot-assets

assets+tarodb: adopt versioning for asset updates+transfers

Open
#146 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

API database sqlc
Dominant language
Go
Stars
525
Forks
150
Avg merge
2d 15h
Merged PRs (30d)
31

Description

Today whenever we go to modify an asset on disk (due to a transfer, import, etc) we just overwrite the asset fields in place, but hold onto the same asset primary key. In the future, it would be nice to be able to do things like query for the balances of a given asset at a given point in time (block hash).

In order to allow such queries we should:
* Add a version field to each asset
* Bump that each time we modify the asset
* Never delete the old managed UTXOs or chain_txns on disk (just update the primary key pointer)
* Always order by the version field descending (distinct and fetch last) for queries

With the above changes, we can find the balance at a given hash with:
* find the chain txn that has that hash
* join w/ managed utxo to find the one that matches
* join w/ asset to find the version that pointed to that utxo
* do the normal balance stuff

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the asset, managed UTXO, and chain transaction persistence and query entry points in the Go repository. Define how asset versions are added and incremented, how old records remain available while primary-key pointers change, and how queries order by descending version. Done means historical asset balances can be resolved for a block hash using the specified joins.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.