lightninglabs / taproot-assets

A layer 1 daemon, for the Taproot Assets Protocol specification, written in Go (golang)
MIT License
457 stars 110 forks source link

[feature]: Enhance `asset_sum` report to clarify conservation #1106

Open dstadulis opened 3 weeks ago

dstadulis commented 3 weeks ago

Background

Strict, asset-amount conservation checks exists in the tapd VM to prevent undue inflation of asset quantities. However, there may be instances where the daemon reports asset amounts that appear to be double counted, even though they are being properly conserved.

Asset Balance Clarification

To avoid confusion, it is essential to clearly delineate between payment-channel balances and L1-only asset balances. This will ensure that users have a comprehensive understanding of their asset holdings.

Task 1: Ensure Mutual Exclusivity

Comprehensive Asset Sum Calculations

To ensure accuracy in asset sum calculations, we need to investigate the comprehensiveness of these calculations.

Task 2: Investigate asset sum Calculation

Force Close Scenario

Background

In the scenario where two nodes have a channel Node 1 force closes Node 2 (the responder) -- even if it didn't have the channel's entire balance, the node insert the force close transaction, into it's own database These inserted transaction are added to the database fields that are importing the outputs as well While these outputs cannot be spent due to the presence of a script path. But litd/tapd displays these as part of the node's balance today

Solution

make another delineated name space, to track the amounts in order for the wallet balance commands to by default not show these balance, by default

Considerations

These values are used during tests to assert certain outcomes have been met add a flag to enable reporting in order for assertion tests to have the necessary data available to run tests

ryanthegentry commented 2 weeks ago

Further detail per debugging with @guggero: "maybe we forgot to not count "script_key_has_script_path": true in the asset sum. or maybe the leased assets still show up there."

Context: the output of tapcli assets balance includes amounts from the tapcli assets list --show_leased output that it shouldn't. Namely channel funding outputs (identified by "script_key_is_local": false, AND script_key_has_script_path": true) that have 6d7cd7ee247587eef86766140262685819deebc034ad80664fb74ec2ad6e11d7 listed as the lease_owner (representing a tapd internal lock`), meaning they've since been spent.

dstadulis commented 2 weeks ago

Updated original issue with more context

dstadulis commented 1 week ago

@gijswijs Will start task 2 - show balance script key path is true and considering

spend flag is leased situation and this is a directly spendable have for asset list but not asset sum a) default values b) RPC call sum (asset balance)