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

Migration UI - 3 - Signing #7562

Closed
exezbcz opened this issue Oct 9, 2023 · 19 comments · Fixed by #7909
Closed

Migration UI - 3 - Signing #7562

exezbcz opened this issue Oct 9, 2023 · 19 comments · Fixed by #7909
Labels
$ ~<50usd A-migration A-rmrk related rmrkV1 A-rmrk2 A-statemine-ahk related for statemine common chain, under new name Asset Hub Kusama A-statemint-ahp Polkadot Asset Hub related issues intern tasks intended for internal team p1 preventing everyone from using app S-blocked-✋

Comments

@exezbcz
Copy link
Member

exezbcz commented Oct 9, 2023

part of a bigger issue:

Signing 🚥

  • new part, will be the same as with auto teleport (but in modal)
  • the reason everything is on its own page and not in the small modal is simply the space and no way of accidentally closing it and losing the progress. It's quite a lot of transactions if you decide to migrate 1k collection.
image
  • it's a step signing.
  • here are possible events of the small sub-part
image
  • the parent section changes based on whether its in progress, its done, or inactive, changes between three states.
    image image image

  • the grey 1/4 circle is a loading wheel, please match the style as much as possible.

  • The same icons are used for the subsections. Every step is in this case one signed transaction.

  • let me give an example.
    image

  • the contextual message is in this case what is changing.

  • when you cancel signing, you have the option to retry (it could say failed or canceled)

