taproot-assets: [bug]: Troubleshoot discrepancy between command results: `asset balance` and `assets list`
@HannahMR reported the following:
It seems there is an error in the tapcli assets balance command on v0.3.1. My balance is 10, but appears as 30.
So I was making demo videos and trasfering assets between an Alice node and a Bob node. The Alice node is my tapd demo node that I’ve been using for the demo videos, and my Bob node is the Velas Commerce testnet node. Both are running LND 0.17 and tapd 0.3.1
I minted two rounds of two different assets, 100 units each time, on my Alice node, one of which I named APIdemobux. On Friday I had sent two transactions of 10 APIdemobux to Leo, he send 10 of those back leaving me with a total of 190 APIdemobux.
Today, for a demo video, using the command line, I transfered 10 APIdemobux to the Bob node. At the time of recording, those assets were showing up as expected when using the $ tapcli assets balance command.
However, an hour or so later, when running that command on the Bob node, the balance showed as 20. And after restarting the tapd service on the server, the balances shows as 30!
I can however run the assets list command and the balance apears appropriately as 10.
The output of the tapcli assets balance and the assets list command on the Alice node are still showing the correct amounts.
I only put that transaction through one time… just went and double checked the video.
I can send logs if that’s helpful. I also have the output of the balance and list commands from each node.
Just to summaries the issue I think you’ve encountered: the reported balance for an asset is different between these two commands:
tapcli asset balance
and tapcli assets list
. And also the result returned by tapcli asset balance
changes over time after receiving an asset.
I’ve got a copy of Bob’s tapd.db
. I will inspect.
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 23 (14 by maintainers)
Commits related to this issue
- itest: attempt to reproduce asset balance bug report Bug report: https://github.com/lightninglabs/taproot-assets/issues/665 — committed to lightninglabs/taproot-assets by ffranr 8 months ago
- itest: attempt to reproduce asset balance bug report Bug report: https://github.com/lightninglabs/taproot-assets/issues/665 — committed to lightninglabs/taproot-assets by ffranr 8 months ago
- itest: ensure that asset balance does not increase on tapd restart Bug report: https://github.com/lightninglabs/taproot-assets/issues/665 — committed to lightninglabs/taproot-assets by ffranr 7 months ago
- itest: ensure that asset balance does not increase on tapd restart Bug report: https://github.com/lightninglabs/taproot-assets/issues/665 — committed to lightninglabs/taproot-assets by ffranr 7 months ago
I think this bug is possible in part because of a defective
UNIQUE
constraint in theassets
SQL table. TheUNIQUE
constraint is currently:However,
asset_id
is not theasset.ID
of the asset. It is aBIGINT
primary key. Basically an integer which is incremented with each new entry in theassets
table. Given thatasset_id
is included in theUNIQUE
constraint, it’s always possible to add an asset into the table even if it already exists. Which means we can have duplicate assets in this table.I think we should change this
UNIQUE
constraint to:For a
utxo
, a asset genesis profile, and a script key there should not be a duplicate entry in theassets
table.#687 is a simpler and safer solution than #684. I think we should focus on #687 for 0.3.2.
tapd.log tapd.log.5.gz tapd.log.6.gz tapd.log.7.gz