Skip to content

Conversation

darioAnongba
Copy link
Contributor

@darioAnongba darioAnongba commented Oct 1, 2025

Garbage collect the residue zero-value UTXOs when creating transactions. Zero-value UTXOs occur when creating tombstones or full burns.
Currently, these UTXOs accumulate in the DB and are never cleaned. This PR introduces a garbage collection mechanism to collect these UTXOs and use them as inputs of transactions initiated by tapd:

  • Transfers
  • Burns

The PR adds a new swept flag to the managed_utxo table because UTXOs are not removed from the table when spent. This flag is also returned by the ListUtxos RPC endpoint.

The mechanism preserves the liveness and safety properties, ensuring that zero-value UTXOs can never accumulate in the DB. Adding garbage collection to Mint transactions is not necessary to ensure this properties.

Fixes #514

** Note to reviewers**

  1. UTXO meaning unspent, keeping the spent outputs in a table called manage_utxos seems like a contradiction, same logic applies for the need of a swept flag in that table. We should either rename the table or store spent utxos somewhere else?
  2. Similar to 1. Feels wrong to return the spent UTXOs in the ListUtxos call. Should we rename this to ListOutputs?
  3. The pkScript is retrieved by querying the chain_txs table. Is it possible/more efficient to avoid this and somehow recompute it from the data we have?

@darioAnongba darioAnongba self-assigned this Oct 1, 2025
@coveralls
Copy link

coveralls commented Oct 1, 2025

Pull Request Test Coverage Report for Build 18382547235

Details

  • 21 of 354 (5.93%) changed or added relevant lines in 10 files are covered.
  • 28020 unchanged lines in 195 files lost coverage.
  • Overall coverage decreased (-15.2%) to 34.469%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tapfreighter/parcel.go 0 4 0.0%
tapdb/sqlc/assets.sql.go 0 6 0.0%
rpcserver.go 0 11 0.0%
tapfreighter/coin_select.go 0 29 0.0%
tapfreighter/chain_porter.go 0 40 0.0%
tapfreighter/wallet.go 0 70 0.0%
tapdb/assets_store.go 3 176 1.7%
Files with Coverage Reduction New Missed Lines %
universe/supplyverifier/util.go 1 98.75%
proof/util.go 2 81.63%
tapdb/migrations.go 2 76.19%
address/log.go 3 0.0%
commitment/log.go 3 0.0%
internal/pedersen/commitment.go 3 95.31%
lndservices/log.go 3 0.0%
rfq/log.go 3 0.0%
tapchannel/log.go 3 0.0%
tapdb/supply_syncer.go 3 73.85%
Totals Coverage Status
Change from base Build 18359865357: -15.2%
Covered Lines: 30524
Relevant Lines: 88554

💛 - Coveralls

@levmi levmi moved this from 🆕 New to 🏗 In progress in Taproot-Assets Project Board Oct 2, 2025
@darioAnongba darioAnongba force-pushed the feat/zero-value-utxo-selection branch from f3a3bff to f55b6c5 Compare October 3, 2025 16:21
@darioAnongba darioAnongba changed the base branch from main to 0-8-0-staging October 6, 2025 09:43
@darioAnongba darioAnongba force-pushed the feat/zero-value-utxo-selection branch 3 times, most recently from 3bd769d to 6fe11a5 Compare October 6, 2025 15:03
@darioAnongba darioAnongba changed the base branch from 0-8-0-staging to main October 6, 2025 15:03
@darioAnongba darioAnongba force-pushed the feat/zero-value-utxo-selection branch 10 times, most recently from a8f3ce4 to afbfebf Compare October 9, 2025 13:04
@darioAnongba darioAnongba marked this pull request as ready for review October 9, 2025 13:09
@darioAnongba darioAnongba force-pushed the feat/zero-value-utxo-selection branch 3 times, most recently from 0bb387d to bf3e3ee Compare October 9, 2025 14:33
@darioAnongba darioAnongba force-pushed the feat/zero-value-utxo-selection branch from bf3e3ee to d812a8e Compare October 9, 2025 16:04
@darioAnongba darioAnongba force-pushed the feat/zero-value-utxo-selection branch from d812a8e to 0ceaf76 Compare October 9, 2025 16:32
@darioAnongba darioAnongba moved this from 🏗 In progress to 👀 In review in Taproot-Assets Project Board Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

wallet: garbage collect tombstone UTXOs

2 participants