lightninglabs / taproot-assets

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

[bug] Correct collectible-groups `universe stats`+`assets mint batches` CLI output #522

Closed jamaljsr closed 1 year ago

jamaljsr commented 1 year ago

I am trying to wrap my head around the process of creating a group of collectibles. I may be doing this wrong so I'm primarily looking for clarity on the proper way to get this done to continue testing and querying the Universe stats RPCs properly.

My high-level goal is to use the REST endpoints to display assets in a web app. I'd like to have collectibles grouped together in the UI, to not have too much noise with potentially hundreds/thousands of individual collectibles. I thought I would be able to simply aggregate multiple assets with the same group_key, but only one of the collectibles is showing in the RPC output for my 5 minted collectibles.

I have written a script based on https://github.com/jharveyb/remintooor using my regtest docker node to mint 5 collectibles in a single batch. I have excluded the image metadata to simplify the process. I've tested on v0.2.3 as well as the main branch (commit https://github.com/lightninglabs/taproot-assets/commit/4ee966a5568d26a749e5971cfe809f1b078d82f7), using LND v0.16.4-beta.

Here's the output of my script/commands below.

View CLI commands & output ``` Creating 5 TEST collectibles on bob Minting anchor asset TEST101 tapcli assets mint --type collectible --name TEST101 --supply 1 --enable_emission Batch key: 03a3d931af0e8bf8b3f74f4460920a123e16cea2602b154ab064d75eba76c1bb54 Minting remaining assets... tapcli assets mint --type collectible --name TEST102 --supply 1 --group_anchor TEST101 { "pending_batch": { "batch_key": "03a3d931af0e8bf8b3f74f4460920a123e16cea2602b154ab064d75eba76c1bb54", "assets": [ { "asset_type": "COLLECTIBLE", "name": "TEST101", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" }, { "asset_type": "COLLECTIBLE", "name": "TEST102", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" } ], "state": "BATCH_STATE_PEDNING" } } tapcli assets mint --type collectible --name TEST103 --supply 1 --group_anchor TEST101 { "pending_batch": { "batch_key": "03a3d931af0e8bf8b3f74f4460920a123e16cea2602b154ab064d75eba76c1bb54", "assets": [ { "asset_type": "COLLECTIBLE", "name": "TEST103", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" }, { "asset_type": "COLLECTIBLE", "name": "TEST101", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" }, { "asset_type": "COLLECTIBLE", "name": "TEST102", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" } ], "state": "BATCH_STATE_PEDNING" } } tapcli assets mint --type collectible --name TEST104 --supply 1 --group_anchor TEST101 { "pending_batch": { "batch_key": "03a3d931af0e8bf8b3f74f4460920a123e16cea2602b154ab064d75eba76c1bb54", "assets": [ { "asset_type": "COLLECTIBLE", "name": "TEST101", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" }, { "asset_type": "COLLECTIBLE", "name": "TEST102", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" }, { "asset_type": "COLLECTIBLE", "name": "TEST103", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" }, { "asset_type": "COLLECTIBLE", "name": "TEST104", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" } ], "state": "BATCH_STATE_PEDNING" } } tapcli assets mint --type collectible --name TEST105 --supply 1 --group_anchor TEST101 { "pending_batch": { "batch_key": "03a3d931af0e8bf8b3f74f4460920a123e16cea2602b154ab064d75eba76c1bb54", "assets": [ { "asset_type": "COLLECTIBLE", "name": "TEST103", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" }, { "asset_type": "COLLECTIBLE", "name": "TEST104", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" }, { "asset_type": "COLLECTIBLE", "name": "TEST105", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" }, { "asset_type": "COLLECTIBLE", "name": "TEST101", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" }, { "asset_type": "COLLECTIBLE", "name": "TEST102", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" } ], "state": "BATCH_STATE_PEDNING" } } Finalizing mint... tapcli assets mint finalize { "batch": { "batch_key": "03a3d931af0e8bf8b3f74f4460920a123e16cea2602b154ab064d75eba76c1bb54", "assets": [ { "asset_type": "COLLECTIBLE", "name": "TEST103", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" }, { "asset_type": "COLLECTIBLE", "name": "TEST104", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" }, { "asset_type": "COLLECTIBLE", "name": "TEST105", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" }, { "asset_type": "COLLECTIBLE", "name": "TEST101", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" }, { "asset_type": "COLLECTIBLE", "name": "TEST102", "asset_meta": null, "amount": "1", "group_key": "", "group_anchor": "" } ], "state": "BATCH_STATE_BROADCAST" } } Assets created. Mining blocks to confirm... mine 1 mine 1 tapcli assets mint batches --batch_key 03a3d931af0e8bf8b3f74f4460920a123e16cea2602b154ab064d75eba76c1bb54 { "batches": [ { "batch_key": "03a3d931af0e8bf8b3f74f4460920a123e16cea2602b154ab064d75eba76c1bb54", "assets": [], "state": "BATCH_STATE_FINALIZED" } ] } tapcli universe stats { "num_total_assets": "1", "num_total_syncs": "0", "num_total_proofs": "5" } tapcli universe stats events { "events": [ { "date": "2023-09-21", "sync_events": "0", "new_proof_events": "5" } ] } tapcli universe stats assets --sort_by asset_name { "asset_stats": [ { "asset_id": "b7c7d638d3da3738b4a404e8c13c3b9e9e89a9960f56dcb4162484ccecf7653c", "group_key": "024ce27ea300e54a2ac600a6a8567dfcca458d2e5127f263ca737bb79821b25136", "genesis_point": "8b37631d56a253c3564aae253c0ad27fd87cefb3cf6b0b80431f1fa00324c4fc:1", "total_supply": "1", "asset_name": "TEST104", "asset_type": "COLLECTIBLE", "genesis_height": 303, "genesis_timestamp": "1695270393", "total_syncs": "0", "total_proofs": "5" } ] } tapcli assets list { "assets": [ { "version": 0, "asset_genesis": { "genesis_point": "8b37631d56a253c3564aae253c0ad27fd87cefb3cf6b0b80431f1fa00324c4fc:1", "name": "TEST103", "meta_hash": "0000000000000000000000000000000000000000000000000000000000000000", "asset_id": "961992f72d039a0d97b22b22cfac4d7a090d21d9770b3955cb5dda3a95ffd98e", "output_index": 0, "version": 0 }, "asset_type": "COLLECTIBLE", "amount": "1", "lock_time": 0, "relative_lock_time": 0, "script_version": 0, "script_key": "02f611b8bc920541c2e733c9c25798207ac6927d92a860bd4e3fbaad164e31c1e4", "script_key_is_local": true, "asset_group": { "raw_group_key": "03dd36ea72e95bf1b88ea2ac8c02d09935d9e5b9a2961e0a7623cc69e706ef6cd0", "tweaked_group_key": "024ce27ea300e54a2ac600a6a8567dfcca458d2e5127f263ca737bb79821b25136", "asset_id_sig": "c251df99e1bbbba416ade561f02a388ab3138c307922789342e1e489f405e277fb69fec904e0ffff36272d32e3a464b2ffbcee85450174316c067e8b0818191b" }, "chain_anchor": { "anchor_tx": "02000000000101fcc42403a01f1f43800b6bcfb3ef7cd87fd20a3c25ae4a56c353a2561d63378b0100000000ffffffff02e803000000000000225120054c3c7cd770c783e8952effc8a9e34d38bcabddc2ce1d1e74aa2fb249dd049969dbdd2b00000000225120d38d5a27145a81f4f23a0755a079ee5147fae36d93f03e6e16d12ef96cbb06d101405f56e0a12cf4f040bb0213fc78e9da4c1122a61d0612a7a827633a26371389500df1c22825ff43e061666e9aafb3623163b14d4fe9a3eee31a6540abe18f108700000000", "anchor_txid": "a4490e3c750294b55deb5f7fcb73b722052657dbed6ba2e1d8c5b0227aea7118", "anchor_block_hash": "4428415b93a30fb41340b76988075a5b6c7f26a18292eed259ece52c100577a4", "anchor_outpoint": "a4490e3c750294b55deb5f7fcb73b722052657dbed6ba2e1d8c5b0227aea7118:0", "internal_key": "03a3d931af0e8bf8b3f74f4460920a123e16cea2602b154ab064d75eba76c1bb54", "merkle_root": "33175f098e1a38bc7084cc2ad57df0889fcaf2a8d162ed626cfbf92dbdf32ecb", "tapscript_sibling": "", "block_height": 0 }, "prev_witnesses": [], "is_spent": false, "lease_owner": "", "lease_expiry": "0", "is_burn": false }, { "version": 0, "asset_genesis": { "genesis_point": "8b37631d56a253c3564aae253c0ad27fd87cefb3cf6b0b80431f1fa00324c4fc:1", "name": "TEST104", "meta_hash": "0000000000000000000000000000000000000000000000000000000000000000", "asset_id": "b7c7d638d3da3738b4a404e8c13c3b9e9e89a9960f56dcb4162484ccecf7653c", "output_index": 0, "version": 0 }, "asset_type": "COLLECTIBLE", "amount": "1", "lock_time": 0, "relative_lock_time": 0, "script_version": 0, "script_key": "029897a74ea5c86af1150f90bc8772ef90c5b8bf6cb5abed0550026f276f485634", "script_key_is_local": true, "asset_group": { "raw_group_key": "03dd36ea72e95bf1b88ea2ac8c02d09935d9e5b9a2961e0a7623cc69e706ef6cd0", "tweaked_group_key": "024ce27ea300e54a2ac600a6a8567dfcca458d2e5127f263ca737bb79821b25136", "asset_id_sig": "4d8e03f3d35006827d14233c2b93f6c338a16e3aa0d221c42958f13e8db8dc39efa572b5e37cf2973c283fd3ab7c7a87101473b54833ceeb347d8dcde6b72a1a" }, "chain_anchor": { "anchor_tx": "02000000000101fcc42403a01f1f43800b6bcfb3ef7cd87fd20a3c25ae4a56c353a2561d63378b0100000000ffffffff02e803000000000000225120054c3c7cd770c783e8952effc8a9e34d38bcabddc2ce1d1e74aa2fb249dd049969dbdd2b00000000225120d38d5a27145a81f4f23a0755a079ee5147fae36d93f03e6e16d12ef96cbb06d101405f56e0a12cf4f040bb0213fc78e9da4c1122a61d0612a7a827633a26371389500df1c22825ff43e061666e9aafb3623163b14d4fe9a3eee31a6540abe18f108700000000", "anchor_txid": "a4490e3c750294b55deb5f7fcb73b722052657dbed6ba2e1d8c5b0227aea7118", "anchor_block_hash": "4428415b93a30fb41340b76988075a5b6c7f26a18292eed259ece52c100577a4", "anchor_outpoint": "a4490e3c750294b55deb5f7fcb73b722052657dbed6ba2e1d8c5b0227aea7118:0", "internal_key": "03a3d931af0e8bf8b3f74f4460920a123e16cea2602b154ab064d75eba76c1bb54", "merkle_root": "33175f098e1a38bc7084cc2ad57df0889fcaf2a8d162ed626cfbf92dbdf32ecb", "tapscript_sibling": "", "block_height": 0 }, "prev_witnesses": [], "is_spent": false, "lease_owner": "", "lease_expiry": "0", "is_burn": false }, { "version": 0, "asset_genesis": { "genesis_point": "8b37631d56a253c3564aae253c0ad27fd87cefb3cf6b0b80431f1fa00324c4fc:1", "name": "TEST105", "meta_hash": "0000000000000000000000000000000000000000000000000000000000000000", "asset_id": "a66bb41d51e44f358181b67f1010d0329f6df795b1dd9833f4fa3c786069c006", "output_index": 0, "version": 0 }, "asset_type": "COLLECTIBLE", "amount": "1", "lock_time": 0, "relative_lock_time": 0, "script_version": 0, "script_key": "02d8f92c30b48e4a0933cdad3f3f5a194fd0d0a528a31696fe838289aeffc45af7", "script_key_is_local": true, "asset_group": { "raw_group_key": "03dd36ea72e95bf1b88ea2ac8c02d09935d9e5b9a2961e0a7623cc69e706ef6cd0", "tweaked_group_key": "024ce27ea300e54a2ac600a6a8567dfcca458d2e5127f263ca737bb79821b25136", "asset_id_sig": "5f92d318d9f9990cf7d518f084149b1b2cef002ce4b487899e583bb42da922563a0f7557b4cc732b9913b6a357716f2372c745246aa58b5bc83a982dcf22f610" }, "chain_anchor": { "anchor_tx": "02000000000101fcc42403a01f1f43800b6bcfb3ef7cd87fd20a3c25ae4a56c353a2561d63378b0100000000ffffffff02e803000000000000225120054c3c7cd770c783e8952effc8a9e34d38bcabddc2ce1d1e74aa2fb249dd049969dbdd2b00000000225120d38d5a27145a81f4f23a0755a079ee5147fae36d93f03e6e16d12ef96cbb06d101405f56e0a12cf4f040bb0213fc78e9da4c1122a61d0612a7a827633a26371389500df1c22825ff43e061666e9aafb3623163b14d4fe9a3eee31a6540abe18f108700000000", "anchor_txid": "a4490e3c750294b55deb5f7fcb73b722052657dbed6ba2e1d8c5b0227aea7118", "anchor_block_hash": "4428415b93a30fb41340b76988075a5b6c7f26a18292eed259ece52c100577a4", "anchor_outpoint": "a4490e3c750294b55deb5f7fcb73b722052657dbed6ba2e1d8c5b0227aea7118:0", "internal_key": "03a3d931af0e8bf8b3f74f4460920a123e16cea2602b154ab064d75eba76c1bb54", "merkle_root": "33175f098e1a38bc7084cc2ad57df0889fcaf2a8d162ed626cfbf92dbdf32ecb", "tapscript_sibling": "", "block_height": 0 }, "prev_witnesses": [], "is_spent": false, "lease_owner": "", "lease_expiry": "0", "is_burn": false }, { "version": 0, "asset_genesis": { "genesis_point": "8b37631d56a253c3564aae253c0ad27fd87cefb3cf6b0b80431f1fa00324c4fc:1", "name": "TEST101", "meta_hash": "0000000000000000000000000000000000000000000000000000000000000000", "asset_id": "85d6549232164a1759b5c5c222d3ca623e7a701303fa6ae0930c2231e28c8011", "output_index": 0, "version": 0 }, "asset_type": "COLLECTIBLE", "amount": "1", "lock_time": 0, "relative_lock_time": 0, "script_version": 0, "script_key": "02644fdd9710af698de489ef3174e768a8c522d312a0ad669dacf290f4ee5c1dac", "script_key_is_local": true, "asset_group": { "raw_group_key": "03dd36ea72e95bf1b88ea2ac8c02d09935d9e5b9a2961e0a7623cc69e706ef6cd0", "tweaked_group_key": "024ce27ea300e54a2ac600a6a8567dfcca458d2e5127f263ca737bb79821b25136", "asset_id_sig": "dc8d33b262505ffb084403975f5b3e97dee2324fb407539cf466e2354e81cec0710479c588f3e23b5f602e3301728ff670018069aa4e516c48b35516cc8de202" }, "chain_anchor": { "anchor_tx": "02000000000101fcc42403a01f1f43800b6bcfb3ef7cd87fd20a3c25ae4a56c353a2561d63378b0100000000ffffffff02e803000000000000225120054c3c7cd770c783e8952effc8a9e34d38bcabddc2ce1d1e74aa2fb249dd049969dbdd2b00000000225120d38d5a27145a81f4f23a0755a079ee5147fae36d93f03e6e16d12ef96cbb06d101405f56e0a12cf4f040bb0213fc78e9da4c1122a61d0612a7a827633a26371389500df1c22825ff43e061666e9aafb3623163b14d4fe9a3eee31a6540abe18f108700000000", "anchor_txid": "a4490e3c750294b55deb5f7fcb73b722052657dbed6ba2e1d8c5b0227aea7118", "anchor_block_hash": "4428415b93a30fb41340b76988075a5b6c7f26a18292eed259ece52c100577a4", "anchor_outpoint": "a4490e3c750294b55deb5f7fcb73b722052657dbed6ba2e1d8c5b0227aea7118:0", "internal_key": "03a3d931af0e8bf8b3f74f4460920a123e16cea2602b154ab064d75eba76c1bb54", "merkle_root": "33175f098e1a38bc7084cc2ad57df0889fcaf2a8d162ed626cfbf92dbdf32ecb", "tapscript_sibling": "", "block_height": 0 }, "prev_witnesses": [], "is_spent": false, "lease_owner": "", "lease_expiry": "0", "is_burn": false }, { "version": 0, "asset_genesis": { "genesis_point": "8b37631d56a253c3564aae253c0ad27fd87cefb3cf6b0b80431f1fa00324c4fc:1", "name": "TEST102", "meta_hash": "0000000000000000000000000000000000000000000000000000000000000000", "asset_id": "28e4bbef2649c7bebec5fb352ca32917e2f5b884771fcfb619dd2369b8cf528d", "output_index": 0, "version": 0 }, "asset_type": "COLLECTIBLE", "amount": "1", "lock_time": 0, "relative_lock_time": 0, "script_version": 0, "script_key": "02b48cafadba57463d3297cc0391ade0e971b62f88965d1a756dd47e1f6c52d436", "script_key_is_local": true, "asset_group": { "raw_group_key": "03dd36ea72e95bf1b88ea2ac8c02d09935d9e5b9a2961e0a7623cc69e706ef6cd0", "tweaked_group_key": "024ce27ea300e54a2ac600a6a8567dfcca458d2e5127f263ca737bb79821b25136", "asset_id_sig": "c5867d44c7e36b83b239d14bcd6ae0a6e7fa9cc7e28e64a439830688cc8b78eca2609ea1bf263dd93ac0a7c2a5ee5e2dcae7ddd0a07055698f8e75f92a2257c6" }, "chain_anchor": { "anchor_tx": "02000000000101fcc42403a01f1f43800b6bcfb3ef7cd87fd20a3c25ae4a56c353a2561d63378b0100000000ffffffff02e803000000000000225120054c3c7cd770c783e8952effc8a9e34d38bcabddc2ce1d1e74aa2fb249dd049969dbdd2b00000000225120d38d5a27145a81f4f23a0755a079ee5147fae36d93f03e6e16d12ef96cbb06d101405f56e0a12cf4f040bb0213fc78e9da4c1122a61d0612a7a827633a26371389500df1c22825ff43e061666e9aafb3623163b14d4fe9a3eee31a6540abe18f108700000000", "anchor_txid": "a4490e3c750294b55deb5f7fcb73b722052657dbed6ba2e1d8c5b0227aea7118", "anchor_block_hash": "4428415b93a30fb41340b76988075a5b6c7f26a18292eed259ece52c100577a4", "anchor_outpoint": "a4490e3c750294b55deb5f7fcb73b722052657dbed6ba2e1d8c5b0227aea7118:0", "internal_key": "03a3d931af0e8bf8b3f74f4460920a123e16cea2602b154ab064d75eba76c1bb54", "merkle_root": "33175f098e1a38bc7084cc2ad57df0889fcaf2a8d162ed626cfbf92dbdf32ecb", "tapscript_sibling": "", "block_height": 0 }, "prev_witnesses": [], "is_spent": false, "lease_owner": "", "lease_expiry": "0", "is_burn": false } ] } ```