image
  • after you finish all of this long signing, you can click on the button to finish (it's not automatic because in this signing, there are also transaction links (as you can see above)
@exezbcz exezbcz added A-migration A-statemine-ahk related for statemine common chain, under new name Asset Hub Kusama A-rmrk related rmrkV1 A-rmrk2 A-statemint-ahp Polkadot Asset Hub related issues labels Oct 9, 2023
@exezbcz exezbcz mentioned this issue Oct 9, 2023
@yangwao yangwao added the $ ~<50usd label Oct 11, 2023
@exezbcz exezbcz added the intern tasks intended for internal team label Oct 11, 2023
@yangwao yangwao added the p1 preventing everyone from using app label Oct 13, 2023
@exezbcz
Copy link
Member Author

exezbcz commented Oct 17, 2023

Some changes will be made, mainly to the structure of what you are signing, and maybe some flow as well.

don't take this issue please till we update that.

cc @vikiival

@yangwao
Copy link
Member

yangwao commented Oct 18, 2023

@exezbcz where the user will see if everything was migrated successfully with on-chain checks? Like item list for example?

@exezbcz
Copy link
Member Author

exezbcz commented Oct 18, 2023

@exezbcz where the user will see if everything was migrated successfully with on-chain checks? Like item list for example?

After each transaction is complete, you can click on the link. Once everything is completed it also works like a list of transactions. It does proceed to the congratulations before you click the complete button

I will add more comprehensive list on the congratulations screen - list of items with status and link to tx. Thanks for feedback sir

@vikiival
Copy link
Member

vikiival commented Oct 20, 2023

Context

So as I wrote the migration script I found out a unpleasant truth: If user wants to presign items, he/she need to sign MANUALY EVERY SINGLE ITEM.
As this should be as easy as possible, I found a new way

The code

The create collectoion tx should be composed of

// Step 1
const nextId = weHaveACodeForThis()
const collection = getCollectionById('ksm', collectionId)

batch [
create(accountId, defaultSettings),
set_collection_metadata(nextId, collection.metadata),
set_team(nextId, KODA_BOT, accountId, accountId)
]

after transaction is successful the code should call an API

POST /relocations

body

{
  "from": {
    "chain": "ksm", // or rmrk depends which 
    "collection": "" // collection id from 
  },
   "to": {
    "chain": "ahk", // or ahp depends
    "collection": "" // collection id 
  },
  "issuer": "" // account id
}

Once API call was returned with status 200.

we need to compose another API call that sends all the required params to sign.

// Step 2
PUT /relocations/{chainFrom}/{collectionFrom}/iterations/{iteration}

The return of this api call is a list of Signatures where signature is composed at least from

{
  "result": {
    "ok": true,
    "id": "", //basically id of last one 
    "error": null
  },
  "data": [
    {
      "account": "", //current owner of nft
      "attributes": "", // attributes to be created
      "chain": "ksm", // chain 
      "collection": "", // rmrk_collection_id
      "data": "", // packed data, check step 3, sig.data
      "deadline": 12000000,
      "id": "", // internal id
      "metadata": "", // metadta to be minted along 
      "signature": "", // signature, check step 3, sig.signature
      "signer": "",// signer, check step 3, sig. signer
      "sn": "", // rmrk_sn_id
      "to_chain": "ahk",
      "to_collection": "", // collection_id
      "to_sn": "" // future_nft_sn
    }
  ]

Keep in mind that API returns just a list of owned nfts, other signatures are dedicated for other users

Once you get this list of signatures we need to build a payload for tx

// Step 3
function createItem(api: ApiPromise, sig: Signature) {
  const preSignInfo = api.createType("PalletNftsPreSignedMint", sig.data);
  const create = api.tx.nfts.mintPreSigned(preSignInfo, {
    Ed25519: sig.signature,
  }, sig.signer);
  return create;
}

const items = iterations.data.map((sig) => createItem(api, sig));

batch(
  items
)

Once this is successful we can burn the existing nfts

// Step 4

Last step is to iterate over signatures one more time and build proper system.remark for BURN

so iterate over nfts build proper extrinsic (do not remeber from head so can find along the way).

Once this is done.
Call API to mark these nfts as migrated and continue to #7563

TBA

DELETE /relocations/{chainFrom}/{collectionFrom}

Body

[
 
]

From design perspective

I wrote the code first so I can guide better.

1. Create collection (✅)

2. Waiting API to sign NFTs

This will be possibly done in iterations.
my bet is 1000 items per one iteration would be sufficient

3. Creating your own NFTs (✅)

Due to the limit of the AH blockchain my estimation is that 200 items can be minted in one iteration. Each iteration needs to wait for the in block state (then we can reflect it as done).

4. Burning migrated NFTs on Kusama

Same as step 3, but different naming, however we are not limited (13K items were tested).

Questions

  1. @exezbcz please let me know if anything is unclear.
  2. @kodadot/internal-dev is anything unclear here? Happy to hear your opinion.

@exezbcz
Copy link
Member Author

exezbcz commented Oct 20, 2023

Thank you sir; mostly clear, however, ad signing txs - some questions

For me, it's important how many tx the user will sign and after which step the user will wait.

from what i understand:

  • you sign the first one, wait till the collection is created
  • signing the API - or giving it rights to manage items?
  • ad step 3 is there also needed a signature for every 200 items or that is handled by someone else
  • step 4 - one tx for burning

cc @vikiival

@vikiival
Copy link
Member

For me, it's important how many tx the user will sign

  1. To create collection
  2. No need to sign anything from user
  3. NumberOfItems / BatchSize = iterations
  4. One to burn

So min 3

@exezbcz
Copy link
Member Author

exezbcz commented Oct 22, 2023

@vikiival, last question just to be sure

What will user sign if he is not the owner of the collection - migrating only items that were pre-signed by the owner

  • is there min. of 2 transactions?
  • what about step two, same as with migrating as the owner of the collection? Or its not needed as the user is migrating only items he owns.

thanks!

@vikiival
Copy link
Member

vikiival commented Oct 22, 2023

What will user sign if he is not the owner of the collection - migrating only items that were pre-signed by the owner

There should be a separated screen for /migrations where user can find list of waiting mogrations and can transact them in the batch

EDIT:
@exezbcz already designed the screen

photo_2023-10-23 13 21 46

photo_2023-10-23 13 21 49

@exezbcz
Copy link
Member Author

exezbcz commented Oct 23, 2023

Changes/second iteration

image

Initiation stage

image

  • two steps
  • sign collection creation
  • automated step - no signing needed, just waiting, more states here:
    image
  • its under the sections

Migrating your items

  • that is the mentioned batch transactions, there is a limit of items that could be migrated.
  • viki mentioned that there might be an additional step of unlisting all items - if it's needed to add it, do so before the three transactions in this section.

image


Finalization

  • the fancy name for burning items on the source chain, I did not want to mention that explicitly.
    image

  • rest stays the same

@vikiival
Copy link
Member

I updated the API

@preschian
Copy link
Member

hi @vikiival, is there something wrong with my args in here? https://assethub-kusama.subscan.io/block/0xf8cbf28ce3b0ce89b07ab484654c589efd443e6ed241902c437a59b52f920b73

I'm getting a 400 error on the /relocations endpoint. It returns Cannot read properties of null (reading 'currentOwner')

@vikiival
Copy link
Member

For the logs purposes

hi @vikiival, is there something wrong with my args in here? https://assethub-kusama.subscan.io/block/0xf8cbf28ce3b0ce89b07ab484654c589efd443e6ed241902c437a59b52f920b73

Everything is good here

I'm getting a 400 error on the /relocations endpoint. It returns Cannot read properties of null (reading 'currentOwner')

There was a bug with usage of uniquery I was requesting image field on rmrk endpoint that does not exist.
Fixed and deployed

@preschian
Copy link
Member

Updates:

  • still in progress step 3, preparing pre-signed items. Currently, I still ask Viki related to the backend via Telegram
  • rmrk => looks good until step 3
  • ksm => sometimes, error on step 1

I will check again tomorrow

@preschian
Copy link
Member

preschian commented Oct 31, 2023

Updates:

image

@preschian
Copy link
Member

Updates #7909:

On ahk:

On ahp:

  • ✅ create collection
  • ❌ mock API on /relocations returns Target collection not found or you are not the owner
  • ❌ real API on /relocations return D1_ERROR

cc @vikiival

Iterations and Burn not yet implemented. I will implement that once migration nfts look ok

@preschian
Copy link
Member

Because of the API error, I will try to help on the backend side also on https://github.com/kodadot/private-workers

@vikiival
Copy link
Member

vikiival commented Nov 2, 2023

❌ mock API on /relocations returns Target collection not found or you are not the owner

This was fixed

@preschian
Copy link
Member

Because of the API error, I will try to help on the backend side also on kodadot/private-workers

I'm still not able to test this out. My dashboard has been blank since yesterday. There were some issues on the Cloudflare side. ref: kodadot/workers#192 (comment)

https://www.cloudflarestatus.com/

image

@vikiival
Copy link
Member

vikiival commented Nov 3, 2023

Still dead :/

Screenshot 2023-11-03 at 12 50 00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
$ ~<50usd A-migration A-rmrk related rmrkV1 A-rmrk2 A-statemine-ahk related for statemine common chain, under new name Asset Hub Kusama A-statemint-ahp Polkadot Asset Hub related issues intern tasks intended for internal team p1 preventing everyone from using app S-blocked-✋
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants