Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asset meta data is overwritten incorrectly/not passed around correctly when performing receives #368

Closed
habibitcoin opened this issue Jun 16, 2023 · 6 comments · Fixed by #370
Assignees
Labels
bug Something isn't working meta universe

Comments

@habibitcoin
Copy link
Contributor

habibitcoin commented Jun 16, 2023

Using latest version on main

I've now tried to receive/pass around the metadata for a few different assets, and it seems that receiving an asset causes the meta_data to be incorrectly populated

Step 1: I fetch the meta data for an asset I am interested in receiving. Presumably I was able to fetch this because it's stored in someone's universe

habibitcoin@648bbcf308054721fb175b6d:~$ tapcli --rpcserver=193.149.176.138:10029 assets meta --asset_id fead959d3257a9b2f5aea591eac16ade40a9837e45c7b64685b2f313f837e4d8
{
    "data": "89504e470d0a1a0a0000000d49484452000000100000001008060000001ff3ff61000000017352474200aece1ce90000023349444154384f6d534d6b1351143d6f32c94c1ac7a64d9a6ad52a6d3536a0e84610ec42dd88144137aedc0842a082a5a2d02269d21495508c15b10bc56edc29085d17c45d7f40408ad252544c3f4c88f9e84c66de3c9999269999f4aedeb91fe79d7bdfbb04fb184b829307cf2600bd1915efe4520460ee74e2762c4f9e0e8dc4f81d78796748d5e05bcaf1e423a83de02050de47197cdefd44b57caa0adfc6aa87242d794d02e5ed505bb1ac6810463f817e1d075fcfb748a80ee1ee2a07809904e74e04832b8948b19151557474c7bf9b70f3f5107aefff80b218752aab6b10e36bc420e0e537fdaabd674d07f44b5948b11b8e22e5dda0038bf7d678b29bed4b12919f76372ec4374c97bc701c5b158afe47bfb0337f0c926028b76c7d93cc9152a6272d74789fb4118cfd365dbbdf3ec33f7cd33c17b24710f0d932eb14a4f83494165d042a05a4893f589f89a052673833bb6da9993fecb8872914a43c1b4ef122976844e8f02d04ae2f98b03a77081ec2205f984270e401ca995e783d2d8e8b2f4ba78c210ab55448263eabb79f058a9399bfee8e4c5c7b160167fb39fec96db1017b6ae9f056a3aaa23288b73f408a5d43ee6137340a1cede410f0daaa551d1d3305f3190de3aa53418a3d15557f046a218fbee74554a64356426bf8006508a48b410025fb57eeaa3eee2cc0f64c869203f65b0d268d61254fbf5c5d2c5f31a07b990e9627a452631eee41b0ba0ee945390ca039a4b66ddc23edba3c209e5f1ae5970d92f0ab4a54018c65f8e726fd0f6306b7c385165e030000000049454e44ae426082",
    "type": "META_TYPE_OPAQUE",
    "meta_hash": "49f7b90f9eefe6a5e5c6fe3e1317e1894ad721f9c9f2ac0070a631e7b3bf0302"
}

Step 2: I receive the asset, and run the same query.. The meta data is now empty and the meta_hash is incorrect

habibitcoin@648bbcf308054721fb175b6d:~$ tapcli --rpcserver=193.149.176.138:10029 assets meta --asset_id fead959d3257a9b2f5aea591eac16ade40a9837e45c7b64685b2f313f837e4d8
{
    "data": "",
    "type": "META_TYPE_OPAQUE",
    "meta_hash": "01e246b58d8e782fc96881c090d833eefa37e804cb308aeae0f7471c9ef1ea1a"
}
@habibitcoin
Copy link
Contributor Author

The incorrect metahash is always 01e246b58d8e782fc96881c090d833eefa37e804cb308aeae0f7471c9ef1ea1a

But interestingly you can see the correct meta hash in the full proof: https://habibi.cash/asset/BitcoinIsForever/proof

@habibitcoin
Copy link
Contributor Author

1 more weird thing:

tapcli --rpcserver=193.149.176.138:10029 assets meta --asset_meta 49f7b90f9eefe6a5e5c6fe3e1317e1894ad721f9c9f2ac0070a631e7b3bf0302
{
    "data": "",
    "type": "META_TYPE_OPAQUE",
    "meta_hash": "01e246b58d8e782fc96881c090d833eefa37e804cb308aeae0f7471c9ef1ea1a"
}

@habibitcoin
Copy link
Contributor Author

I think the upsertAssetMeta query might be part of the issue:

-- name: UpsertAssetMeta :one
INSERT INTO assets_meta (
    meta_data_hash, meta_data_blob, meta_data_type
) VALUES (
    $1, $2, $3 
) ON CONFLICT (meta_data_hash)
    -- In this case, we may be inserting the data+type for an existing blob. So
    -- we'll set both of those values. At this layer we assume the meta hash
    -- has been validated elsewhere.
    DO UPDATE SET meta_data_blob = EXCLUDED.meta_data_blob, 
        meta_data_type = EXCLUDED.meta_data_type
RETURNING meta_id

After receiving the asset, it appears the meta data gets overwritten to nothing:
image

@habibitcoin
Copy link
Contributor Author

Confirmed. This is reproducible.

  1. Look in your table for a genesis_asset you don't own yet but have received via gossip that has valid meta data.

  2. Receive the asset.

  3. Asset_meta table record is corrupted

@guggero
Copy link
Member

guggero commented Jun 19, 2023

Thanks for the report, I was able to reproduce this in an integration test, will create a fix.

@jharveyb
Copy link
Contributor

Fixed with #370.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working meta universe
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

4 participants