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

[bug]: Can't generate addr after sync asset from other universe #841

Closed lukegao209 closed 5 months ago

lukegao209 commented 6 months ago

Background

Alice(Tapd V0.3.0) ,Bob(Tapd V0.3.3) Step1 : Bob => excute cmd : tapcli -n mainnet universe sync --universe_host

        {
"synced_universes":  [
    {
        "old_asset_root":  {
            "id":  null,
            "mssmt_root":  null,
            "asset_name":  "",
            "amounts_by_asset_id":  {}
        },
        "new_asset_root":  {
            "id":  {
                "asset_id":  "475a642ed13bc44af6490c8571404988d7b514386cf8f3a603d04a0d2fa9f8f5",
                "proof_type":  "PROOF_TYPE_ISSUANCE"
            },
            "mssmt_root":  {
                "root_hash":  "f6b42e0cb6cf9de9cc83adfc645ec7d751a12bc402cbdcc2175750a6881c9461",
                "root_sum":  "2100000000"
            },
            "asset_name":  "",
            "amounts_by_asset_id":  {}
        },
        "new_asset_leaves":  []
    }
]

} Step2 : Bob=> tapcli -n mainnet addrs new --amt 11 --asset_id xxxx

[tapcli] unable to make addr: rpc error: code = Unknown desc = unable to make new addr: unable to make address for unknown asset xxxx: asset group is unknown

The asset is a normal type without group, but it fails to generate a new addrs. I think the 'asset group is unknown' is a correct status,but it show as error. The check code should be here in book.go line 252(V.0.3.3)