I have a few observations & questions:

  1. Before finalizing the batch, the output of tapcli assets mint batches doesn't have any value for group_key or group_anchor. Should these have values?
  2. After finalizing the batch and confirming the txn, the output of tapcli assets mint batches doesn't contain any assets. Is this expected?
  3. The output of tapcli universe stats assets only shows one asset using the name of the last collectible minted. It has a total_supply of 1 and total_proofs is 5. In this case, does total_proofs indicate the number of collectibles in the group? Will it remain at 5 when the collectibles are transferred around? Should there be 5 assets listed with the same group_key instead?
  4. The output of tapcli universe stats also shows 1 asset like above.
guggero commented 1 year ago

Thanks for the detailed report. I think you are creating the grouped assets correctly and all your observations are on point.

  1. Yes, that's weird. I also would expect at least the group_anchor to be set in this case.
  2. Yes, the assets should be shown (unless --short is specified). I thought I explicitly fixed that already. But apparently not.
  3. That's weird as well. I think it is meant to represent the asset group, but then there shouldn't be a single asset name. I'm not 100% sure what the expectation for a group of assets is in this case, I'll look into it.
  4. Same as above, probably shouldn't be that way.

So there are a couple of things here that we need to look into or just fix.

jamaljsr commented 1 year ago

Cool. Thanks for confirming. 🙏

I'll continue testing and let you know if I se anything else that stands out.

jharveyb commented 1 year ago
3. That's weird as well. I think it is meant to represent the asset group, but then there shouldn't be a single asset name. I'm not 100% sure what the expectation for a group of assets is in this case, I'll look into it.

The display of a random asset name is a known quirk but never got a tracking issue; I don't recall exactly where that name is populated. Not sure what the best name to display would be. Also not sure why the displayed sum is incorrect.