lightninglabs / taproot-assets

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

[sync with universe] unable to sync universe: proof for key is invalid #320

Closed Umiiii closed 1 year ago

Umiiii commented 1 year ago

Hi, I am trying to mint my own taproot assets and I followed the steps:

after that, mint asset:

root@umibitcoin ~ # tapcli assets mint --type normal --name fantasycoin --supply 100 --meta_bytes "fantastic money"
{
    "batch_key": "0395abdd75f14cdb7ce6b70bd822146a24e9734450c9585fd3759eca76c001d508"
}
root@umibitcoin ~ # tapcli assets mint finalize
{
    "batch_key": "0395abdd75f14cdb7ce6b70bd822146a24e9734450c9585fd3759eca76c001d508"
}
root@umibitcoin ~ # tapcli assets list
{
    "assets": [
        {
            "version": 0,
            "asset_genesis": {
                "genesis_point": "6b47b7f3b5b4f016795cb9189fc1c03e8383aa811cb30b9d545232714dae0796:1",
                "name": "umicoin",
                "meta_hash": "4ff1b02c93487f8762f49d09877d2c8edcb19104ecff0bc0119b4f22b85b3e4c",
                "asset_id": "a466936816b579a3e94ddcfb6acebe6561783533fc726cbc0bb9c31ec7a046de",
                "output_index": 0,
                "version": 0
            },
            "asset_type": "NORMAL",
            "amount": "100",
            "lock_time": 0,
            "relative_lock_time": 0,
            "script_version": 0,
            "script_key": "0269de60f71c12b4a0af995d985ac0a6fb0d2245f46c1f1b66c991fecc8bc126f1",
            "script_key_is_local": true,
            "asset_group": null,
            "chain_anchor": {
                "anchor_tx": "020000000001019607ae4d713252549d0bb31c81aa83833ec0c19f18b95c7916f0b4b5f3b7476b0100000000ffffffff02e803000000000000225120c9b3a5ce2a56b709942c62b0cd03644861169d6de70864be277a4bbcd101289c84270000000000002251205d01bdb7edfc1e979f6d87abc68d5e028e16571c2d851f3621ef9ecbcbea8e7401403aa5205ab10d2602c1706a678d7138656b8fb53e20e6b904240967aa8a3315c2875a8b571b8d8ff900bae5d969ec517ec62b13df11d18459aa684cd4e0b4e4c100000000",
                "anchor_txid": "20bddae3da15e81dfced293be1b90a282b15d7765b3c8b9832cb0a517999361f",
                "anchor_block_hash": "196e7df84ee470d28ad1e4474989e38e98815d7eed9399bb0600000000000000",
                "anchor_outpoint": "20bddae3da15e81dfced293be1b90a282b15d7765b3c8b9832cb0a517999361f:0",
                "internal_key": "03e136f8df58e3cdd048c1004237c06f197dc903a14218b0e4a22dd35edad77017",
                "merkle_root": "a533a174f089f6fa7b58a204d3c2e4b15ba790567d7efc1fbc7ede0ddc7be655",
                "tapscript_sibling": ""
            },
            "prev_witnesses": [],
            "is_spent": false
        }
    ]
}

And then, when I want to sync with universe, I got this error:

root@umibitcoin ~ # tapcli universe sync --universe_host testnet.universe.lightning.finance
[tapcli] rpc error: code = Unknown desc = unable to sync universe: proof for key=(universe.BaseKey) {
 MintingOutpoint: (wire.OutPoint) afbb5f6b0ca78c2798d7671d5dccbd34efc8983079aa732b1f719779a95dfd8a:0,
 ScriptKey: (*asset.ScriptKey)(0xc0002efc80)({
  PubKey: (*secp256k1.PublicKey)(0xc000a20910)({
   x: (secp256k1.FieldVal) 7f9b360585bf4d55b05e4726514114eb0ec39bf1b27e19768d51e7b09ceab2a0,
   y: (secp256k1.FieldVal) 537430f37dd123fd639b1492b8e16ad2dee246a421b00cd0d04d2862faac4ea2
  }),
  TweakedScriptKey: (*asset.TweakedScriptKey)(<nil>)
 })
}
 is invalid
guggero commented 1 year ago

Interesting, it looks like you're trying to download a proof from the server that your tapd then thinks is invalid. So the problem might not be on your end at all. Thanks for the report, we'll investigate.

Roasbeef commented 1 year ago

Dug into this a bit, and it looks like the proof returned by the server fails before the actual tap level validation. instead the SMT inclusion proof doesn't match the universe root we fetch.

jharveyb commented 1 year ago

Confirmed the same RPC error on my testnet setup, same minting outpoint. ScriptKey shows different x & y values.

Roasbeef commented 1 year ago

ScriptKey shows different x & y values.

Can you elaborate on that? As in another leaf for that asset group or something else?

Roasbeef commented 1 year ago

Some inserted debug logs:

2023-05-26 17:33:14.435 [INF] UNIV: Reconstructed root: (mssmt.NodeHash) (len=32 cap=32) 75fa411dc1702cb57819dc699b8c662f649cffda918efc4a750875f190cfe25f

2023-05-26 17:33:14.435 [INF] UNIV: Expected root: (mssmt.NodeHash) (len=32 cap=32) 174d433bd665bad3be8ea975c14e5945804d92913abd9852e024fc85c347d2f9

2023-05-26 17:33:14.435 [INF] UNIV: Universe root root: (mssmt.NodeHash) (len=32 cap=32) 174d433bd665bad3be8ea975c14e5945804d92913abd9852e024fc85c347d2f9

So it is the case that the roots mismatch. I think then this would mean the issuance proof isn't being serialized properly for the request/response of RpcUniverseDiff.

vanditshah99 commented 1 year ago

Encountered the similar issue while syncing universe. I was testing a workflow to transfer one asset from one tapd instance to address generated on another tapd instance.

The CLI command I hit was : tapcli universe sync --universe_host testnet.universe.lightning.finance

And the output I received was [tapcli] rpc error: code = Unknown desc = unable to sync universe: proof for key=(universe.BaseKey) { MintingOutpoint: (wire.OutPoint) afbb5f6b0ca78c2798d7671d5dccbd34efc8983079aa732b1f719779a95dfd8a:0, ScriptKey: (asset.ScriptKey)(0xc000031030)({ PubKey: (secp256k1.PublicKey)(0xc00093a000)({ x: (secp256k1.FieldVal) 63d5f10e1912bfbc9a53ea1decd49b55af231a30675a342b40954af6d1d2103e, y: (secp256k1.FieldVal) 5c7da2252d8e24e26adaedb5f6887ff58c7699d3131812d94b22f683e670fc60 }), TweakedScriptKey: (*asset.TweakedScriptKey)() }) } is invalid

dstadulis commented 1 year ago

Will be the team's P0 priority as this issue will be encountered by many users.

dstadulis commented 1 year ago

Solve by cleaning up DB state