// NewAddress creates a new Taproot Asset address based on the input parameters.
func (b *Book) NewAddress(ctx context.Context, assetID asset.ID, amount uint64,
    tapscriptSibling *commitment.TapscriptPreimage,
    proofCourierAddr url.URL, addrOpts ...NewAddrOpt,
) (*AddrWithKeyInfo, error) {

    // Before we proceed and make new keys, make sure that we actually know
    // of this asset ID, or can import it.
    if _, err := b.queryAssetInfo(ctx, assetID); err != nil {
        return nil, fmt.Errorf("unable to make address for unknown "+
            "asset %x: %w", assetID[:], err)
    }

    rawScriptKeyDesc, err := b.cfg.KeyRing.DeriveNextTaprootAssetKey(ctx)
    if err != nil {
        return nil, fmt.Errorf("unable to gen key: %w", err)
    }

Is this a bug or need to import more things from Alice tapd?

Roasbeef commented 6 months ago

Just to clarify: xxx is the same asset ID as 475a642ed13bc44af6490c8571404988d7b514386cf8f3a603d04a0d2fa9f8f5?

Do you have logs during/after the sync, and then when you try to make the addr?

lukegao209 commented 6 months ago

Just to clarify: xxx is the same asset ID as 475a642ed13bc44af6490c8571404988d7b514386cf8f3a603d04a0d2fa9f8f5?

Do you have logs during/after the sync, and then when you try to make the addr?

‘Just to clarify: xxx is the same asset ID as 475a642ed13bc44af6490c8571404988d7b514386cf8f3a603d04a0d2fa9f8f5?’ yep, correct!

I don't have the logs now, but I remeber there was no error logs on tapd .

guggero commented 6 months ago

What's the timing on this? How long after running the universe sync subcommand do you call addrs new? Could be that the sync just takes quite a while (and the response of the universe sync command returns immediately, not waiting for the sync to be complete) and after some time the addrs new command would actually succeed?

lukegao209 commented 6 months ago

I set federation config like this , and then run universe sync. I think it will just sync one asset, is it right? The origin universe has too many assets data, sync cost too long time and then memory leak.

tapcli -n mainnet universe federation config info
{
    "global_sync_configs":  [
        {
            "proof_type":  "PROOF_TYPE_ISSUANCE",
            "allow_sync_insert":  false,
            "allow_sync_export":  true
        },
        {
            "proof_type":  "PROOF_TYPE_TRANSFER",
            "allow_sync_insert":  false,
            "allow_sync_export":  true
        }
    ],
    "asset_sync_configs":  [
        {
            "id":  {
                "asset_id":  "475a642ed13bc44af6490c8571404988d7b514386cf8f3a603d04a0d2fa9f8f5",
                "proof_type":  "PROOF_TYPE_ISSUANCE"
            },
            "allow_sync_insert":  true,
            "allow_sync_export":  true
        },
        {
            "id":  {
                "asset_id":  "475a642ed13bc44af6490c8571404988d7b514386cf8f3a603d04a0d2fa9f8f5",
                "proof_type":  "PROOF_TYPE_TRANSFER"
            },
            "allow_sync_insert":  true,
            "allow_sync_export":  true
        }
    ]
}
lukegao209 commented 6 months ago

I just want to sync one asset. @guggero

guggero commented 6 months ago

Okay, but the same question still applies: How long do you wait after syncing and creating the address? It still might take a couple of seconds to complete.

lukegao209 commented 6 months ago

it doesn't work even 1 day later. And I sync from tapdV0.3.0 -> tapdV0.3.3. I want to migrate the assets on my old node to new version node.

guggero commented 6 months ago

Hmm, okay. This should work as you intended. Not sure what's going on. Can you please share the log of the node?

lukegao209 commented 6 months ago

got it . I will try it again and collect all the logs. will send you tomo

jharveyb commented 6 months ago

I think this part of the address itest should cover this behavior:

https://github.com/lightninglabs/taproot-assets/blob/649425831ce5310ff2cca50a7ca85e5245000f4e/itest/addrs_test.go#L363

From the first CLI output posted, I think asset_name and amounts_by_asset_id should have been populated though (unless that's gated behind a CLI flag).

lukegao209 commented 6 months ago

Guys, there are the info about the whole sync =====> @guggero @GeorgeTsagk Alice : tapd : v0.3.0 --allow-public-uni-proof-courier Bob : tapd : v0.3.3 --allow-public-uni-proof-courier --allow-public-stats ===> Sync asset from Alice to Bob

Step1 Execute on Bob :

sudo docker exec -it alice-tap-v033 tapcli -n mainnet universe sync --universe_host internal-tapd.nostrassets.com:30029 --asset_id 338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64
{
    "synced_universes":  [
        {
            "old_asset_root":  {
                "id":  null,
                "mssmt_root":  null,
                "asset_name":  "",
                "amounts_by_asset_id":  {}
            },
            "new_asset_root":  {
                "id":  {
                    "asset_id":  "338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64",
                    "proof_type":  "PROOF_TYPE_ISSUANCE"
                },
                "mssmt_root":  {
                    "root_hash":  "c8f25410cfee1dbdc5fb3c27856145e6beff53e910fa34b72d94f3d877c3c4e6",
                    "root_sum":  "210000000"
                },
                "asset_name":  "",
                "amounts_by_asset_id":  {}
            },
            "new_asset_leaves":  []
        }
    ]
}

Step1 Logs on Bob :

2024-03-23 02:29:54.034 [INF] UNIV: Attempting to sync universe: host=internal-tapd.nostrassets.com:30029, sync_type=issuance, ids=([]universe.Identifier) (len=1 cap=1) {
 (universe.Identifier) issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64
}

2024-03-23 02:29:54.036 [INF] UNIV: Fetching 1 roots
2024-03-23 02:29:54.042 [INF] UNIV: Obtained 1 roots from remote Universe server
2024-03-23 02:29:54.042 [DBG] UNIV: Looking up root node for base Universe (universe.Identifier) issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64

2024-03-23 02:29:54.045 [INF] UNIV: UniverseRoot(issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64) diverges, performing leaf diff...
2024-03-23 02:29:54.046 [DBG] UNIV: Retrieving all keys for Universe: id=issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64 (asset_id=338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64, group_key=<nil>, proof_type=issuance)
2024-03-23 02:29:54.048 [DBG] TADB: storing leaf keys for issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64 (asset_id=338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64, group_key=<nil>, proof_type=issuance) in cache
2024-03-23 02:29:54.049 [INF] UNIV: UniverseRoot(issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64): diff_size=0
2024-03-23 02:29:54.049 [DBG] UNIV: UniverseRoot(issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64): Inserting 0 new leaves (0 of 0)
2024-03-23 02:29:54.049 [INF] UNIV: Verifying 0 new proofs for insertion into Universe
2024-03-23 02:29:54.049 [INF] UNIV: Inserting 0 verified group anchor proofs into Universe
2024-03-23 02:29:54.049 [DBG] TADB: wiping universe cache
2024-03-23 02:29:54.049 [INF] UNIV: Inserting 0 verified proofs into Universe
2024-03-23 02:29:54.049 [DBG] TADB: wiping universe cache
2024-03-23 02:29:54.049 [INF] UNIV: Universe sync for UniverseRoot(issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64) complete, 0 new leaves inserted
2024-03-23 02:29:54.049 [INF] UNIV: Sync for UniverseRoot(issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64) complete!

Step1 Logs on Alice:

2024-03-23 02:29:54.039 [DBG] RPCS: Querying for asset (group) issuance universe root for (universe.Identifier) issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64

2024-03-23 02:29:54.040 [DBG] UNIV: Looking up root node for base Universe (universe.Identifier) issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64

2024-03-23 02:29:54.041 [DBG] RPCS: Querying for asset (group) transfer universe root for (universe.Identifier) issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64

2024-03-23 02:29:54.041 [DBG] UNIV: Looking up root node for base Universe (universe.Identifier) transfer-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64

2024-03-23 02:29:54.045 [DBG] UNIV: Retrieving all keys for Universe: id=unspecified-28010a20338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9d (asset_id=28010a20338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9d, group_key=<nil>, proof_type=unspecified)

Step2 Generate address for asset on Bob :

sudo docker exec -it alice-tap-v033 tapcli -n mainnet addrs new --amt 888 --asset_id 338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64
[tapcli] unable to make addr: rpc error: code = Unknown desc = unable to make new addr: unable to make address for unknown asset 338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64: asset group is unknown

Step2 Logs on Bob:

2024-03-23 02:31:00.810 [INF] RPCS: [NewAddr]: making new addr: asset_id=338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64, amt=888
2024-03-23 02:31:00.812 [DBG] ADDR: asset 338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64 is unknown, attempting to bootstrap
2024-03-23 02:31:00.812 [INF] UNIV: Attempting to sync universe: host=universe.lightning.finance:10029, sync_type=issuance, ids=([]universe.Identifier) <nil>

2024-03-23 02:31:00.813 [INF] UNIV: Attempting to sync universe: host=internal-tapd.nostrassets.com:30029, sync_type=issuance, ids=([]universe.Identifier) <nil>

2024-03-23 02:31:00.813 [INF] UNIV: Fetching 1 roots
2024-03-23 02:31:00.815 [DBG] UNIV: asset lookup for 338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64 failed with remoteserver: universe.lightning.finance:10029
2024-03-23 02:31:00.820 [INF] UNIV: Obtained 1 roots from remote Universe server
2024-03-23 02:31:00.821 [DBG] UNIV: Looking up root node for base Universe (universe.Identifier) issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64

2024-03-23 02:31:00.821 [INF] UNIV: UniverseRoot(issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64) diverges, performing leaf diff...
2024-03-23 02:31:00.822 [DBG] UNIV: Retrieving all keys for Universe: id=issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64 (asset_id=338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64, group_key=<nil>, proof_type=issuance)
2024-03-23 02:31:00.822 [DBG] TADB: storing leaf keys for issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64 (asset_id=338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64, group_key=<nil>, proof_type=issuance) in cache
2024-03-23 02:31:00.822 [INF] UNIV: UniverseRoot(issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64): diff_size=0
2024-03-23 02:31:00.822 [DBG] UNIV: UniverseRoot(issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64): Inserting 0 new leaves (0 of 0)
2024-03-23 02:31:00.822 [INF] UNIV: Verifying 0 new proofs for insertion into Universe
2024-03-23 02:31:00.822 [INF] UNIV: Inserting 0 verified group anchor proofs into Universe
2024-03-23 02:31:00.822 [DBG] TADB: wiping universe cache
2024-03-23 02:31:00.822 [INF] UNIV: Inserting 0 verified proofs into Universe
2024-03-23 02:31:00.822 [DBG] TADB: wiping universe cache
2024-03-23 02:31:00.822 [INF] UNIV: Universe sync for UniverseRoot(issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64) complete, 0 new leaves inserted
2024-03-23 02:31:00.822 [INF] UNIV: Sync for UniverseRoot(issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64) complete!
2024-03-23 02:31:00.822 [INF] UNIV: Synced new Universe leaves for asset 338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64, diff_size=1
2024-03-23 02:31:00.822 [ERR] RPCS: [/taprpc.TaprootAssets/NewAddr]: unable to make new addr: unable to make address for unknown asset 338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64: asset group is unknown

Step2 Logs on Alice :

2024-03-23 02:31:00.817 [DBG] RPCS: Querying for asset (group) issuance universe root for (universe.Identifier) issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64

2024-03-23 02:31:00.818 [DBG] UNIV: Looking up root node for base Universe (universe.Identifier) issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64

2024-03-23 02:31:00.819 [DBG] RPCS: Querying for asset (group) transfer universe root for (universe.Identifier) issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64

2024-03-23 02:31:00.819 [DBG] UNIV: Looking up root node for base Universe (universe.Identifier) transfer-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64

2024-03-23 02:31:00.821 [DBG] UNIV: Retrieving all keys for Universe: id=unspecified-28010a20338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9d (asset_id=28010a20338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9d, group_key=<nil>, proof_type=unspecified)
lukegao209 commented 6 months ago

I checked the taproot source again , it seems " db.FetchGroupByGenesis()" can not fetch the data and there is no record in the view in database asset_group_witnesses for this asset.

func (t *TapAddressBook) QueryAssetGroup(ctx context.Context,
    assetID asset.ID) (*asset.AssetGroup, error) {

    var assetGroup asset.AssetGroup

    readOpts := NewAddrBookReadTx()
    err := t.db.ExecTx(ctx, &readOpts, func(db AddrBook) error {
        assetGen, err := db.FetchGenesisByAssetID(ctx, assetID[:])
        if err != nil {
            return err
        }

        var genesisPrevOut wire.OutPoint
        err = readOutPoint(
            bytes.NewReader(assetGen.PrevOut), 0, 0, &genesisPrevOut,
        )
        if err != nil {
            return fmt.Errorf("unable to read outpoint: %w", err)
        }

        assetGroup.Genesis = &asset.Genesis{
            FirstPrevOut: genesisPrevOut,
            Tag:          assetGen.AssetTag,
            MetaHash: fn.ToArray[[32]byte](
                assetGen.MetaHash,
            ),
            OutputIndex: uint32(assetGen.OutputIndex),
            Type:        asset.Type(assetGen.AssetType),
        }

        // If there's no group associated with this asset, then we'll
        // return early as not all assets have a group.
        groupInfo, err := db.FetchGroupByGenesis(
            ctx, assetGen.GenAssetID,
        )
        switch {
        case errors.Is(err, sql.ErrNoRows):
            return nil
        case err != nil:
            return err
        }

        assetGroup.GroupKey, err = parseGroupKeyInfo(
            groupInfo.TweakedGroupKey, groupInfo.RawKey,
            groupInfo.WitnessStack, groupInfo.TapscriptRoot,
            groupInfo.KeyFamily, groupInfo.KeyIndex,
        )

        return err
    })
    switch {
    case errors.Is(err, sql.ErrNoRows):
        return nil, address.ErrAssetGroupUnknown

    case err != nil:
        return nil, err
    }

    return &assetGroup, nil
}

failed to insert the asset_group_witnesses table when sync? View ==> asset_group_witnesses :

CREATE VIEW "public"."key_group_info_view" AS  SELECT wit.witness_id,
    wit.gen_asset_id,
    wit.witness_stack,
    groups.tapscript_root,
    groups.tweaked_group_key,
    keys.raw_key,
    keys.key_index,
    keys.key_family,
    substr(groups.tweaked_group_key, 2) AS x_only_group_key
   FROM asset_group_witnesses wit
     JOIN asset_groups groups ON wit.group_key_id = groups.group_id
     JOIN internal_keys keys ON keys.key_id = groups.internal_key_id
  WHERE (wit.gen_asset_id IN ( SELECT genesis_info_view.gen_asset_id
           FROM genesis_info_view));
lukegao209 commented 6 months ago

some test : same cmd execute on Bob : tapcli -n mainnet universe sync --universe_host alice:10029 --asset_id xxxx Alice(v0.3.0) --> Bob(v0.3.3) failed Alice(v0.3.3) --> Bob(v0.3.3) succ

Roasbeef commented 6 months ago

Looks like it's just a timing issue?

2024-03-23 02:31:00.822 [INF] UNIV: Universe sync for UniverseRoot(issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64) complete, 0 new leaves inserted
2024-03-23 02:31:00.822 [INF] UNIV: Sync for UniverseRoot(issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64) complete!
2024-03-23 02:31:00.822 [INF] UNIV: Synced new Universe leaves for asset 338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64, diff_size=1
2024-03-23 02:31:00.822 [ERR] RPCS: [/taprpc.TaprootAssets/NewAddr]: unable to make new addr: unable to make address for unknown asset 338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64: asset group is unknown

Right when the sync is finished, a new addr request arrives but the sync hasn't fully propagated internally yet. If you try to make the addr a bit later, does it work?

lukegao209 commented 6 months ago

Looks like it's just a timing issue?

2024-03-23 02:31:00.822 [INF] UNIV: Universe sync for UniverseRoot(issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64) complete, 0 new leaves inserted
2024-03-23 02:31:00.822 [INF] UNIV: Sync for UniverseRoot(issuance-338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64) complete!
2024-03-23 02:31:00.822 [INF] UNIV: Synced new Universe leaves for asset 338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64, diff_size=1
2024-03-23 02:31:00.822 [ERR] RPCS: [/taprpc.TaprootAssets/NewAddr]: unable to make new addr: unable to make address for unknown asset 338563d188a4b4b99be8fe3112bd0fed956f197633bb701a826e3f9db9edaa64: asset group is unknown

Right when the sync is finished, a new addr request arrives but the sync hasn't fully propagated internally yet. If you try to make the addr a bit later, does it work?

@Roasbeef It doesn't work even 1 day later. And I test this : some test : same cmd execute on Bob : tapcli -n mainnet universe sync --universe_host alice:10029 --asset_id xxxx Alice(v0.3.0) --> Bob(v0.3.3) failed (only 1 asset on alice) Alice(v0.3.3) --> Bob(v0.3.3) succ (only 1 asset on alice)

guggero commented 5 months ago

Thanks for the info. When first looking at the issue, I totally glanced over the fact that Alice is on v0.3.0 while Bob is on v0.3.3. These two versions are quite a few months apart from each other, which in alpha (and with all the low-level changes we're doing to the daemon currently) is a very long time to be backward compatible to. So before digging deeper into whether a fix is even possible, here my question: What's blocking you from updating Alice to v0.3.3?

EDIT: I was able to reproduce the problem by the way. So it definitely is a version incompatibility (on the RPC level), which I'm not sure we currently take into account (again, given the alpha status of the project).

lnfi-network commented 5 months ago

@guggero thanks for your reply. I possess several assets on Alice (v0.3.0, PostgreSQL) and am looking to upgrade Alice to v0.3.3. However, a direct upgrade to v0.3.3 seems infeasible, likely due to significant differences in the database tables. As a workaround, I'm considering transferring the assets from Alice (v0.3.0) to Bob (v0.3.3) to see if that approach is viable

guggero commented 5 months ago

However, a direct upgrade to v0.3.3 seems infeasible, likely due to significant differences in the database tables.

I'm not sure I understand this part. We do provide upgrade scripts for the tables, which should be executed automatically when you run a new version on an existing code base (at least that's true for any version starting at v0.3.0). Do these fail for you?

lnfi-network commented 5 months ago

it failed to upgrade to v0.3.2 about 2-3 months ago , JHB knew thats. So I try the planB : send the assets from old version to new version.

lnfi-network commented 5 months ago

it would be easier if I send it to new version. And the current bug is that : cant send assets from v0.3.0 to v.0.3.3

lukegao209 commented 5 months ago

@guggero any other way to fix the issue? for example : export/import proof ? It seems the key is that Bob can import the right proof file of the asset

guggero commented 5 months ago

it failed to upgrade to v0.3.2 about 2-3 months ago , JHB knew thats. So I try the planB : send the assets from old version to new version.

Did you create an issue for that? Or do you still have the error you received back then? Just so we can avoid problems like that in the future. We do want to have a clear upgrade path from v0.3.0 and onward.

@guggero any other way to fix the issue? for example : export/import proof ? It seems the key is that Bob can import the right proof file of the asset

Yes, working on that now.

guggero commented 5 months ago

@guggero any other way to fix the issue? for example : export/import proof ? It seems the key is that Bob can import the right proof file of the asset

So you can export the proof like this on Alice:

tapcli -n mainnet universe leaves --asset_id 475a642ed13bc44af6490c8571404988d7b514386cf8f3a603d04a0d2fa9f8f5 |  jq -r '.leaves[0].proof' | xxd -p -r > /tmp/proof.leaf

Then you can transfer that proof to Bob and run decode on it (e.g. tapcli -n mainnet proofs decode --proof_file /tmp/proof.leaf). You need to decode the proof to find out some of the values that are required for the import call:

tapcli -n mainnet universe proofs insert --asset_id  475a642ed13bc44af6490c8571404988d7b514386cf8f3a603d04a0d2fa9f8f5 --outpoint <outpoint> --script_key <script_key> --proof_type issuance --proof_file /tmp/proof.leaf

The following values you need to take from the decoded proof:

Unfortunately for the import command to work on Bob, you also need to patch tapcli with this small patch: insert.diff.txt Otherwise you get the error tapcli] unable to decode proof file: invalid prefix magic bytes, expected TAPF, got TAPP.

jharveyb commented 5 months ago

it failed to upgrade to v0.3.2 about 2-3 months ago , JHB knew thats. So I try the planB : send the assets from old version to new version.

Did you create an issue for that? Or do you still have the error you received back then? Just so we can avoid problems like that in the future. We do want to have a clear upgrade path from v0.3.0 and onward.

That may be this issue: https://github.com/lightninglabs/taproot-assets/issues/725

lukegao209 commented 5 months ago

@guggero

it works fine on the main branch for me. but when I use new version tapcli(main branch) import it to v0.3.3 tapd(tapd server), the response is :

[tapcli] rpc error: code = Unknown desc = unable to register new issuance: SQL logic error: no such table: multiverse_roots (1)

I think it works on the latest version of tapd but fails on v0.3.3

guggero commented 5 months ago

What exactly do you mean with "import it to v0.3.3"? Copying the binary to the docker container? Are you sure you only copy tapcli and not tapd itself? You can also use the self-compiled tapd from outside of the container and just talk to tapd through the RPC port (if you've exposed that on the container).

lukegao209 commented 5 months ago

I think the patch is base on current main branch , not v0.3.3. so the patch works fine for current main branch and doesnt work on v0.3.3 maybe need a patch base on v0.3.3.

But I will try to check this path first : v0.3.0 --> v(current main branch) ---> v0.3.3

guggero commented 5 months ago

The patch mostly comments out some stuff. Should be easy to do for v0.3.3 (or I think it should apply directly to that commit). But can send you an updated patch file for v0.3.3 if you can't get it to work.

lukegao209 commented 5 months ago

it would be great if you can send me a v0.3.3 patch.

guggero commented 5 months ago

Actually, this patch file (https://github.com/lightninglabs/taproot-assets/files/14744484/insert.diff.txt) was created on v0.3.3. You run it with patch cmd/tapcli/universe.go insert.diff.txt (assuming you are in the root of the repository).

lukegao209 commented 5 months ago

thanks

lukegao209 commented 5 months ago

@guggero
I execute the export cmd on mainnet env Alice(v0.3.0) ,but it failed, the treat.leaf is empty. (it works on my regtest env).

tapcli -n mainnet --rpcserver host:10029 universe leaves --asset_id 0f8b9bb57522a824746b2ce364ae606ad433bc36db66ab86756e0e156a1ed34d | jq -r '.leaves[0].proof' | xxd -p -r > treat.leaf

and here is the assets info on Alice(v0.3.0)

{
            "version": "ASSET_VERSION_V0",
            "asset_genesis": {
                "genesis_point": "316f806c0ee133fe27fd888dc4e1099da8eb3abd8175a127db0104f416b2c7fb:0",
                "name": "TREAT",
                "meta_hash": "8bed240d0ed6daed414c1282d6b06a8720bb10064ecb149ab76d991b676027ef",
                "asset_id": "0f8b9bb57522a824746b2ce364ae606ad433bc36db66ab86756e0e156a1ed34d",
                "output_index": 0,
                "version": 0
            },
            "asset_type": "NORMAL",
            "amount": "110000000",
            "lock_time": 0,
            "relative_lock_time": 0,
            "script_version": 0,
            "script_key": "022d07757150e3cad6032e92af8352340c678abab2aaec727738c5ef9c7e046ce4",
            "script_key_is_local": true,
            "asset_group": null,
            "chain_anchor": {
                "anchor_tx": "02000000000102d9ac61df15860fa0d1f4d1dc4cb06fc14cba263403ed3c87b42ddbd89e915ee90100000000ffffffffd9ac61df15860fa0d1f4d1dc4cb06fc14cba263403ed3c87b42ddbd89e915ee900000000000000000003e80300000000000022512056c7681fc9fdcdb4c4b5e646f91f474445c01b6887e638bfaf832535118db24ee803000000000000225120d672ca174b0c8012d7d56383f70ab6b68a614072356ff420d623e175aadf3ad69675010000000000225120b35bc872be8813e9feb2e140a2731a8e9e3a4f1d065cd8de52de3f0e21832a200140d3027124628985118ee7455b1e873206aca511b2fbd198acf2e76018ac46295c6481c730982fc4275e7cf7a96c6e835bbc8c5f2ce614d2402a0b844055f03dd50140ee72ac3514b7321e1bfa587b3e5566d4a77ee8adb54f142eb2e8d4e393fe452160cdbe1e609aa9eae3789500d591ed0008f63837ff596ccb20a16a2fda9a9b6600000000",
                "anchor_txid": "df6de9e999d6437b4916cabb181e8da883308aeb173e1c823c5ddce00914816d",
                "anchor_block_hash": "00000000000000000000dd8b81eff820cb492dbc5efd68af845662d3dc0c85a7",
                "anchor_outpoint": "df6de9e999d6437b4916cabb181e8da883308aeb173e1c823c5ddce00914816d:0",
                "internal_key": "032ba0769f239630680e3d5767a0f9eb6e08e31b5ef387a6b503ce38524b310b93",
                "merkle_root": "9c0b497af950408de6be0361237c64d7e893fc64b19bf53e3d06bb65726d7a03",
                "tapscript_sibling": "",
                "block_height": 0
            },
            "prev_witnesses": [],
            "is_spent": false,
            "lease_owner": "",
            "lease_expiry": "0",
            "is_burn": false
        },
        {
            "version": "ASSET_VERSION_V0",
            "asset_genesis": {
                "genesis_point": "316f806c0ee133fe27fd888dc4e1099da8eb3abd8175a127db0104f416b2c7fb:0",
                "name": "TREAT",
                "meta_hash": "8bed240d0ed6daed414c1282d6b06a8720bb10064ecb149ab76d991b676027ef",
                "asset_id": "0f8b9bb57522a824746b2ce364ae606ad433bc36db66ab86756e0e156a1ed34d",
                "output_index": 0,
                "version": 0
            },
            "asset_type": "NORMAL",
            "amount": "100000000",
            "lock_time": 0,
            "relative_lock_time": 0,
            "script_version": 0,
            "script_key": "025965f0d956902add92438bbf8c46d80393eebc3139d519244abd5254005635f8",
            "script_key_is_local": true,
            "asset_group": null,
            "chain_anchor": {
                "anchor_tx": "02000000000102d9ac61df15860fa0d1f4d1dc4cb06fc14cba263403ed3c87b42ddbd89e915ee90100000000ffffffffd9ac61df15860fa0d1f4d1dc4cb06fc14cba263403ed3c87b42ddbd89e915ee900000000000000000003e80300000000000022512056c7681fc9fdcdb4c4b5e646f91f474445c01b6887e638bfaf832535118db24ee803000000000000225120d672ca174b0c8012d7d56383f70ab6b68a614072356ff420d623e175aadf3ad69675010000000000225120b35bc872be8813e9feb2e140a2731a8e9e3a4f1d065cd8de52de3f0e21832a200140d3027124628985118ee7455b1e873206aca511b2fbd198acf2e76018ac46295c6481c730982fc4275e7cf7a96c6e835bbc8c5f2ce614d2402a0b844055f03dd50140ee72ac3514b7321e1bfa587b3e5566d4a77ee8adb54f142eb2e8d4e393fe452160cdbe1e609aa9eae3789500d591ed0008f63837ff596ccb20a16a2fda9a9b6600000000",
                "anchor_txid": "df6de9e999d6437b4916cabb181e8da883308aeb173e1c823c5ddce00914816d",
                "anchor_block_hash": "00000000000000000000dd8b81eff820cb492dbc5efd68af845662d3dc0c85a7",
                "anchor_outpoint": "df6de9e999d6437b4916cabb181e8da883308aeb173e1c823c5ddce00914816d:1",
                "internal_key": "034f6aff0d5a186d9456fb671c60e3ac2224737756a240af696b3bc5b3ea7d44cf",
                "merkle_root": "6ebed46af85ea033dd6d2a2479cdb191827ff10ff9fc3451fe50414950e3087b",
                "tapscript_sibling": "",
                "block_height": 0
            },
            "prev_witnesses": [],
            "is_spent": false,
            "lease_owner": "",
            "lease_expiry": "0",
            "is_burn": false
        }
guggero commented 5 months ago

What do you get for just tapcli -n mainnet --rpcserver host:10029 universe leaves --asset_id 0f8b9bb57522a824746b2ce364ae606ad433bc36db66ab86756e0e156a1ed34d?

lukegao209 commented 5 months ago

@guggero the response is

{
    "leaves": [
        {
            "asset": {
                "version": "ASSET_VERSION_V0",
                "asset_genesis": {
                    "genesis_point": "316f806c0ee133fe27fd888dc4e1099da8eb3abd8175a127db0104f416b2c7fb:0",
                    "name": "TREAT",
                    "meta_hash": "8bed240d0ed6daed414c1282d6b06a8720bb10064ecb149ab76d991b676027ef",
                    "asset_id": "0f8b9bb57522a824746b2ce364ae606ad433bc36db66ab86756e0e156a1ed34d",
                    "output_index": 0,
                    "version": 0
                },
                "asset_type": "NORMAL",
                "amount": "210000000",
                "lock_time": 0,
                "relative_lock_time": 0,
                "script_version": 0,
                "script_key": "022a54a6748972b1734cdc309d29cfac1568144b2b14c4a5ca4e08a6b2569573ca",
                "script_key_is_local": false,
                "asset_group": null,
                "chain_anchor": null,
                "prev_witnesses": [
                    {
                        "prev_id": {
                            "anchor_point": "0000000000000000000000000000000000000000000000000000000000000000:0",
                            "asset_id": "0000000000000000000000000000000000000000000000000000000000000000",
                            "script_key": "000000000000000000000000000000000000000000000000000000000000000000",
                            "amount": "0"
                        },
                        "tx_witness": [],
                        "split_commitment": null
                    }
                ],
                "is_spent": false,
                "lease_owner": "",
                "lease_expiry": "0",
                "is_burn": false
            },
            "issuance_proof": "544150500004000000000224fbc7b216f40401db27a17581bd3aeba89d09e1c48d88fd27fe33e10e6c806f3100000000045000a08f2edd423e51a3d984e7f29625a1b505e590e8c9c70227ea0300000000000000000066588e984225e5bc58f8f9db1c2d91d95ec7b40da594c40c4a5aff28317d924deb353e65a99c04179f2d3c1f06cd02000000000101fbc7b216f40401db27a17581bd3aeba89d09e1c48d88fd27fe33e10e6c806f310000000000ffffffff02e80300000000000022512099733cb31b6c8023653c42ba883c3d521c5019a1c9bec1252ce9b982f916a0bee07d010000000000225120c5e89bd57cc2893cf38775a3b14752ec6da9c73845d23c9d286d4c77e780a87a0140e176557720a32cb97247feec26c68563b1a2aa5586ba6bafe828dfaa75f573f580771b68f3347e2d7509d1ec0a446a5da6dfce23390e0df17e51c9c9fff212f70000000008fd01630b814fa3780bca746106b9aef82781012fb21867c301e436ec596059fff1c201db14212debd43daed2de74b06c013966dfedd8e0b86338d89ee9821cc455b657bf3037cff6d307c688a76f0e8243760e32d7011f59aa3d303d399f64df3f2e578b4bb521475accd9f0733bd57ba0c150f4be2d51b30fc37008c455c31b6ed6e2a64c3f7fc024a867111184862136e4df20c4edd2923b6edd33ff8f08564335632a7aadd623b4d6e87065b5c7a91ff51c913e4fd9e8bf5a3f83f2041e5c88eec9b592d64c6a2969820f20445e3e7f3eddc867e4477afe9b863d7b6cd3867c6a5319e9da68eb169797d84bcdc71665fe181704a4b28c7f58a72268ba70c96d2ddc9fefaf279231466e3c582dc0a7780cc6f81480539370255843d993052263b21a83fd22a884b9923a9b34f9d0da73ff332e0f30aac980e477d7a4c19266e2cf113ab65df5154adf4677aa6008f8fd2b022b16eea5760f20ad54e9027acbc0c925b2b5050af0000100024ffbc7b216f40401db27a17581bd3aeba89d09e1c48d88fd27fe33e10e6c806f31000000000554524541548bed240d0ed6daed414c1282d6b06a8720bb10064ecb149ab76d991b676027ef00000000000401000605fe0c8458800b690167016500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0200001021022a54a6748972b1734cdc309d29cfac1568144b2b14c4a5ca4e08a6b2569573ca0c9f0004000000000221027ab08f1c4ab1f5c28a892fe8afcbd92d1accc3d15f232fac3897ef3c6b261d830374014900010002200f8b9bb57522a824746b2ce364ae606ad433bc36db66ab86756e0e156a1ed34d04220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff022700010002220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0d30012e0004000000010221029c2d59985de022b4b0f7ee7183bfbb4207bb7b57029039f25b7b3fe4f0c94fb805030401011190000100028b7b2273796d626f6c223a225452454154222c22616d6f756e74223a3231303030303030302c22646973706c6179446563696d616c223a302c226e616d65223a225452454154222c226c6f676f223a2268747470733a2f2f6173736574732e6e6f7374726173736574732e636f6d2f6c6f676f2f74726561742e706e67222c22646563696d616c223a317d0a1604000c6d18174ffbc7b216f40401db27a17581bd3aeba89d09e1c48d88fd27fe33e10e6c806f31000000000554524541548bed240d0ed6daed414c1282d6b06a8720bb10064ecb149ab76d991b676027ef0000000000"
        }
    ]
}

it works if I change .leaves[0].proof to .leaves[0].issuance_proof

tapcli -n mainnet --rpcserver host:10029 universe leaves --asset_id 0f8b9bb57522a824746b2ce364ae606ad433bc36db66ab86756e0e156a1ed34d | jq -r '.leaves[0].issuance_proof' | xxd -p -r > treat.leaf

dstadulis commented 5 months ago

it works if I change .leaves[0].proof to .leaves[0].issuance_proof

Fantastic news, @lukegao209

I'll close out the issue, feel free to reopen it if there are remaining issues that arise again.

lukegao209 commented 5 months ago

thanks guys. @dstadulis @guggero